id
stringlengths 2
6
| java
stringlengths 48
5.92k
| python
stringlengths 33
11.1k
|
---|---|---|
T500 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int [ ] cache = new int [ n ] ; Arrays . fill ( cache , - 1 ) ; System . out . println ( cost ( n - 1 , values , cache ) ) ; } private static int cost ( int i , int [ ] values , int [ ] cache ) { int ans = 0 ; if ( cache [ i ] != - 1 ) { return cache [ i ] ; } if ( i == 0 ) { ans = 0 ; } else if ( i == 1 ) { ans = Math . abs ( values [ 1 ] - values [ 0 ] ) ; } else { int a = cost ( i - 2 , values , cache ) + Math . abs ( values [ i ] - values [ i - 2 ] ) ; int b = cost ( i - 1 , values , cache ) + Math . abs ( values [ i ] - values [ i - 1 ] ) ; ans = Math . min ( a , b ) ; } if ( cache [ i ] == - 1 ) { cache [ i ] = ans ; } return ans ; } }
| n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE dp = [ 0 for i in range ( n ) ] NEW_LINE dp [ 1 ] = abs ( a [ 0 ] - a [ 1 ] ) NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT x = abs ( a [ i ] - a [ i - 2 ] ) + dp [ i - 2 ] NEW_LINE y = abs ( a [ i ] - a [ i - 1 ] ) + dp [ i - 1 ] NEW_LINE dp [ i ] = min ( x , y ) NEW_LINE DEDENT print ( dp [ - 1 ] ) NEW_LINE
|
T501 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int [ ] cache = new int [ n ] ; Arrays . fill ( cache , - 1 ) ; System . out . println ( cost ( n - 1 , values , cache ) ) ; } private static int cost ( int i , int [ ] values , int [ ] cache ) { int ans = 0 ; if ( cache [ i ] != - 1 ) { return cache [ i ] ; } if ( i == 0 ) { ans = 0 ; } else if ( i == 1 ) { ans = Math . abs ( values [ 1 ] - values [ 0 ] ) ; } else { int a = cost ( i - 2 , values , cache ) + Math . abs ( values [ i ] - values [ i - 2 ] ) ; int b = cost ( i - 1 , values , cache ) + Math . abs ( values [ i ] - values [ i - 1 ] ) ; ans = Math . min ( a , b ) ; } if ( cache [ i ] == - 1 ) { cache [ i ] = ans ; } return ans ; } }
| if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT scaffold_count = int ( input ( ) ) NEW_LINE scaffold_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE jump_costs = [ 0 ] * scaffold_count NEW_LINE jump_costs [ 0 ] = 0 NEW_LINE jump_costs [ 1 ] = abs ( scaffold_list [ 0 ] - scaffold_list [ 1 ] ) NEW_LINE for i in range ( 2 , scaffold_count ) : NEW_LINE INDENT jump_costs [ i ] = min ( jump_costs [ i - 2 ] + abs ( scaffold_list [ i - 2 ] - scaffold_list [ i ] ) , jump_costs [ i - 1 ] + abs ( scaffold_list [ i - 1 ] - scaffold_list [ i ] ) ) NEW_LINE DEDENT print ( jump_costs [ scaffold_count - 1 ] ) NEW_LINE DEDENT
|
T502 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int [ ] cache = new int [ n ] ; Arrays . fill ( cache , - 1 ) ; System . out . println ( cost ( n - 1 , values , cache ) ) ; } private static int cost ( int i , int [ ] values , int [ ] cache ) { int ans = 0 ; if ( cache [ i ] != - 1 ) { return cache [ i ] ; } if ( i == 0 ) { ans = 0 ; } else if ( i == 1 ) { ans = Math . abs ( values [ 1 ] - values [ 0 ] ) ; } else { int a = cost ( i - 2 , values , cache ) + Math . abs ( values [ i ] - values [ i - 2 ] ) ; int b = cost ( i - 1 , values , cache ) + Math . abs ( values [ i ] - values [ i - 1 ] ) ; ans = Math . min ( a , b ) ; } if ( cache [ i ] == - 1 ) { cache [ i ] = ans ; } return ans ; } }
| import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE dp = [ 0 ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE dp [ 1 ] = abs ( a [ 1 ] - a [ 0 ] ) NEW_LINE def dpdfs ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return dp [ 0 ] NEW_LINE DEDENT elif n == 1 : NEW_LINE INDENT return dp [ 1 ] NEW_LINE DEDENT if dp [ n ] != 0 : NEW_LINE INDENT return dp [ n ] NEW_LINE DEDENT dp [ n ] = min ( dpdfs ( n - 1 ) + abs ( a [ n ] - a [ n - 1 ] ) , dpdfs ( n - 2 ) + abs ( a [ n ] - a [ n - 2 ] ) ) NEW_LINE return dp [ n ] NEW_LINE DEDENT dpdfs ( N - 1 ) NEW_LINE print ( dp [ - 1 ] ) NEW_LINE
|
T503 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int [ ] cache = new int [ n ] ; Arrays . fill ( cache , - 1 ) ; System . out . println ( cost ( n - 1 , values , cache ) ) ; } private static int cost ( int i , int [ ] values , int [ ] cache ) { int ans = 0 ; if ( cache [ i ] != - 1 ) { return cache [ i ] ; } if ( i == 0 ) { ans = 0 ; } else if ( i == 1 ) { ans = Math . abs ( values [ 1 ] - values [ 0 ] ) ; } else { int a = cost ( i - 2 , values , cache ) + Math . abs ( values [ i ] - values [ i - 2 ] ) ; int b = cost ( i - 1 , values , cache ) + Math . abs ( values [ i ] - values [ i - 1 ] ) ; ans = Math . min ( a , b ) ; } if ( cache [ i ] == - 1 ) { cache [ i ] = ans ; } return ans ; } }
| _ , t = open ( 0 ) NEW_LINE b , * a = map ( int , t . split ( ) ) NEW_LINE c = b NEW_LINE e = f = 0 NEW_LINE for g in a : e , f , b , c = min ( abs ( b - g ) + e , abs ( c - g ) + f ) , e , g , b NEW_LINE print ( e ) NEW_LINE
|
T504 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int [ ] cache = new int [ n ] ; Arrays . fill ( cache , - 1 ) ; System . out . println ( cost ( n - 1 , values , cache ) ) ; } private static int cost ( int i , int [ ] values , int [ ] cache ) { int ans = 0 ; if ( cache [ i ] != - 1 ) { return cache [ i ] ; } if ( i == 0 ) { ans = 0 ; } else if ( i == 1 ) { ans = Math . abs ( values [ 1 ] - values [ 0 ] ) ; } else { int a = cost ( i - 2 , values , cache ) + Math . abs ( values [ i ] - values [ i - 2 ] ) ; int b = cost ( i - 1 , values , cache ) + Math . abs ( values [ i ] - values [ i - 1 ] ) ; ans = Math . min ( a , b ) ; } if ( cache [ i ] == - 1 ) { cache [ i ] = ans ; } return ans ; } }
| def poll_poll_poll_poll_poll ( N : int , A : list ) -> int : NEW_LINE INDENT dp = [ float ( ' inf ' ) ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] + abs ( A [ i ] - A [ i - 1 ] ) NEW_LINE if i > 1 : NEW_LINE INDENT dp [ i ] = min ( dp [ i ] , dp [ i - 2 ] + abs ( A [ i ] - A [ i - 2 ] ) ) NEW_LINE DEDENT DEDENT return dp [ N - 1 ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = poll_poll_poll_poll_poll ( N , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT
|
T505 | import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; N = reader . nextInt ( ) ; int [ ] arr = new int [ N ] ; int [ ] gaps = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; if ( i > 0 ) { int r = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + gaps [ i - 1 ] ; if ( i > 1 ) { r = Math . min ( r , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + gaps [ i - 2 ] ) ; } gaps [ i ] = r ; } } System . out . println ( gaps [ N - 1 ] ) ; reader . close ( ) ; } }
| n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE dp = [ 0 for i in range ( n ) ] NEW_LINE dp [ 1 ] = abs ( a [ 0 ] - a [ 1 ] ) NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT x = abs ( a [ i ] - a [ i - 2 ] ) + dp [ i - 2 ] NEW_LINE y = abs ( a [ i ] - a [ i - 1 ] ) + dp [ i - 1 ] NEW_LINE dp [ i ] = min ( x , y ) NEW_LINE DEDENT print ( dp [ - 1 ] ) NEW_LINE
|
T506 | import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; N = reader . nextInt ( ) ; int [ ] arr = new int [ N ] ; int [ ] gaps = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; if ( i > 0 ) { int r = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + gaps [ i - 1 ] ; if ( i > 1 ) { r = Math . min ( r , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + gaps [ i - 2 ] ) ; } gaps [ i ] = r ; } } System . out . println ( gaps [ N - 1 ] ) ; reader . close ( ) ; } }
| if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT scaffold_count = int ( input ( ) ) NEW_LINE scaffold_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE jump_costs = [ 0 ] * scaffold_count NEW_LINE jump_costs [ 0 ] = 0 NEW_LINE jump_costs [ 1 ] = abs ( scaffold_list [ 0 ] - scaffold_list [ 1 ] ) NEW_LINE for i in range ( 2 , scaffold_count ) : NEW_LINE INDENT jump_costs [ i ] = min ( jump_costs [ i - 2 ] + abs ( scaffold_list [ i - 2 ] - scaffold_list [ i ] ) , jump_costs [ i - 1 ] + abs ( scaffold_list [ i - 1 ] - scaffold_list [ i ] ) ) NEW_LINE DEDENT print ( jump_costs [ scaffold_count - 1 ] ) NEW_LINE DEDENT
|
T507 | import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; N = reader . nextInt ( ) ; int [ ] arr = new int [ N ] ; int [ ] gaps = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; if ( i > 0 ) { int r = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + gaps [ i - 1 ] ; if ( i > 1 ) { r = Math . min ( r , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + gaps [ i - 2 ] ) ; } gaps [ i ] = r ; } } System . out . println ( gaps [ N - 1 ] ) ; reader . close ( ) ; } }
| import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE dp = [ 0 ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE dp [ 1 ] = abs ( a [ 1 ] - a [ 0 ] ) NEW_LINE def dpdfs ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return dp [ 0 ] NEW_LINE DEDENT elif n == 1 : NEW_LINE INDENT return dp [ 1 ] NEW_LINE DEDENT if dp [ n ] != 0 : NEW_LINE INDENT return dp [ n ] NEW_LINE DEDENT dp [ n ] = min ( dpdfs ( n - 1 ) + abs ( a [ n ] - a [ n - 1 ] ) , dpdfs ( n - 2 ) + abs ( a [ n ] - a [ n - 2 ] ) ) NEW_LINE return dp [ n ] NEW_LINE DEDENT dpdfs ( N - 1 ) NEW_LINE print ( dp [ - 1 ] ) NEW_LINE
|
T508 | import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; N = reader . nextInt ( ) ; int [ ] arr = new int [ N ] ; int [ ] gaps = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; if ( i > 0 ) { int r = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + gaps [ i - 1 ] ; if ( i > 1 ) { r = Math . min ( r , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + gaps [ i - 2 ] ) ; } gaps [ i ] = r ; } } System . out . println ( gaps [ N - 1 ] ) ; reader . close ( ) ; } }
| _ , t = open ( 0 ) NEW_LINE b , * a = map ( int , t . split ( ) ) NEW_LINE c = b NEW_LINE e = f = 0 NEW_LINE for g in a : e , f , b , c = min ( abs ( b - g ) + e , abs ( c - g ) + f ) , e , g , b NEW_LINE print ( e ) NEW_LINE
|
T509 | import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; N = reader . nextInt ( ) ; int [ ] arr = new int [ N ] ; int [ ] gaps = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; if ( i > 0 ) { int r = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + gaps [ i - 1 ] ; if ( i > 1 ) { r = Math . min ( r , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + gaps [ i - 2 ] ) ; } gaps [ i ] = r ; } } System . out . println ( gaps [ N - 1 ] ) ; reader . close ( ) ; } }
| def poll_poll_poll_poll_poll ( N : int , A : list ) -> int : NEW_LINE INDENT dp = [ float ( ' inf ' ) ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] + abs ( A [ i ] - A [ i - 1 ] ) NEW_LINE if i > 1 : NEW_LINE INDENT dp [ i ] = min ( dp [ i ] , dp [ i - 2 ] + abs ( A [ i ] - A [ i - 2 ] ) ) NEW_LINE DEDENT DEDENT return dp [ N - 1 ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = poll_poll_poll_poll_poll ( N , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT
|
T510 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = 0 ; long c = 0 ; if ( a % 2 == 0 ) { if ( b % 2 == 0 ) { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = b ; } else { ans = b ^ 1 ; } } else { c = b - a + 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = 0 ; } else { ans = 1 ; } } } else { if ( b % 2 == 0 ) { c = b - a - 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ^ b ; } else { ans = ( a ^ b ) ^ 1 ; } } else { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ; } else { ans = a ^ 1 ; } } } System . out . println ( ans ) ; } }
| A , B = map ( int , input ( ) . split ( ) ) NEW_LINE A -= 1 NEW_LINE if A % 4 == 1 : NEW_LINE INDENT A = 1 NEW_LINE DEDENT elif A % 4 == 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif A % 4 == 3 : NEW_LINE INDENT A = 0 NEW_LINE DEDENT if B % 4 == 1 : NEW_LINE INDENT B = 1 NEW_LINE DEDENT elif B % 4 == 2 : NEW_LINE INDENT B += 1 NEW_LINE DEDENT elif B % 4 == 3 : NEW_LINE INDENT B = 0 NEW_LINE DEDENT answer = A ^ B NEW_LINE print ( answer ) NEW_LINE
|
T511 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = 0 ; long c = 0 ; if ( a % 2 == 0 ) { if ( b % 2 == 0 ) { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = b ; } else { ans = b ^ 1 ; } } else { c = b - a + 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = 0 ; } else { ans = 1 ; } } } else { if ( b % 2 == 0 ) { c = b - a - 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ^ b ; } else { ans = ( a ^ b ) ^ 1 ; } } else { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ; } else { ans = a ^ 1 ; } } } System . out . println ( ans ) ; } }
| def solve ( string ) : NEW_LINE INDENT a , b = map ( int , string . split ( ) ) NEW_LINE if b == 0 : NEW_LINE INDENT return "0" NEW_LINE DEDENT bin_a = " { :040b } " . format ( a ) NEW_LINE bin_b = " { :040b } " . format ( b ) NEW_LINE aa = [ - 1 if _a == "0" else int ( bin_a [ i + 1 : ] or "0" , 2 ) for i , _a in enumerate ( bin_a ) ] NEW_LINE bb = [ - 1 if _b == "0" else int ( bin_b [ i + 1 : ] or "0" , 2 ) for i , _b in enumerate ( bin_b ) ] NEW_LINE index = 0 NEW_LINE while True : NEW_LINE INDENT if bb [ index ] != - 1 : NEW_LINE INDENT break NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans = [ ] NEW_LINE while index < 40 : NEW_LINE INDENT if aa [ index ] == bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( "0" ) NEW_LINE DEDENT elif aa [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 ) % 2 ) ) NEW_LINE DEDENT elif bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( aa [ index ] % 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 - aa [ index ] ) % 2 ) ) NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans [ - 1 ] = str ( ( b - a ) // 2 % 2 ) if a % 2 == b % 2 == 0 else str ( ( ( b - a ) // 2 + 1 ) % 2 ) NEW_LINE return str ( int ( " " . join ( ans ) , 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT
|
T512 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = 0 ; long c = 0 ; if ( a % 2 == 0 ) { if ( b % 2 == 0 ) { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = b ; } else { ans = b ^ 1 ; } } else { c = b - a + 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = 0 ; } else { ans = 1 ; } } } else { if ( b % 2 == 0 ) { c = b - a - 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ^ b ; } else { ans = ( a ^ b ) ^ 1 ; } } else { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ; } else { ans = a ^ 1 ; } } } System . out . println ( ans ) ; } }
| import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def f ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT if ( n // 2 ) % 2 == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT return 1 ^ n NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( ( n + 1 ) // 2 ) % 2 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT DEDENT def solve ( A : int , B : int ) : NEW_LINE INDENT print ( f ( B ) ^ f ( A - 1 ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE solve ( A , B ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T513 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = 0 ; long c = 0 ; if ( a % 2 == 0 ) { if ( b % 2 == 0 ) { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = b ; } else { ans = b ^ 1 ; } } else { c = b - a + 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = 0 ; } else { ans = 1 ; } } } else { if ( b % 2 == 0 ) { c = b - a - 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ^ b ; } else { ans = ( a ^ b ) ^ 1 ; } } else { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ; } else { ans = a ^ 1 ; } } } System . out . println ( ans ) ; } }
| import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = int ( 0 ) NEW_LINE if B == 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = math . floor ( math . log2 ( B ) + 1 ) NEW_LINE A_mod = A % 4 NEW_LINE B_mod = B % 4 NEW_LINE if A_mod < 2 : NEW_LINE INDENT if B_mod == 1 or B_mod == 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod == 3 or B_mod == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT A_mod = A % ( 2 ** i ) NEW_LINE B_mod = B % ( 2 ** i ) NEW_LINE if A_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT if B_mod >= 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( ( B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( A_mod % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( ( A_mod + B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
|
T514 | import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = 0 ; long c = 0 ; if ( a % 2 == 0 ) { if ( b % 2 == 0 ) { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = b ; } else { ans = b ^ 1 ; } } else { c = b - a + 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = 0 ; } else { ans = 1 ; } } } else { if ( b % 2 == 0 ) { c = b - a - 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ^ b ; } else { ans = ( a ^ b ) ^ 1 ; } } else { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ; } else { ans = a ^ 1 ; } } } System . out . println ( ans ) ; } }
| def SI ( ) : return input ( ) NEW_LINE def II ( ) : return int ( SI ( ) ) NEW_LINE def STI ( ) : return SI ( ) . split ( ) NEW_LINE def ITI ( ) : return map ( int , STI ( ) ) NEW_LINE def SLI ( ) : return list ( SI ( ) ) NEW_LINE def ILI ( ) : return list ( ITI ( ) ) NEW_LINE A , B = ITI ( ) NEW_LINE def cum_xor ( n ) : NEW_LINE INDENT result = ( n + 1 ) // 2 % 2 NEW_LINE if ( n + 1 ) % 2 == 1 : result ^= n NEW_LINE return result NEW_LINE DEDENT print ( cum_xor ( A - 1 ) ^ cum_xor ( B ) ) NEW_LINE
|
T515 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int LOG = 40 ; void solve ( ) { long A = in . nextLong ( ) , B = in . nextLong ( ) ; long ans = xor ( B ) ^ xor ( A - 1 ) ; out . println ( ans ) ; } long xor ( long n ) { if ( n <= 0 ) return 0 ; long res = 0 ; for ( int i = 0 ; i < LOG ; i ++ ) { long period = 1L << ( i + 1 ) ; long zeros = period / 2 , ones = period / 2 ; long q = ( n + 1 ) / period , r = ( n + 1 ) % period ; long v = 0 ; if ( q % 2 == 1 && ones % 2 == 1 ) v ^= 1 ; if ( r > zeros && ( r - zeros ) % 2 == 1 ) v ^= 1 ; res |= v << i ; } return res ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }
| A , B = map ( int , input ( ) . split ( ) ) NEW_LINE A -= 1 NEW_LINE if A % 4 == 1 : NEW_LINE INDENT A = 1 NEW_LINE DEDENT elif A % 4 == 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif A % 4 == 3 : NEW_LINE INDENT A = 0 NEW_LINE DEDENT if B % 4 == 1 : NEW_LINE INDENT B = 1 NEW_LINE DEDENT elif B % 4 == 2 : NEW_LINE INDENT B += 1 NEW_LINE DEDENT elif B % 4 == 3 : NEW_LINE INDENT B = 0 NEW_LINE DEDENT answer = A ^ B NEW_LINE print ( answer ) NEW_LINE
|
T516 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int LOG = 40 ; void solve ( ) { long A = in . nextLong ( ) , B = in . nextLong ( ) ; long ans = xor ( B ) ^ xor ( A - 1 ) ; out . println ( ans ) ; } long xor ( long n ) { if ( n <= 0 ) return 0 ; long res = 0 ; for ( int i = 0 ; i < LOG ; i ++ ) { long period = 1L << ( i + 1 ) ; long zeros = period / 2 , ones = period / 2 ; long q = ( n + 1 ) / period , r = ( n + 1 ) % period ; long v = 0 ; if ( q % 2 == 1 && ones % 2 == 1 ) v ^= 1 ; if ( r > zeros && ( r - zeros ) % 2 == 1 ) v ^= 1 ; res |= v << i ; } return res ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }
| def solve ( string ) : NEW_LINE INDENT a , b = map ( int , string . split ( ) ) NEW_LINE if b == 0 : NEW_LINE INDENT return "0" NEW_LINE DEDENT bin_a = " { :040b } " . format ( a ) NEW_LINE bin_b = " { :040b } " . format ( b ) NEW_LINE aa = [ - 1 if _a == "0" else int ( bin_a [ i + 1 : ] or "0" , 2 ) for i , _a in enumerate ( bin_a ) ] NEW_LINE bb = [ - 1 if _b == "0" else int ( bin_b [ i + 1 : ] or "0" , 2 ) for i , _b in enumerate ( bin_b ) ] NEW_LINE index = 0 NEW_LINE while True : NEW_LINE INDENT if bb [ index ] != - 1 : NEW_LINE INDENT break NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans = [ ] NEW_LINE while index < 40 : NEW_LINE INDENT if aa [ index ] == bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( "0" ) NEW_LINE DEDENT elif aa [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 ) % 2 ) ) NEW_LINE DEDENT elif bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( aa [ index ] % 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 - aa [ index ] ) % 2 ) ) NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans [ - 1 ] = str ( ( b - a ) // 2 % 2 ) if a % 2 == b % 2 == 0 else str ( ( ( b - a ) // 2 + 1 ) % 2 ) NEW_LINE return str ( int ( " " . join ( ans ) , 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT
|
T517 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int LOG = 40 ; void solve ( ) { long A = in . nextLong ( ) , B = in . nextLong ( ) ; long ans = xor ( B ) ^ xor ( A - 1 ) ; out . println ( ans ) ; } long xor ( long n ) { if ( n <= 0 ) return 0 ; long res = 0 ; for ( int i = 0 ; i < LOG ; i ++ ) { long period = 1L << ( i + 1 ) ; long zeros = period / 2 , ones = period / 2 ; long q = ( n + 1 ) / period , r = ( n + 1 ) % period ; long v = 0 ; if ( q % 2 == 1 && ones % 2 == 1 ) v ^= 1 ; if ( r > zeros && ( r - zeros ) % 2 == 1 ) v ^= 1 ; res |= v << i ; } return res ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }
| import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def f ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT if ( n // 2 ) % 2 == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT return 1 ^ n NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( ( n + 1 ) // 2 ) % 2 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT DEDENT def solve ( A : int , B : int ) : NEW_LINE INDENT print ( f ( B ) ^ f ( A - 1 ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE solve ( A , B ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T518 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int LOG = 40 ; void solve ( ) { long A = in . nextLong ( ) , B = in . nextLong ( ) ; long ans = xor ( B ) ^ xor ( A - 1 ) ; out . println ( ans ) ; } long xor ( long n ) { if ( n <= 0 ) return 0 ; long res = 0 ; for ( int i = 0 ; i < LOG ; i ++ ) { long period = 1L << ( i + 1 ) ; long zeros = period / 2 , ones = period / 2 ; long q = ( n + 1 ) / period , r = ( n + 1 ) % period ; long v = 0 ; if ( q % 2 == 1 && ones % 2 == 1 ) v ^= 1 ; if ( r > zeros && ( r - zeros ) % 2 == 1 ) v ^= 1 ; res |= v << i ; } return res ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }
| import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = int ( 0 ) NEW_LINE if B == 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = math . floor ( math . log2 ( B ) + 1 ) NEW_LINE A_mod = A % 4 NEW_LINE B_mod = B % 4 NEW_LINE if A_mod < 2 : NEW_LINE INDENT if B_mod == 1 or B_mod == 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod == 3 or B_mod == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT A_mod = A % ( 2 ** i ) NEW_LINE B_mod = B % ( 2 ** i ) NEW_LINE if A_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT if B_mod >= 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( ( B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( A_mod % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( ( A_mod + B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
|
T519 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int LOG = 40 ; void solve ( ) { long A = in . nextLong ( ) , B = in . nextLong ( ) ; long ans = xor ( B ) ^ xor ( A - 1 ) ; out . println ( ans ) ; } long xor ( long n ) { if ( n <= 0 ) return 0 ; long res = 0 ; for ( int i = 0 ; i < LOG ; i ++ ) { long period = 1L << ( i + 1 ) ; long zeros = period / 2 , ones = period / 2 ; long q = ( n + 1 ) / period , r = ( n + 1 ) % period ; long v = 0 ; if ( q % 2 == 1 && ones % 2 == 1 ) v ^= 1 ; if ( r > zeros && ( r - zeros ) % 2 == 1 ) v ^= 1 ; res |= v << i ; } return res ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }
| def SI ( ) : return input ( ) NEW_LINE def II ( ) : return int ( SI ( ) ) NEW_LINE def STI ( ) : return SI ( ) . split ( ) NEW_LINE def ITI ( ) : return map ( int , STI ( ) ) NEW_LINE def SLI ( ) : return list ( SI ( ) ) NEW_LINE def ILI ( ) : return list ( ITI ( ) ) NEW_LINE A , B = ITI ( ) NEW_LINE def cum_xor ( n ) : NEW_LINE INDENT result = ( n + 1 ) // 2 % 2 NEW_LINE if ( n + 1 ) % 2 == 1 : result ^= n NEW_LINE return result NEW_LINE DEDENT print ( cum_xor ( A - 1 ) ^ cum_xor ( B ) ) NEW_LINE
|
T520 | import java . util . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { out . println ( f ( sc . nextLong ( ) - 1 ) ^ f ( sc . nextLong ( ) ) ) ; out . close ( ) ; } static long f ( long x ) { long c = x % 4 ; if ( c == 0 ) return x ; if ( c == 1 ) return 1 ; if ( c == 2 ) return 1 ^ x ; return 0 ; } static long power ( long x , long n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; n >>= 1 ; } return ans ; } static PrintWriter out = new PrintWriter ( System . out ) ; static class sc { static Scanner s = new Scanner ( System . in ) ; static String next ( ) { return s . next ( ) ; } static int nextInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static double nextDouble ( ) { return Double . parseDouble ( s . next ( ) ) ; } } }
| A , B = map ( int , input ( ) . split ( ) ) NEW_LINE A -= 1 NEW_LINE if A % 4 == 1 : NEW_LINE INDENT A = 1 NEW_LINE DEDENT elif A % 4 == 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif A % 4 == 3 : NEW_LINE INDENT A = 0 NEW_LINE DEDENT if B % 4 == 1 : NEW_LINE INDENT B = 1 NEW_LINE DEDENT elif B % 4 == 2 : NEW_LINE INDENT B += 1 NEW_LINE DEDENT elif B % 4 == 3 : NEW_LINE INDENT B = 0 NEW_LINE DEDENT answer = A ^ B NEW_LINE print ( answer ) NEW_LINE
|
T521 | import java . util . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { out . println ( f ( sc . nextLong ( ) - 1 ) ^ f ( sc . nextLong ( ) ) ) ; out . close ( ) ; } static long f ( long x ) { long c = x % 4 ; if ( c == 0 ) return x ; if ( c == 1 ) return 1 ; if ( c == 2 ) return 1 ^ x ; return 0 ; } static long power ( long x , long n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; n >>= 1 ; } return ans ; } static PrintWriter out = new PrintWriter ( System . out ) ; static class sc { static Scanner s = new Scanner ( System . in ) ; static String next ( ) { return s . next ( ) ; } static int nextInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static double nextDouble ( ) { return Double . parseDouble ( s . next ( ) ) ; } } }
| def solve ( string ) : NEW_LINE INDENT a , b = map ( int , string . split ( ) ) NEW_LINE if b == 0 : NEW_LINE INDENT return "0" NEW_LINE DEDENT bin_a = " { :040b } " . format ( a ) NEW_LINE bin_b = " { :040b } " . format ( b ) NEW_LINE aa = [ - 1 if _a == "0" else int ( bin_a [ i + 1 : ] or "0" , 2 ) for i , _a in enumerate ( bin_a ) ] NEW_LINE bb = [ - 1 if _b == "0" else int ( bin_b [ i + 1 : ] or "0" , 2 ) for i , _b in enumerate ( bin_b ) ] NEW_LINE index = 0 NEW_LINE while True : NEW_LINE INDENT if bb [ index ] != - 1 : NEW_LINE INDENT break NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans = [ ] NEW_LINE while index < 40 : NEW_LINE INDENT if aa [ index ] == bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( "0" ) NEW_LINE DEDENT elif aa [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 ) % 2 ) ) NEW_LINE DEDENT elif bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( aa [ index ] % 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 - aa [ index ] ) % 2 ) ) NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans [ - 1 ] = str ( ( b - a ) // 2 % 2 ) if a % 2 == b % 2 == 0 else str ( ( ( b - a ) // 2 + 1 ) % 2 ) NEW_LINE return str ( int ( " " . join ( ans ) , 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT
|
T522 | import java . util . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { out . println ( f ( sc . nextLong ( ) - 1 ) ^ f ( sc . nextLong ( ) ) ) ; out . close ( ) ; } static long f ( long x ) { long c = x % 4 ; if ( c == 0 ) return x ; if ( c == 1 ) return 1 ; if ( c == 2 ) return 1 ^ x ; return 0 ; } static long power ( long x , long n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; n >>= 1 ; } return ans ; } static PrintWriter out = new PrintWriter ( System . out ) ; static class sc { static Scanner s = new Scanner ( System . in ) ; static String next ( ) { return s . next ( ) ; } static int nextInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static double nextDouble ( ) { return Double . parseDouble ( s . next ( ) ) ; } } }
| import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def f ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT if ( n // 2 ) % 2 == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT return 1 ^ n NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( ( n + 1 ) // 2 ) % 2 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT DEDENT def solve ( A : int , B : int ) : NEW_LINE INDENT print ( f ( B ) ^ f ( A - 1 ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE solve ( A , B ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T523 | import java . util . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { out . println ( f ( sc . nextLong ( ) - 1 ) ^ f ( sc . nextLong ( ) ) ) ; out . close ( ) ; } static long f ( long x ) { long c = x % 4 ; if ( c == 0 ) return x ; if ( c == 1 ) return 1 ; if ( c == 2 ) return 1 ^ x ; return 0 ; } static long power ( long x , long n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; n >>= 1 ; } return ans ; } static PrintWriter out = new PrintWriter ( System . out ) ; static class sc { static Scanner s = new Scanner ( System . in ) ; static String next ( ) { return s . next ( ) ; } static int nextInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static double nextDouble ( ) { return Double . parseDouble ( s . next ( ) ) ; } } }
| import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = int ( 0 ) NEW_LINE if B == 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = math . floor ( math . log2 ( B ) + 1 ) NEW_LINE A_mod = A % 4 NEW_LINE B_mod = B % 4 NEW_LINE if A_mod < 2 : NEW_LINE INDENT if B_mod == 1 or B_mod == 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod == 3 or B_mod == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT A_mod = A % ( 2 ** i ) NEW_LINE B_mod = B % ( 2 ** i ) NEW_LINE if A_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT if B_mod >= 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( ( B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( A_mod % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( ( A_mod + B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
|
T524 | import java . util . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { out . println ( f ( sc . nextLong ( ) - 1 ) ^ f ( sc . nextLong ( ) ) ) ; out . close ( ) ; } static long f ( long x ) { long c = x % 4 ; if ( c == 0 ) return x ; if ( c == 1 ) return 1 ; if ( c == 2 ) return 1 ^ x ; return 0 ; } static long power ( long x , long n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; n >>= 1 ; } return ans ; } static PrintWriter out = new PrintWriter ( System . out ) ; static class sc { static Scanner s = new Scanner ( System . in ) ; static String next ( ) { return s . next ( ) ; } static int nextInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static double nextDouble ( ) { return Double . parseDouble ( s . next ( ) ) ; } } }
| def SI ( ) : return input ( ) NEW_LINE def II ( ) : return int ( SI ( ) ) NEW_LINE def STI ( ) : return SI ( ) . split ( ) NEW_LINE def ITI ( ) : return map ( int , STI ( ) ) NEW_LINE def SLI ( ) : return list ( SI ( ) ) NEW_LINE def ILI ( ) : return list ( ITI ( ) ) NEW_LINE A , B = ITI ( ) NEW_LINE def cum_xor ( n ) : NEW_LINE INDENT result = ( n + 1 ) // 2 % 2 NEW_LINE if ( n + 1 ) % 2 == 1 : result ^= n NEW_LINE return result NEW_LINE DEDENT print ( cum_xor ( A - 1 ) ^ cum_xor ( B ) ) NEW_LINE
|
T525 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long A = scanner . nextLong ( ) ; long B = scanner . nextLong ( ) ; long answer = 0 ; long C = 0 ; if ( A % 2 == 0 ) { if ( B % 2 == 0 ) { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = B ; } else { answer = B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = 1 ; } else { answer = 0 ; } } } else { if ( B % 2 == 0 ) { C = ( B - A - 1 ) / 2 ; if ( C % 2 == 0 ) { answer = A ^ B ; } else { answer = A ^ B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = A ; } else { answer = A ^ 1 ; } } } System . out . println ( answer ) ; } }
| A , B = map ( int , input ( ) . split ( ) ) NEW_LINE A -= 1 NEW_LINE if A % 4 == 1 : NEW_LINE INDENT A = 1 NEW_LINE DEDENT elif A % 4 == 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif A % 4 == 3 : NEW_LINE INDENT A = 0 NEW_LINE DEDENT if B % 4 == 1 : NEW_LINE INDENT B = 1 NEW_LINE DEDENT elif B % 4 == 2 : NEW_LINE INDENT B += 1 NEW_LINE DEDENT elif B % 4 == 3 : NEW_LINE INDENT B = 0 NEW_LINE DEDENT answer = A ^ B NEW_LINE print ( answer ) NEW_LINE
|
T526 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long A = scanner . nextLong ( ) ; long B = scanner . nextLong ( ) ; long answer = 0 ; long C = 0 ; if ( A % 2 == 0 ) { if ( B % 2 == 0 ) { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = B ; } else { answer = B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = 1 ; } else { answer = 0 ; } } } else { if ( B % 2 == 0 ) { C = ( B - A - 1 ) / 2 ; if ( C % 2 == 0 ) { answer = A ^ B ; } else { answer = A ^ B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = A ; } else { answer = A ^ 1 ; } } } System . out . println ( answer ) ; } }
| def solve ( string ) : NEW_LINE INDENT a , b = map ( int , string . split ( ) ) NEW_LINE if b == 0 : NEW_LINE INDENT return "0" NEW_LINE DEDENT bin_a = " { :040b } " . format ( a ) NEW_LINE bin_b = " { :040b } " . format ( b ) NEW_LINE aa = [ - 1 if _a == "0" else int ( bin_a [ i + 1 : ] or "0" , 2 ) for i , _a in enumerate ( bin_a ) ] NEW_LINE bb = [ - 1 if _b == "0" else int ( bin_b [ i + 1 : ] or "0" , 2 ) for i , _b in enumerate ( bin_b ) ] NEW_LINE index = 0 NEW_LINE while True : NEW_LINE INDENT if bb [ index ] != - 1 : NEW_LINE INDENT break NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans = [ ] NEW_LINE while index < 40 : NEW_LINE INDENT if aa [ index ] == bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( "0" ) NEW_LINE DEDENT elif aa [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 ) % 2 ) ) NEW_LINE DEDENT elif bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( aa [ index ] % 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 - aa [ index ] ) % 2 ) ) NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans [ - 1 ] = str ( ( b - a ) // 2 % 2 ) if a % 2 == b % 2 == 0 else str ( ( ( b - a ) // 2 + 1 ) % 2 ) NEW_LINE return str ( int ( " " . join ( ans ) , 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT
|
T527 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long A = scanner . nextLong ( ) ; long B = scanner . nextLong ( ) ; long answer = 0 ; long C = 0 ; if ( A % 2 == 0 ) { if ( B % 2 == 0 ) { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = B ; } else { answer = B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = 1 ; } else { answer = 0 ; } } } else { if ( B % 2 == 0 ) { C = ( B - A - 1 ) / 2 ; if ( C % 2 == 0 ) { answer = A ^ B ; } else { answer = A ^ B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = A ; } else { answer = A ^ 1 ; } } } System . out . println ( answer ) ; } }
| import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def f ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT if ( n // 2 ) % 2 == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT return 1 ^ n NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( ( n + 1 ) // 2 ) % 2 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT DEDENT def solve ( A : int , B : int ) : NEW_LINE INDENT print ( f ( B ) ^ f ( A - 1 ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE solve ( A , B ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T528 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long A = scanner . nextLong ( ) ; long B = scanner . nextLong ( ) ; long answer = 0 ; long C = 0 ; if ( A % 2 == 0 ) { if ( B % 2 == 0 ) { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = B ; } else { answer = B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = 1 ; } else { answer = 0 ; } } } else { if ( B % 2 == 0 ) { C = ( B - A - 1 ) / 2 ; if ( C % 2 == 0 ) { answer = A ^ B ; } else { answer = A ^ B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = A ; } else { answer = A ^ 1 ; } } } System . out . println ( answer ) ; } }
| import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = int ( 0 ) NEW_LINE if B == 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = math . floor ( math . log2 ( B ) + 1 ) NEW_LINE A_mod = A % 4 NEW_LINE B_mod = B % 4 NEW_LINE if A_mod < 2 : NEW_LINE INDENT if B_mod == 1 or B_mod == 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod == 3 or B_mod == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT A_mod = A % ( 2 ** i ) NEW_LINE B_mod = B % ( 2 ** i ) NEW_LINE if A_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT if B_mod >= 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( ( B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( A_mod % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( ( A_mod + B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
|
T529 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long A = scanner . nextLong ( ) ; long B = scanner . nextLong ( ) ; long answer = 0 ; long C = 0 ; if ( A % 2 == 0 ) { if ( B % 2 == 0 ) { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = B ; } else { answer = B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = 1 ; } else { answer = 0 ; } } } else { if ( B % 2 == 0 ) { C = ( B - A - 1 ) / 2 ; if ( C % 2 == 0 ) { answer = A ^ B ; } else { answer = A ^ B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = A ; } else { answer = A ^ 1 ; } } } System . out . println ( answer ) ; } }
| def SI ( ) : return input ( ) NEW_LINE def II ( ) : return int ( SI ( ) ) NEW_LINE def STI ( ) : return SI ( ) . split ( ) NEW_LINE def ITI ( ) : return map ( int , STI ( ) ) NEW_LINE def SLI ( ) : return list ( SI ( ) ) NEW_LINE def ILI ( ) : return list ( ITI ( ) ) NEW_LINE A , B = ITI ( ) NEW_LINE def cum_xor ( n ) : NEW_LINE INDENT result = ( n + 1 ) // 2 % 2 NEW_LINE if ( n + 1 ) % 2 == 1 : result ^= n NEW_LINE return result NEW_LINE DEDENT print ( cum_xor ( A - 1 ) ^ cum_xor ( B ) ) NEW_LINE
|
T530 | import java . util . * ; public class Main { public static class MyPair implements Comparable < MyPair > { int cost ; int supply ; public MyPair ( int cost , int supply ) { this . cost = cost ; this . supply = supply ; } @ Override public int compareTo ( MyPair other ) { return ( this . cost - other . cost ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; boolean AOdd = A % 2 == 1 ; boolean BOdd = B % 2 == 1 ; if ( A == B ) { System . out . println ( A ) ; } else if ( AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; if ( LSB == 1 ) { System . out . println ( A - 1 ) ; } else { System . out . println ( A ) ; } } else if ( AOdd && ! BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; long BToCompare = B + LSB ; long AToCompare = A ; long solution = 0 ; long multiplier = 1 ; while ( BToCompare > 0 ) { if ( AToCompare == 0 ) { solution += BToCompare % 2 * multiplier ; BToCompare /= 2 ; } else { if ( BToCompare % 2 != AToCompare % 2 ) { solution += multiplier ; } BToCompare /= 2 ; AToCompare /= 2 ; } multiplier *= 2 ; } System . out . println ( solution ) ; } else if ( ! AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff + 1 ) / 2 % 2 ; System . out . println ( LSB ) ; } else { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; System . out . println ( B + LSB ) ; } } }
| A , B = map ( int , input ( ) . split ( ) ) NEW_LINE A -= 1 NEW_LINE if A % 4 == 1 : NEW_LINE INDENT A = 1 NEW_LINE DEDENT elif A % 4 == 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif A % 4 == 3 : NEW_LINE INDENT A = 0 NEW_LINE DEDENT if B % 4 == 1 : NEW_LINE INDENT B = 1 NEW_LINE DEDENT elif B % 4 == 2 : NEW_LINE INDENT B += 1 NEW_LINE DEDENT elif B % 4 == 3 : NEW_LINE INDENT B = 0 NEW_LINE DEDENT answer = A ^ B NEW_LINE print ( answer ) NEW_LINE
|
T531 | import java . util . * ; public class Main { public static class MyPair implements Comparable < MyPair > { int cost ; int supply ; public MyPair ( int cost , int supply ) { this . cost = cost ; this . supply = supply ; } @ Override public int compareTo ( MyPair other ) { return ( this . cost - other . cost ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; boolean AOdd = A % 2 == 1 ; boolean BOdd = B % 2 == 1 ; if ( A == B ) { System . out . println ( A ) ; } else if ( AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; if ( LSB == 1 ) { System . out . println ( A - 1 ) ; } else { System . out . println ( A ) ; } } else if ( AOdd && ! BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; long BToCompare = B + LSB ; long AToCompare = A ; long solution = 0 ; long multiplier = 1 ; while ( BToCompare > 0 ) { if ( AToCompare == 0 ) { solution += BToCompare % 2 * multiplier ; BToCompare /= 2 ; } else { if ( BToCompare % 2 != AToCompare % 2 ) { solution += multiplier ; } BToCompare /= 2 ; AToCompare /= 2 ; } multiplier *= 2 ; } System . out . println ( solution ) ; } else if ( ! AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff + 1 ) / 2 % 2 ; System . out . println ( LSB ) ; } else { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; System . out . println ( B + LSB ) ; } } }
| def solve ( string ) : NEW_LINE INDENT a , b = map ( int , string . split ( ) ) NEW_LINE if b == 0 : NEW_LINE INDENT return "0" NEW_LINE DEDENT bin_a = " { :040b } " . format ( a ) NEW_LINE bin_b = " { :040b } " . format ( b ) NEW_LINE aa = [ - 1 if _a == "0" else int ( bin_a [ i + 1 : ] or "0" , 2 ) for i , _a in enumerate ( bin_a ) ] NEW_LINE bb = [ - 1 if _b == "0" else int ( bin_b [ i + 1 : ] or "0" , 2 ) for i , _b in enumerate ( bin_b ) ] NEW_LINE index = 0 NEW_LINE while True : NEW_LINE INDENT if bb [ index ] != - 1 : NEW_LINE INDENT break NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans = [ ] NEW_LINE while index < 40 : NEW_LINE INDENT if aa [ index ] == bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( "0" ) NEW_LINE DEDENT elif aa [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 ) % 2 ) ) NEW_LINE DEDENT elif bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( aa [ index ] % 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 - aa [ index ] ) % 2 ) ) NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans [ - 1 ] = str ( ( b - a ) // 2 % 2 ) if a % 2 == b % 2 == 0 else str ( ( ( b - a ) // 2 + 1 ) % 2 ) NEW_LINE return str ( int ( " " . join ( ans ) , 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT
|
T532 | import java . util . * ; public class Main { public static class MyPair implements Comparable < MyPair > { int cost ; int supply ; public MyPair ( int cost , int supply ) { this . cost = cost ; this . supply = supply ; } @ Override public int compareTo ( MyPair other ) { return ( this . cost - other . cost ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; boolean AOdd = A % 2 == 1 ; boolean BOdd = B % 2 == 1 ; if ( A == B ) { System . out . println ( A ) ; } else if ( AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; if ( LSB == 1 ) { System . out . println ( A - 1 ) ; } else { System . out . println ( A ) ; } } else if ( AOdd && ! BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; long BToCompare = B + LSB ; long AToCompare = A ; long solution = 0 ; long multiplier = 1 ; while ( BToCompare > 0 ) { if ( AToCompare == 0 ) { solution += BToCompare % 2 * multiplier ; BToCompare /= 2 ; } else { if ( BToCompare % 2 != AToCompare % 2 ) { solution += multiplier ; } BToCompare /= 2 ; AToCompare /= 2 ; } multiplier *= 2 ; } System . out . println ( solution ) ; } else if ( ! AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff + 1 ) / 2 % 2 ; System . out . println ( LSB ) ; } else { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; System . out . println ( B + LSB ) ; } } }
| import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def f ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT if ( n // 2 ) % 2 == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT return 1 ^ n NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( ( n + 1 ) // 2 ) % 2 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT DEDENT def solve ( A : int , B : int ) : NEW_LINE INDENT print ( f ( B ) ^ f ( A - 1 ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE solve ( A , B ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T533 | import java . util . * ; public class Main { public static class MyPair implements Comparable < MyPair > { int cost ; int supply ; public MyPair ( int cost , int supply ) { this . cost = cost ; this . supply = supply ; } @ Override public int compareTo ( MyPair other ) { return ( this . cost - other . cost ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; boolean AOdd = A % 2 == 1 ; boolean BOdd = B % 2 == 1 ; if ( A == B ) { System . out . println ( A ) ; } else if ( AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; if ( LSB == 1 ) { System . out . println ( A - 1 ) ; } else { System . out . println ( A ) ; } } else if ( AOdd && ! BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; long BToCompare = B + LSB ; long AToCompare = A ; long solution = 0 ; long multiplier = 1 ; while ( BToCompare > 0 ) { if ( AToCompare == 0 ) { solution += BToCompare % 2 * multiplier ; BToCompare /= 2 ; } else { if ( BToCompare % 2 != AToCompare % 2 ) { solution += multiplier ; } BToCompare /= 2 ; AToCompare /= 2 ; } multiplier *= 2 ; } System . out . println ( solution ) ; } else if ( ! AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff + 1 ) / 2 % 2 ; System . out . println ( LSB ) ; } else { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; System . out . println ( B + LSB ) ; } } }
| import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = int ( 0 ) NEW_LINE if B == 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = math . floor ( math . log2 ( B ) + 1 ) NEW_LINE A_mod = A % 4 NEW_LINE B_mod = B % 4 NEW_LINE if A_mod < 2 : NEW_LINE INDENT if B_mod == 1 or B_mod == 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod == 3 or B_mod == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT A_mod = A % ( 2 ** i ) NEW_LINE B_mod = B % ( 2 ** i ) NEW_LINE if A_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT if B_mod >= 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( ( B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( A_mod % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( ( A_mod + B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE
|
T534 | import java . util . * ; public class Main { public static class MyPair implements Comparable < MyPair > { int cost ; int supply ; public MyPair ( int cost , int supply ) { this . cost = cost ; this . supply = supply ; } @ Override public int compareTo ( MyPair other ) { return ( this . cost - other . cost ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; boolean AOdd = A % 2 == 1 ; boolean BOdd = B % 2 == 1 ; if ( A == B ) { System . out . println ( A ) ; } else if ( AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; if ( LSB == 1 ) { System . out . println ( A - 1 ) ; } else { System . out . println ( A ) ; } } else if ( AOdd && ! BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; long BToCompare = B + LSB ; long AToCompare = A ; long solution = 0 ; long multiplier = 1 ; while ( BToCompare > 0 ) { if ( AToCompare == 0 ) { solution += BToCompare % 2 * multiplier ; BToCompare /= 2 ; } else { if ( BToCompare % 2 != AToCompare % 2 ) { solution += multiplier ; } BToCompare /= 2 ; AToCompare /= 2 ; } multiplier *= 2 ; } System . out . println ( solution ) ; } else if ( ! AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff + 1 ) / 2 % 2 ; System . out . println ( LSB ) ; } else { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; System . out . println ( B + LSB ) ; } } }
| def SI ( ) : return input ( ) NEW_LINE def II ( ) : return int ( SI ( ) ) NEW_LINE def STI ( ) : return SI ( ) . split ( ) NEW_LINE def ITI ( ) : return map ( int , STI ( ) ) NEW_LINE def SLI ( ) : return list ( SI ( ) ) NEW_LINE def ILI ( ) : return list ( ITI ( ) ) NEW_LINE A , B = ITI ( ) NEW_LINE def cum_xor ( n ) : NEW_LINE INDENT result = ( n + 1 ) // 2 % 2 NEW_LINE if ( n + 1 ) % 2 == 1 : result ^= n NEW_LINE return result NEW_LINE DEDENT print ( cum_xor ( A - 1 ) ^ cum_xor ( B ) ) NEW_LINE
|
T535 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; if ( h < 17 ) { if ( m == 0 ) { ans = ( 18 - h ) * 60 ; } else { ans = ( ( 17 - h ) * 60 ) + ( 60 - m ) ; } } else { ans = 60 - m ; } System . out . println ( ans ) ; } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE min = 60 * h + m NEW_LINE a = 18 * 60 NEW_LINE print ( a - min ) NEW_LINE
|
T536 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; if ( h < 17 ) { if ( m == 0 ) { ans = ( 18 - h ) * 60 ; } else { ans = ( ( 17 - h ) * 60 ) + ( 60 - m ) ; } } else { ans = 60 - m ; } System . out . println ( ans ) ; } }
| import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE h , m = map ( int , input ( ) . split ( ) ) NEW_LINE ams = 0 NEW_LINE if m == 0 : NEW_LINE INDENT ans = ( 18 - h ) * 60 NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( 18 - h - 1 ) * 60 + ( 60 - m ) NEW_LINE DEDENT print ( ans ) NEW_LINE
|
T537 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; if ( h < 17 ) { if ( m == 0 ) { ans = ( 18 - h ) * 60 ; } else { ans = ( ( 17 - h ) * 60 ) + ( 60 - m ) ; } } else { ans = 60 - m ; } System . out . println ( ans ) ; } }
| H , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( 18 - H ) * 60 - M ) NEW_LINE
|
T538 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; if ( h < 17 ) { if ( m == 0 ) { ans = ( 18 - h ) * 60 ; } else { ans = ( ( 17 - h ) * 60 ) + ( 60 - m ) ; } } else { ans = 60 - m ; } System . out . println ( ans ) ; } }
| def main ( ) : NEW_LINE INDENT h , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 18 * 60 - ( h * 60 + m ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T539 | import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; if ( h < 17 ) { if ( m == 0 ) { ans = ( 18 - h ) * 60 ; } else { ans = ( ( 17 - h ) * 60 ) + ( 60 - m ) ; } } else { ans = 60 - m ; } System . out . println ( ans ) ; } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE def get_minute ( in_h , in_m ) : NEW_LINE INDENT return in_h * 60 + in_m NEW_LINE DEDENT ans = get_minute ( 18 , 0 ) - get_minute ( h , m ) NEW_LINE print ( ans ) NEW_LINE
|
T540 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = 18 * 60 ; int H = sc . nextInt ( ) * 60 ; int M = sc . nextInt ( ) ; pl ( N - H - M ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE min = 60 * h + m NEW_LINE a = 18 * 60 NEW_LINE print ( a - min ) NEW_LINE
|
T541 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = 18 * 60 ; int H = sc . nextInt ( ) * 60 ; int M = sc . nextInt ( ) ; pl ( N - H - M ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }
| import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE h , m = map ( int , input ( ) . split ( ) ) NEW_LINE ams = 0 NEW_LINE if m == 0 : NEW_LINE INDENT ans = ( 18 - h ) * 60 NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( 18 - h - 1 ) * 60 + ( 60 - m ) NEW_LINE DEDENT print ( ans ) NEW_LINE
|
T542 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = 18 * 60 ; int H = sc . nextInt ( ) * 60 ; int M = sc . nextInt ( ) ; pl ( N - H - M ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }
| H , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( 18 - H ) * 60 - M ) NEW_LINE
|
T543 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = 18 * 60 ; int H = sc . nextInt ( ) * 60 ; int M = sc . nextInt ( ) ; pl ( N - H - M ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }
| def main ( ) : NEW_LINE INDENT h , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 18 * 60 - ( h * 60 + m ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T544 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = 18 * 60 ; int H = sc . nextInt ( ) * 60 ; int M = sc . nextInt ( ) ; pl ( N - H - M ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE def get_minute ( in_h , in_m ) : NEW_LINE INDENT return in_h * 60 + in_m NEW_LINE DEDENT ans = get_minute ( 18 , 0 ) - get_minute ( h , m ) NEW_LINE print ( ans ) NEW_LINE
|
T545 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( ( 18 - in . nextInt ( ) ) * 60 - in . nextInt ( ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE min = 60 * h + m NEW_LINE a = 18 * 60 NEW_LINE print ( a - min ) NEW_LINE
|
T546 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( ( 18 - in . nextInt ( ) ) * 60 - in . nextInt ( ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }
| import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE h , m = map ( int , input ( ) . split ( ) ) NEW_LINE ams = 0 NEW_LINE if m == 0 : NEW_LINE INDENT ans = ( 18 - h ) * 60 NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( 18 - h - 1 ) * 60 + ( 60 - m ) NEW_LINE DEDENT print ( ans ) NEW_LINE
|
T547 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( ( 18 - in . nextInt ( ) ) * 60 - in . nextInt ( ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }
| H , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( 18 - H ) * 60 - M ) NEW_LINE
|
T548 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( ( 18 - in . nextInt ( ) ) * 60 - in . nextInt ( ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }
| def main ( ) : NEW_LINE INDENT h , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 18 * 60 - ( h * 60 + m ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T549 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( ( 18 - in . nextInt ( ) ) * 60 - in . nextInt ( ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE def get_minute ( in_h , in_m ) : NEW_LINE INDENT return in_h * 60 + in_m NEW_LINE DEDENT ans = get_minute ( 18 , 0 ) - get_minute ( h , m ) NEW_LINE print ( ans ) NEW_LINE
|
T550 | import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int limit = 18 * 60 ; System . out . println ( limit - s . nextInt ( ) * 60 - s . nextInt ( ) ) ; } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE min = 60 * h + m NEW_LINE a = 18 * 60 NEW_LINE print ( a - min ) NEW_LINE
|
T551 | import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int limit = 18 * 60 ; System . out . println ( limit - s . nextInt ( ) * 60 - s . nextInt ( ) ) ; } }
| import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE h , m = map ( int , input ( ) . split ( ) ) NEW_LINE ams = 0 NEW_LINE if m == 0 : NEW_LINE INDENT ans = ( 18 - h ) * 60 NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( 18 - h - 1 ) * 60 + ( 60 - m ) NEW_LINE DEDENT print ( ans ) NEW_LINE
|
T552 | import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int limit = 18 * 60 ; System . out . println ( limit - s . nextInt ( ) * 60 - s . nextInt ( ) ) ; } }
| H , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( 18 - H ) * 60 - M ) NEW_LINE
|
T553 | import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int limit = 18 * 60 ; System . out . println ( limit - s . nextInt ( ) * 60 - s . nextInt ( ) ) ; } }
| def main ( ) : NEW_LINE INDENT h , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 18 * 60 - ( h * 60 + m ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T554 | import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int limit = 18 * 60 ; System . out . println ( limit - s . nextInt ( ) * 60 - s . nextInt ( ) ) ; } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE def get_minute ( in_h , in_m ) : NEW_LINE INDENT return in_h * 60 + in_m NEW_LINE DEDENT ans = get_minute ( 18 , 0 ) - get_minute ( h , m ) NEW_LINE print ( ans ) NEW_LINE
|
T555 | import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int h = sc . nextInt ( ) , m = sc . nextInt ( ) ; out . println ( 18 * 60 - 60 * h - m ) ; } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE min = 60 * h + m NEW_LINE a = 18 * 60 NEW_LINE print ( a - min ) NEW_LINE
|
T556 | import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int h = sc . nextInt ( ) , m = sc . nextInt ( ) ; out . println ( 18 * 60 - 60 * h - m ) ; } }
| import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE h , m = map ( int , input ( ) . split ( ) ) NEW_LINE ams = 0 NEW_LINE if m == 0 : NEW_LINE INDENT ans = ( 18 - h ) * 60 NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( 18 - h - 1 ) * 60 + ( 60 - m ) NEW_LINE DEDENT print ( ans ) NEW_LINE
|
T557 | import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int h = sc . nextInt ( ) , m = sc . nextInt ( ) ; out . println ( 18 * 60 - 60 * h - m ) ; } }
| H , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( 18 - H ) * 60 - M ) NEW_LINE
|
T558 | import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int h = sc . nextInt ( ) , m = sc . nextInt ( ) ; out . println ( 18 * 60 - 60 * h - m ) ; } }
| def main ( ) : NEW_LINE INDENT h , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 18 * 60 - ( h * 60 + m ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT
|
T559 | import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int h = sc . nextInt ( ) , m = sc . nextInt ( ) ; out . println ( 18 * 60 - 60 * h - m ) ; } }
| h , m = map ( int , input ( ) . split ( ) ) NEW_LINE def get_minute ( in_h , in_m ) : NEW_LINE INDENT return in_h * 60 + in_m NEW_LINE DEDENT ans = get_minute ( 18 , 0 ) - get_minute ( h , m ) NEW_LINE print ( ans ) NEW_LINE
|
T560 | import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { sb . append ( s . charAt ( i ) ) ; } System . out . println ( sb ) ; } }
| s = input ( ) NEW_LINE print ( s [ : : 2 ] ) NEW_LINE
|
T561 | import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { sb . append ( s . charAt ( i ) ) ; } System . out . println ( sb ) ; } }
| import sys 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 s = list ( ns ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , len ( s ) , 2 ) : NEW_LINE INDENT ans . append ( s [ i ] ) NEW_LINE DEDENT print ( ' ' . join ( ans ) ) NEW_LINE
|
T562 | import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { sb . append ( s . charAt ( i ) ) ; } System . out . println ( sb ) ; } }
| s = input ( ) NEW_LINE n = len ( s ) NEW_LINE a = " " NEW_LINE if n % 2 == 0 : NEW_LINE INDENT for i in range ( 0 , n , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 0 , n + 1 , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE
|
T563 | import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { sb . append ( s . charAt ( i ) ) ; } System . out . println ( sb ) ; } }
| A = input ( ) NEW_LINE B = [ ] NEW_LINE for i , v in enumerate ( A ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT B . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( " " . join ( B ) ) NEW_LINE
|
T564 | import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { sb . append ( s . charAt ( i ) ) ; } System . out . println ( sb ) ; } }
| s = list ( input ( ) ) NEW_LINE AnsList = s [ : : 2 ] NEW_LINE print ( ' ' . join ( AnsList ) ) NEW_LINE
|
T565 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { out . print ( s . charAt ( i ) ) ; } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }
| s = input ( ) NEW_LINE print ( s [ : : 2 ] ) NEW_LINE
|
T566 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { out . print ( s . charAt ( i ) ) ; } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }
| import sys 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 s = list ( ns ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , len ( s ) , 2 ) : NEW_LINE INDENT ans . append ( s [ i ] ) NEW_LINE DEDENT print ( ' ' . join ( ans ) ) NEW_LINE
|
T567 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { out . print ( s . charAt ( i ) ) ; } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }
| s = input ( ) NEW_LINE n = len ( s ) NEW_LINE a = " " NEW_LINE if n % 2 == 0 : NEW_LINE INDENT for i in range ( 0 , n , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 0 , n + 1 , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE
|
T568 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { out . print ( s . charAt ( i ) ) ; } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }
| A = input ( ) NEW_LINE B = [ ] NEW_LINE for i , v in enumerate ( A ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT B . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( " " . join ( B ) ) NEW_LINE
|
T569 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { out . print ( s . charAt ( i ) ) ; } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }
| s = list ( input ( ) ) NEW_LINE AnsList = s [ : : 2 ] NEW_LINE print ( ' ' . join ( AnsList ) ) NEW_LINE
|
T570 | import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int some = roundup ( s . length ( ) ) ; char [ ] ans = new char [ some ] ; for ( int i = 0 ; i < some ; i ++ ) { ans [ i ] = s . charAt ( i * 2 ) ; } System . out . print ( ans ) ; } public static int roundup ( int x ) { int ans = 0 ; if ( x % 2 == 0 ) { ans = x / 2 ; } else { ans = x / 2 + 1 ; } return ans ; } }
| s = input ( ) NEW_LINE print ( s [ : : 2 ] ) NEW_LINE
|
T571 | import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int some = roundup ( s . length ( ) ) ; char [ ] ans = new char [ some ] ; for ( int i = 0 ; i < some ; i ++ ) { ans [ i ] = s . charAt ( i * 2 ) ; } System . out . print ( ans ) ; } public static int roundup ( int x ) { int ans = 0 ; if ( x % 2 == 0 ) { ans = x / 2 ; } else { ans = x / 2 + 1 ; } return ans ; } }
| import sys 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 s = list ( ns ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , len ( s ) , 2 ) : NEW_LINE INDENT ans . append ( s [ i ] ) NEW_LINE DEDENT print ( ' ' . join ( ans ) ) NEW_LINE
|
T572 | import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int some = roundup ( s . length ( ) ) ; char [ ] ans = new char [ some ] ; for ( int i = 0 ; i < some ; i ++ ) { ans [ i ] = s . charAt ( i * 2 ) ; } System . out . print ( ans ) ; } public static int roundup ( int x ) { int ans = 0 ; if ( x % 2 == 0 ) { ans = x / 2 ; } else { ans = x / 2 + 1 ; } return ans ; } }
| s = input ( ) NEW_LINE n = len ( s ) NEW_LINE a = " " NEW_LINE if n % 2 == 0 : NEW_LINE INDENT for i in range ( 0 , n , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 0 , n + 1 , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE
|
T573 | import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int some = roundup ( s . length ( ) ) ; char [ ] ans = new char [ some ] ; for ( int i = 0 ; i < some ; i ++ ) { ans [ i ] = s . charAt ( i * 2 ) ; } System . out . print ( ans ) ; } public static int roundup ( int x ) { int ans = 0 ; if ( x % 2 == 0 ) { ans = x / 2 ; } else { ans = x / 2 + 1 ; } return ans ; } }
| A = input ( ) NEW_LINE B = [ ] NEW_LINE for i , v in enumerate ( A ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT B . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( " " . join ( B ) ) NEW_LINE
|
T574 | import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int some = roundup ( s . length ( ) ) ; char [ ] ans = new char [ some ] ; for ( int i = 0 ; i < some ; i ++ ) { ans [ i ] = s . charAt ( i * 2 ) ; } System . out . print ( ans ) ; } public static int roundup ( int x ) { int ans = 0 ; if ( x % 2 == 0 ) { ans = x / 2 ; } else { ans = x / 2 + 1 ; } return ans ; } }
| s = list ( input ( ) ) NEW_LINE AnsList = s [ : : 2 ] NEW_LINE print ( ' ' . join ( AnsList ) ) NEW_LINE
|
T575 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < word . length ( ) ; i += 2 ) { builder . append ( word . charAt ( i ) ) ; } System . out . println ( builder ) ; } }
| s = input ( ) NEW_LINE print ( s [ : : 2 ] ) NEW_LINE
|
T576 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < word . length ( ) ; i += 2 ) { builder . append ( word . charAt ( i ) ) ; } System . out . println ( builder ) ; } }
| import sys 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 s = list ( ns ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , len ( s ) , 2 ) : NEW_LINE INDENT ans . append ( s [ i ] ) NEW_LINE DEDENT print ( ' ' . join ( ans ) ) NEW_LINE
|
T577 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < word . length ( ) ; i += 2 ) { builder . append ( word . charAt ( i ) ) ; } System . out . println ( builder ) ; } }
| s = input ( ) NEW_LINE n = len ( s ) NEW_LINE a = " " NEW_LINE if n % 2 == 0 : NEW_LINE INDENT for i in range ( 0 , n , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 0 , n + 1 , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE
|
T578 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < word . length ( ) ; i += 2 ) { builder . append ( word . charAt ( i ) ) ; } System . out . println ( builder ) ; } }
| A = input ( ) NEW_LINE B = [ ] NEW_LINE for i , v in enumerate ( A ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT B . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( " " . join ( B ) ) NEW_LINE
|
T579 | import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < word . length ( ) ; i += 2 ) { builder . append ( word . charAt ( i ) ) ; } System . out . println ( builder ) ; } }
| s = list ( input ( ) ) NEW_LINE AnsList = s [ : : 2 ] NEW_LINE print ( ' ' . join ( AnsList ) ) NEW_LINE
|
T580 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BOddString solver = new BOddString ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BOddString { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; String concate = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) out . print ( s . charAt ( i ) ) ; } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }
| s = input ( ) NEW_LINE print ( s [ : : 2 ] ) NEW_LINE
|
T581 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BOddString solver = new BOddString ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BOddString { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; String concate = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) out . print ( s . charAt ( i ) ) ; } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }
| import sys 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 s = list ( ns ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , len ( s ) , 2 ) : NEW_LINE INDENT ans . append ( s [ i ] ) NEW_LINE DEDENT print ( ' ' . join ( ans ) ) NEW_LINE
|
T582 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BOddString solver = new BOddString ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BOddString { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; String concate = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) out . print ( s . charAt ( i ) ) ; } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }
| s = input ( ) NEW_LINE n = len ( s ) NEW_LINE a = " " NEW_LINE if n % 2 == 0 : NEW_LINE INDENT for i in range ( 0 , n , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 0 , n + 1 , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE
|
T583 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BOddString solver = new BOddString ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BOddString { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; String concate = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) out . print ( s . charAt ( i ) ) ; } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }
| A = input ( ) NEW_LINE B = [ ] NEW_LINE for i , v in enumerate ( A ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT B . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( " " . join ( B ) ) NEW_LINE
|
T584 | import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BOddString solver = new BOddString ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BOddString { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; String concate = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) out . print ( s . charAt ( i ) ) ; } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }
| s = list ( input ( ) ) NEW_LINE AnsList = s [ : : 2 ] NEW_LINE print ( ' ' . join ( AnsList ) ) NEW_LINE
|
T585 | import java . util . * ; public class Main { static class TriTree { Node root = new Node ( ) ; class Node { ArrayList < Node > child = new ArrayList < > ( ) ; char c ; long depth ; public void add ( Node node ) { child . add ( node ) ; } public Node ( ) { } public Node ( char c , long depth ) { this . c = c ; this . depth = depth ; } public long xorGrundy ( ) { long xor = 0 ; for ( Node node : child ) xor ^= node . xorGrundy ( ) ; if ( child . size ( ) == 1 ) xor ^= grundy ( L - depth ) ; return xor ; } } public void addLeaf ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { boolean found = false ; for ( Node child : cur . child ) { if ( child . c == s . charAt ( i ) ) { cur = child ; found = true ; break ; } } if ( ! found ) { Node next = new Node ( s . charAt ( i ) , i + 1 ) ; cur . add ( next ) ; cur = next ; } } } public long xorGrundy ( ) { return root . xorGrundy ( ) ; } } static long L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; L = sc . nextLong ( ) ; TriTree tree = new TriTree ( ) ; for ( int i = 0 ; i < N ; i ++ ) tree . addLeaf ( sc . next ( ) ) ; System . out . println ( tree . xorGrundy ( ) == 0 ? " Bob " : " Alice " ) ; sc . close ( ) ; } static long grundy ( long n ) { long ans = 1 ; while ( n % ans == 0 ) ans <<= 1 ; return ans ; } }
| def getGrundyNumber ( x ) : NEW_LINE INDENT ans = 1 NEW_LINE while x % ( ans * 2 ) == 0 : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT return ans NEW_LINE DEDENT N , L = map ( int , input ( ) . split ( ) ) NEW_LINE Ss = [ input ( ) for i in range ( N ) ] NEW_LINE Ss . sort ( ) NEW_LINE Hgts = { L : 2 } NEW_LINE prev = ' _ ' NEW_LINE for S in Ss : NEW_LINE INDENT for iS , ( a , b ) in enumerate ( zip ( prev , S ) ) : NEW_LINE INDENT if a != b : NEW_LINE INDENT Hgts [ L - iS ] -= 1 NEW_LINE for h in range ( L - len ( S ) + 1 , L - iS ) : NEW_LINE INDENT Hgts [ h ] = Hgts . get ( h , 0 ) + 1 NEW_LINE DEDENT break NEW_LINE DEDENT DEDENT prev = S NEW_LINE DEDENT ans = 0 NEW_LINE for Hgt , num in Hgts . items ( ) : NEW_LINE INDENT if num % 2 : NEW_LINE INDENT ans ^= getGrundyNumber ( Hgt ) NEW_LINE DEDENT DEDENT if ans : NEW_LINE INDENT print ( ' Alice ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Bob ' ) NEW_LINE DEDENT
|
T586 | import java . util . * ; public class Main { static class TriTree { Node root = new Node ( ) ; class Node { ArrayList < Node > child = new ArrayList < > ( ) ; char c ; long depth ; public void add ( Node node ) { child . add ( node ) ; } public Node ( ) { } public Node ( char c , long depth ) { this . c = c ; this . depth = depth ; } public long xorGrundy ( ) { long xor = 0 ; for ( Node node : child ) xor ^= node . xorGrundy ( ) ; if ( child . size ( ) == 1 ) xor ^= grundy ( L - depth ) ; return xor ; } } public void addLeaf ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { boolean found = false ; for ( Node child : cur . child ) { if ( child . c == s . charAt ( i ) ) { cur = child ; found = true ; break ; } } if ( ! found ) { Node next = new Node ( s . charAt ( i ) , i + 1 ) ; cur . add ( next ) ; cur = next ; } } } public long xorGrundy ( ) { return root . xorGrundy ( ) ; } } static long L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; L = sc . nextLong ( ) ; TriTree tree = new TriTree ( ) ; for ( int i = 0 ; i < N ; i ++ ) tree . addLeaf ( sc . next ( ) ) ; System . out . println ( tree . xorGrundy ( ) == 0 ? " Bob " : " Alice " ) ; sc . close ( ) ; } static long grundy ( long n ) { long ans = 1 ; while ( n % ans == 0 ) ans <<= 1 ; return ans ; } }
| import sys NEW_LINE sys . setrecursionlimit ( 2 * 10 ** 5 ) NEW_LINE class TrieNode : NEW_LINE INDENT def __init__ ( self , char ) : NEW_LINE INDENT self . char = char NEW_LINE self . nextnode = dict ( ) NEW_LINE self . is_indict = False NEW_LINE DEDENT DEDENT class Trie : NEW_LINE INDENT def __init__ ( self , charset ) : NEW_LINE INDENT self . charset = charset NEW_LINE self . root = TrieNode ( ' ' ) NEW_LINE DEDENT def add ( self , a_str ) : NEW_LINE INDENT node = self . root NEW_LINE for i , char in enumerate ( a_str ) : NEW_LINE INDENT if char not in node . nextnode : NEW_LINE INDENT node . nextnode [ char ] = TrieNode ( char ) NEW_LINE DEDENT node = node . nextnode [ char ] NEW_LINE if i == len ( a_str ) - 1 : NEW_LINE INDENT node . is_indict = True NEW_LINE DEDENT DEDENT DEDENT def dfs ( self , node , dep ) : NEW_LINE INDENT ret , cnt = 0 , 0 NEW_LINE if node . is_indict : NEW_LINE INDENT return 0 NEW_LINE DEDENT for s in '01' : NEW_LINE INDENT if s not in node . nextnode : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ret ^= self . dfs ( node . nextnode [ s ] , dep + 1 ) NEW_LINE DEDENT DEDENT height = L - dep NEW_LINE if cnt % 2 : NEW_LINE INDENT power2 = 0 NEW_LINE while height > 0 and height % 2 == 0 : NEW_LINE INDENT power2 += 1 NEW_LINE height //= 2 NEW_LINE DEDENT ret ^= 2 ** power2 NEW_LINE DEDENT return ret NEW_LINE DEDENT def debug_output ( self , node , now ) : NEW_LINE INDENT print ( node . char , list ( node . nextnode . items ( ) ) , node . is_indict , now ) NEW_LINE if node . is_indict : NEW_LINE INDENT print ( now ) NEW_LINE DEDENT for n in node . nextnode . values ( ) : NEW_LINE INDENT self . debug_output ( n , now + n . char ) NEW_LINE DEDENT DEDENT DEDENT N , L = map ( int , input ( ) . split ( ) ) NEW_LINE T = Trie ( '01' ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT T . add ( input ( ) ) NEW_LINE DEDENT print ( " Alice " if T . dfs ( T . root , 0 ) else " Bob " ) NEW_LINE
|
T587 | import java . util . * ; public class Main { static class TriTree { Node root = new Node ( ) ; class Node { ArrayList < Node > child = new ArrayList < > ( ) ; char c ; long depth ; public void add ( Node node ) { child . add ( node ) ; } public Node ( ) { } public Node ( char c , long depth ) { this . c = c ; this . depth = depth ; } public long xorGrundy ( ) { long xor = 0 ; for ( Node node : child ) xor ^= node . xorGrundy ( ) ; if ( child . size ( ) == 1 ) xor ^= grundy ( L - depth ) ; return xor ; } } public void addLeaf ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { boolean found = false ; for ( Node child : cur . child ) { if ( child . c == s . charAt ( i ) ) { cur = child ; found = true ; break ; } } if ( ! found ) { Node next = new Node ( s . charAt ( i ) , i + 1 ) ; cur . add ( next ) ; cur = next ; } } } public long xorGrundy ( ) { return root . xorGrundy ( ) ; } } static long L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; L = sc . nextLong ( ) ; TriTree tree = new TriTree ( ) ; for ( int i = 0 ; i < N ; i ++ ) tree . addLeaf ( sc . next ( ) ) ; System . out . println ( tree . xorGrundy ( ) == 0 ? " Bob " : " Alice " ) ; sc . close ( ) ; } static long grundy ( long n ) { long ans = 1 ; while ( n % ans == 0 ) ans <<= 1 ; return ans ; } }
| N , L = map ( int , input ( ) . split ( ) ) NEW_LINE make = lambda : [ None , None , 0 ] NEW_LINE root = make ( ) NEW_LINE def construct ( s ) : NEW_LINE INDENT n = root NEW_LINE for i in s : NEW_LINE INDENT if n [ i ] is None : NEW_LINE INDENT n [ i ] = n = make ( ) NEW_LINE DEDENT else : NEW_LINE INDENT n = n [ i ] NEW_LINE DEDENT DEDENT n [ 2 ] = 1 NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT s = map ( int , input ( ) ) NEW_LINE construct ( s ) NEW_LINE DEDENT caps = { } NEW_LINE st = [ ( root , 0 , 0 ) ] NEW_LINE while st : NEW_LINE INDENT n , i , l = st . pop ( ) NEW_LINE if i : NEW_LINE INDENT if n [ 1 ] is None : NEW_LINE INDENT caps [ L - l ] = caps . get ( L - l , 0 ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT if not n [ 1 ] [ 2 ] : NEW_LINE INDENT st . append ( ( n [ 1 ] , 0 , l + 1 ) ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT st . append ( ( n , 1 , l ) ) NEW_LINE if n [ 0 ] is None : NEW_LINE INDENT caps [ L - l ] = caps . get ( L - l , 0 ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT if not n [ 0 ] [ 2 ] : NEW_LINE INDENT st . append ( ( n [ 0 ] , 0 , l + 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for v in caps : NEW_LINE INDENT k = caps [ v ] NEW_LINE if k % 2 == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT v -= 1 NEW_LINE r = 1 NEW_LINE while v % 4 == 3 : NEW_LINE INDENT v //= 4 NEW_LINE r *= 4 NEW_LINE DEDENT if v % 4 == 1 : NEW_LINE INDENT ans ^= r * 2 NEW_LINE DEDENT else : NEW_LINE INDENT ans ^= r NEW_LINE DEDENT DEDENT print ( ' Alice ' if ans else ' Bob ' ) NEW_LINE
|
T588 | import java . util . * ; public class Main { static class TriTree { Node root = new Node ( ) ; class Node { ArrayList < Node > child = new ArrayList < > ( ) ; char c ; long depth ; public void add ( Node node ) { child . add ( node ) ; } public Node ( ) { } public Node ( char c , long depth ) { this . c = c ; this . depth = depth ; } public long xorGrundy ( ) { long xor = 0 ; for ( Node node : child ) xor ^= node . xorGrundy ( ) ; if ( child . size ( ) == 1 ) xor ^= grundy ( L - depth ) ; return xor ; } } public void addLeaf ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { boolean found = false ; for ( Node child : cur . child ) { if ( child . c == s . charAt ( i ) ) { cur = child ; found = true ; break ; } } if ( ! found ) { Node next = new Node ( s . charAt ( i ) , i + 1 ) ; cur . add ( next ) ; cur = next ; } } } public long xorGrundy ( ) { return root . xorGrundy ( ) ; } } static long L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; L = sc . nextLong ( ) ; TriTree tree = new TriTree ( ) ; for ( int i = 0 ; i < N ; i ++ ) tree . addLeaf ( sc . next ( ) ) ; System . out . println ( tree . xorGrundy ( ) == 0 ? " Bob " : " Alice " ) ; sc . close ( ) ; } static long grundy ( long n ) { long ans = 1 ; while ( n % ans == 0 ) ans <<= 1 ; return ans ; } }
| import sys NEW_LINE input = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE from collections import deque NEW_LINE class Node : NEW_LINE INDENT def __init__ ( self , depth ) : NEW_LINE INDENT self . depth = depth NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def insert ( node , s ) : NEW_LINE INDENT n = node NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT t = s [ i ] NEW_LINE if t == '0' : NEW_LINE INDENT if n . left is None : NEW_LINE INDENT n . left = Node ( i + 1 ) NEW_LINE DEDENT n = n . left NEW_LINE DEDENT else : NEW_LINE INDENT if n . right is None : NEW_LINE INDENT n . right = Node ( i + 1 ) NEW_LINE DEDENT n = n . right NEW_LINE DEDENT DEDENT DEDENT class Trie : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . root = Node ( 0 ) NEW_LINE DEDENT def insert ( self , s : str ) : NEW_LINE INDENT insert ( self . root , s ) NEW_LINE DEDENT DEDENT n , l = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ input ( ) . strip ( ) for _ in range ( n ) ] NEW_LINE trie = Trie ( ) NEW_LINE for s in S : NEW_LINE INDENT trie . insert ( s ) NEW_LINE DEDENT Data = [ ] NEW_LINE q = deque ( [ trie . root ] ) NEW_LINE def dfs ( node ) : NEW_LINE INDENT if node . right is None and node . left is None : NEW_LINE INDENT return NEW_LINE DEDENT if node . right is None or node . left is None : NEW_LINE INDENT Data . append ( l - node . depth ) NEW_LINE DEDENT if node . right : NEW_LINE INDENT q . append ( node . right ) NEW_LINE DEDENT if node . left : NEW_LINE INDENT q . append ( node . left ) NEW_LINE DEDENT DEDENT while q : NEW_LINE INDENT dfs ( q . popleft ( ) ) NEW_LINE DEDENT xor = 0 NEW_LINE def Grundy ( n ) : NEW_LINE INDENT ret = 1 NEW_LINE while n % 2 == 0 : NEW_LINE INDENT n //= 2 NEW_LINE ret *= 2 NEW_LINE DEDENT return ret NEW_LINE DEDENT for i in Data : NEW_LINE INDENT xor ^= Grundy ( i ) NEW_LINE DEDENT print ( ' Alice ' if xor else ' Bob ' ) NEW_LINE
|
T589 | import java . util . * ; public class Main { static class TriTree { Node root = new Node ( ) ; class Node { ArrayList < Node > child = new ArrayList < > ( ) ; char c ; long depth ; public void add ( Node node ) { child . add ( node ) ; } public Node ( ) { } public Node ( char c , long depth ) { this . c = c ; this . depth = depth ; } public long xorGrundy ( ) { long xor = 0 ; for ( Node node : child ) xor ^= node . xorGrundy ( ) ; if ( child . size ( ) == 1 ) xor ^= grundy ( L - depth ) ; return xor ; } } public void addLeaf ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { boolean found = false ; for ( Node child : cur . child ) { if ( child . c == s . charAt ( i ) ) { cur = child ; found = true ; break ; } } if ( ! found ) { Node next = new Node ( s . charAt ( i ) , i + 1 ) ; cur . add ( next ) ; cur = next ; } } } public long xorGrundy ( ) { return root . xorGrundy ( ) ; } } static long L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; L = sc . nextLong ( ) ; TriTree tree = new TriTree ( ) ; for ( int i = 0 ; i < N ; i ++ ) tree . addLeaf ( sc . next ( ) ) ; System . out . println ( tree . xorGrundy ( ) == 0 ? " Bob " : " Alice " ) ; sc . close ( ) ; } static long grundy ( long n ) { long ans = 1 ; while ( n % ans == 0 ) ans <<= 1 ; return ans ; } }
| from collections import defaultdict NEW_LINE def solve ( n , l , nums ) : NEW_LINE INDENT xor = 0 NEW_LINE if n == 1 : NEW_LINE INDENT for i in range ( min ( nums ) , l + 1 ) : NEW_LINE INDENT xor ^= i & - i NEW_LINE DEDENT return xor NEW_LINE DEDENT for i in range ( min ( nums ) , l + 1 ) : NEW_LINE INDENT ni = nums [ i ] NEW_LINE for k in ni : NEW_LINE INDENT if k ^ 1 not in ni : NEW_LINE INDENT xor ^= i & - i NEW_LINE DEDENT nums [ i + 1 ] . add ( k // 2 ) NEW_LINE DEDENT del nums [ i ] NEW_LINE DEDENT return xor NEW_LINE DEDENT n , l = map ( int , input ( ) . split ( ) ) NEW_LINE nums = defaultdict ( set ) NEW_LINE for s in ( input ( ) for _ in range ( n ) ) : NEW_LINE INDENT nums [ l - len ( s ) + 1 ] . add ( int ( s , 2 ) + ( 1 << len ( s ) ) ) NEW_LINE DEDENT print ( ' Alice ' if solve ( n , l , nums ) else ' Bob ' ) NEW_LINE
|
T590 | import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] rate = new int [ ] { 400 , 800 , 1200 , 1600 , 2000 , 2400 , 2800 , 3200 } ; boolean [ ] exist = new boolean [ 8 ] ; int master = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= 3200 ) { master ++ ; continue ; } for ( int j = 0 ; j < rate . length ; j ++ ) { if ( a [ i ] < rate [ j ] ) { exist [ j ] = true ; break ; } } } int min = 0 ; for ( int i = 0 ; i < exist . length ; i ++ ) { if ( exist [ i ] ) { min ++ ; } } int max = min + master ; if ( min == 0 ) { min = 1 ; } 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
|
T591 | import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] rate = new int [ ] { 400 , 800 , 1200 , 1600 , 2000 , 2400 , 2800 , 3200 } ; boolean [ ] exist = new boolean [ 8 ] ; int master = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= 3200 ) { master ++ ; continue ; } for ( int j = 0 ; j < rate . length ; j ++ ) { if ( a [ i ] < rate [ j ] ) { exist [ j ] = true ; break ; } } } int min = 0 ; for ( int i = 0 ; i < exist . length ; i ++ ) { if ( exist [ i ] ) { min ++ ; } } int max = min + master ; if ( min == 0 ) { min = 1 ; } 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
|
T592 | import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] rate = new int [ ] { 400 , 800 , 1200 , 1600 , 2000 , 2400 , 2800 , 3200 } ; boolean [ ] exist = new boolean [ 8 ] ; int master = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= 3200 ) { master ++ ; continue ; } for ( int j = 0 ; j < rate . length ; j ++ ) { if ( a [ i ] < rate [ j ] ) { exist [ j ] = true ; break ; } } } int min = 0 ; for ( int i = 0 ; i < exist . length ; i ++ ) { if ( exist [ i ] ) { min ++ ; } } int max = min + master ; if ( min == 0 ) { min = 1 ; } 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
|
T593 | import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] rate = new int [ ] { 400 , 800 , 1200 , 1600 , 2000 , 2400 , 2800 , 3200 } ; boolean [ ] exist = new boolean [ 8 ] ; int master = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= 3200 ) { master ++ ; continue ; } for ( int j = 0 ; j < rate . length ; j ++ ) { if ( a [ i ] < rate [ j ] ) { exist [ j ] = true ; break ; } } } int min = 0 ; for ( int i = 0 ; i < exist . length ; i ++ ) { if ( exist [ i ] ) { min ++ ; } } int max = min + master ; if ( min == 0 ) { min = 1 ; } 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
|
T594 | import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] rate = new int [ ] { 400 , 800 , 1200 , 1600 , 2000 , 2400 , 2800 , 3200 } ; boolean [ ] exist = new boolean [ 8 ] ; int master = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= 3200 ) { master ++ ; continue ; } for ( int j = 0 ; j < rate . length ; j ++ ) { if ( a [ i ] < rate [ j ] ) { exist [ j ] = true ; break ; } } } int min = 0 ; for ( int i = 0 ; i < exist . length ; i ++ ) { if ( exist [ i ] ) { min ++ ; } } int max = min + master ; if ( min == 0 ) { min = 1 ; } 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
|
T595 | import java . util . * ; import java . lang . * ; import java . math . * ; class Main { static int n ; static int m ; static int ans ; static int [ ] rate ; static int var ; static int ansmin ; static int ansmax ; static int [ ] w ; static int [ ] ww ; static boolean [ ] visit ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; ansmin = 0 ; ansmax = 0 ; rate = new int [ 9 ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp >= 3200 ) { tmp = 3200 ; } rate [ tmp / 400 ] ++ ; } for ( int i = 0 ; i < 7 ; i ++ ) { if ( rate [ i ] != 0 ) { ansmin ++ ; ansmax ++ ; } } if ( rate [ 7 ] == 0 ) { if ( rate [ 8 ] != 0 ) { ansmin ++ ; ansmax += rate [ 8 ] ; } } else { ansmin ++ ; ansmax ++ ; if ( rate [ 8 ] != 0 ) { ansmax += ( rate [ 8 ] ) ; } } System . out . println ( ansmin + " β " + ansmax ) ; sc . close ( ) ; } public static void dfs ( int placenow ) { visit [ placenow ] = true ; boolean success = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( visit [ i ] == false ) { success = false ; break ; } } if ( success ) { ans ++ ; visit [ placenow ] = false ; return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( w [ i ] == placenow && visit [ ww [ i ] ] == false ) { dfs ( ww [ i ] ) ; } else if ( ww [ i ] == placenow && visit [ w [ i ] ] == false ) { dfs ( w [ i ] ) ; } else { continue ; } } visit [ placenow ] = false ; return ; } }
| 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
|
T596 | import java . util . * ; import java . lang . * ; import java . math . * ; class Main { static int n ; static int m ; static int ans ; static int [ ] rate ; static int var ; static int ansmin ; static int ansmax ; static int [ ] w ; static int [ ] ww ; static boolean [ ] visit ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; ansmin = 0 ; ansmax = 0 ; rate = new int [ 9 ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp >= 3200 ) { tmp = 3200 ; } rate [ tmp / 400 ] ++ ; } for ( int i = 0 ; i < 7 ; i ++ ) { if ( rate [ i ] != 0 ) { ansmin ++ ; ansmax ++ ; } } if ( rate [ 7 ] == 0 ) { if ( rate [ 8 ] != 0 ) { ansmin ++ ; ansmax += rate [ 8 ] ; } } else { ansmin ++ ; ansmax ++ ; if ( rate [ 8 ] != 0 ) { ansmax += ( rate [ 8 ] ) ; } } System . out . println ( ansmin + " β " + ansmax ) ; sc . close ( ) ; } public static void dfs ( int placenow ) { visit [ placenow ] = true ; boolean success = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( visit [ i ] == false ) { success = false ; break ; } } if ( success ) { ans ++ ; visit [ placenow ] = false ; return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( w [ i ] == placenow && visit [ ww [ i ] ] == false ) { dfs ( ww [ i ] ) ; } else if ( ww [ i ] == placenow && visit [ w [ i ] ] == false ) { dfs ( w [ i ] ) ; } else { continue ; } } visit [ placenow ] = false ; return ; } }
| 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
|
T597 | import java . util . * ; import java . lang . * ; import java . math . * ; class Main { static int n ; static int m ; static int ans ; static int [ ] rate ; static int var ; static int ansmin ; static int ansmax ; static int [ ] w ; static int [ ] ww ; static boolean [ ] visit ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; ansmin = 0 ; ansmax = 0 ; rate = new int [ 9 ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp >= 3200 ) { tmp = 3200 ; } rate [ tmp / 400 ] ++ ; } for ( int i = 0 ; i < 7 ; i ++ ) { if ( rate [ i ] != 0 ) { ansmin ++ ; ansmax ++ ; } } if ( rate [ 7 ] == 0 ) { if ( rate [ 8 ] != 0 ) { ansmin ++ ; ansmax += rate [ 8 ] ; } } else { ansmin ++ ; ansmax ++ ; if ( rate [ 8 ] != 0 ) { ansmax += ( rate [ 8 ] ) ; } } System . out . println ( ansmin + " β " + ansmax ) ; sc . close ( ) ; } public static void dfs ( int placenow ) { visit [ placenow ] = true ; boolean success = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( visit [ i ] == false ) { success = false ; break ; } } if ( success ) { ans ++ ; visit [ placenow ] = false ; return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( w [ i ] == placenow && visit [ ww [ i ] ] == false ) { dfs ( ww [ i ] ) ; } else if ( ww [ i ] == placenow && visit [ w [ i ] ] == false ) { dfs ( w [ i ] ) ; } else { continue ; } } visit [ placenow ] = false ; return ; } }
| 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
|
T598 | import java . util . * ; import java . lang . * ; import java . math . * ; class Main { static int n ; static int m ; static int ans ; static int [ ] rate ; static int var ; static int ansmin ; static int ansmax ; static int [ ] w ; static int [ ] ww ; static boolean [ ] visit ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; ansmin = 0 ; ansmax = 0 ; rate = new int [ 9 ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp >= 3200 ) { tmp = 3200 ; } rate [ tmp / 400 ] ++ ; } for ( int i = 0 ; i < 7 ; i ++ ) { if ( rate [ i ] != 0 ) { ansmin ++ ; ansmax ++ ; } } if ( rate [ 7 ] == 0 ) { if ( rate [ 8 ] != 0 ) { ansmin ++ ; ansmax += rate [ 8 ] ; } } else { ansmin ++ ; ansmax ++ ; if ( rate [ 8 ] != 0 ) { ansmax += ( rate [ 8 ] ) ; } } System . out . println ( ansmin + " β " + ansmax ) ; sc . close ( ) ; } public static void dfs ( int placenow ) { visit [ placenow ] = true ; boolean success = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( visit [ i ] == false ) { success = false ; break ; } } if ( success ) { ans ++ ; visit [ placenow ] = false ; return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( w [ i ] == placenow && visit [ ww [ i ] ] == false ) { dfs ( ww [ i ] ) ; } else if ( ww [ i ] == placenow && visit [ w [ i ] ] == false ) { dfs ( w [ i ] ) ; } else { continue ; } } visit [ placenow ] = false ; return ; } }
| 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
|
T599 | import java . util . * ; import java . lang . * ; import java . math . * ; class Main { static int n ; static int m ; static int ans ; static int [ ] rate ; static int var ; static int ansmin ; static int ansmax ; static int [ ] w ; static int [ ] ww ; static boolean [ ] visit ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; ansmin = 0 ; ansmax = 0 ; rate = new int [ 9 ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp >= 3200 ) { tmp = 3200 ; } rate [ tmp / 400 ] ++ ; } for ( int i = 0 ; i < 7 ; i ++ ) { if ( rate [ i ] != 0 ) { ansmin ++ ; ansmax ++ ; } } if ( rate [ 7 ] == 0 ) { if ( rate [ 8 ] != 0 ) { ansmin ++ ; ansmax += rate [ 8 ] ; } } else { ansmin ++ ; ansmax ++ ; if ( rate [ 8 ] != 0 ) { ansmax += ( rate [ 8 ] ) ; } } System . out . println ( ansmin + " β " + ansmax ) ; sc . close ( ) ; } public static void dfs ( int placenow ) { visit [ placenow ] = true ; boolean success = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( visit [ i ] == false ) { success = false ; break ; } } if ( success ) { ans ++ ; visit [ placenow ] = false ; return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( w [ i ] == placenow && visit [ ww [ i ] ] == false ) { dfs ( ww [ i ] ) ; } else if ( ww [ i ] == placenow && visit [ w [ i ] ] == false ) { dfs ( w [ i ] ) ; } else { continue ; } } visit [ placenow ] = false ; return ; } }
| 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
|