id
stringlengths
2
6
java
stringlengths
48
5.92k
python
stringlengths
33
11.1k
T600
public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) , ans = 0 , colors [ ] = new int [ 9 ] ; for ( int i = 0 , temp ; i < n ; i ++ ) if ( ++ colors [ temp = Color . getColor ( scanner . nextInt ( ) ) . ordinal ( ) ] == 1 && temp != 8 ) ans ++ ; System . out . println ( Math . max ( 1 , ans ) + " ▁ " + ( ans + colors [ 8 ] ) ) ; } enum Color { GRAY ( 1 , 399 ) , BROWN ( 400 , 799 ) , GREEN ( 800 , 1199 ) , LIGHT_BLUE ( 1200 , 1599 ) , BLUE ( 1600 , 1999 ) , YELLOW ( 2000 , 2399 ) , ORANGE ( 2400 , 2799 ) , RED ( 2800 , 3199 ) , FREE ( 3200 , 4800 ) ; int min , max ; Color ( int min , int max ) { this . min = min ; this . max = max ; } static Color getColor ( int rate ) { for ( Color color : values ( ) ) if ( color . min <= rate && rate <= color . max ) return color ; return null ; } } }
N = int ( input ( ) ) NEW_LINE a = map ( int , input ( ) . split ( ) ) NEW_LINE color_set = set ( ) NEW_LINE original_cnt = 0 NEW_LINE red_flag = False NEW_LINE for val in a : NEW_LINE INDENT if val >= 3200 : NEW_LINE INDENT original_cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if val >= 2800 : NEW_LINE INDENT red_flag = True NEW_LINE DEDENT color_set . add ( int ( val / 400 ) ) NEW_LINE DEDENT DEDENT if red_flag is True : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if original_cnt > 0 : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) + 1 , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) , len ( color_set ) ) ) NEW_LINE DEDENT DEDENT
T601
public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) , ans = 0 , colors [ ] = new int [ 9 ] ; for ( int i = 0 , temp ; i < n ; i ++ ) if ( ++ colors [ temp = Color . getColor ( scanner . nextInt ( ) ) . ordinal ( ) ] == 1 && temp != 8 ) ans ++ ; System . out . println ( Math . max ( 1 , ans ) + " ▁ " + ( ans + colors [ 8 ] ) ) ; } enum Color { GRAY ( 1 , 399 ) , BROWN ( 400 , 799 ) , GREEN ( 800 , 1199 ) , LIGHT_BLUE ( 1200 , 1599 ) , BLUE ( 1600 , 1999 ) , YELLOW ( 2000 , 2399 ) , ORANGE ( 2400 , 2799 ) , RED ( 2800 , 3199 ) , FREE ( 3200 , 4800 ) ; int min , max ; Color ( int min , int max ) { this . min = min ; this . max = max ; } static Color getColor ( int rate ) { for ( Color color : values ( ) ) if ( color . min <= rate && rate <= color . max ) return color ; return null ; } } }
from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE a = Counter ( list ( map ( lambda x : x // 400 , map ( int , input ( ) . split ( ) ) ) ) ) NEW_LINE c = n = 0 NEW_LINE for key in [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ] : NEW_LINE INDENT if a [ key ] : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for key in [ 8 , 9 , 10 , 11 , 12 ] : NEW_LINE INDENT n += a [ key ] NEW_LINE DEDENT max_n = c + n NEW_LINE if c : NEW_LINE INDENT min_n = c NEW_LINE DEDENT else : NEW_LINE INDENT min_n = 1 NEW_LINE DEDENT print ( min_n , max_n ) NEW_LINE
T602
public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) , ans = 0 , colors [ ] = new int [ 9 ] ; for ( int i = 0 , temp ; i < n ; i ++ ) if ( ++ colors [ temp = Color . getColor ( scanner . nextInt ( ) ) . ordinal ( ) ] == 1 && temp != 8 ) ans ++ ; System . out . println ( Math . max ( 1 , ans ) + " ▁ " + ( ans + colors [ 8 ] ) ) ; } enum Color { GRAY ( 1 , 399 ) , BROWN ( 400 , 799 ) , GREEN ( 800 , 1199 ) , LIGHT_BLUE ( 1200 , 1599 ) , BLUE ( 1600 , 1999 ) , YELLOW ( 2000 , 2399 ) , ORANGE ( 2400 , 2799 ) , RED ( 2800 , 3199 ) , FREE ( 3200 , 4800 ) ; int min , max ; Color ( int min , int max ) { this . min = min ; this . max = max ; } static Color getColor ( int rate ) { for ( Color color : values ( ) ) if ( color . min <= rate && rate <= color . max ) return color ; return null ; } } }
import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE l = [ 0 for _ in range ( 9 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] <= 399 : NEW_LINE INDENT l [ 0 ] += 1 NEW_LINE DEDENT elif 400 <= a [ i ] <= 799 : NEW_LINE INDENT l [ 1 ] += 1 NEW_LINE DEDENT elif 800 <= a [ i ] <= 1199 : NEW_LINE INDENT l [ 2 ] += 1 NEW_LINE DEDENT elif 1200 <= a [ i ] <= 1599 : NEW_LINE INDENT l [ 3 ] += 1 NEW_LINE DEDENT elif 1600 <= a [ i ] <= 1999 : NEW_LINE INDENT l [ 4 ] += 1 NEW_LINE DEDENT elif 2000 <= a [ i ] <= 2399 : NEW_LINE INDENT l [ 5 ] += 1 NEW_LINE DEDENT elif 2400 <= a [ i ] <= 2799 : NEW_LINE INDENT l [ 6 ] += 1 NEW_LINE DEDENT elif 2800 <= a [ i ] <= 3199 : NEW_LINE INDENT l [ 7 ] += 1 NEW_LINE DEDENT elif 3200 <= a [ i ] : NEW_LINE INDENT l [ 8 ] += 1 NEW_LINE DEDENT DEDENT if l [ 8 ] == 0 : NEW_LINE INDENT print ( 9 - l . count ( 0 ) , 9 - l . count ( 0 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if l . count ( 0 ) == 8 : NEW_LINE INDENT print ( 1 , l [ 8 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 8 - l . count ( 0 ) , 8 - l . count ( 0 ) + l [ 8 ] ) NEW_LINE DEDENT DEDENT
T603
public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) , ans = 0 , colors [ ] = new int [ 9 ] ; for ( int i = 0 , temp ; i < n ; i ++ ) if ( ++ colors [ temp = Color . getColor ( scanner . nextInt ( ) ) . ordinal ( ) ] == 1 && temp != 8 ) ans ++ ; System . out . println ( Math . max ( 1 , ans ) + " ▁ " + ( ans + colors [ 8 ] ) ) ; } enum Color { GRAY ( 1 , 399 ) , BROWN ( 400 , 799 ) , GREEN ( 800 , 1199 ) , LIGHT_BLUE ( 1200 , 1599 ) , BLUE ( 1600 , 1999 ) , YELLOW ( 2000 , 2399 ) , ORANGE ( 2400 , 2799 ) , RED ( 2800 , 3199 ) , FREE ( 3200 , 4800 ) ; int min , max ; Color ( int min , int max ) { this . min = min ; this . max = max ; } static Color getColor ( int rate ) { for ( Color color : values ( ) ) if ( color . min <= rate && rate <= color . max ) return color ; return null ; } } }
from collections import OrderedDict NEW_LINE import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE a = np . array ( [ int ( i ) for i in input ( ) . split ( ) ] ) NEW_LINE scores = OrderedDict ( ) NEW_LINE scores [ 1 ] = 0 NEW_LINE scores [ 400 ] = 0 NEW_LINE scores [ 800 ] = 0 NEW_LINE scores [ 1200 ] = 0 NEW_LINE scores [ 1600 ] = 0 NEW_LINE scores [ 2000 ] = 0 NEW_LINE scores [ 2400 ] = 0 NEW_LINE scores [ 2800 ] = 0 NEW_LINE scores [ 3200 ] = 0 NEW_LINE for record in a : NEW_LINE INDENT for s in list ( scores . keys ( ) ) [ : : - 1 ] : NEW_LINE INDENT if record >= s : NEW_LINE INDENT scores [ s ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT colors = np . sum ( [ int ( v > 0 ) for k , v in scores . items ( ) if k < 3200 ] ) NEW_LINE if scores [ 3200 ] > 0 and colors == 0 : NEW_LINE INDENT min_colors = 1 NEW_LINE DEDENT else : NEW_LINE INDENT min_colors = colors NEW_LINE DEDENT max_colors = colors + scores [ 3200 ] NEW_LINE print ( min_colors , max_colors ) NEW_LINE
T604
public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) , ans = 0 , colors [ ] = new int [ 9 ] ; for ( int i = 0 , temp ; i < n ; i ++ ) if ( ++ colors [ temp = Color . getColor ( scanner . nextInt ( ) ) . ordinal ( ) ] == 1 && temp != 8 ) ans ++ ; System . out . println ( Math . max ( 1 , ans ) + " ▁ " + ( ans + colors [ 8 ] ) ) ; } enum Color { GRAY ( 1 , 399 ) , BROWN ( 400 , 799 ) , GREEN ( 800 , 1199 ) , LIGHT_BLUE ( 1200 , 1599 ) , BLUE ( 1600 , 1999 ) , YELLOW ( 2000 , 2399 ) , ORANGE ( 2400 , 2799 ) , RED ( 2800 , 3199 ) , FREE ( 3200 , 4800 ) ; int min , max ; Color ( int min , int max ) { this . min = min ; this . max = max ; } static Color getColor ( int rate ) { for ( Color color : values ( ) ) if ( color . min <= rate && rate <= color . max ) return color ; return null ; } } }
import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE wildcard = 0 NEW_LINE color = [ 0 ] * 8 NEW_LINE for a in A : NEW_LINE INDENT if a < 400 : NEW_LINE INDENT color [ 0 ] = 1 NEW_LINE DEDENT elif a < 800 : NEW_LINE INDENT color [ 1 ] = 1 NEW_LINE DEDENT elif a < 1200 : NEW_LINE INDENT color [ 2 ] = 1 NEW_LINE DEDENT elif a < 1600 : NEW_LINE INDENT color [ 3 ] = 1 NEW_LINE DEDENT elif a < 2000 : NEW_LINE INDENT color [ 4 ] = 1 NEW_LINE DEDENT elif a < 2400 : NEW_LINE INDENT color [ 5 ] = 1 NEW_LINE DEDENT elif a < 2800 : NEW_LINE INDENT color [ 6 ] = 1 NEW_LINE DEDENT elif a < 3200 : NEW_LINE INDENT color [ 7 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT wildcard += 1 NEW_LINE DEDENT DEDENT nc = sum ( color ) NEW_LINE print ( max ( 1 , nc ) , nc + wildcard ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T605
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String remain = "01234567" ; int over = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int num = reader . nextInt ( ) / 400 ; if ( num < 8 ) { remain = remain . replace ( Integer . toString ( num ) , " " ) ; } else { over ++ ; } } int min = 8 - remain . length ( ) ; int max = min + over ; if ( min < 1 ) { min = 1 ; } reader . close ( ) ; System . out . print ( min + " ▁ " + max ) ; } }
N = int ( input ( ) ) NEW_LINE a = map ( int , input ( ) . split ( ) ) NEW_LINE color_set = set ( ) NEW_LINE original_cnt = 0 NEW_LINE red_flag = False NEW_LINE for val in a : NEW_LINE INDENT if val >= 3200 : NEW_LINE INDENT original_cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if val >= 2800 : NEW_LINE INDENT red_flag = True NEW_LINE DEDENT color_set . add ( int ( val / 400 ) ) NEW_LINE DEDENT DEDENT if red_flag is True : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if original_cnt > 0 : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) + 1 , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) , len ( color_set ) ) ) NEW_LINE DEDENT DEDENT
T606
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String remain = "01234567" ; int over = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int num = reader . nextInt ( ) / 400 ; if ( num < 8 ) { remain = remain . replace ( Integer . toString ( num ) , " " ) ; } else { over ++ ; } } int min = 8 - remain . length ( ) ; int max = min + over ; if ( min < 1 ) { min = 1 ; } reader . close ( ) ; System . out . print ( min + " ▁ " + max ) ; } }
from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE a = Counter ( list ( map ( lambda x : x // 400 , map ( int , input ( ) . split ( ) ) ) ) ) NEW_LINE c = n = 0 NEW_LINE for key in [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ] : NEW_LINE INDENT if a [ key ] : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for key in [ 8 , 9 , 10 , 11 , 12 ] : NEW_LINE INDENT n += a [ key ] NEW_LINE DEDENT max_n = c + n NEW_LINE if c : NEW_LINE INDENT min_n = c NEW_LINE DEDENT else : NEW_LINE INDENT min_n = 1 NEW_LINE DEDENT print ( min_n , max_n ) NEW_LINE
T607
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String remain = "01234567" ; int over = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int num = reader . nextInt ( ) / 400 ; if ( num < 8 ) { remain = remain . replace ( Integer . toString ( num ) , " " ) ; } else { over ++ ; } } int min = 8 - remain . length ( ) ; int max = min + over ; if ( min < 1 ) { min = 1 ; } reader . close ( ) ; System . out . print ( min + " ▁ " + max ) ; } }
import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE l = [ 0 for _ in range ( 9 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] <= 399 : NEW_LINE INDENT l [ 0 ] += 1 NEW_LINE DEDENT elif 400 <= a [ i ] <= 799 : NEW_LINE INDENT l [ 1 ] += 1 NEW_LINE DEDENT elif 800 <= a [ i ] <= 1199 : NEW_LINE INDENT l [ 2 ] += 1 NEW_LINE DEDENT elif 1200 <= a [ i ] <= 1599 : NEW_LINE INDENT l [ 3 ] += 1 NEW_LINE DEDENT elif 1600 <= a [ i ] <= 1999 : NEW_LINE INDENT l [ 4 ] += 1 NEW_LINE DEDENT elif 2000 <= a [ i ] <= 2399 : NEW_LINE INDENT l [ 5 ] += 1 NEW_LINE DEDENT elif 2400 <= a [ i ] <= 2799 : NEW_LINE INDENT l [ 6 ] += 1 NEW_LINE DEDENT elif 2800 <= a [ i ] <= 3199 : NEW_LINE INDENT l [ 7 ] += 1 NEW_LINE DEDENT elif 3200 <= a [ i ] : NEW_LINE INDENT l [ 8 ] += 1 NEW_LINE DEDENT DEDENT if l [ 8 ] == 0 : NEW_LINE INDENT print ( 9 - l . count ( 0 ) , 9 - l . count ( 0 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if l . count ( 0 ) == 8 : NEW_LINE INDENT print ( 1 , l [ 8 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 8 - l . count ( 0 ) , 8 - l . count ( 0 ) + l [ 8 ] ) NEW_LINE DEDENT DEDENT
T608
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String remain = "01234567" ; int over = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int num = reader . nextInt ( ) / 400 ; if ( num < 8 ) { remain = remain . replace ( Integer . toString ( num ) , " " ) ; } else { over ++ ; } } int min = 8 - remain . length ( ) ; int max = min + over ; if ( min < 1 ) { min = 1 ; } reader . close ( ) ; System . out . print ( min + " ▁ " + max ) ; } }
from collections import OrderedDict NEW_LINE import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE a = np . array ( [ int ( i ) for i in input ( ) . split ( ) ] ) NEW_LINE scores = OrderedDict ( ) NEW_LINE scores [ 1 ] = 0 NEW_LINE scores [ 400 ] = 0 NEW_LINE scores [ 800 ] = 0 NEW_LINE scores [ 1200 ] = 0 NEW_LINE scores [ 1600 ] = 0 NEW_LINE scores [ 2000 ] = 0 NEW_LINE scores [ 2400 ] = 0 NEW_LINE scores [ 2800 ] = 0 NEW_LINE scores [ 3200 ] = 0 NEW_LINE for record in a : NEW_LINE INDENT for s in list ( scores . keys ( ) ) [ : : - 1 ] : NEW_LINE INDENT if record >= s : NEW_LINE INDENT scores [ s ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT colors = np . sum ( [ int ( v > 0 ) for k , v in scores . items ( ) if k < 3200 ] ) NEW_LINE if scores [ 3200 ] > 0 and colors == 0 : NEW_LINE INDENT min_colors = 1 NEW_LINE DEDENT else : NEW_LINE INDENT min_colors = colors NEW_LINE DEDENT max_colors = colors + scores [ 3200 ] NEW_LINE print ( min_colors , max_colors ) NEW_LINE
T609
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String remain = "01234567" ; int over = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int num = reader . nextInt ( ) / 400 ; if ( num < 8 ) { remain = remain . replace ( Integer . toString ( num ) , " " ) ; } else { over ++ ; } } int min = 8 - remain . length ( ) ; int max = min + over ; if ( min < 1 ) { min = 1 ; } reader . close ( ) ; System . out . print ( min + " ▁ " + max ) ; } }
import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE wildcard = 0 NEW_LINE color = [ 0 ] * 8 NEW_LINE for a in A : NEW_LINE INDENT if a < 400 : NEW_LINE INDENT color [ 0 ] = 1 NEW_LINE DEDENT elif a < 800 : NEW_LINE INDENT color [ 1 ] = 1 NEW_LINE DEDENT elif a < 1200 : NEW_LINE INDENT color [ 2 ] = 1 NEW_LINE DEDENT elif a < 1600 : NEW_LINE INDENT color [ 3 ] = 1 NEW_LINE DEDENT elif a < 2000 : NEW_LINE INDENT color [ 4 ] = 1 NEW_LINE DEDENT elif a < 2400 : NEW_LINE INDENT color [ 5 ] = 1 NEW_LINE DEDENT elif a < 2800 : NEW_LINE INDENT color [ 6 ] = 1 NEW_LINE DEDENT elif a < 3200 : NEW_LINE INDENT color [ 7 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT wildcard += 1 NEW_LINE DEDENT DEDENT nc = sum ( color ) NEW_LINE print ( max ( 1 , nc ) , nc + wildcard ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T610
import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; HashSet < Integer > kinds = new HashSet < > ( ) ; int any = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int value = sc . nextInt ( ) ; if ( value <= 399 ) { kinds . add ( 0 ) ; } else if ( value <= 799 ) { kinds . add ( 1 ) ; } else if ( value <= 1199 ) { kinds . add ( 2 ) ; } else if ( value <= 1599 ) { kinds . add ( 3 ) ; } else if ( value <= 1999 ) { kinds . add ( 4 ) ; } else if ( value <= 2399 ) { kinds . add ( 5 ) ; } else if ( value <= 2799 ) { kinds . add ( 6 ) ; } else if ( value <= 3199 ) { kinds . add ( 7 ) ; } else { any ++ ; } } int min = ( kinds . size ( ) == 0 ) ? 1 : kinds . size ( ) ; int max = kinds . size ( ) + any ; System . out . println ( min + " ▁ " + max ) ; } }
N = int ( input ( ) ) NEW_LINE a = map ( int , input ( ) . split ( ) ) NEW_LINE color_set = set ( ) NEW_LINE original_cnt = 0 NEW_LINE red_flag = False NEW_LINE for val in a : NEW_LINE INDENT if val >= 3200 : NEW_LINE INDENT original_cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if val >= 2800 : NEW_LINE INDENT red_flag = True NEW_LINE DEDENT color_set . add ( int ( val / 400 ) ) NEW_LINE DEDENT DEDENT if red_flag is True : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if original_cnt > 0 : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) + 1 , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' { } ▁ { } ' . format ( len ( color_set ) , len ( color_set ) ) ) NEW_LINE DEDENT DEDENT
T611
import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; HashSet < Integer > kinds = new HashSet < > ( ) ; int any = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int value = sc . nextInt ( ) ; if ( value <= 399 ) { kinds . add ( 0 ) ; } else if ( value <= 799 ) { kinds . add ( 1 ) ; } else if ( value <= 1199 ) { kinds . add ( 2 ) ; } else if ( value <= 1599 ) { kinds . add ( 3 ) ; } else if ( value <= 1999 ) { kinds . add ( 4 ) ; } else if ( value <= 2399 ) { kinds . add ( 5 ) ; } else if ( value <= 2799 ) { kinds . add ( 6 ) ; } else if ( value <= 3199 ) { kinds . add ( 7 ) ; } else { any ++ ; } } int min = ( kinds . size ( ) == 0 ) ? 1 : kinds . size ( ) ; int max = kinds . size ( ) + any ; System . out . println ( min + " ▁ " + max ) ; } }
from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE a = Counter ( list ( map ( lambda x : x // 400 , map ( int , input ( ) . split ( ) ) ) ) ) NEW_LINE c = n = 0 NEW_LINE for key in [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ] : NEW_LINE INDENT if a [ key ] : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for key in [ 8 , 9 , 10 , 11 , 12 ] : NEW_LINE INDENT n += a [ key ] NEW_LINE DEDENT max_n = c + n NEW_LINE if c : NEW_LINE INDENT min_n = c NEW_LINE DEDENT else : NEW_LINE INDENT min_n = 1 NEW_LINE DEDENT print ( min_n , max_n ) NEW_LINE
T612
import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; HashSet < Integer > kinds = new HashSet < > ( ) ; int any = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int value = sc . nextInt ( ) ; if ( value <= 399 ) { kinds . add ( 0 ) ; } else if ( value <= 799 ) { kinds . add ( 1 ) ; } else if ( value <= 1199 ) { kinds . add ( 2 ) ; } else if ( value <= 1599 ) { kinds . add ( 3 ) ; } else if ( value <= 1999 ) { kinds . add ( 4 ) ; } else if ( value <= 2399 ) { kinds . add ( 5 ) ; } else if ( value <= 2799 ) { kinds . add ( 6 ) ; } else if ( value <= 3199 ) { kinds . add ( 7 ) ; } else { any ++ ; } } int min = ( kinds . size ( ) == 0 ) ? 1 : kinds . size ( ) ; int max = kinds . size ( ) + any ; System . out . println ( min + " ▁ " + max ) ; } }
import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE l = [ 0 for _ in range ( 9 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] <= 399 : NEW_LINE INDENT l [ 0 ] += 1 NEW_LINE DEDENT elif 400 <= a [ i ] <= 799 : NEW_LINE INDENT l [ 1 ] += 1 NEW_LINE DEDENT elif 800 <= a [ i ] <= 1199 : NEW_LINE INDENT l [ 2 ] += 1 NEW_LINE DEDENT elif 1200 <= a [ i ] <= 1599 : NEW_LINE INDENT l [ 3 ] += 1 NEW_LINE DEDENT elif 1600 <= a [ i ] <= 1999 : NEW_LINE INDENT l [ 4 ] += 1 NEW_LINE DEDENT elif 2000 <= a [ i ] <= 2399 : NEW_LINE INDENT l [ 5 ] += 1 NEW_LINE DEDENT elif 2400 <= a [ i ] <= 2799 : NEW_LINE INDENT l [ 6 ] += 1 NEW_LINE DEDENT elif 2800 <= a [ i ] <= 3199 : NEW_LINE INDENT l [ 7 ] += 1 NEW_LINE DEDENT elif 3200 <= a [ i ] : NEW_LINE INDENT l [ 8 ] += 1 NEW_LINE DEDENT DEDENT if l [ 8 ] == 0 : NEW_LINE INDENT print ( 9 - l . count ( 0 ) , 9 - l . count ( 0 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if l . count ( 0 ) == 8 : NEW_LINE INDENT print ( 1 , l [ 8 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 8 - l . count ( 0 ) , 8 - l . count ( 0 ) + l [ 8 ] ) NEW_LINE DEDENT DEDENT
T613
import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; HashSet < Integer > kinds = new HashSet < > ( ) ; int any = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int value = sc . nextInt ( ) ; if ( value <= 399 ) { kinds . add ( 0 ) ; } else if ( value <= 799 ) { kinds . add ( 1 ) ; } else if ( value <= 1199 ) { kinds . add ( 2 ) ; } else if ( value <= 1599 ) { kinds . add ( 3 ) ; } else if ( value <= 1999 ) { kinds . add ( 4 ) ; } else if ( value <= 2399 ) { kinds . add ( 5 ) ; } else if ( value <= 2799 ) { kinds . add ( 6 ) ; } else if ( value <= 3199 ) { kinds . add ( 7 ) ; } else { any ++ ; } } int min = ( kinds . size ( ) == 0 ) ? 1 : kinds . size ( ) ; int max = kinds . size ( ) + any ; System . out . println ( min + " ▁ " + max ) ; } }
from collections import OrderedDict NEW_LINE import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE a = np . array ( [ int ( i ) for i in input ( ) . split ( ) ] ) NEW_LINE scores = OrderedDict ( ) NEW_LINE scores [ 1 ] = 0 NEW_LINE scores [ 400 ] = 0 NEW_LINE scores [ 800 ] = 0 NEW_LINE scores [ 1200 ] = 0 NEW_LINE scores [ 1600 ] = 0 NEW_LINE scores [ 2000 ] = 0 NEW_LINE scores [ 2400 ] = 0 NEW_LINE scores [ 2800 ] = 0 NEW_LINE scores [ 3200 ] = 0 NEW_LINE for record in a : NEW_LINE INDENT for s in list ( scores . keys ( ) ) [ : : - 1 ] : NEW_LINE INDENT if record >= s : NEW_LINE INDENT scores [ s ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT colors = np . sum ( [ int ( v > 0 ) for k , v in scores . items ( ) if k < 3200 ] ) NEW_LINE if scores [ 3200 ] > 0 and colors == 0 : NEW_LINE INDENT min_colors = 1 NEW_LINE DEDENT else : NEW_LINE INDENT min_colors = colors NEW_LINE DEDENT max_colors = colors + scores [ 3200 ] NEW_LINE print ( min_colors , max_colors ) NEW_LINE
T614
import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; HashSet < Integer > kinds = new HashSet < > ( ) ; int any = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int value = sc . nextInt ( ) ; if ( value <= 399 ) { kinds . add ( 0 ) ; } else if ( value <= 799 ) { kinds . add ( 1 ) ; } else if ( value <= 1199 ) { kinds . add ( 2 ) ; } else if ( value <= 1599 ) { kinds . add ( 3 ) ; } else if ( value <= 1999 ) { kinds . add ( 4 ) ; } else if ( value <= 2399 ) { kinds . add ( 5 ) ; } else if ( value <= 2799 ) { kinds . add ( 6 ) ; } else if ( value <= 3199 ) { kinds . add ( 7 ) ; } else { any ++ ; } } int min = ( kinds . size ( ) == 0 ) ? 1 : kinds . size ( ) ; int max = kinds . size ( ) + any ; System . out . println ( min + " ▁ " + max ) ; } }
import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE wildcard = 0 NEW_LINE color = [ 0 ] * 8 NEW_LINE for a in A : NEW_LINE INDENT if a < 400 : NEW_LINE INDENT color [ 0 ] = 1 NEW_LINE DEDENT elif a < 800 : NEW_LINE INDENT color [ 1 ] = 1 NEW_LINE DEDENT elif a < 1200 : NEW_LINE INDENT color [ 2 ] = 1 NEW_LINE DEDENT elif a < 1600 : NEW_LINE INDENT color [ 3 ] = 1 NEW_LINE DEDENT elif a < 2000 : NEW_LINE INDENT color [ 4 ] = 1 NEW_LINE DEDENT elif a < 2400 : NEW_LINE INDENT color [ 5 ] = 1 NEW_LINE DEDENT elif a < 2800 : NEW_LINE INDENT color [ 6 ] = 1 NEW_LINE DEDENT elif a < 3200 : NEW_LINE INDENT color [ 7 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT wildcard += 1 NEW_LINE DEDENT DEDENT nc = sum ( color ) NEW_LINE print ( max ( 1 , nc ) , nc + wildcard ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T615
import java . util . * ; public class Main { public static boolean isValid ( char c ) { if ( c == ' A ' || c == ' C ' || c == ' T ' || c == ' G ' ) { return true ; } return false ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int max = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int count = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { if ( isValid ( s . charAt ( j ) ) ) { count ++ ; max = Math . max ( max , count ) ; } else { break ; } } } System . out . println ( max ) ; } }
print ( len ( max ( " " . join ( str ( int ( c in { " A " , " T " , " G " , " C " } ) ) for c in input ( ) ) . split ( "0" ) ) ) ) NEW_LINE
T616
import java . util . * ; public class Main { public static boolean isValid ( char c ) { if ( c == ' A ' || c == ' C ' || c == ' T ' || c == ' G ' ) { return true ; } return false ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int max = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int count = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { if ( isValid ( s . charAt ( j ) ) ) { count ++ ; max = Math . max ( max , count ) ; } else { break ; } } } System . out . println ( max ) ; } }
s = input ( ) NEW_LINE counter = 0 NEW_LINE max_count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' A ' or s [ i ] == ' C ' or s [ i ] == ' G ' or s [ i ] == ' T ' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE counter = 0 NEW_LINE DEDENT else : NEW_LINE INDENT counter = 0 NEW_LINE DEDENT DEDENT DEDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE DEDENT print ( max_count ) NEW_LINE
T617
import java . util . * ; public class Main { public static boolean isValid ( char c ) { if ( c == ' A ' || c == ' C ' || c == ' T ' || c == ' G ' ) { return true ; } return false ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int max = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int count = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { if ( isValid ( s . charAt ( j ) ) ) { count ++ ; max = Math . max ( max , count ) ; } else { break ; } } } System . out . println ( max ) ; } }
l = list ( input ( ) ) NEW_LINE counter = 0 NEW_LINE atcorder = [ ] NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if ( l [ i ] == " A " or l [ i ] == " T " or l [ i ] == " G " or l [ i ] == " C " ) : NEW_LINE INDENT counter += 1 NEW_LINE atcorder . append ( counter ) NEW_LINE continue NEW_LINE DEDENT counter = 0 NEW_LINE DEDENT if ( len ( atcorder ) != 0 ) : NEW_LINE INDENT print ( max ( atcorder ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "0" ) NEW_LINE DEDENT
T618
import java . util . * ; public class Main { public static boolean isValid ( char c ) { if ( c == ' A ' || c == ' C ' || c == ' T ' || c == ' G ' ) { return true ; } return false ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int max = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int count = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { if ( isValid ( s . charAt ( j ) ) ) { count ++ ; max = Math . max ( max , count ) ; } else { break ; } } } System . out . println ( max ) ; } }
import sys NEW_LINE def i2s ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) . rstrip ( ) NEW_LINE DEDENT def ii2ss ( n ) : NEW_LINE INDENT return [ sys . stdin . readline ( ) for _ in range ( n ) ] NEW_LINE DEDENT def sp2nn ( sp , sep = ' ▁ ' ) : NEW_LINE INDENT return [ int ( s ) for s in sp . split ( sep ) ] NEW_LINE DEDENT def ss2nn ( ss ) : NEW_LINE INDENT return [ int ( s ) for s in list ( ss ) ] NEW_LINE DEDENT def main ( S ) : NEW_LINE INDENT st = set ( ( ' A ' , ' C ' , ' G ' , ' T ' ) ) NEW_LINE cmax = 0 NEW_LINE c = 0 NEW_LINE for s in S : NEW_LINE INDENT if s in st : NEW_LINE INDENT c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT c = 0 NEW_LINE DEDENT DEDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT print ( cmax ) NEW_LINE DEDENT main ( i2s ( ) ) NEW_LINE
T619
import java . util . * ; public class Main { public static boolean isValid ( char c ) { if ( c == ' A ' || c == ' C ' || c == ' T ' || c == ' G ' ) { return true ; } return false ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int max = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int count = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { if ( isValid ( s . charAt ( j ) ) ) { count ++ ; max = Math . max ( max , count ) ; } else { break ; } } } System . out . println ( max ) ; } }
s = input ( ) NEW_LINE t = [ - 1 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] != " A " and s [ i ] != " G " and s [ i ] != " C " and s [ i ] != " T " : NEW_LINE INDENT t . append ( i ) NEW_LINE DEDENT DEDENT t . append ( len ( s ) ) NEW_LINE ans = 0 NEW_LINE for j in range ( len ( t ) - 1 ) : NEW_LINE INDENT x = t [ j + 1 ] - t [ j ] - 1 NEW_LINE if x > ans : NEW_LINE INDENT ans = x NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T620
import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { char moji [ ] = new char [ 11 ] ; int count [ ] = new int [ 11 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { moji [ i ] = ( char ) System . in . read ( ) ; if ( moji [ i ] == ' \n ' ) { break ; } } for ( int i = 0 , j = 0 ; i < moji . length ; i ++ , j ++ ) { while ( moji [ i ] == ' A ' || moji [ i ] == ' C ' || moji [ i ] == ' G ' || moji [ i ] == ' T ' ) { count [ j ] ++ ; i ++ ; } } int max = 0 ; for ( int i = 0 ; i < count . length ; i ++ ) { if ( max < count [ i ] ) { max = count [ i ] ; } } System . out . println ( max ) ; } }
print ( len ( max ( " " . join ( str ( int ( c in { " A " , " T " , " G " , " C " } ) ) for c in input ( ) ) . split ( "0" ) ) ) ) NEW_LINE
T621
import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { char moji [ ] = new char [ 11 ] ; int count [ ] = new int [ 11 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { moji [ i ] = ( char ) System . in . read ( ) ; if ( moji [ i ] == ' \n ' ) { break ; } } for ( int i = 0 , j = 0 ; i < moji . length ; i ++ , j ++ ) { while ( moji [ i ] == ' A ' || moji [ i ] == ' C ' || moji [ i ] == ' G ' || moji [ i ] == ' T ' ) { count [ j ] ++ ; i ++ ; } } int max = 0 ; for ( int i = 0 ; i < count . length ; i ++ ) { if ( max < count [ i ] ) { max = count [ i ] ; } } System . out . println ( max ) ; } }
s = input ( ) NEW_LINE counter = 0 NEW_LINE max_count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' A ' or s [ i ] == ' C ' or s [ i ] == ' G ' or s [ i ] == ' T ' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE counter = 0 NEW_LINE DEDENT else : NEW_LINE INDENT counter = 0 NEW_LINE DEDENT DEDENT DEDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE DEDENT print ( max_count ) NEW_LINE
T622
import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { char moji [ ] = new char [ 11 ] ; int count [ ] = new int [ 11 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { moji [ i ] = ( char ) System . in . read ( ) ; if ( moji [ i ] == ' \n ' ) { break ; } } for ( int i = 0 , j = 0 ; i < moji . length ; i ++ , j ++ ) { while ( moji [ i ] == ' A ' || moji [ i ] == ' C ' || moji [ i ] == ' G ' || moji [ i ] == ' T ' ) { count [ j ] ++ ; i ++ ; } } int max = 0 ; for ( int i = 0 ; i < count . length ; i ++ ) { if ( max < count [ i ] ) { max = count [ i ] ; } } System . out . println ( max ) ; } }
l = list ( input ( ) ) NEW_LINE counter = 0 NEW_LINE atcorder = [ ] NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if ( l [ i ] == " A " or l [ i ] == " T " or l [ i ] == " G " or l [ i ] == " C " ) : NEW_LINE INDENT counter += 1 NEW_LINE atcorder . append ( counter ) NEW_LINE continue NEW_LINE DEDENT counter = 0 NEW_LINE DEDENT if ( len ( atcorder ) != 0 ) : NEW_LINE INDENT print ( max ( atcorder ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "0" ) NEW_LINE DEDENT
T623
import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { char moji [ ] = new char [ 11 ] ; int count [ ] = new int [ 11 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { moji [ i ] = ( char ) System . in . read ( ) ; if ( moji [ i ] == ' \n ' ) { break ; } } for ( int i = 0 , j = 0 ; i < moji . length ; i ++ , j ++ ) { while ( moji [ i ] == ' A ' || moji [ i ] == ' C ' || moji [ i ] == ' G ' || moji [ i ] == ' T ' ) { count [ j ] ++ ; i ++ ; } } int max = 0 ; for ( int i = 0 ; i < count . length ; i ++ ) { if ( max < count [ i ] ) { max = count [ i ] ; } } System . out . println ( max ) ; } }
import sys NEW_LINE def i2s ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) . rstrip ( ) NEW_LINE DEDENT def ii2ss ( n ) : NEW_LINE INDENT return [ sys . stdin . readline ( ) for _ in range ( n ) ] NEW_LINE DEDENT def sp2nn ( sp , sep = ' ▁ ' ) : NEW_LINE INDENT return [ int ( s ) for s in sp . split ( sep ) ] NEW_LINE DEDENT def ss2nn ( ss ) : NEW_LINE INDENT return [ int ( s ) for s in list ( ss ) ] NEW_LINE DEDENT def main ( S ) : NEW_LINE INDENT st = set ( ( ' A ' , ' C ' , ' G ' , ' T ' ) ) NEW_LINE cmax = 0 NEW_LINE c = 0 NEW_LINE for s in S : NEW_LINE INDENT if s in st : NEW_LINE INDENT c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT c = 0 NEW_LINE DEDENT DEDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT print ( cmax ) NEW_LINE DEDENT main ( i2s ( ) ) NEW_LINE
T624
import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { char moji [ ] = new char [ 11 ] ; int count [ ] = new int [ 11 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { moji [ i ] = ( char ) System . in . read ( ) ; if ( moji [ i ] == ' \n ' ) { break ; } } for ( int i = 0 , j = 0 ; i < moji . length ; i ++ , j ++ ) { while ( moji [ i ] == ' A ' || moji [ i ] == ' C ' || moji [ i ] == ' G ' || moji [ i ] == ' T ' ) { count [ j ] ++ ; i ++ ; } } int max = 0 ; for ( int i = 0 ; i < count . length ; i ++ ) { if ( max < count [ i ] ) { max = count [ i ] ; } } System . out . println ( max ) ; } }
s = input ( ) NEW_LINE t = [ - 1 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] != " A " and s [ i ] != " G " and s [ i ] != " C " and s [ i ] != " T " : NEW_LINE INDENT t . append ( i ) NEW_LINE DEDENT DEDENT t . append ( len ( s ) ) NEW_LINE ans = 0 NEW_LINE for j in range ( len ( t ) - 1 ) : NEW_LINE INDENT x = t [ j + 1 ] - t [ j ] - 1 NEW_LINE if x > ans : NEW_LINE INDENT ans = x NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T625
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BATCoder solver = new BATCoder ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BATCoder { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int longest = 0 ; int current = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' || s . charAt ( i ) == ' C ' || s . charAt ( i ) == ' G ' || s . charAt ( i ) == ' T ' ) { current ++ ; if ( current > longest ) { longest = current ; } } else { current = 0 ; } } out . println ( longest ) ; } } }
print ( len ( max ( " " . join ( str ( int ( c in { " A " , " T " , " G " , " C " } ) ) for c in input ( ) ) . split ( "0" ) ) ) ) NEW_LINE
T626
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BATCoder solver = new BATCoder ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BATCoder { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int longest = 0 ; int current = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' || s . charAt ( i ) == ' C ' || s . charAt ( i ) == ' G ' || s . charAt ( i ) == ' T ' ) { current ++ ; if ( current > longest ) { longest = current ; } } else { current = 0 ; } } out . println ( longest ) ; } } }
s = input ( ) NEW_LINE counter = 0 NEW_LINE max_count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' A ' or s [ i ] == ' C ' or s [ i ] == ' G ' or s [ i ] == ' T ' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE counter = 0 NEW_LINE DEDENT else : NEW_LINE INDENT counter = 0 NEW_LINE DEDENT DEDENT DEDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE DEDENT print ( max_count ) NEW_LINE
T627
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BATCoder solver = new BATCoder ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BATCoder { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int longest = 0 ; int current = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' || s . charAt ( i ) == ' C ' || s . charAt ( i ) == ' G ' || s . charAt ( i ) == ' T ' ) { current ++ ; if ( current > longest ) { longest = current ; } } else { current = 0 ; } } out . println ( longest ) ; } } }
l = list ( input ( ) ) NEW_LINE counter = 0 NEW_LINE atcorder = [ ] NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if ( l [ i ] == " A " or l [ i ] == " T " or l [ i ] == " G " or l [ i ] == " C " ) : NEW_LINE INDENT counter += 1 NEW_LINE atcorder . append ( counter ) NEW_LINE continue NEW_LINE DEDENT counter = 0 NEW_LINE DEDENT if ( len ( atcorder ) != 0 ) : NEW_LINE INDENT print ( max ( atcorder ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "0" ) NEW_LINE DEDENT
T628
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BATCoder solver = new BATCoder ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BATCoder { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int longest = 0 ; int current = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' || s . charAt ( i ) == ' C ' || s . charAt ( i ) == ' G ' || s . charAt ( i ) == ' T ' ) { current ++ ; if ( current > longest ) { longest = current ; } } else { current = 0 ; } } out . println ( longest ) ; } } }
import sys NEW_LINE def i2s ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) . rstrip ( ) NEW_LINE DEDENT def ii2ss ( n ) : NEW_LINE INDENT return [ sys . stdin . readline ( ) for _ in range ( n ) ] NEW_LINE DEDENT def sp2nn ( sp , sep = ' ▁ ' ) : NEW_LINE INDENT return [ int ( s ) for s in sp . split ( sep ) ] NEW_LINE DEDENT def ss2nn ( ss ) : NEW_LINE INDENT return [ int ( s ) for s in list ( ss ) ] NEW_LINE DEDENT def main ( S ) : NEW_LINE INDENT st = set ( ( ' A ' , ' C ' , ' G ' , ' T ' ) ) NEW_LINE cmax = 0 NEW_LINE c = 0 NEW_LINE for s in S : NEW_LINE INDENT if s in st : NEW_LINE INDENT c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT c = 0 NEW_LINE DEDENT DEDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT print ( cmax ) NEW_LINE DEDENT main ( i2s ( ) ) NEW_LINE
T629
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BATCoder solver = new BATCoder ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BATCoder { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int longest = 0 ; int current = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' || s . charAt ( i ) == ' C ' || s . charAt ( i ) == ' G ' || s . charAt ( i ) == ' T ' ) { current ++ ; if ( current > longest ) { longest = current ; } } else { current = 0 ; } } out . println ( longest ) ; } } }
s = input ( ) NEW_LINE t = [ - 1 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] != " A " and s [ i ] != " G " and s [ i ] != " C " and s [ i ] != " T " : NEW_LINE INDENT t . append ( i ) NEW_LINE DEDENT DEDENT t . append ( len ( s ) ) NEW_LINE ans = 0 NEW_LINE for j in range ( len ( t ) - 1 ) : NEW_LINE INDENT x = t [ j + 1 ] - t [ j ] - 1 NEW_LINE if x > ans : NEW_LINE INDENT ans = x NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T630
import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; char [ ] arr = br . readLine ( ) . toCharArray ( ) ; int max = 0 , cur = 0 ; for ( char c : arr ) { if ( c == ' A ' || c == ' T ' || c == ' C ' || c == ' G ' ) { max = Math . max ( max , ++ cur ) ; } else { cur = 0 ; } } bw . write ( max + " " ) ; bw . close ( ) ; } }
print ( len ( max ( " " . join ( str ( int ( c in { " A " , " T " , " G " , " C " } ) ) for c in input ( ) ) . split ( "0" ) ) ) ) NEW_LINE
T631
import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; char [ ] arr = br . readLine ( ) . toCharArray ( ) ; int max = 0 , cur = 0 ; for ( char c : arr ) { if ( c == ' A ' || c == ' T ' || c == ' C ' || c == ' G ' ) { max = Math . max ( max , ++ cur ) ; } else { cur = 0 ; } } bw . write ( max + " " ) ; bw . close ( ) ; } }
s = input ( ) NEW_LINE counter = 0 NEW_LINE max_count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' A ' or s [ i ] == ' C ' or s [ i ] == ' G ' or s [ i ] == ' T ' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE counter = 0 NEW_LINE DEDENT else : NEW_LINE INDENT counter = 0 NEW_LINE DEDENT DEDENT DEDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE DEDENT print ( max_count ) NEW_LINE
T632
import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; char [ ] arr = br . readLine ( ) . toCharArray ( ) ; int max = 0 , cur = 0 ; for ( char c : arr ) { if ( c == ' A ' || c == ' T ' || c == ' C ' || c == ' G ' ) { max = Math . max ( max , ++ cur ) ; } else { cur = 0 ; } } bw . write ( max + " " ) ; bw . close ( ) ; } }
l = list ( input ( ) ) NEW_LINE counter = 0 NEW_LINE atcorder = [ ] NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if ( l [ i ] == " A " or l [ i ] == " T " or l [ i ] == " G " or l [ i ] == " C " ) : NEW_LINE INDENT counter += 1 NEW_LINE atcorder . append ( counter ) NEW_LINE continue NEW_LINE DEDENT counter = 0 NEW_LINE DEDENT if ( len ( atcorder ) != 0 ) : NEW_LINE INDENT print ( max ( atcorder ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "0" ) NEW_LINE DEDENT
T633
import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; char [ ] arr = br . readLine ( ) . toCharArray ( ) ; int max = 0 , cur = 0 ; for ( char c : arr ) { if ( c == ' A ' || c == ' T ' || c == ' C ' || c == ' G ' ) { max = Math . max ( max , ++ cur ) ; } else { cur = 0 ; } } bw . write ( max + " " ) ; bw . close ( ) ; } }
import sys NEW_LINE def i2s ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) . rstrip ( ) NEW_LINE DEDENT def ii2ss ( n ) : NEW_LINE INDENT return [ sys . stdin . readline ( ) for _ in range ( n ) ] NEW_LINE DEDENT def sp2nn ( sp , sep = ' ▁ ' ) : NEW_LINE INDENT return [ int ( s ) for s in sp . split ( sep ) ] NEW_LINE DEDENT def ss2nn ( ss ) : NEW_LINE INDENT return [ int ( s ) for s in list ( ss ) ] NEW_LINE DEDENT def main ( S ) : NEW_LINE INDENT st = set ( ( ' A ' , ' C ' , ' G ' , ' T ' ) ) NEW_LINE cmax = 0 NEW_LINE c = 0 NEW_LINE for s in S : NEW_LINE INDENT if s in st : NEW_LINE INDENT c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT c = 0 NEW_LINE DEDENT DEDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT print ( cmax ) NEW_LINE DEDENT main ( i2s ( ) ) NEW_LINE
T634
import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; char [ ] arr = br . readLine ( ) . toCharArray ( ) ; int max = 0 , cur = 0 ; for ( char c : arr ) { if ( c == ' A ' || c == ' T ' || c == ' C ' || c == ' G ' ) { max = Math . max ( max , ++ cur ) ; } else { cur = 0 ; } } bw . write ( max + " " ) ; bw . close ( ) ; } }
s = input ( ) NEW_LINE t = [ - 1 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] != " A " and s [ i ] != " G " and s [ i ] != " C " and s [ i ] != " T " : NEW_LINE INDENT t . append ( i ) NEW_LINE DEDENT DEDENT t . append ( len ( s ) ) NEW_LINE ans = 0 NEW_LINE for j in range ( len ( t ) - 1 ) : NEW_LINE INDENT x = t [ j + 1 ] - t [ j ] - 1 NEW_LINE if x > ans : NEW_LINE INDENT ans = x NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T635
import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Main main = new Main ( ) ; main . start ( ) ; } public void start ( ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String letters [ ] = str . split ( " " ) ; int max = 0 ; for ( int i = 0 ; i < letters . length ; i ++ ) { int num = countLength ( letters , i ) ; if ( num > max ) max = num ; } System . out . println ( max ) ; } public int countLength ( String [ ] letters , int index ) { int count = 0 ; for ( int i = index ; i < letters . length ; i ++ ) { if ( letters [ i ] . equals ( " A " ) || letters [ i ] . equals ( " C " ) || letters [ i ] . equals ( " T " ) || letters [ i ] . equals ( " G " ) ) { count ++ ; } else { return count ; } } return count ++ ; } }
print ( len ( max ( " " . join ( str ( int ( c in { " A " , " T " , " G " , " C " } ) ) for c in input ( ) ) . split ( "0" ) ) ) ) NEW_LINE
T636
import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Main main = new Main ( ) ; main . start ( ) ; } public void start ( ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String letters [ ] = str . split ( " " ) ; int max = 0 ; for ( int i = 0 ; i < letters . length ; i ++ ) { int num = countLength ( letters , i ) ; if ( num > max ) max = num ; } System . out . println ( max ) ; } public int countLength ( String [ ] letters , int index ) { int count = 0 ; for ( int i = index ; i < letters . length ; i ++ ) { if ( letters [ i ] . equals ( " A " ) || letters [ i ] . equals ( " C " ) || letters [ i ] . equals ( " T " ) || letters [ i ] . equals ( " G " ) ) { count ++ ; } else { return count ; } } return count ++ ; } }
s = input ( ) NEW_LINE counter = 0 NEW_LINE max_count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' A ' or s [ i ] == ' C ' or s [ i ] == ' G ' or s [ i ] == ' T ' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE counter = 0 NEW_LINE DEDENT else : NEW_LINE INDENT counter = 0 NEW_LINE DEDENT DEDENT DEDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE DEDENT print ( max_count ) NEW_LINE
T637
import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Main main = new Main ( ) ; main . start ( ) ; } public void start ( ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String letters [ ] = str . split ( " " ) ; int max = 0 ; for ( int i = 0 ; i < letters . length ; i ++ ) { int num = countLength ( letters , i ) ; if ( num > max ) max = num ; } System . out . println ( max ) ; } public int countLength ( String [ ] letters , int index ) { int count = 0 ; for ( int i = index ; i < letters . length ; i ++ ) { if ( letters [ i ] . equals ( " A " ) || letters [ i ] . equals ( " C " ) || letters [ i ] . equals ( " T " ) || letters [ i ] . equals ( " G " ) ) { count ++ ; } else { return count ; } } return count ++ ; } }
l = list ( input ( ) ) NEW_LINE counter = 0 NEW_LINE atcorder = [ ] NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if ( l [ i ] == " A " or l [ i ] == " T " or l [ i ] == " G " or l [ i ] == " C " ) : NEW_LINE INDENT counter += 1 NEW_LINE atcorder . append ( counter ) NEW_LINE continue NEW_LINE DEDENT counter = 0 NEW_LINE DEDENT if ( len ( atcorder ) != 0 ) : NEW_LINE INDENT print ( max ( atcorder ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "0" ) NEW_LINE DEDENT
T638
import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Main main = new Main ( ) ; main . start ( ) ; } public void start ( ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String letters [ ] = str . split ( " " ) ; int max = 0 ; for ( int i = 0 ; i < letters . length ; i ++ ) { int num = countLength ( letters , i ) ; if ( num > max ) max = num ; } System . out . println ( max ) ; } public int countLength ( String [ ] letters , int index ) { int count = 0 ; for ( int i = index ; i < letters . length ; i ++ ) { if ( letters [ i ] . equals ( " A " ) || letters [ i ] . equals ( " C " ) || letters [ i ] . equals ( " T " ) || letters [ i ] . equals ( " G " ) ) { count ++ ; } else { return count ; } } return count ++ ; } }
import sys NEW_LINE def i2s ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) . rstrip ( ) NEW_LINE DEDENT def ii2ss ( n ) : NEW_LINE INDENT return [ sys . stdin . readline ( ) for _ in range ( n ) ] NEW_LINE DEDENT def sp2nn ( sp , sep = ' ▁ ' ) : NEW_LINE INDENT return [ int ( s ) for s in sp . split ( sep ) ] NEW_LINE DEDENT def ss2nn ( ss ) : NEW_LINE INDENT return [ int ( s ) for s in list ( ss ) ] NEW_LINE DEDENT def main ( S ) : NEW_LINE INDENT st = set ( ( ' A ' , ' C ' , ' G ' , ' T ' ) ) NEW_LINE cmax = 0 NEW_LINE c = 0 NEW_LINE for s in S : NEW_LINE INDENT if s in st : NEW_LINE INDENT c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT c = 0 NEW_LINE DEDENT DEDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT print ( cmax ) NEW_LINE DEDENT main ( i2s ( ) ) NEW_LINE
T639
import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Main main = new Main ( ) ; main . start ( ) ; } public void start ( ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String letters [ ] = str . split ( " " ) ; int max = 0 ; for ( int i = 0 ; i < letters . length ; i ++ ) { int num = countLength ( letters , i ) ; if ( num > max ) max = num ; } System . out . println ( max ) ; } public int countLength ( String [ ] letters , int index ) { int count = 0 ; for ( int i = index ; i < letters . length ; i ++ ) { if ( letters [ i ] . equals ( " A " ) || letters [ i ] . equals ( " C " ) || letters [ i ] . equals ( " T " ) || letters [ i ] . equals ( " G " ) ) { count ++ ; } else { return count ; } } return count ++ ; } }
s = input ( ) NEW_LINE t = [ - 1 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] != " A " and s [ i ] != " G " and s [ i ] != " C " and s [ i ] != " T " : NEW_LINE INDENT t . append ( i ) NEW_LINE DEDENT DEDENT t . append ( len ( s ) ) NEW_LINE ans = 0 NEW_LINE for j in range ( len ( t ) - 1 ) : NEW_LINE INDENT x = t [ j + 1 ] - t [ j ] - 1 NEW_LINE if x > ans : NEW_LINE INDENT ans = x NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T640
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) * 10 ; long ans = 0 ; for ( long i = 10 ; i < 10000000000L ; i *= 10 ) { long digit = N % ( i * 10 ) / i ; ans += N / ( i * 10 ) * i / 10 ; if ( digit == 1 ) { ans += N % i / 10 + 1 ; } else if ( digit != 0 ) { ans += i / 10 ; } } System . out . println ( ans ) ; } }
N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 9 ) : NEW_LINE INDENT A = ( N // ( 10 ** ( i ) ) ) NEW_LINE if ( A ) % 10 == 1 : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE ans += ( N % ( 10 ** ( i ) ) + 1 ) NEW_LINE DEDENT elif ( A ) % 10 > 1 : NEW_LINE INDENT ans += ( A // 10 + 1 ) * ( 10 ** i ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T641
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) * 10 ; long ans = 0 ; for ( long i = 10 ; i < 10000000000L ; i *= 10 ) { long digit = N % ( i * 10 ) / i ; ans += N / ( i * 10 ) * i / 10 ; if ( digit == 1 ) { ans += N % i / 10 + 1 ; } else if ( digit != 0 ) { ans += i / 10 ; } } System . out . println ( ans ) ; } }
def one ( N : int ) -> int : NEW_LINE INDENT res = 0 NEW_LINE M = 10 NEW_LINE while N // M : NEW_LINE INDENT R = N % M NEW_LINE res += ( N - R ) // 10 NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT res += R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT res += M // 10 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res += 0 NEW_LINE DEDENT M *= 10 NEW_LINE DEDENT R = N % M NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT return res + R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return res + M // 10 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = one ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT
T642
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) * 10 ; long ans = 0 ; for ( long i = 10 ; i < 10000000000L ; i *= 10 ) { long digit = N % ( i * 10 ) / i ; ans += N / ( i * 10 ) * i / 10 ; if ( digit == 1 ) { ans += N % i / 10 + 1 ; } else if ( digit != 0 ) { ans += i / 10 ; } } System . out . println ( ans ) ; } }
import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = input ( ) [ : - 1 ] NEW_LINE dp = [ [ [ 0 ] * ( len ( N ) + 1 ) for _ in range ( 2 ) ] for _ in range ( len ( N ) + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) ) : NEW_LINE INDENT if dp [ i ] [ j ] [ k ] == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT elif j == 1 : NEW_LINE INDENT dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] * 9 NEW_LINE DEDENT else : NEW_LINE INDENT if N [ i ] == '1' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT elif N [ i ] == '0' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] = dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] = dp [ i ] [ j ] [ k ] * ( int ( N [ i ] ) - 1 ) NEW_LINE dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) + 1 ) : NEW_LINE INDENT if dp [ len ( N ) ] [ j ] [ k ] : NEW_LINE INDENT ans += k * dp [ len ( N ) ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
T643
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) * 10 ; long ans = 0 ; for ( long i = 10 ; i < 10000000000L ; i *= 10 ) { long digit = N % ( i * 10 ) / i ; ans += N / ( i * 10 ) * i / 10 ; if ( digit == 1 ) { ans += N % i / 10 + 1 ; } else if ( digit != 0 ) { ans += i / 10 ; } } System . out . println ( ans ) ; } }
n = input ( ) NEW_LINE memo = [ [ [ None for _ in range ( len ( n ) + 1 ) ] for _ in range ( 2 ) ] for _ in range ( len ( n ) + 1 ) ] NEW_LINE def rec ( i , threshold , s ) : NEW_LINE INDENT if i == len ( n ) : NEW_LINE INDENT return s NEW_LINE DEDENT if memo [ i ] [ threshold ] [ s ] is not None : NEW_LINE INDENT return memo [ i ] [ threshold ] [ s ] NEW_LINE DEDENT ret = 0 NEW_LINE limit = int ( n [ i ] ) if threshold == 1 else 9 NEW_LINE for j in range ( limit + 1 ) : NEW_LINE INDENT nex_threshold = 1 if ( j == limit and threshold == 1 ) else 0 NEW_LINE if j == 1 : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s ) NEW_LINE DEDENT memo [ i ] [ threshold ] [ s ] = ret NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( rec ( 0 , 1 , 0 ) ) NEW_LINE
T644
import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) * 10 ; long ans = 0 ; for ( long i = 10 ; i < 10000000000L ; i *= 10 ) { long digit = N % ( i * 10 ) / i ; ans += N / ( i * 10 ) * i / 10 ; if ( digit == 1 ) { ans += N % i / 10 + 1 ; } else if ( digit != 0 ) { ans += i / 10 ; } } System . out . println ( ans ) ; } }
def dp_table ( * counts ) : NEW_LINE INDENT if counts : NEW_LINE INDENT return [ dp_table ( * counts [ 1 : ] ) for _ in range ( counts [ 0 ] ) ] NEW_LINE DEDENT else : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT def solve ( dp , N : str , index : int = 0 , tight : bool = True , amount_1 : int = 0 ) : NEW_LINE INDENT if len ( N ) == index : NEW_LINE INDENT return amount_1 NEW_LINE DEDENT elif dp [ index ] [ tight ] [ amount_1 ] is not None : NEW_LINE INDENT return dp [ index ] [ tight ] [ amount_1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if tight : NEW_LINE INDENT for_max = int ( N [ index ] ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT for_max = 10 NEW_LINE DEDENT return_ = 0 NEW_LINE for i in range ( for_max ) : NEW_LINE INDENT return_ += solve ( dp , N , index + 1 , tight and i == int ( N [ index ] ) , amount_1 + 1 if i == 1 else amount_1 ) NEW_LINE DEDENT dp [ index ] [ tight ] [ amount_1 ] = return_ NEW_LINE return return_ NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE digit_N = str ( N ) NEW_LINE dp = dp_table ( len ( digit_N ) + 1 , 2 , len ( digit_N ) + 1 ) NEW_LINE print ( solve ( dp , digit_N ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T645
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D1 solver = new D1 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D1 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= 100000000 ; i *= 10 ) { if ( n / i % 10 == 1 ) { ans += n % i + 1 ; } ans += ( n + 8 * i ) / ( 10 * i ) * i ; } out . println ( ans ) ; } } }
N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 9 ) : NEW_LINE INDENT A = ( N // ( 10 ** ( i ) ) ) NEW_LINE if ( A ) % 10 == 1 : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE ans += ( N % ( 10 ** ( i ) ) + 1 ) NEW_LINE DEDENT elif ( A ) % 10 > 1 : NEW_LINE INDENT ans += ( A // 10 + 1 ) * ( 10 ** i ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T646
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D1 solver = new D1 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D1 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= 100000000 ; i *= 10 ) { if ( n / i % 10 == 1 ) { ans += n % i + 1 ; } ans += ( n + 8 * i ) / ( 10 * i ) * i ; } out . println ( ans ) ; } } }
def one ( N : int ) -> int : NEW_LINE INDENT res = 0 NEW_LINE M = 10 NEW_LINE while N // M : NEW_LINE INDENT R = N % M NEW_LINE res += ( N - R ) // 10 NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT res += R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT res += M // 10 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res += 0 NEW_LINE DEDENT M *= 10 NEW_LINE DEDENT R = N % M NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT return res + R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return res + M // 10 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = one ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT
T647
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D1 solver = new D1 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D1 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= 100000000 ; i *= 10 ) { if ( n / i % 10 == 1 ) { ans += n % i + 1 ; } ans += ( n + 8 * i ) / ( 10 * i ) * i ; } out . println ( ans ) ; } } }
import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = input ( ) [ : - 1 ] NEW_LINE dp = [ [ [ 0 ] * ( len ( N ) + 1 ) for _ in range ( 2 ) ] for _ in range ( len ( N ) + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) ) : NEW_LINE INDENT if dp [ i ] [ j ] [ k ] == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT elif j == 1 : NEW_LINE INDENT dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] * 9 NEW_LINE DEDENT else : NEW_LINE INDENT if N [ i ] == '1' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT elif N [ i ] == '0' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] = dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] = dp [ i ] [ j ] [ k ] * ( int ( N [ i ] ) - 1 ) NEW_LINE dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) + 1 ) : NEW_LINE INDENT if dp [ len ( N ) ] [ j ] [ k ] : NEW_LINE INDENT ans += k * dp [ len ( N ) ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
T648
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D1 solver = new D1 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D1 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= 100000000 ; i *= 10 ) { if ( n / i % 10 == 1 ) { ans += n % i + 1 ; } ans += ( n + 8 * i ) / ( 10 * i ) * i ; } out . println ( ans ) ; } } }
n = input ( ) NEW_LINE memo = [ [ [ None for _ in range ( len ( n ) + 1 ) ] for _ in range ( 2 ) ] for _ in range ( len ( n ) + 1 ) ] NEW_LINE def rec ( i , threshold , s ) : NEW_LINE INDENT if i == len ( n ) : NEW_LINE INDENT return s NEW_LINE DEDENT if memo [ i ] [ threshold ] [ s ] is not None : NEW_LINE INDENT return memo [ i ] [ threshold ] [ s ] NEW_LINE DEDENT ret = 0 NEW_LINE limit = int ( n [ i ] ) if threshold == 1 else 9 NEW_LINE for j in range ( limit + 1 ) : NEW_LINE INDENT nex_threshold = 1 if ( j == limit and threshold == 1 ) else 0 NEW_LINE if j == 1 : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s ) NEW_LINE DEDENT memo [ i ] [ threshold ] [ s ] = ret NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( rec ( 0 , 1 , 0 ) ) NEW_LINE
T649
import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D1 solver = new D1 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D1 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= 100000000 ; i *= 10 ) { if ( n / i % 10 == 1 ) { ans += n % i + 1 ; } ans += ( n + 8 * i ) / ( 10 * i ) * i ; } out . println ( ans ) ; } } }
def dp_table ( * counts ) : NEW_LINE INDENT if counts : NEW_LINE INDENT return [ dp_table ( * counts [ 1 : ] ) for _ in range ( counts [ 0 ] ) ] NEW_LINE DEDENT else : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT def solve ( dp , N : str , index : int = 0 , tight : bool = True , amount_1 : int = 0 ) : NEW_LINE INDENT if len ( N ) == index : NEW_LINE INDENT return amount_1 NEW_LINE DEDENT elif dp [ index ] [ tight ] [ amount_1 ] is not None : NEW_LINE INDENT return dp [ index ] [ tight ] [ amount_1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if tight : NEW_LINE INDENT for_max = int ( N [ index ] ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT for_max = 10 NEW_LINE DEDENT return_ = 0 NEW_LINE for i in range ( for_max ) : NEW_LINE INDENT return_ += solve ( dp , N , index + 1 , tight and i == int ( N [ index ] ) , amount_1 + 1 if i == 1 else amount_1 ) NEW_LINE DEDENT dp [ index ] [ tight ] [ amount_1 ] = return_ NEW_LINE return return_ NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE digit_N = str ( N ) NEW_LINE dp = dp_table ( len ( digit_N ) + 1 , 2 , len ( digit_N ) + 1 ) NEW_LINE print ( solve ( dp , digit_N ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T650
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( ans ( n , 0 ) ) ; } static int ans ( int n , int c ) { if ( c == 10 ) return 0 ; int temp = 0 ; if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) { temp = power ( 10 , c ) ; } else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) { temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ; } return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ; } static int power ( int n , int m ) { if ( m == 0 ) return 1 ; if ( m % 2 == 1 ) return power ( n , m - 1 ) * n ; int e = power ( n , m / 2 ) ; return e * e ; } }
N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 9 ) : NEW_LINE INDENT A = ( N // ( 10 ** ( i ) ) ) NEW_LINE if ( A ) % 10 == 1 : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE ans += ( N % ( 10 ** ( i ) ) + 1 ) NEW_LINE DEDENT elif ( A ) % 10 > 1 : NEW_LINE INDENT ans += ( A // 10 + 1 ) * ( 10 ** i ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T651
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( ans ( n , 0 ) ) ; } static int ans ( int n , int c ) { if ( c == 10 ) return 0 ; int temp = 0 ; if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) { temp = power ( 10 , c ) ; } else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) { temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ; } return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ; } static int power ( int n , int m ) { if ( m == 0 ) return 1 ; if ( m % 2 == 1 ) return power ( n , m - 1 ) * n ; int e = power ( n , m / 2 ) ; return e * e ; } }
def one ( N : int ) -> int : NEW_LINE INDENT res = 0 NEW_LINE M = 10 NEW_LINE while N // M : NEW_LINE INDENT R = N % M NEW_LINE res += ( N - R ) // 10 NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT res += R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT res += M // 10 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res += 0 NEW_LINE DEDENT M *= 10 NEW_LINE DEDENT R = N % M NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT return res + R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return res + M // 10 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = one ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT
T652
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( ans ( n , 0 ) ) ; } static int ans ( int n , int c ) { if ( c == 10 ) return 0 ; int temp = 0 ; if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) { temp = power ( 10 , c ) ; } else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) { temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ; } return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ; } static int power ( int n , int m ) { if ( m == 0 ) return 1 ; if ( m % 2 == 1 ) return power ( n , m - 1 ) * n ; int e = power ( n , m / 2 ) ; return e * e ; } }
import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = input ( ) [ : - 1 ] NEW_LINE dp = [ [ [ 0 ] * ( len ( N ) + 1 ) for _ in range ( 2 ) ] for _ in range ( len ( N ) + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) ) : NEW_LINE INDENT if dp [ i ] [ j ] [ k ] == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT elif j == 1 : NEW_LINE INDENT dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] * 9 NEW_LINE DEDENT else : NEW_LINE INDENT if N [ i ] == '1' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT elif N [ i ] == '0' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] = dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] = dp [ i ] [ j ] [ k ] * ( int ( N [ i ] ) - 1 ) NEW_LINE dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) + 1 ) : NEW_LINE INDENT if dp [ len ( N ) ] [ j ] [ k ] : NEW_LINE INDENT ans += k * dp [ len ( N ) ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
T653
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( ans ( n , 0 ) ) ; } static int ans ( int n , int c ) { if ( c == 10 ) return 0 ; int temp = 0 ; if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) { temp = power ( 10 , c ) ; } else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) { temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ; } return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ; } static int power ( int n , int m ) { if ( m == 0 ) return 1 ; if ( m % 2 == 1 ) return power ( n , m - 1 ) * n ; int e = power ( n , m / 2 ) ; return e * e ; } }
n = input ( ) NEW_LINE memo = [ [ [ None for _ in range ( len ( n ) + 1 ) ] for _ in range ( 2 ) ] for _ in range ( len ( n ) + 1 ) ] NEW_LINE def rec ( i , threshold , s ) : NEW_LINE INDENT if i == len ( n ) : NEW_LINE INDENT return s NEW_LINE DEDENT if memo [ i ] [ threshold ] [ s ] is not None : NEW_LINE INDENT return memo [ i ] [ threshold ] [ s ] NEW_LINE DEDENT ret = 0 NEW_LINE limit = int ( n [ i ] ) if threshold == 1 else 9 NEW_LINE for j in range ( limit + 1 ) : NEW_LINE INDENT nex_threshold = 1 if ( j == limit and threshold == 1 ) else 0 NEW_LINE if j == 1 : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s ) NEW_LINE DEDENT memo [ i ] [ threshold ] [ s ] = ret NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( rec ( 0 , 1 , 0 ) ) NEW_LINE
T654
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( ans ( n , 0 ) ) ; } static int ans ( int n , int c ) { if ( c == 10 ) return 0 ; int temp = 0 ; if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) { temp = power ( 10 , c ) ; } else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) { temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ; } return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ; } static int power ( int n , int m ) { if ( m == 0 ) return 1 ; if ( m % 2 == 1 ) return power ( n , m - 1 ) * n ; int e = power ( n , m / 2 ) ; return e * e ; } }
def dp_table ( * counts ) : NEW_LINE INDENT if counts : NEW_LINE INDENT return [ dp_table ( * counts [ 1 : ] ) for _ in range ( counts [ 0 ] ) ] NEW_LINE DEDENT else : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT def solve ( dp , N : str , index : int = 0 , tight : bool = True , amount_1 : int = 0 ) : NEW_LINE INDENT if len ( N ) == index : NEW_LINE INDENT return amount_1 NEW_LINE DEDENT elif dp [ index ] [ tight ] [ amount_1 ] is not None : NEW_LINE INDENT return dp [ index ] [ tight ] [ amount_1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if tight : NEW_LINE INDENT for_max = int ( N [ index ] ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT for_max = 10 NEW_LINE DEDENT return_ = 0 NEW_LINE for i in range ( for_max ) : NEW_LINE INDENT return_ += solve ( dp , N , index + 1 , tight and i == int ( N [ index ] ) , amount_1 + 1 if i == 1 else amount_1 ) NEW_LINE DEDENT dp [ index ] [ tight ] [ amount_1 ] = return_ NEW_LINE return return_ NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE digit_N = str ( N ) NEW_LINE dp = dp_table ( len ( digit_N ) + 1 , 2 , len ( digit_N ) + 1 ) NEW_LINE print ( solve ( dp , digit_N ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T655
import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; long count = 0 ; for ( int i = 0 ; i < 11 ; i ++ ) { count += ( n / pow10 ( i + 1 ) ) * pow10 ( i ) ; long target = ( n % pow10 ( i + 1 ) ) / pow10 ( i ) ; if ( target > 1 ) { count += pow10 ( i ) ; } else if ( target == 1 ) { count += n % pow10 ( i ) + 1 ; } } System . out . println ( count ) ; } static long pow10 ( int n ) { if ( n == 0 ) { return 1 ; } else { return 10 * pow10 ( n - 1 ) ; } } }
N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 9 ) : NEW_LINE INDENT A = ( N // ( 10 ** ( i ) ) ) NEW_LINE if ( A ) % 10 == 1 : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE ans += ( N % ( 10 ** ( i ) ) + 1 ) NEW_LINE DEDENT elif ( A ) % 10 > 1 : NEW_LINE INDENT ans += ( A // 10 + 1 ) * ( 10 ** i ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T656
import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; long count = 0 ; for ( int i = 0 ; i < 11 ; i ++ ) { count += ( n / pow10 ( i + 1 ) ) * pow10 ( i ) ; long target = ( n % pow10 ( i + 1 ) ) / pow10 ( i ) ; if ( target > 1 ) { count += pow10 ( i ) ; } else if ( target == 1 ) { count += n % pow10 ( i ) + 1 ; } } System . out . println ( count ) ; } static long pow10 ( int n ) { if ( n == 0 ) { return 1 ; } else { return 10 * pow10 ( n - 1 ) ; } } }
def one ( N : int ) -> int : NEW_LINE INDENT res = 0 NEW_LINE M = 10 NEW_LINE while N // M : NEW_LINE INDENT R = N % M NEW_LINE res += ( N - R ) // 10 NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT res += R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT res += M // 10 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res += 0 NEW_LINE DEDENT M *= 10 NEW_LINE DEDENT R = N % M NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT return res + R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return res + M // 10 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = one ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT
T657
import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; long count = 0 ; for ( int i = 0 ; i < 11 ; i ++ ) { count += ( n / pow10 ( i + 1 ) ) * pow10 ( i ) ; long target = ( n % pow10 ( i + 1 ) ) / pow10 ( i ) ; if ( target > 1 ) { count += pow10 ( i ) ; } else if ( target == 1 ) { count += n % pow10 ( i ) + 1 ; } } System . out . println ( count ) ; } static long pow10 ( int n ) { if ( n == 0 ) { return 1 ; } else { return 10 * pow10 ( n - 1 ) ; } } }
import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = input ( ) [ : - 1 ] NEW_LINE dp = [ [ [ 0 ] * ( len ( N ) + 1 ) for _ in range ( 2 ) ] for _ in range ( len ( N ) + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) ) : NEW_LINE INDENT if dp [ i ] [ j ] [ k ] == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT elif j == 1 : NEW_LINE INDENT dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] * 9 NEW_LINE DEDENT else : NEW_LINE INDENT if N [ i ] == '1' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT elif N [ i ] == '0' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] = dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] = dp [ i ] [ j ] [ k ] * ( int ( N [ i ] ) - 1 ) NEW_LINE dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) + 1 ) : NEW_LINE INDENT if dp [ len ( N ) ] [ j ] [ k ] : NEW_LINE INDENT ans += k * dp [ len ( N ) ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
T658
import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; long count = 0 ; for ( int i = 0 ; i < 11 ; i ++ ) { count += ( n / pow10 ( i + 1 ) ) * pow10 ( i ) ; long target = ( n % pow10 ( i + 1 ) ) / pow10 ( i ) ; if ( target > 1 ) { count += pow10 ( i ) ; } else if ( target == 1 ) { count += n % pow10 ( i ) + 1 ; } } System . out . println ( count ) ; } static long pow10 ( int n ) { if ( n == 0 ) { return 1 ; } else { return 10 * pow10 ( n - 1 ) ; } } }
n = input ( ) NEW_LINE memo = [ [ [ None for _ in range ( len ( n ) + 1 ) ] for _ in range ( 2 ) ] for _ in range ( len ( n ) + 1 ) ] NEW_LINE def rec ( i , threshold , s ) : NEW_LINE INDENT if i == len ( n ) : NEW_LINE INDENT return s NEW_LINE DEDENT if memo [ i ] [ threshold ] [ s ] is not None : NEW_LINE INDENT return memo [ i ] [ threshold ] [ s ] NEW_LINE DEDENT ret = 0 NEW_LINE limit = int ( n [ i ] ) if threshold == 1 else 9 NEW_LINE for j in range ( limit + 1 ) : NEW_LINE INDENT nex_threshold = 1 if ( j == limit and threshold == 1 ) else 0 NEW_LINE if j == 1 : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s ) NEW_LINE DEDENT memo [ i ] [ threshold ] [ s ] = ret NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( rec ( 0 , 1 , 0 ) ) NEW_LINE
T659
import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; long count = 0 ; for ( int i = 0 ; i < 11 ; i ++ ) { count += ( n / pow10 ( i + 1 ) ) * pow10 ( i ) ; long target = ( n % pow10 ( i + 1 ) ) / pow10 ( i ) ; if ( target > 1 ) { count += pow10 ( i ) ; } else if ( target == 1 ) { count += n % pow10 ( i ) + 1 ; } } System . out . println ( count ) ; } static long pow10 ( int n ) { if ( n == 0 ) { return 1 ; } else { return 10 * pow10 ( n - 1 ) ; } } }
def dp_table ( * counts ) : NEW_LINE INDENT if counts : NEW_LINE INDENT return [ dp_table ( * counts [ 1 : ] ) for _ in range ( counts [ 0 ] ) ] NEW_LINE DEDENT else : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT def solve ( dp , N : str , index : int = 0 , tight : bool = True , amount_1 : int = 0 ) : NEW_LINE INDENT if len ( N ) == index : NEW_LINE INDENT return amount_1 NEW_LINE DEDENT elif dp [ index ] [ tight ] [ amount_1 ] is not None : NEW_LINE INDENT return dp [ index ] [ tight ] [ amount_1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if tight : NEW_LINE INDENT for_max = int ( N [ index ] ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT for_max = 10 NEW_LINE DEDENT return_ = 0 NEW_LINE for i in range ( for_max ) : NEW_LINE INDENT return_ += solve ( dp , N , index + 1 , tight and i == int ( N [ index ] ) , amount_1 + 1 if i == 1 else amount_1 ) NEW_LINE DEDENT dp [ index ] [ tight ] [ amount_1 ] = return_ NEW_LINE return return_ NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE digit_N = str ( N ) NEW_LINE dp = dp_table ( len ( digit_N ) + 1 , 2 , len ( digit_N ) + 1 ) NEW_LINE print ( solve ( dp , digit_N ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T660
import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int souwa = 0 ; souwa += N / 10 ; if ( N % 10 >= 1 ) { souwa ++ ; } souwa += N / 100 * 10 ; if ( N % 100 >= 10 ) { souwa += Math . min ( N % 100 - 9 , 10 ) ; } souwa += N / 1000 * 100 ; if ( N % 1000 >= 100 ) { souwa += Math . min ( N % 1000 - 99 , 100 ) ; } souwa += N / 10000 * 1000 ; if ( N % 10000 >= 1000 ) { souwa += Math . min ( N % 10000 - 999 , 1000 ) ; } souwa += N / 100000 * 10000 ; if ( N % 100000 >= 10000 ) { souwa += Math . min ( N % 100000 - 9999 , 10000 ) ; } souwa += N / 1000000 * 100000 ; if ( N % 1000000 >= 100000 ) { souwa += Math . min ( N % 1000000 - 99999 , 100000 ) ; } souwa += N / 10000000 * 1000000 ; if ( N % 10000000 >= 1000000 ) { souwa += Math . min ( N % 10000000 - 999999 , 1000000 ) ; } souwa += N / 100000000 * 10000000 ; if ( N % 100000000 >= 10000000 ) { souwa += Math . min ( N % 100000000 - 9999999 , 10000000 ) ; } souwa += N / 1000000000 * 100000000 ; if ( N % 1000000000 >= 100000000 ) { souwa += Math . min ( N % 1000000000 - 99999999 , 100000000 ) ; } if ( N == 1000000000 ) { souwa ++ ; } System . out . println ( souwa ) ; } }
N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 9 ) : NEW_LINE INDENT A = ( N // ( 10 ** ( i ) ) ) NEW_LINE if ( A ) % 10 == 1 : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE ans += ( N % ( 10 ** ( i ) ) + 1 ) NEW_LINE DEDENT elif ( A ) % 10 > 1 : NEW_LINE INDENT ans += ( A // 10 + 1 ) * ( 10 ** i ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE
T661
import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int souwa = 0 ; souwa += N / 10 ; if ( N % 10 >= 1 ) { souwa ++ ; } souwa += N / 100 * 10 ; if ( N % 100 >= 10 ) { souwa += Math . min ( N % 100 - 9 , 10 ) ; } souwa += N / 1000 * 100 ; if ( N % 1000 >= 100 ) { souwa += Math . min ( N % 1000 - 99 , 100 ) ; } souwa += N / 10000 * 1000 ; if ( N % 10000 >= 1000 ) { souwa += Math . min ( N % 10000 - 999 , 1000 ) ; } souwa += N / 100000 * 10000 ; if ( N % 100000 >= 10000 ) { souwa += Math . min ( N % 100000 - 9999 , 10000 ) ; } souwa += N / 1000000 * 100000 ; if ( N % 1000000 >= 100000 ) { souwa += Math . min ( N % 1000000 - 99999 , 100000 ) ; } souwa += N / 10000000 * 1000000 ; if ( N % 10000000 >= 1000000 ) { souwa += Math . min ( N % 10000000 - 999999 , 1000000 ) ; } souwa += N / 100000000 * 10000000 ; if ( N % 100000000 >= 10000000 ) { souwa += Math . min ( N % 100000000 - 9999999 , 10000000 ) ; } souwa += N / 1000000000 * 100000000 ; if ( N % 1000000000 >= 100000000 ) { souwa += Math . min ( N % 1000000000 - 99999999 , 100000000 ) ; } if ( N == 1000000000 ) { souwa ++ ; } System . out . println ( souwa ) ; } }
def one ( N : int ) -> int : NEW_LINE INDENT res = 0 NEW_LINE M = 10 NEW_LINE while N // M : NEW_LINE INDENT R = N % M NEW_LINE res += ( N - R ) // 10 NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT res += R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT res += M // 10 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res += 0 NEW_LINE DEDENT M *= 10 NEW_LINE DEDENT R = N % M NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT return res + R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return res + M // 10 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = one ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT
T662
import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int souwa = 0 ; souwa += N / 10 ; if ( N % 10 >= 1 ) { souwa ++ ; } souwa += N / 100 * 10 ; if ( N % 100 >= 10 ) { souwa += Math . min ( N % 100 - 9 , 10 ) ; } souwa += N / 1000 * 100 ; if ( N % 1000 >= 100 ) { souwa += Math . min ( N % 1000 - 99 , 100 ) ; } souwa += N / 10000 * 1000 ; if ( N % 10000 >= 1000 ) { souwa += Math . min ( N % 10000 - 999 , 1000 ) ; } souwa += N / 100000 * 10000 ; if ( N % 100000 >= 10000 ) { souwa += Math . min ( N % 100000 - 9999 , 10000 ) ; } souwa += N / 1000000 * 100000 ; if ( N % 1000000 >= 100000 ) { souwa += Math . min ( N % 1000000 - 99999 , 100000 ) ; } souwa += N / 10000000 * 1000000 ; if ( N % 10000000 >= 1000000 ) { souwa += Math . min ( N % 10000000 - 999999 , 1000000 ) ; } souwa += N / 100000000 * 10000000 ; if ( N % 100000000 >= 10000000 ) { souwa += Math . min ( N % 100000000 - 9999999 , 10000000 ) ; } souwa += N / 1000000000 * 100000000 ; if ( N % 1000000000 >= 100000000 ) { souwa += Math . min ( N % 1000000000 - 99999999 , 100000000 ) ; } if ( N == 1000000000 ) { souwa ++ ; } System . out . println ( souwa ) ; } }
import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = input ( ) [ : - 1 ] NEW_LINE dp = [ [ [ 0 ] * ( len ( N ) + 1 ) for _ in range ( 2 ) ] for _ in range ( len ( N ) + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) ) : NEW_LINE INDENT if dp [ i ] [ j ] [ k ] == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT elif j == 1 : NEW_LINE INDENT dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] * 9 NEW_LINE DEDENT else : NEW_LINE INDENT if N [ i ] == '1' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT elif N [ i ] == '0' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] = dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] = dp [ i ] [ j ] [ k ] * ( int ( N [ i ] ) - 1 ) NEW_LINE dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) + 1 ) : NEW_LINE INDENT if dp [ len ( N ) ] [ j ] [ k ] : NEW_LINE INDENT ans += k * dp [ len ( N ) ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
T663
import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int souwa = 0 ; souwa += N / 10 ; if ( N % 10 >= 1 ) { souwa ++ ; } souwa += N / 100 * 10 ; if ( N % 100 >= 10 ) { souwa += Math . min ( N % 100 - 9 , 10 ) ; } souwa += N / 1000 * 100 ; if ( N % 1000 >= 100 ) { souwa += Math . min ( N % 1000 - 99 , 100 ) ; } souwa += N / 10000 * 1000 ; if ( N % 10000 >= 1000 ) { souwa += Math . min ( N % 10000 - 999 , 1000 ) ; } souwa += N / 100000 * 10000 ; if ( N % 100000 >= 10000 ) { souwa += Math . min ( N % 100000 - 9999 , 10000 ) ; } souwa += N / 1000000 * 100000 ; if ( N % 1000000 >= 100000 ) { souwa += Math . min ( N % 1000000 - 99999 , 100000 ) ; } souwa += N / 10000000 * 1000000 ; if ( N % 10000000 >= 1000000 ) { souwa += Math . min ( N % 10000000 - 999999 , 1000000 ) ; } souwa += N / 100000000 * 10000000 ; if ( N % 100000000 >= 10000000 ) { souwa += Math . min ( N % 100000000 - 9999999 , 10000000 ) ; } souwa += N / 1000000000 * 100000000 ; if ( N % 1000000000 >= 100000000 ) { souwa += Math . min ( N % 1000000000 - 99999999 , 100000000 ) ; } if ( N == 1000000000 ) { souwa ++ ; } System . out . println ( souwa ) ; } }
n = input ( ) NEW_LINE memo = [ [ [ None for _ in range ( len ( n ) + 1 ) ] for _ in range ( 2 ) ] for _ in range ( len ( n ) + 1 ) ] NEW_LINE def rec ( i , threshold , s ) : NEW_LINE INDENT if i == len ( n ) : NEW_LINE INDENT return s NEW_LINE DEDENT if memo [ i ] [ threshold ] [ s ] is not None : NEW_LINE INDENT return memo [ i ] [ threshold ] [ s ] NEW_LINE DEDENT ret = 0 NEW_LINE limit = int ( n [ i ] ) if threshold == 1 else 9 NEW_LINE for j in range ( limit + 1 ) : NEW_LINE INDENT nex_threshold = 1 if ( j == limit and threshold == 1 ) else 0 NEW_LINE if j == 1 : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s ) NEW_LINE DEDENT memo [ i ] [ threshold ] [ s ] = ret NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( rec ( 0 , 1 , 0 ) ) NEW_LINE
T664
import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int souwa = 0 ; souwa += N / 10 ; if ( N % 10 >= 1 ) { souwa ++ ; } souwa += N / 100 * 10 ; if ( N % 100 >= 10 ) { souwa += Math . min ( N % 100 - 9 , 10 ) ; } souwa += N / 1000 * 100 ; if ( N % 1000 >= 100 ) { souwa += Math . min ( N % 1000 - 99 , 100 ) ; } souwa += N / 10000 * 1000 ; if ( N % 10000 >= 1000 ) { souwa += Math . min ( N % 10000 - 999 , 1000 ) ; } souwa += N / 100000 * 10000 ; if ( N % 100000 >= 10000 ) { souwa += Math . min ( N % 100000 - 9999 , 10000 ) ; } souwa += N / 1000000 * 100000 ; if ( N % 1000000 >= 100000 ) { souwa += Math . min ( N % 1000000 - 99999 , 100000 ) ; } souwa += N / 10000000 * 1000000 ; if ( N % 10000000 >= 1000000 ) { souwa += Math . min ( N % 10000000 - 999999 , 1000000 ) ; } souwa += N / 100000000 * 10000000 ; if ( N % 100000000 >= 10000000 ) { souwa += Math . min ( N % 100000000 - 9999999 , 10000000 ) ; } souwa += N / 1000000000 * 100000000 ; if ( N % 1000000000 >= 100000000 ) { souwa += Math . min ( N % 1000000000 - 99999999 , 100000000 ) ; } if ( N == 1000000000 ) { souwa ++ ; } System . out . println ( souwa ) ; } }
def dp_table ( * counts ) : NEW_LINE INDENT if counts : NEW_LINE INDENT return [ dp_table ( * counts [ 1 : ] ) for _ in range ( counts [ 0 ] ) ] NEW_LINE DEDENT else : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT def solve ( dp , N : str , index : int = 0 , tight : bool = True , amount_1 : int = 0 ) : NEW_LINE INDENT if len ( N ) == index : NEW_LINE INDENT return amount_1 NEW_LINE DEDENT elif dp [ index ] [ tight ] [ amount_1 ] is not None : NEW_LINE INDENT return dp [ index ] [ tight ] [ amount_1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if tight : NEW_LINE INDENT for_max = int ( N [ index ] ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT for_max = 10 NEW_LINE DEDENT return_ = 0 NEW_LINE for i in range ( for_max ) : NEW_LINE INDENT return_ += solve ( dp , N , index + 1 , tight and i == int ( N [ index ] ) , amount_1 + 1 if i == 1 else amount_1 ) NEW_LINE DEDENT dp [ index ] [ tight ] [ amount_1 ] = return_ NEW_LINE return return_ NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE digit_N = str ( N ) NEW_LINE dp = dp_table ( len ( digit_N ) + 1 , 2 , len ( digit_N ) + 1 ) NEW_LINE print ( solve ( dp , digit_N ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T665
import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) a [ i ] = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; while ( true ) { Arrays . sort ( a ) ; if ( a [ 0 ] == a [ 1 ] && a [ 1 ] == a [ 2 ] ) break ; else if ( a [ 1 ] == a [ 2 ] ) a [ 0 ] += 2 ; else { a [ 0 ] ++ ; a [ 1 ] ++ ; } c ++ ; } System . out . println ( c ) ; } }
def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C , B , A = sorted ( inpl ( ) ) NEW_LINE if ( B - C ) % 2 == 0 : NEW_LINE INDENT print ( ( 2 * A - B - C ) // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( 2 * A - B - C + 3 ) // 2 ) NEW_LINE DEDENT
T666
import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) a [ i ] = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; while ( true ) { Arrays . sort ( a ) ; if ( a [ 0 ] == a [ 1 ] && a [ 1 ] == a [ 2 ] ) break ; else if ( a [ 1 ] == a [ 2 ] ) a [ 0 ] += 2 ; else { a [ 0 ] ++ ; a [ 1 ] ++ ; } c ++ ; } System . out . println ( c ) ; } }
A , B , C = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ret = 0 NEW_LINE m = A % 2 + B % 2 + C % 2 NEW_LINE if m == 3 or m == 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ret += 1 NEW_LINE if m == 2 : NEW_LINE INDENT if A % 2 == 0 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 0 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A % 2 == 1 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 1 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ret + ( C - B ) // 2 + ( C - A ) // 2 ) NEW_LINE
T667
import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) a [ i ] = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; while ( true ) { Arrays . sort ( a ) ; if ( a [ 0 ] == a [ 1 ] && a [ 1 ] == a [ 2 ] ) break ; else if ( a [ 1 ] == a [ 2 ] ) a [ 0 ] += 2 ; else { a [ 0 ] ++ ; a [ 1 ] ++ ; } c ++ ; } System . out . println ( c ) ; } }
a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = sorted ( a ) NEW_LINE c = a [ 0 ] % 2 + a [ 1 ] % 2 + a [ 2 ] % 2 NEW_LINE ans = 0 NEW_LINE if ( c == 0 or c == 3 ) : NEW_LINE INDENT ans += a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] NEW_LINE ans //= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if ( c == 1 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 == 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT elif ( c == 2 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 != 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans += 1 NEW_LINE ans += ( a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] ) // 2 NEW_LINE DEDENT print ( ans ) NEW_LINE
T668
import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) a [ i ] = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; while ( true ) { Arrays . sort ( a ) ; if ( a [ 0 ] == a [ 1 ] && a [ 1 ] == a [ 2 ] ) break ; else if ( a [ 1 ] == a [ 2 ] ) a [ 0 ] += 2 ; else { a [ 0 ] ++ ; a [ 1 ] ++ ; } c ++ ; } System . out . println ( c ) ; } }
import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE nums . sort ( ) NEW_LINE ans = 0 NEW_LINE while nums [ 0 ] != nums [ - 1 ] : NEW_LINE INDENT if nums [ 0 ] < nums [ 1 ] : NEW_LINE INDENT nums [ 0 ] += 2 NEW_LINE DEDENT else : NEW_LINE INDENT nums [ 0 ] += 1 NEW_LINE nums [ 1 ] += 1 NEW_LINE DEDENT ans += 1 NEW_LINE nums . sort ( ) NEW_LINE DEDENT print ( ans ) NEW_LINE
T669
import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) a [ i ] = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; while ( true ) { Arrays . sort ( a ) ; if ( a [ 0 ] == a [ 1 ] && a [ 1 ] == a [ 2 ] ) break ; else if ( a [ 1 ] == a [ 2 ] ) a [ 0 ] += 2 ; else { a [ 0 ] ++ ; a [ 1 ] ++ ; } c ++ ; } System . out . println ( c ) ; } }
X , Y , Z = sorted ( list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) ) NEW_LINE print ( ( Z - Y ) + ( Y - X ) // 2 + 2 * ( ( X - Y ) % 2 ) ) NEW_LINE
T670
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String [ ] sl = r . readLine ( ) . split ( " [ \\ s ] + " ) ; int a = Integer . parseInt ( sl [ 0 ] ) ; int b = Integer . parseInt ( sl [ 1 ] ) ; int c = Integer . parseInt ( sl [ 2 ] ) ; if ( a > b ) { int t = a ; a = b ; b = t ; } if ( b > c ) { int t = b ; b = c ; c = t ; } if ( a > b ) { int t = a ; a = b ; b = t ; } if ( a == b && b == c ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } if ( b == c ) { if ( ( b - a ) % 2 == 0 ) { System . out . println ( ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } if ( a == b ) { System . out . println ( c - a ) ; System . exit ( 0 ) ; } int v = 0 ; v += c - b ; a += c - b ; b += c - b ; if ( ( b - a ) % 2 == 0 ) { System . out . println ( v + ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( v + ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } }
def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C , B , A = sorted ( inpl ( ) ) NEW_LINE if ( B - C ) % 2 == 0 : NEW_LINE INDENT print ( ( 2 * A - B - C ) // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( 2 * A - B - C + 3 ) // 2 ) NEW_LINE DEDENT
T671
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String [ ] sl = r . readLine ( ) . split ( " [ \\ s ] + " ) ; int a = Integer . parseInt ( sl [ 0 ] ) ; int b = Integer . parseInt ( sl [ 1 ] ) ; int c = Integer . parseInt ( sl [ 2 ] ) ; if ( a > b ) { int t = a ; a = b ; b = t ; } if ( b > c ) { int t = b ; b = c ; c = t ; } if ( a > b ) { int t = a ; a = b ; b = t ; } if ( a == b && b == c ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } if ( b == c ) { if ( ( b - a ) % 2 == 0 ) { System . out . println ( ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } if ( a == b ) { System . out . println ( c - a ) ; System . exit ( 0 ) ; } int v = 0 ; v += c - b ; a += c - b ; b += c - b ; if ( ( b - a ) % 2 == 0 ) { System . out . println ( v + ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( v + ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } }
A , B , C = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ret = 0 NEW_LINE m = A % 2 + B % 2 + C % 2 NEW_LINE if m == 3 or m == 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ret += 1 NEW_LINE if m == 2 : NEW_LINE INDENT if A % 2 == 0 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 0 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A % 2 == 1 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 1 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ret + ( C - B ) // 2 + ( C - A ) // 2 ) NEW_LINE
T672
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String [ ] sl = r . readLine ( ) . split ( " [ \\ s ] + " ) ; int a = Integer . parseInt ( sl [ 0 ] ) ; int b = Integer . parseInt ( sl [ 1 ] ) ; int c = Integer . parseInt ( sl [ 2 ] ) ; if ( a > b ) { int t = a ; a = b ; b = t ; } if ( b > c ) { int t = b ; b = c ; c = t ; } if ( a > b ) { int t = a ; a = b ; b = t ; } if ( a == b && b == c ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } if ( b == c ) { if ( ( b - a ) % 2 == 0 ) { System . out . println ( ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } if ( a == b ) { System . out . println ( c - a ) ; System . exit ( 0 ) ; } int v = 0 ; v += c - b ; a += c - b ; b += c - b ; if ( ( b - a ) % 2 == 0 ) { System . out . println ( v + ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( v + ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } }
a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = sorted ( a ) NEW_LINE c = a [ 0 ] % 2 + a [ 1 ] % 2 + a [ 2 ] % 2 NEW_LINE ans = 0 NEW_LINE if ( c == 0 or c == 3 ) : NEW_LINE INDENT ans += a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] NEW_LINE ans //= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if ( c == 1 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 == 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT elif ( c == 2 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 != 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans += 1 NEW_LINE ans += ( a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] ) // 2 NEW_LINE DEDENT print ( ans ) NEW_LINE
T673
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String [ ] sl = r . readLine ( ) . split ( " [ \\ s ] + " ) ; int a = Integer . parseInt ( sl [ 0 ] ) ; int b = Integer . parseInt ( sl [ 1 ] ) ; int c = Integer . parseInt ( sl [ 2 ] ) ; if ( a > b ) { int t = a ; a = b ; b = t ; } if ( b > c ) { int t = b ; b = c ; c = t ; } if ( a > b ) { int t = a ; a = b ; b = t ; } if ( a == b && b == c ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } if ( b == c ) { if ( ( b - a ) % 2 == 0 ) { System . out . println ( ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } if ( a == b ) { System . out . println ( c - a ) ; System . exit ( 0 ) ; } int v = 0 ; v += c - b ; a += c - b ; b += c - b ; if ( ( b - a ) % 2 == 0 ) { System . out . println ( v + ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( v + ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } }
import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE nums . sort ( ) NEW_LINE ans = 0 NEW_LINE while nums [ 0 ] != nums [ - 1 ] : NEW_LINE INDENT if nums [ 0 ] < nums [ 1 ] : NEW_LINE INDENT nums [ 0 ] += 2 NEW_LINE DEDENT else : NEW_LINE INDENT nums [ 0 ] += 1 NEW_LINE nums [ 1 ] += 1 NEW_LINE DEDENT ans += 1 NEW_LINE nums . sort ( ) NEW_LINE DEDENT print ( ans ) NEW_LINE
T674
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String [ ] sl = r . readLine ( ) . split ( " [ \\ s ] + " ) ; int a = Integer . parseInt ( sl [ 0 ] ) ; int b = Integer . parseInt ( sl [ 1 ] ) ; int c = Integer . parseInt ( sl [ 2 ] ) ; if ( a > b ) { int t = a ; a = b ; b = t ; } if ( b > c ) { int t = b ; b = c ; c = t ; } if ( a > b ) { int t = a ; a = b ; b = t ; } if ( a == b && b == c ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } if ( b == c ) { if ( ( b - a ) % 2 == 0 ) { System . out . println ( ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } if ( a == b ) { System . out . println ( c - a ) ; System . exit ( 0 ) ; } int v = 0 ; v += c - b ; a += c - b ; b += c - b ; if ( ( b - a ) % 2 == 0 ) { System . out . println ( v + ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( v + ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } }
X , Y , Z = sorted ( list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) ) NEW_LINE print ( ( Z - Y ) + ( Y - X ) // 2 + 2 * ( ( X - Y ) % 2 ) ) NEW_LINE
T675
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { List < Integer > list = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ; ) { list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int min = list . get ( 0 ) ; int middle = list . get ( 1 ) ; int max = list . get ( 2 ) ; int count = 0 ; while ( min != middle || middle != max ) { for ( int i = 0 ; i < 2 ; i ++ ) { min ++ ; if ( min > middle ) { int tmp = middle ; middle = min ; min = tmp ; } if ( min > max ) { int tmp = max ; max = min ; min = tmp ; } } count ++ ; } System . out . println ( count ) ; } }
def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C , B , A = sorted ( inpl ( ) ) NEW_LINE if ( B - C ) % 2 == 0 : NEW_LINE INDENT print ( ( 2 * A - B - C ) // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( 2 * A - B - C + 3 ) // 2 ) NEW_LINE DEDENT
T676
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { List < Integer > list = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ; ) { list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int min = list . get ( 0 ) ; int middle = list . get ( 1 ) ; int max = list . get ( 2 ) ; int count = 0 ; while ( min != middle || middle != max ) { for ( int i = 0 ; i < 2 ; i ++ ) { min ++ ; if ( min > middle ) { int tmp = middle ; middle = min ; min = tmp ; } if ( min > max ) { int tmp = max ; max = min ; min = tmp ; } } count ++ ; } System . out . println ( count ) ; } }
A , B , C = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ret = 0 NEW_LINE m = A % 2 + B % 2 + C % 2 NEW_LINE if m == 3 or m == 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ret += 1 NEW_LINE if m == 2 : NEW_LINE INDENT if A % 2 == 0 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 0 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A % 2 == 1 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 1 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ret + ( C - B ) // 2 + ( C - A ) // 2 ) NEW_LINE
T677
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { List < Integer > list = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ; ) { list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int min = list . get ( 0 ) ; int middle = list . get ( 1 ) ; int max = list . get ( 2 ) ; int count = 0 ; while ( min != middle || middle != max ) { for ( int i = 0 ; i < 2 ; i ++ ) { min ++ ; if ( min > middle ) { int tmp = middle ; middle = min ; min = tmp ; } if ( min > max ) { int tmp = max ; max = min ; min = tmp ; } } count ++ ; } System . out . println ( count ) ; } }
a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = sorted ( a ) NEW_LINE c = a [ 0 ] % 2 + a [ 1 ] % 2 + a [ 2 ] % 2 NEW_LINE ans = 0 NEW_LINE if ( c == 0 or c == 3 ) : NEW_LINE INDENT ans += a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] NEW_LINE ans //= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if ( c == 1 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 == 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT elif ( c == 2 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 != 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans += 1 NEW_LINE ans += ( a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] ) // 2 NEW_LINE DEDENT print ( ans ) NEW_LINE
T678
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { List < Integer > list = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ; ) { list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int min = list . get ( 0 ) ; int middle = list . get ( 1 ) ; int max = list . get ( 2 ) ; int count = 0 ; while ( min != middle || middle != max ) { for ( int i = 0 ; i < 2 ; i ++ ) { min ++ ; if ( min > middle ) { int tmp = middle ; middle = min ; min = tmp ; } if ( min > max ) { int tmp = max ; max = min ; min = tmp ; } } count ++ ; } System . out . println ( count ) ; } }
import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE nums . sort ( ) NEW_LINE ans = 0 NEW_LINE while nums [ 0 ] != nums [ - 1 ] : NEW_LINE INDENT if nums [ 0 ] < nums [ 1 ] : NEW_LINE INDENT nums [ 0 ] += 2 NEW_LINE DEDENT else : NEW_LINE INDENT nums [ 0 ] += 1 NEW_LINE nums [ 1 ] += 1 NEW_LINE DEDENT ans += 1 NEW_LINE nums . sort ( ) NEW_LINE DEDENT print ( ans ) NEW_LINE
T679
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { List < Integer > list = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ; ) { list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int min = list . get ( 0 ) ; int middle = list . get ( 1 ) ; int max = list . get ( 2 ) ; int count = 0 ; while ( min != middle || middle != max ) { for ( int i = 0 ; i < 2 ; i ++ ) { min ++ ; if ( min > middle ) { int tmp = middle ; middle = min ; min = tmp ; } if ( min > max ) { int tmp = max ; max = min ; min = tmp ; } } count ++ ; } System . out . println ( count ) ; } }
X , Y , Z = sorted ( list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) ) NEW_LINE print ( ( Z - Y ) + ( Y - X ) // 2 + 2 * ( ( X - Y ) % 2 ) ) NEW_LINE
T680
import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int i = 0 ; i < abc . length ; i ++ ) abc [ i ] = nextInt ( ) ; Arrays . sort ( abc ) ; int diff1 = abc [ 2 ] - abc [ 0 ] ; int diff2 = abc [ 2 ] - abc [ 1 ] ; if ( diff1 % 2 == 0 && diff2 % 2 == 0 ) System . out . println ( diff1 / 2 + diff2 / 2 ) ; else if ( diff1 % 2 == 1 && diff2 % 2 == 0 ) System . out . println ( 1 + diff2 / 2 + ( diff1 + 1 ) / 2 ) ; else if ( diff1 % 2 == 0 && diff2 % 2 == 1 ) System . out . println ( 1 + diff1 / 2 + ( diff2 + 1 ) / 2 ) ; else System . out . println ( 1 + ( diff1 - 1 ) / 2 + ( diff2 - 1 ) / 2 ) ; } private static BufferedReader reader ; private static StringTokenizer tokenizer ; private static void init ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tokenizer = new StringTokenizer ( " " ) ; } private static String next ( ) throws IOException { String read ; while ( ! tokenizer . hasMoreTokens ( ) ) { read = reader . readLine ( ) ; if ( read == null || read . equals ( " " ) ) return " - 1" ; tokenizer = new StringTokenizer ( read ) ; } return tokenizer . nextToken ( ) ; } private static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } }
def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C , B , A = sorted ( inpl ( ) ) NEW_LINE if ( B - C ) % 2 == 0 : NEW_LINE INDENT print ( ( 2 * A - B - C ) // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( 2 * A - B - C + 3 ) // 2 ) NEW_LINE DEDENT
T681
import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int i = 0 ; i < abc . length ; i ++ ) abc [ i ] = nextInt ( ) ; Arrays . sort ( abc ) ; int diff1 = abc [ 2 ] - abc [ 0 ] ; int diff2 = abc [ 2 ] - abc [ 1 ] ; if ( diff1 % 2 == 0 && diff2 % 2 == 0 ) System . out . println ( diff1 / 2 + diff2 / 2 ) ; else if ( diff1 % 2 == 1 && diff2 % 2 == 0 ) System . out . println ( 1 + diff2 / 2 + ( diff1 + 1 ) / 2 ) ; else if ( diff1 % 2 == 0 && diff2 % 2 == 1 ) System . out . println ( 1 + diff1 / 2 + ( diff2 + 1 ) / 2 ) ; else System . out . println ( 1 + ( diff1 - 1 ) / 2 + ( diff2 - 1 ) / 2 ) ; } private static BufferedReader reader ; private static StringTokenizer tokenizer ; private static void init ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tokenizer = new StringTokenizer ( " " ) ; } private static String next ( ) throws IOException { String read ; while ( ! tokenizer . hasMoreTokens ( ) ) { read = reader . readLine ( ) ; if ( read == null || read . equals ( " " ) ) return " - 1" ; tokenizer = new StringTokenizer ( read ) ; } return tokenizer . nextToken ( ) ; } private static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } }
A , B , C = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ret = 0 NEW_LINE m = A % 2 + B % 2 + C % 2 NEW_LINE if m == 3 or m == 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ret += 1 NEW_LINE if m == 2 : NEW_LINE INDENT if A % 2 == 0 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 0 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A % 2 == 1 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 1 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ret + ( C - B ) // 2 + ( C - A ) // 2 ) NEW_LINE
T682
import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int i = 0 ; i < abc . length ; i ++ ) abc [ i ] = nextInt ( ) ; Arrays . sort ( abc ) ; int diff1 = abc [ 2 ] - abc [ 0 ] ; int diff2 = abc [ 2 ] - abc [ 1 ] ; if ( diff1 % 2 == 0 && diff2 % 2 == 0 ) System . out . println ( diff1 / 2 + diff2 / 2 ) ; else if ( diff1 % 2 == 1 && diff2 % 2 == 0 ) System . out . println ( 1 + diff2 / 2 + ( diff1 + 1 ) / 2 ) ; else if ( diff1 % 2 == 0 && diff2 % 2 == 1 ) System . out . println ( 1 + diff1 / 2 + ( diff2 + 1 ) / 2 ) ; else System . out . println ( 1 + ( diff1 - 1 ) / 2 + ( diff2 - 1 ) / 2 ) ; } private static BufferedReader reader ; private static StringTokenizer tokenizer ; private static void init ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tokenizer = new StringTokenizer ( " " ) ; } private static String next ( ) throws IOException { String read ; while ( ! tokenizer . hasMoreTokens ( ) ) { read = reader . readLine ( ) ; if ( read == null || read . equals ( " " ) ) return " - 1" ; tokenizer = new StringTokenizer ( read ) ; } return tokenizer . nextToken ( ) ; } private static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } }
a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = sorted ( a ) NEW_LINE c = a [ 0 ] % 2 + a [ 1 ] % 2 + a [ 2 ] % 2 NEW_LINE ans = 0 NEW_LINE if ( c == 0 or c == 3 ) : NEW_LINE INDENT ans += a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] NEW_LINE ans //= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if ( c == 1 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 == 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT elif ( c == 2 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 != 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans += 1 NEW_LINE ans += ( a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] ) // 2 NEW_LINE DEDENT print ( ans ) NEW_LINE
T683
import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int i = 0 ; i < abc . length ; i ++ ) abc [ i ] = nextInt ( ) ; Arrays . sort ( abc ) ; int diff1 = abc [ 2 ] - abc [ 0 ] ; int diff2 = abc [ 2 ] - abc [ 1 ] ; if ( diff1 % 2 == 0 && diff2 % 2 == 0 ) System . out . println ( diff1 / 2 + diff2 / 2 ) ; else if ( diff1 % 2 == 1 && diff2 % 2 == 0 ) System . out . println ( 1 + diff2 / 2 + ( diff1 + 1 ) / 2 ) ; else if ( diff1 % 2 == 0 && diff2 % 2 == 1 ) System . out . println ( 1 + diff1 / 2 + ( diff2 + 1 ) / 2 ) ; else System . out . println ( 1 + ( diff1 - 1 ) / 2 + ( diff2 - 1 ) / 2 ) ; } private static BufferedReader reader ; private static StringTokenizer tokenizer ; private static void init ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tokenizer = new StringTokenizer ( " " ) ; } private static String next ( ) throws IOException { String read ; while ( ! tokenizer . hasMoreTokens ( ) ) { read = reader . readLine ( ) ; if ( read == null || read . equals ( " " ) ) return " - 1" ; tokenizer = new StringTokenizer ( read ) ; } return tokenizer . nextToken ( ) ; } private static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } }
import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE nums . sort ( ) NEW_LINE ans = 0 NEW_LINE while nums [ 0 ] != nums [ - 1 ] : NEW_LINE INDENT if nums [ 0 ] < nums [ 1 ] : NEW_LINE INDENT nums [ 0 ] += 2 NEW_LINE DEDENT else : NEW_LINE INDENT nums [ 0 ] += 1 NEW_LINE nums [ 1 ] += 1 NEW_LINE DEDENT ans += 1 NEW_LINE nums . sort ( ) NEW_LINE DEDENT print ( ans ) NEW_LINE
T684
import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int i = 0 ; i < abc . length ; i ++ ) abc [ i ] = nextInt ( ) ; Arrays . sort ( abc ) ; int diff1 = abc [ 2 ] - abc [ 0 ] ; int diff2 = abc [ 2 ] - abc [ 1 ] ; if ( diff1 % 2 == 0 && diff2 % 2 == 0 ) System . out . println ( diff1 / 2 + diff2 / 2 ) ; else if ( diff1 % 2 == 1 && diff2 % 2 == 0 ) System . out . println ( 1 + diff2 / 2 + ( diff1 + 1 ) / 2 ) ; else if ( diff1 % 2 == 0 && diff2 % 2 == 1 ) System . out . println ( 1 + diff1 / 2 + ( diff2 + 1 ) / 2 ) ; else System . out . println ( 1 + ( diff1 - 1 ) / 2 + ( diff2 - 1 ) / 2 ) ; } private static BufferedReader reader ; private static StringTokenizer tokenizer ; private static void init ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tokenizer = new StringTokenizer ( " " ) ; } private static String next ( ) throws IOException { String read ; while ( ! tokenizer . hasMoreTokens ( ) ) { read = reader . readLine ( ) ; if ( read == null || read . equals ( " " ) ) return " - 1" ; tokenizer = new StringTokenizer ( read ) ; } return tokenizer . nextToken ( ) ; } private static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } }
X , Y , Z = sorted ( list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) ) NEW_LINE print ( ( Z - Y ) + ( Y - X ) // 2 + 2 * ( ( X - Y ) % 2 ) ) NEW_LINE
T685
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " ▁ " ) ; List < Integer > values = new ArrayList < > ( ) ; for ( String token : tokens ) { values . add ( Integer . parseInt ( token ) ) ; } Collections . sort ( values ) ; int result = 0 ; while ( true ) { int r = operation ( values ) ; if ( r == 0 ) { break ; } result += r ; Collections . sort ( values ) ; } System . out . println ( result ) ; in . close ( ) ; } public static int operation ( List < Integer > values ) { if ( values . get ( 0 ) == values . get ( 2 ) ) { return 0 ; } if ( values . get ( 0 ) == values . get ( 1 ) ) { int result = values . get ( 2 ) - values . get ( 1 ) ; values . set ( 0 , values . get ( 2 ) ) ; values . set ( 1 , values . get ( 2 ) ) ; return result ; } if ( ( values . get ( 1 ) - values . get ( 0 ) ) % 2 == 0 ) { int result = ( values . get ( 1 ) - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; return result ; } else { int result = ( values . get ( 1 ) + 1 - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; values . set ( 1 , values . get ( 1 ) + 1 ) ; return result ; } } }
def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C , B , A = sorted ( inpl ( ) ) NEW_LINE if ( B - C ) % 2 == 0 : NEW_LINE INDENT print ( ( 2 * A - B - C ) // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( 2 * A - B - C + 3 ) // 2 ) NEW_LINE DEDENT
T686
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " ▁ " ) ; List < Integer > values = new ArrayList < > ( ) ; for ( String token : tokens ) { values . add ( Integer . parseInt ( token ) ) ; } Collections . sort ( values ) ; int result = 0 ; while ( true ) { int r = operation ( values ) ; if ( r == 0 ) { break ; } result += r ; Collections . sort ( values ) ; } System . out . println ( result ) ; in . close ( ) ; } public static int operation ( List < Integer > values ) { if ( values . get ( 0 ) == values . get ( 2 ) ) { return 0 ; } if ( values . get ( 0 ) == values . get ( 1 ) ) { int result = values . get ( 2 ) - values . get ( 1 ) ; values . set ( 0 , values . get ( 2 ) ) ; values . set ( 1 , values . get ( 2 ) ) ; return result ; } if ( ( values . get ( 1 ) - values . get ( 0 ) ) % 2 == 0 ) { int result = ( values . get ( 1 ) - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; return result ; } else { int result = ( values . get ( 1 ) + 1 - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; values . set ( 1 , values . get ( 1 ) + 1 ) ; return result ; } } }
A , B , C = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ret = 0 NEW_LINE m = A % 2 + B % 2 + C % 2 NEW_LINE if m == 3 or m == 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ret += 1 NEW_LINE if m == 2 : NEW_LINE INDENT if A % 2 == 0 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 0 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A % 2 == 1 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 1 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ret + ( C - B ) // 2 + ( C - A ) // 2 ) NEW_LINE
T687
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " ▁ " ) ; List < Integer > values = new ArrayList < > ( ) ; for ( String token : tokens ) { values . add ( Integer . parseInt ( token ) ) ; } Collections . sort ( values ) ; int result = 0 ; while ( true ) { int r = operation ( values ) ; if ( r == 0 ) { break ; } result += r ; Collections . sort ( values ) ; } System . out . println ( result ) ; in . close ( ) ; } public static int operation ( List < Integer > values ) { if ( values . get ( 0 ) == values . get ( 2 ) ) { return 0 ; } if ( values . get ( 0 ) == values . get ( 1 ) ) { int result = values . get ( 2 ) - values . get ( 1 ) ; values . set ( 0 , values . get ( 2 ) ) ; values . set ( 1 , values . get ( 2 ) ) ; return result ; } if ( ( values . get ( 1 ) - values . get ( 0 ) ) % 2 == 0 ) { int result = ( values . get ( 1 ) - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; return result ; } else { int result = ( values . get ( 1 ) + 1 - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; values . set ( 1 , values . get ( 1 ) + 1 ) ; return result ; } } }
a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = sorted ( a ) NEW_LINE c = a [ 0 ] % 2 + a [ 1 ] % 2 + a [ 2 ] % 2 NEW_LINE ans = 0 NEW_LINE if ( c == 0 or c == 3 ) : NEW_LINE INDENT ans += a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] NEW_LINE ans //= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if ( c == 1 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 == 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT elif ( c == 2 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 != 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans += 1 NEW_LINE ans += ( a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] ) // 2 NEW_LINE DEDENT print ( ans ) NEW_LINE
T688
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " ▁ " ) ; List < Integer > values = new ArrayList < > ( ) ; for ( String token : tokens ) { values . add ( Integer . parseInt ( token ) ) ; } Collections . sort ( values ) ; int result = 0 ; while ( true ) { int r = operation ( values ) ; if ( r == 0 ) { break ; } result += r ; Collections . sort ( values ) ; } System . out . println ( result ) ; in . close ( ) ; } public static int operation ( List < Integer > values ) { if ( values . get ( 0 ) == values . get ( 2 ) ) { return 0 ; } if ( values . get ( 0 ) == values . get ( 1 ) ) { int result = values . get ( 2 ) - values . get ( 1 ) ; values . set ( 0 , values . get ( 2 ) ) ; values . set ( 1 , values . get ( 2 ) ) ; return result ; } if ( ( values . get ( 1 ) - values . get ( 0 ) ) % 2 == 0 ) { int result = ( values . get ( 1 ) - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; return result ; } else { int result = ( values . get ( 1 ) + 1 - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; values . set ( 1 , values . get ( 1 ) + 1 ) ; return result ; } } }
import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE nums . sort ( ) NEW_LINE ans = 0 NEW_LINE while nums [ 0 ] != nums [ - 1 ] : NEW_LINE INDENT if nums [ 0 ] < nums [ 1 ] : NEW_LINE INDENT nums [ 0 ] += 2 NEW_LINE DEDENT else : NEW_LINE INDENT nums [ 0 ] += 1 NEW_LINE nums [ 1 ] += 1 NEW_LINE DEDENT ans += 1 NEW_LINE nums . sort ( ) NEW_LINE DEDENT print ( ans ) NEW_LINE
T689
import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " ▁ " ) ; List < Integer > values = new ArrayList < > ( ) ; for ( String token : tokens ) { values . add ( Integer . parseInt ( token ) ) ; } Collections . sort ( values ) ; int result = 0 ; while ( true ) { int r = operation ( values ) ; if ( r == 0 ) { break ; } result += r ; Collections . sort ( values ) ; } System . out . println ( result ) ; in . close ( ) ; } public static int operation ( List < Integer > values ) { if ( values . get ( 0 ) == values . get ( 2 ) ) { return 0 ; } if ( values . get ( 0 ) == values . get ( 1 ) ) { int result = values . get ( 2 ) - values . get ( 1 ) ; values . set ( 0 , values . get ( 2 ) ) ; values . set ( 1 , values . get ( 2 ) ) ; return result ; } if ( ( values . get ( 1 ) - values . get ( 0 ) ) % 2 == 0 ) { int result = ( values . get ( 1 ) - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; return result ; } else { int result = ( values . get ( 1 ) + 1 - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; values . set ( 1 , values . get ( 1 ) + 1 ) ; return result ; } } }
X , Y , Z = sorted ( list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) ) NEW_LINE print ( ( Z - Y ) + ( Y - X ) // 2 + 2 * ( ( X - Y ) % 2 ) ) NEW_LINE
T690
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int num = Integer . parseInt ( br . readLine ( ) ) ; int tenNum = num / 10 ; int remainder = num % 10 ; int answer = 0 ; if ( remainder * 15 > 100 ) { answer = ( tenNum + 1 ) * 100 ; } else { answer = tenNum * 100 + remainder * 15 ; } System . out . println ( answer ) ; } }
n = int ( input ( ) ) NEW_LINE print ( ( n // 10 ) * 100 + min ( 100 , ( n % 10 ) * 15 ) ) NEW_LINE
T691
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int num = Integer . parseInt ( br . readLine ( ) ) ; int tenNum = num / 10 ; int remainder = num % 10 ; int answer = 0 ; if ( remainder * 15 > 100 ) { answer = ( tenNum + 1 ) * 100 ; } else { answer = tenNum * 100 + remainder * 15 ; } System . out . println ( answer ) ; } }
import sys NEW_LINE import copy NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE ans = 1000000000000000 NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT for j in range ( 100 ) : NEW_LINE INDENT money = i * 15 + j * 100 NEW_LINE tako = i + j * 10 NEW_LINE if tako >= N : NEW_LINE INDENT ans = min ( ans , money ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
T692
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int num = Integer . parseInt ( br . readLine ( ) ) ; int tenNum = num / 10 ; int remainder = num % 10 ; int answer = 0 ; if ( remainder * 15 > 100 ) { answer = ( tenNum + 1 ) * 100 ; } else { answer = tenNum * 100 + remainder * 15 ; } System . out . println ( answer ) ; } }
n = int ( input ( ) ) NEW_LINE num = float ( ' inf ' ) NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT num = min ( num , i * 100 + max ( 0 , ( n - i * 10 ) ) * 15 ) NEW_LINE DEDENT print ( num ) NEW_LINE
T693
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int num = Integer . parseInt ( br . readLine ( ) ) ; int tenNum = num / 10 ; int remainder = num % 10 ; int answer = 0 ; if ( remainder * 15 > 100 ) { answer = ( tenNum + 1 ) * 100 ; } else { answer = tenNum * 100 + remainder * 15 ; } System . out . println ( answer ) ; } }
def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE print ( min ( ( n // 10 ) * 100 + ( n % 10 ) * 15 , ( ( n - 1 ) // 10 + 1 ) * 100 ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T694
import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int num = Integer . parseInt ( br . readLine ( ) ) ; int tenNum = num / 10 ; int remainder = num % 10 ; int answer = 0 ; if ( remainder * 15 > 100 ) { answer = ( tenNum + 1 ) * 100 ; } else { answer = tenNum * 100 + remainder * 15 ; } System . out . println ( answer ) ; } }
n = int ( input ( ) ) NEW_LINE ten = n // 10 NEW_LINE one = n % 10 NEW_LINE print ( min ( ( ten + 1 ) * 100 , ten * 100 + one * 15 ) ) NEW_LINE
T695
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( n >= 10 ? min ( ( n / 10 ) * 100 + ( n % 10 ) * 15 , ( n / 10 + 1 ) * 100 ) : min ( n * 15 , 100 ) ) ; } }
n = int ( input ( ) ) NEW_LINE print ( ( n // 10 ) * 100 + min ( 100 , ( n % 10 ) * 15 ) ) NEW_LINE
T696
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( n >= 10 ? min ( ( n / 10 ) * 100 + ( n % 10 ) * 15 , ( n / 10 + 1 ) * 100 ) : min ( n * 15 , 100 ) ) ; } }
import sys NEW_LINE import copy NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE ans = 1000000000000000 NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT for j in range ( 100 ) : NEW_LINE INDENT money = i * 15 + j * 100 NEW_LINE tako = i + j * 10 NEW_LINE if tako >= N : NEW_LINE INDENT ans = min ( ans , money ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
T697
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( n >= 10 ? min ( ( n / 10 ) * 100 + ( n % 10 ) * 15 , ( n / 10 + 1 ) * 100 ) : min ( n * 15 , 100 ) ) ; } }
n = int ( input ( ) ) NEW_LINE num = float ( ' inf ' ) NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT num = min ( num , i * 100 + max ( 0 , ( n - i * 10 ) ) * 15 ) NEW_LINE DEDENT print ( num ) NEW_LINE
T698
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( n >= 10 ? min ( ( n / 10 ) * 100 + ( n % 10 ) * 15 , ( n / 10 + 1 ) * 100 ) : min ( n * 15 , 100 ) ) ; } }
def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE print ( min ( ( n // 10 ) * 100 + ( n % 10 ) * 15 , ( ( n - 1 ) // 10 + 1 ) * 100 ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
T699
import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( n >= 10 ? min ( ( n / 10 ) * 100 + ( n % 10 ) * 15 , ( n / 10 + 1 ) * 100 ) : min ( n * 15 , 100 ) ) ; } }
n = int ( input ( ) ) NEW_LINE ten = n // 10 NEW_LINE one = n % 10 NEW_LINE print ( min ( ( ten + 1 ) * 100 , ten * 100 + one * 15 ) ) NEW_LINE