id
stringlengths 13
20
| java
sequence | python
sequence |
---|---|---|
codeforces_149_A | [
"import java . util . * ; public class dummycodes { public static int solve ( int arr [ ] , int k ) { Arrays . parallelSort ( arr ) ; int sum = 0 ; int cnt = 0 ; int i = 11 ; while ( sum < k && i >= 0 ) { sum += arr [ i ] ; cnt ++ ; i -- ; } return sum < k ? - 1 : cnt ; } public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int arr [ ] = new int [ 12 ] ; for ( int i = 0 ; i < 12 ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } System . out . println ( solve ( arr , k ) ) ; } } ",
"import java . util . * ; public class Starting { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ 12 ] ; for ( int i = 0 ; i < 12 ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . sort ( arr ) ; int sum = 0 , ans = 0 ; for ( int i = 11 ; i >= 0 ; i -- ) { sum += arr [ i ] ; ++ ans ; if ( sum >= k ) break ; } if ( k == 0 ) System . out . println ( \"0\" ) ; else if ( sum < k ) System . out . println ( \" - 1\" ) ; else System . out . println ( ans ) ; sc . close ( ) ; } }",
"import java . io . IOException ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int k = in . nextInt ( ) ; if ( k == 0 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } int [ ] inputs = new int [ 12 ] ; int i , sum = 0 , cnt = 0 ; for ( i = 0 ; i < 12 ; i ++ ) { inputs [ i ] = in . nextInt ( ) ; } Arrays . sort ( inputs ) ; int flag = 0 ; for ( i = inputs . length - 1 ; i >= 0 ; i -- ) { sum += inputs [ i ] ; cnt ++ ; if ( sum >= k ) { flag = 1 ; break ; } } if ( flag == 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( cnt ) ; } } }",
"import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Bai7 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; Integer month [ ] = new Integer [ 12 ] ; for ( int i = 0 ; i < 12 ; i ++ ) { month [ i ] = sc . nextInt ( ) ; } Arrays . sort ( month , Collections . reverseOrder ( ) ) ; int current_grow = 0 ; int count = 0 ; for ( int i = 0 ; i < 12 ; i ++ ) { if ( current_grow >= k ) { break ; } else if ( i == 11 && ( current_grow += month [ i ] ) < k ) { count = - 1 ; break ; } current_grow += month [ i ] ; count ++ ; } System . out . println ( count ) ; } }",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; public class CodeForces { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; int [ ] arr = new int [ 12 ] ; for ( int i = 0 ; i < 12 ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int count = 1 ; if ( t != 0 ) { int sum = arr [ 11 ] ; for ( int i = 10 ; i >= 0 ; i -- ) { if ( sum < t ) { count ++ ; sum += arr [ i ] ; } else { break ; } } System . out . println ( sum >= t ? count : - 1 ) ; } else { System . out . println ( 0 ) ; } } }"
] | [
"k = int ( input ( ) ) lst = list ( map ( int , input ( ) . split ( ) ) ) if k <= 0 : print ( 0 ) else : lst . sort ( reverse = True ) for idx , growth in enumerate ( lst ) : k -= growth if k <= 0 : print ( idx + 1 ) break else : print ( - 1 ) NEW_LINE",
"k = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) l . reverse ( ) s = 0 if k == 0 : print ( 0 ) else : for i in range ( 12 ) : s += l [ i ] if ( s >= k ) : print ( i + 1 ) break else : print ( - 1 ) NEW_LINE",
"k = int ( input ( ) ) list = ( input ( ) . split ( ' ▁ ' ) ) for i in range ( 12 ) : list [ i ] = int ( list [ i ] ) c = 0 g = 0 max = 0 while True : if len ( list ) == 0 or g >= k or all ( i < 1 for i in list ) : break i = ( 0 , 0 ) for i in enumerate ( list ) : if i [ 1 ] > max : max = i [ 1 ] list . remove ( max ) NEW_LINE",
"k = int ( input ( ) ) length = [ int ( i ) for i in input ( ) . split ( ) ] length . sort ( reverse = True ) tot = 0 count = 0 if sum ( length ) < k : print ( - 1 ) else : for i in length : if tot < k : tot = i + tot count = count + 1 NEW_LINE"
] |
codeforces_1013_A | [
"import java . util . * ; public class cf183 { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ar [ ] = new int [ n ] ; int br [ ] = new int [ n ] ; int i = 0 ; long s1 = 0 ; long s2 = 0 ; for ( i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } for ( i = 0 ; i < n ; i ++ ) { br [ i ] = sc . nextInt ( ) ; } for ( i = 0 ; i < n ; i ++ ) { s1 += ar [ i ] ; s2 += br [ i ] ; } if ( s1 >= s2 ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }",
"import java . util . * ; public class CodeForces1013A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = input . nextInt ( ) ; sum += x ; } for ( int i = 0 ; i < n ; i ++ ) { sum -= input . nextInt ( ) ; } if ( sum < 0 ) { System . out . println ( \" No \" ) ; } else { System . out . println ( \" Yes \" ) ; } } }",
"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; ",
"import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; public class _p001013A { static public void main ( final String [ ] args ) throws IOException { p001013A . _main ( args ) ; }",
"import java . util . * ; public class P2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; int sum1 = 0 ; int sum2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; sum1 += a [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; sum2 += b [ i ] ; } if ( sum2 <= sum1 ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } }"
] | [
"x = int ( input ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) [ : x ] b = list ( map ( int , input ( ) . split ( ) ) ) [ : x ] ars = sum ( ar ) brs = sum ( b ) if ( brs <= ars ) : print ( \" Yes \" ) else : print ( \" No \" ) NEW_LINE",
"size = int ( input ( ) ) num1 = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) nums2 = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) sum1 = sum ( num1 ) sum2 = sum ( nums2 ) if sum2 <= sum1 : print ( ' Yes ' ) else : print ( ' No ' ) NEW_LINE",
"n = int ( input ( ) ) print ( ' YES ' if sum ( [ int ( i ) for i in input ( ) . split ( ) ] ) >= sum ( [ int ( i ) for i in input ( ) . split ( ) ] ) else ' NO ' ) NEW_LINE",
"n = int ( input ( ) ) x = [ int ( x ) for x in input ( ) . split ( ) ] y = [ int ( x ) for x in input ( ) . split ( ) ] if sum ( x ) >= sum ( y ) : print ( \" Yes \" ) else : print ( ' No ' ) NEW_LINE"
] |
codeforces_213_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Random ; import java . util . StringTokenizer ; public class Solution { static final int mod = ( int ) 1e9 + 7 ; static final int N = 105 ; static int n ; static int [ ] a ; static int [ ] fact , invfact ; public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { n = fs . nextInt ( ) ; int sum = 0 ; a = new int [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { a [ i ] = fs . nextInt ( ) ; sum += a [ i ] ; } fact = new int [ N ] ; fact [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) fact [ i ] = mul ( fact [ i - 1 ] , i ) ; invfact = new int [ N ] ; invfact [ N - 1 ] = inv ( fact [ N - 1 ] ) ; for ( int i = N - 2 ; i >= 0 ; i -- ) invfact [ i ] = mul ( invfact [ i + 1 ] , i + 1 ) ;",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; } public static int mod = 1_000_000_007 ; long [ ] [ ] dp ; int [ ] a ; void run ( FastScanner in , PrintWriter out ) { int N = in . nextInt ( ) ; a = new int [ 10 ] ; int tot = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) { a [ i ] = in . nextInt ( ) ; tot += a [ i ] ; } if ( tot > N ) { out . println ( 0 ) ; return ; } f = new long [ 102 ] ; f [ 0 ] = 1 ; for ( int i = 1 ; i < 102 ; i ++ ) { f [ i ] = ( f [ i - 1 ] * i ) % mod ; } dp = new long [ N + 1 ] [ 10 ] ; for ( int i = 9 ; i >= 0 && a [ i ] == 0 ; i -- ) { dp [ 0 ] [ i ] = 1 ; } long sum = 0 ; for ( int len = 1 ; len <= N ; len ++ ) { "
] | [
"from math import factorialdp = [ [ - 1 for i in range ( 101 ) ] for j in range ( 101 ) ] def solve ( n , p , a ) : if dp [ n ] [ p ] is not - 1 : return dp [ n ] [ p ] elif p is 9 : if n >= a [ 9 ] : return 1 else : return 0 elif p is 0 : ans = 0 for i in range ( a [ 0 ] , n ) : z = solve ( n - i , 1 , a ) z *= factorial ( n - 1 ) z //= factorial ( i ) z //= factorial ( n - 1 - i ) ans += z dp [ n ] [ p ] = ans return ans else : ans = 0 for i in range ( a [ p ] , n + 1 ) : z = solve ( n - i , p + 1 , a ) z *= factorial ( n ) z //= factorial ( i ) z //= factorial ( n - i ) ans += z dp [ n ] [ p ] = ans return anshell = 1000000007 n = int ( input ( ) ) a = input ( ) . rstrip ( ) . split ( ' ▁ ' ) ; for i in range ( 0 , len ( a ) ) : a [ i ] = int ( a [ i ] ) ans = 0 for i in range ( 1 , n + 1 ) : ans += solve ( i , 0 , a ) ans %= hellprint ( ans ) NEW_LINE",
"from math import factorialdp = [ [ - 1 for i in range ( 101 ) ] for j in range ( 101 ) ] def solve ( n , p , a ) : if dp [ n ] [ p ] is not - 1 : return dp [ n ] [ p ] elif p is 9 : if n >= a [ 9 ] : return 1 else : return 0 elif p is 0 : ans = 0 for i in range ( a [ 0 ] , n ) : z = solve ( n - i , 1 , a ) z *= factorial ( n - 1 ) z //= factorial ( i ) z //= factorial ( n - 1 - i ) ans += z dp [ n ] [ p ] = ans return ans else : ans = 0 for i in range ( a [ p ] , n + 1 ) : z = solve ( n - i , p + 1 , a ) z *= factorial ( n ) z //= factorial ( i ) z //= factorial ( n - i ) ans += z dp [ n ] [ p ] = ans return anshell = 1000000007 n = int ( input ( ) ) a = input ( ) . rstrip ( ) . split ( ' ▁ ' ) ; for i in range ( 0 , len ( a ) ) : a [ i ] = int ( a [ i ] ) ans = 0 for i in range ( 1 , n + 1 ) : ans += solve ( i , 0 , a ) ans %= hellprint ( ans ) NEW_LINE"
] |
codeforces_1055_A | [
"import java . io . * ; import java . util . * ; import java . math . * ; public class Main { public static void main ( String args [ ] ) throws Exception { FastScanner fs = new FastScanner ( ) ;",
"import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ; public class A1055 { static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) { int tc = 1 ;",
"import javax . sound . midi . Soundbank ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { task ( ) ; } public static void task ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int [ ] A = new int [ n ] ; int [ ] B = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } if ( A [ s - 1 ] == 0 && B [ s - 1 ] == 0 ) { System . out . println ( \" NO \" ) ; return ; } else if ( A [ 0 ] == 0 ) { System . out . println ( \" NO \" ) ; return ; } else if ( A [ s - 1 ] == 1 ) { System . out . println ( \" YES \" ) ; return ; } else { for ( int i = s ; i < n ; i ++ ) { if ( A [ i ] == 1 && B [ i ] == 1 ) { System . out . println ( \" YES \" ) ; return ; } } } System . out . println ( \" NO \" ) ; } }",
"import java . util . * ; public class Test { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int s = input . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] b = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { b [ i ] = input . nextInt ( ) ; } boolean result = false ; if ( a [ 1 ] == 1 ) { if ( a [ s ] == 1 ) { result = true ; } else { for ( int i = s ; i <= n ; i ++ ) { if ( i != s && a [ i ] == 1 && b [ i ] == 1 && b [ s ] == 1 ) { result = true ; break ; } } } } System . out . println ( ( result ) ? \" YES \" : \" NO \" ) ; } }",
"import java . util . * ; import java . io . * ; import java . util . stream . * ; public class Solution { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } boolean result ; if ( a [ 0 ] == 0 ) { result = false ; } else if ( a [ s - 1 ] == 1 ) { result = true ; } else if ( b [ s - 1 ] == 0 ) { result = false ; } else { result = false ; for ( int i = s ; i < n ; i ++ ) { if ( b [ i ] == 1 && a [ i ] == 1 ) { result = true ; break ; } } } System . out . println ( result ? \" YES \" : \" NO \" ) ; } }"
] | [
"n , s = map ( int , input ( ) . split ( ) ) go = list ( map ( int , input ( ) . split ( ) ) ) come = list ( map ( int , input ( ) . split ( ) ) ) if go [ 0 ] == 0 : print ( ' NO ' ) exit ( ) if go [ s - 1 ] == 0 and come [ s - 1 ] == 0 : print ( ' NO ' ) exit ( ) if go [ s - 1 ] == 1 : print ( ' YES ' ) exit ( ) for i in range ( s , n ) : if go [ i ] == 1 and come [ i ] == 1 : print ( ' YES ' ) exit ( ) print ( ' NO ' ) NEW_LINE",
"s , n = map ( int , input ( ) . split ( ) ) l1 = list ( map ( int , input ( ) . split ( ) ) ) l2 = list ( map ( int , input ( ) . split ( ) ) ) f = 0 if l1 [ 0 ] == 1 : if l1 [ n - 1 ] == 1 : print ( \" YES \" ) else : for i in range ( n , s ) : if l1 [ i ] == 1 and l2 [ n - 1 ] == 1 and l2 [ i ] == 1 : f = 1 break if f == 1 : print ( \" YES \" ) else : print ( \" NO \" ) else : print ( \" NO \" ) NEW_LINE",
"n , s = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) if a [ 0 ] == 1 : if a [ s - 1 ] == 1 : print ( \" YES \" ) elif b [ s - 1 ] == 1 : flag = True for i in range ( s , n ) : if a [ i ] == 1 and b [ i ] == 1 : print ( \" Yes \" ) flag = False break if flag : print ( \" NO \" ) else : print ( \" NO \" ) else : print ( \" NO \" ) NEW_LINE",
"n , s = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) ans = \" NO \" if a [ 0 ] == 1 and a [ s - 1 ] == 1 : ans = \" YES \" elif a [ 0 ] == 1 and b [ s - 1 ] == 1 : for i in range ( s , n ) : if a [ i ] == 1 and b [ i ] == 1 : ans = \" YES \" breakprint ( ans ) NEW_LINE",
"def avialable_station ( ) : for i in range ( s , n ) : if ft [ i ] == 1 and st [ i ] == 1 : return True return Falsetry : n , s = map ( int , input ( ) . split ( ) ) ft = list ( map ( int , input ( ) . split ( ) ) ) st = list ( map ( int , input ( ) . split ( ) ) ) if ft [ s - 1 ] == 1 and ft [ 0 ] == 1 : print ( \" YES \" ) elif ft [ 0 ] == 0 or ( st [ s - 1 ] == 0 and ft [ s - 1 ] == 0 ) or not avialable_station ( ) : print ( \" NO \" ) else : print ( \" YES \" ) except : pass NEW_LINE"
] |
codeforces_251_A | [
"import java . util . * ; import java . io . * ; import java . math . * ; public class First { public static void process ( ) throws IOException { int n = ni ( ) ; long d = nl ( ) ; long a [ ] = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = nl ( ) ; } long count = 0l ;",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . LinkedHashMap ; import java . util . Map ; import java . util . Scanner ; import java . util . * ; import java . util . stream . Collectors ; public class absolute { public static void main ( String [ ] args ) {",
"import java . util . * ; import java . io . * ;",
"import java . util . * ; import java . lang . * ;"
] | [
"n , d = list ( map ( int , input ( ) . split ( ) ) ) array = list ( map ( int , input ( ) . split ( ) ) ) start = 0 end = 0 ans = 0 while end < n : while array [ end ] - array [ start ] > d : start += 1 k = end - start ans += k * ( k - 1 ) // 2 end += 1 print ( ans ) NEW_LINE",
"n , d = map ( int , input ( ) . split ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) i , j , s = 0 , 0 , 0 while i < n : while ar [ i ] - ar [ j ] > d : j += 1 N = i - j s += N * ( N - 1 ) // 2 i += 1 print ( s ) NEW_LINE"
] |
codeforces_676_B | [
"import java . util . * ; public class Main { static void sol ( int i , int j , double l , int n , double data [ ] [ ] ) { if ( n == 0 ) return ; data [ i ] [ j ] += l ; if ( data [ i ] [ j ] <= 1.0 ) return ; else { l = data [ i ] [ j ] - 1.0 ; data [ i ] [ j ] = 1.0 ; sol ( i + 1 , j , l / 2 , n - 1 , data ) ; sol ( i + 1 , j + 1 , l / 2 , n - 1 , data ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; double L = sc . nextDouble ( ) ; double data [ ] [ ] = new double [ N ] [ N ] ; int c = 0 ; sol ( 0 , 0 , L , N , data ) ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) { if ( data [ i ] [ j ] == 1.0 ) c ++ ; } System . out . println ( c ) ; } }",
"import java . util . ArrayList ; import java . util . Scanner ; public class Glass { public static void func ( int i , int j , double l , double [ ] [ ] arr ) { arr [ i ] [ j ] += l ; if ( arr [ i ] [ j ] <= 1.0 || i > arr . length - 2 ) { return ; } l = arr [ i ] [ j ] - 1.0 ; arr [ i ] [ j ] = 1.0 ; func ( i + 1 , j , l / 2 , arr ) ; func ( i + 1 , j + 1 , l / 2 , arr ) ; } public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int count = 0 ; int n = sc . nextInt ( ) ; double l = sc . nextDouble ( ) ; double [ ] [ ] arr = new double [ n + 1 ] [ n + 1 ] ; func ( 0 , 0 , l , arr ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ i ] [ j ] >= 1.0 ) count ++ ; } } System . out . println ( count ) ; } }",
"import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class A { static InputReader in = new InputReader ( System . in ) ; static OutputWriter out = new OutputWriter ( System . out ) ; static StringBuilder sb = new StringBuilder ( ) ; static long MOD = ( long ) ( 998244353 ) ;",
"import java . util . * ; public class pyramidOfGlass { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; if ( in . hasNextLine ( ) ) { int n = in . nextInt ( ) ;"
] | [
"n , t = map ( int , input ( ) . split ( ) ) an = [ [ 0 for i in range ( j + 1 ) ] for j in range ( n ) ] def dfs ( i , j , v ) : if an [ i ] [ j ] + v > 1 : vv = v - ( 1 - an [ i ] [ j ] ) an [ i ] [ j ] = 1 if i == n - 1 : return dfs ( i + 1 , j , vv / 2 ) dfs ( i + 1 , j + 1 , vv / 2 ) return d = 1 if ( j == 0 or j == i ) else 2 an [ i ] [ j ] += v for i in range ( t ) : dfs ( 0 , 0 , 1 ) ans = 0 for i in range ( n ) : for j in range ( i + 1 ) : ans += an [ i ] [ j ] >= 1 print ( ans ) NEW_LINE",
"n , t = list ( map ( int , input ( ) . split ( ) ) ) li = [ [ t - 1 ] ] cnt = 1 if t - 1 >= 0 else 0 for i in range ( 2 , n + 1 ) : tr = li [ - 1 ] [ 0 ] / 2 - 1 if tr >= 0 : cnt += 2 li . append ( [ tr ] ) for j in range ( 1 , i - 1 ) : a = li [ - 2 ] [ j - 1 ] b = li [ - 2 ] [ j ] temp = - 1 if a > 0 : temp += a / 2 if b > 0 : temp += b / 2 if temp >= 0 : cnt += 1 li [ - 1 ] . append ( temp ) li [ - 1 ] . append ( tr ) print ( cnt ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) dp = [ [ 0 for i in range ( n ) ] for i in range ( n ) ] dp [ 0 ] [ 0 ] = m NEW_LINE"
] |
codeforces_1427_A | [
"import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class A1427 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; Integer [ ] A = new Integer [ N ] ; int sum = 0 ; for ( int n = 0 ; n < N ; n ++ ) { int a = in . nextInt ( ) ; sum += a ; A [ n ] = a ; } if ( sum == 0 ) { System . out . println ( \" NO \" ) ; } else { Arrays . sort ( A ) ; if ( sum > 0 ) { Collections . reverse ( Arrays . asList ( A ) ) ; } StringBuilder output = new StringBuilder ( ) ; output . append ( \" YES \\n \" ) ; for ( int n = 0 ; n < N ; n ++ ) { output . append ( A [ n ] ) . append ( ' ▁ ' ) ; } System . out . println ( output ) ; } } } }",
"import java . util . * ; public class HelloWorld { public static void main ( String [ ] args ) {",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . StringTokenizer ; import java . util . TreeMap ; public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = true ; void solve ( FastScanner in , PrintWriter out , int testNumber ) { n = in . nextInt ( ) ; Integer [ ] a = in . nextArray2 ( n ) ; long sum = Array . sum ( a ) ; if ( sum == 0 ) { out . println ( \" NO \" ) ; } else { out . println ( \" YES \" ) ; if ( sum > 0 ) { Arrays . sort ( a , Comparator . comparing ( v -> - v ) ) ; } else Arrays . sort ( a , Comparator . comparing ( v -> v ) ) ; for ( int x : a ) { out . print ( x + \" ▁ \" ) ; } out . println ( ) ; } } ",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class problem82 { public static void main ( String [ ] args ) {"
] | [
"cases = int ( input ( ) ) NEW_LINE while cases : cases -= 1 NEW_LINE num = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE summ = sum ( arr ) NEW_LINE if summ == 0 : NEW_LINE INDENT print ( \" NO \" ) elif summ < 0 : NEW_LINE ans = sorted ( arr ) NEW_LINE DEDENT print ( \" YES \" ) NEW_LINE print ( * ans ) else : ans = sorted ( arr , reverse = True ) NEW_LINE print ( \" YES \" ) NEW_LINE print ( * ans ) NEW_LINE",
"test = int ( input ( ) ) NEW_LINE for t in range ( test ) : n = int ( input ( ) ) NEW_LINE lt = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE lst = sorted ( lt ) NEW_LINE if ( sum ( lst ) == 0 ) : NEW_LINE INDENT print ( \" NO \" ) elif sum ( lst ) < 0 : NEW_LINE print ( \" YES \" ) NEW_LINE DEDENT print ( * lst ) else : print ( \" YES \" ) NEW_LINE tmp = [ ] NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : tmp . append ( lst [ i ] ) NEW_LINE print ( * tmp ) NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = [ * map ( int , input ( ) . split ( ) ) ] NEW_LINE s = sum ( a ) NEW_LINE if s == 0 : NEW_LINE INDENT print ( \" No \" ) else : NEW_LINE b = [ ] NEW_LINE DEDENT sun = 0 NEW_LINE sup = 0 NEW_LINE for i in a : if NEW_LINE i < 0 : sun += i else : sup += i NEW_LINE if sup > abs ( sun ) : for NEW_LINE i in a : NEW_LINE if i > 0 : b . append ( i ) NEW_LINE for i in a : if NEW_LINE i <= 0 : b . append ( i ) else : for i in a : if NEW_LINE i < 0 : b . append ( i ) NEW_LINE for i in a : if NEW_LINE i >= 0 : b . append ( i ) NEW_LINE print ( \" Yes \" ) NEW_LINE print ( * b ) NEW_LINE",
"cases = int ( input ( ) ) NEW_LINE while cases : cases -= 1 NEW_LINE num = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) summ = sum ( arr ) if summ == 0 : NEW_LINE INDENT print ( \" NO \" ) elif summ < 0 : NEW_LINE ans = sorted ( arr ) NEW_LINE DEDENT print ( \" YES \" ) NEW_LINE print ( * ans ) else : ans = sorted ( arr , reverse = True ) NEW_LINE print ( \" YES \" ) NEW_LINE print ( * ans ) NEW_LINE",
"for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if sum ( a ) == 0 : print ( ' NO ' ) NEW_LINE continue NEW_LINE pos , neg , zero = [ ] , [ ] , [ ] NEW_LINE for i in a : if NEW_LINE i > 0 : pos . append ( i ) elif i < 0 : neg . append ( i ) else : zero . append ( i ) NEW_LINE b = [ ] NEW_LINE if sum ( pos ) > abs ( sum ( neg ) ) : NEW_LINE INDENT b = pos + neg + zero else : NEW_LINE b = neg + pos + zero NEW_LINE DEDENT print ( ' YES ' ) NEW_LINE print ( * b ) NEW_LINE"
] |
codeforces_244_A | [
"import java . util . * ; import java . math . * ; public class gfg { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) a [ i ] = sc . nextInt ( ) ; int [ ] b = Arrays . copyOf ( a , k ) ; Arrays . sort ( b ) ; int total = n * k + 1 ; int [ ] available = new int [ total ] ; int count = 0 ; for ( int i = 1 ; i <= total ; i ++ ) { if ( Arrays . binarySearch ( b , i ) < 0 ) { available [ count ] = i ; count ++ ; } } count = 0 ; for ( int i = 0 ; i < k ; i ++ ) { System . out . print ( a [ i ] + \" ▁ \" ) ; for ( int j = 0 ; j < n - 1 ; j ++ ) { System . out . print ( available [ count ++ ] + \" ▁ \" ) ; } System . out . println ( \" \" ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) ; int a [ ] = new int [ n * k ] ; for ( int i = 0 ; i < n * k ; i ++ ) { a [ i ] = i + 1 ; } String ans [ ] = new String [ k ] ;",
"import java . util . * ; public class DividingOrange { public static void main ( String [ ] args ) {",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { FastScanner scan = new Main ( ) . new FastScanner ( ) ; ; int t = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; boolean bl [ ] = new boolean [ t * k + 1 ] ; ArrayList < Integer > T = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < k ; ++ i ) { T . add ( scan . nextInt ( ) ) ; bl [ T . get ( i ) ] = true ; } for ( int i = 0 ; i < k ; ++ i ) { System . out . print ( T . get ( i ) + \" ▁ \" ) ; int count = 0 ; for ( int j = 1 ; j <= t * k + 1 ; ++ j ) { if ( count == t - 1 ) { break ; } if ( bl [ j ] == false ) { ++ count ; System . out . print ( j + \" ▁ \" ) ; bl [ j ] = true ; } } System . out . println ( ) ; } } class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }"
] | [
"n , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l1 = [ ] ans = n * kfor i in range ( 1 , ans + 1 ) : l1 . append ( i ) l2 = [ ] N = n - 1 for i in range ( len ( l1 ) ) : if ( l1 [ i ] in l ) : continue else : l2 . append ( l1 [ i ] ) def divide_chunks ( l , n ) : for i in range ( 0 , len ( l ) , n ) : yield l [ i : i + n ] if ( n == 1 ) : for i in range ( len ( l ) ) : print ( l [ i ] ) else : l3 = list ( divide_chunks ( l2 , N ) ) for i in range ( len ( l3 ) ) : l3 [ i ] . append ( l [ i ] ) print ( * l3 [ i ] ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = r ( ) num = 1 for i in arr : print ( i , end = \" ▁ \" ) lim = n - 1 while lim : if num not in arr : print ( num , end = \" ▁ \" ) lim -= 1 num += 1 print ( ) NEW_LINE",
"n , k = list ( map ( int , input ( ) . split ( ) ) ) req = list ( map ( int , input ( ) . split ( ) ) ) req . append ( \" fake \" ) idx = 0 ans = [ req [ 0 ] ] hashSet = set ( req ) for i in range ( 1 , n * k + 1 ) : if i not in hashSet : ans . append ( i ) if len ( ans ) == n : print ( * ans ) idx += 1 ans = [ req [ idx ] ] NEW_LINE",
"import mathfrom math import gcd , floor , sqrt , logdef iin ( ) : return int ( input ( ) ) def sin ( ) : return input ( ) . strip ( ) def listin ( ) : return list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) def liststr ( ) : return list ( map ( str , input ( ) . strip ( ) . split ( ) ) ) def ceill ( x ) : return int ( x ) if ( x == int ( x ) ) else int ( x ) + 1 def ceilldiv ( x , d ) : return x // d if ( x % d == 0 ) else x // d + 1 def LCM ( a , b ) : return ( a * b ) // gcd ( a , b ) def solve ( ) : n , k = listin ( ) a = listin ( ) z = [ i for i in range ( 1 , n * k + 1 ) if i not in a ] temp = 0 for j in range ( k ) : print ( a [ j ] , end = \" ▁ \" ) for i in range ( temp , n + temp - 1 ) : print ( z [ i ] , end = ' ▁ ' ) temp += n - 1 print ( ) t = 1 NEW_LINE"
] |
codeforces_925_A | [
"import java . io . * ; import java . util . * ; import java . math . * ; public class StairsElevators { static class InputReader { BufferedReader reader ; StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } 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 long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } static InputReader r = new InputReader ( System . in ) ; static PrintWriter pw = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { long n = r . nextInt ( ) ;",
"import java . io . * ; import java . util . * ; import java . util . concurrent . TimeUnit ; public class b implements Runnable { public static void main ( String [ ] args ) { try { new Thread ( null , new b ( ) , \" process \" , 1 << 26 ) . start ( ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } public void run ( ) { FastReader scan = new FastReader ( ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ;"
] | [
"import sysinput = sys . stdin . readlineimport mathimport bisectn , m , cl , ce , v = map ( int , input ( ) . split ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) if i != ' \\n ' ] e = [ int ( i ) for i in input ( ) . split ( ) if i != ' \\n ' ] q = int ( input ( ) ) for i in range ( q ) : x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) lft , neareststa , sta , nearestele = 0 , 0 , 0 , 0 if x2 == x1 and y1 == y2 : output = 0 elif x2 == x1 : output = abs ( y2 - y1 ) else : lft = math . ceil ( abs ( ( x2 - x1 ) ) / v ) sta = abs ( x2 - x1 ) if cl > 0 : nearestele = bisect . bisect_left ( l , y1 ) if len ( l ) > nearestele : first = abs ( l [ nearestele ] - y1 ) + abs ( y2 - l [ nearestele ] ) else : first = 1000000000001 if nearestele != 0 : second = abs ( l [ nearestele - 1 ] - y1 ) + abs ( y2 - l [ nearestele - 1 ] ) else : second = 1000000000001 nearestele = min ( first , second ) else : nearestele = 1000000000001 if ce > 0 : neareststa = bisect . bisect_left ( e , y1 ) if len ( e ) > neareststa : first = abs ( e [ neareststa ] - y1 ) + abs ( y2 - e [ neareststa ] ) else : first = 1000000000001 if neareststa != 0 : second = abs ( e [ neareststa - 1 ] - y1 ) + abs ( y2 - e [ neareststa - 1 ] ) else : second = 1000000000001 neareststa = min ( first , second ) else : neareststa = 1000000000001 output = min ( lft + neareststa , sta + nearestele ) sys . stdout . write ( str ( output ) + ' \\n ' ) NEW_LINE",
"def takeClosest ( myList , myNumber ) : \"\"\" ▁ ▁ ▁ ▁ Assumes ▁ myList ▁ is ▁ sorted . ▁ Returns ▁ closest ▁ value ▁ to ▁ myNumber . ▁ ▁ ▁ ▁ If ▁ two ▁ numbers ▁ are ▁ equally ▁ close , ▁ return ▁ the ▁ smallest ▁ number . ▁ ▁ ▁ ▁ \"\"\" if len ( myList ) == 0 : return 9e10 pos = bisect_left ( myList , myNumber ) if pos == 0 : return myList [ 0 ] if pos == len ( myList ) : return myList [ - 1 ] before = myList [ pos - 1 ] after = myList [ pos ] if after - myNumber < myNumber - before : return after else : return before from bisect import bisect_left from math import ceil n , m , n_stairs , n_elevators , v = map ( int , input ( ) . split ( \" ▁ \" ) ) if n_stairs > 0 : stairs = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) else : stairs = [ ] input ( ) if n_elevators > 0 : elevators = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) else : elevators = [ ] input ( ) queries = int ( input ( ) ) res = [ ] for i in range ( queries ) : x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( \" ▁ \" ) ) next_elevator = takeClosest ( elevators , ( y1 + y2 ) / 2 ) next_stairs = takeClosest ( stairs , ( y1 + y2 ) / 2 ) time_elevator = abs ( x1 - x2 ) / v time_stairs = abs ( x1 - x2 ) mi = min ( y1 , y2 ) ma = max ( y1 , y2 ) if next_elevator < mi : time_elevator += ( mi - next_elevator ) * 2 elif next_elevator > ma : time_elevator += ( next_elevator - ma ) * 2 if next_stairs < mi : time_stairs += ( mi - next_stairs ) * 2 elif next_stairs > ma : time_stairs += ( next_stairs - ma ) * 2 dis = abs ( y1 - y2 ) if time_elevator < time_stairs : dis += time_elevator else : dis += time_stairs if x1 == x2 : res . append ( abs ( y1 - y2 ) ) else : res . append ( ceil ( dis ) ) print ( * res , sep = \" \\n \" ) NEW_LINE",
"import sysinput = sys . stdin . readlineimport mathimport bisectn , m , cl , ce , v = map ( int , input ( ) . split ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) if i != ' \\n ' ] e = [ int ( i ) for i in input ( ) . split ( ) if i != ' \\n ' ] q = int ( input ( ) ) for i in range ( q ) : x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) lft , neareststa , sta , nearestele = 0 , 0 , 0 , 0 if x2 == x1 and y1 == y2 : output = 0 elif x2 == x1 : output = abs ( y2 - y1 ) else : lft = math . ceil ( abs ( ( x2 - x1 ) ) / v ) NEW_LINE"
] |
codeforces_1146_A | [
"import java . util . Scanner ; public class Love_A { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . nextLine ( ) ; int sa = s . replaceAll ( \" [ ^ a ] \" , \" \" ) . length ( ) ; if ( sa <= s . length ( ) / 2 ) { System . out . println ( 2 * sa - 1 ) ; } else { System . out . println ( s . length ( ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String str = s . next ( ) ; int n = str . length ( ) , ca = 0 , co = 0 ; char [ ] a = str . toCharArray ( ) ; for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] == ' a ' ) ca ++ ; else co ++ ; while ( co >= ca ) co -- ; System . out . println ( co + ca ) ; } }",
"import java . util . * ; public class questionCF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int a = 0 , len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = s . charAt ( i ) ; if ( c == ' a ' ) a ++ ; } if ( a > len / 2 ) System . out . println ( len ) ; else { System . out . println ( ( 2 * a ) - 1 ) ; } } }"
] | [
"s = input ( ) d = s . count ( ' a ' ) e = len ( s ) - dprint ( min ( len ( s ) , 2 * d - 1 ) ) NEW_LINE",
"s = input ( ) print ( min ( 2 * s . count ( ' a ' ) - 1 , len ( s ) ) ) NEW_LINE",
"stringa = input ( ) if stringa . count ( ' a ' ) <= 1 / 2 * len ( stringa ) : stringa . count ( ' a ' ) print ( stringa . count ( ' a ' ) * 2 - 1 ) else : print ( len ( stringa ) ) NEW_LINE",
"s = [ i for i in input ( ) ] i = 0 a = 0 x = 0 while i < len ( s ) : if s [ i ] == ' a ' : a = a + 1 else : x = x + 1 i = i + 1 if a > x : print ( a + x ) else : print ( a + a - 1 ) NEW_LINE"
] |
codeforces_764_B | [
" import java . util . * ; public class Practise { ",
" import java . util . * ; public class Practise { ",
"import java . util . Scanner ; public class problem97 { public static void main ( String [ ] args ) {"
] | [
"n = int ( input ( ) ) a = list ( input ( ) . split ( ) ) k = n // 2 for i in range ( 0 , k , 2 ) : a [ i ] , a [ n - i - 1 ] = a [ n - i - 1 ] , a [ i ] print ( * a ) NEW_LINE",
"x = int ( input ( ' ' ) ) ar = list ( map ( int , input ( ' ' ) . split ( ) ) ) for i in range ( 0 , x // 2 , 2 ) : ar [ i ] , ar [ - i - 1 ] = ar [ - i - 1 ] , ar [ i ] print ( * ar ) NEW_LINE",
"import sysimport mathdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) n = iinput ( ) l = listinput ( ) temp = 0 for i in range ( 0 , int ( n / 2 ) ) : if i % 2 == 0 : temp = l [ i ] l [ i ] = l [ n - i - 1 ] l [ n - i - 1 ] = tempprint ( * l ) NEW_LINE",
"if __name__ == \" _ _ main _ _ \" : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l = l [ : : - 1 ] if n <= 2 : print ( * l ) else : i = 1 till = n // 2 - 1 while i < n // 2 : l [ i ] , l [ n - i - 1 ] = l [ n - i - 1 ] , l [ i ] i = i + 2 print ( * l ) NEW_LINE",
"import sysdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) n = iinput ( ) l = listinput ( ) if n % 2 == 1 : for i in range ( n // 2 + 1 ) : if i % 2 == 0 : l [ i ] , l [ n - i - 1 ] = l [ n - i - 1 ] , l [ i ] else : for i in range ( n // 2 ) : if i % 2 == 0 : l [ i ] , l [ n - i - 1 ] = l [ n - i - 1 ] , l [ i ] print ( * l ) NEW_LINE"
] |
codeforces_1228_A | [
"import java . util . * ; import java . lang . * ; import java . io . * ; public class Main { PrintWriter out ; FastReader sc ; long mod = ( long ) ( 1e9 + 7 ) ; long maxlong = Long . MAX_VALUE ; long minlong = Long . MIN_VALUE ; boolean find ( int n ) { HashSet < Integer > h = new HashSet < > ( ) ; while ( n > 0 ) { int p = n % 10 ; n /= 10 ; if ( h . contains ( p ) ) return false ; h . add ( p ) ; } return true ; } public void sol ( ) { int l = ni ( ) , r = ni ( ) ; for ( int i = l ; i <= r ; i ++ ) { if ( find ( i ) ) { pl ( i ) ; return ; } } pl ( \" - 1\" ) ; } public static void main ( String [ ] args ) { Main g = new Main ( ) ; g . out = new PrintWriter ( System . out ) ; g . sc = new FastReader ( ) ; int t = 1 ;",
"import java . util . Scanner ; public class Main { public static boolean check ( int n ) { boolean arr [ ] = new boolean [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { arr [ i ] = false ; } while ( n > 0 ) { int digit = n % 10 ; if ( arr [ digit ] ) { return false ; } arr [ digit ] = true ; n = n / 10 ; } return true ; } public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int f = 0 ; int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; for ( int i = a ; i <= b ; i ++ ) { if ( check ( i ) ) { System . out . print ( i ) ; f = 1 ; break ; } } if ( f == 0 ) { System . out . print ( - 1 ) ; } } }",
"import java . io . * ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class digitosDistintos { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) { FastReader entrada = new FastReader ( ) ; int larg = entrada . nextInt ( ) ; int rad = entrada . nextInt ( ) ; int fork = 0 ; for ( int i = larg ; i <= rad ; i ++ ) { int numero = i ; boolean visitou [ ] = new boolean [ 100 ] ; while ( numero != 0 ) { if ( visitou [ numero % 10 ] ) break ; visitou [ numero % 10 ] = true ; numero = numero / 10 ; } if ( numero == 0 ) { fork = 1 ; System . out . print ( i ) ; break ; } } if ( fork == 0 ) { System . out . println ( - 1 ) ; } } }",
"import java . io . IOException ; import java . util . HashSet ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; boolean b = false ; for ( int i = l ; i <= r ; i ++ ) { int x = i ; int count = 0 ; HashSet < Integer > set = new HashSet < Integer > ( ) ; while ( x != 0 ) { set . add ( x % 10 ) ; x /= 10 ; count ++ ; } if ( set . size ( ) == count ) { System . out . println ( i ) ; b = true ; break ; } } if ( ! b ) { System . out . println ( - 1 ) ; } } }",
"import java . util . HashSet ; import java . util . Scanner ; public class A1228 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int l = scanner . nextInt ( ) , r = scanner . nextInt ( ) ; boolean flag = false ; for ( int i = l ; i <= r ; i ++ ) { int a = i , t = 0 ; HashSet < Integer > set = new HashSet < > ( ) ; while ( a > 0 ) { set . add ( a % 10 ) ; a /= 10 ; t ++ ; } if ( set . size ( ) == t ) { System . out . println ( i ) ; flag = false ; break ; } else { flag = true ; } } if ( flag ) System . out . println ( - 1 ) ; } }"
] | [
"l , r = map ( int , input ( ) . split ( ) ) while ( l <= r ) & ( len ( set ( str ( l ) ) ) < len ( str ( l ) ) ) : l += 1 print ( ( l , - 1 ) [ l > r ] ) NEW_LINE",
"import sysinput = sys . stdin . readline ''' ''' def distinct_digits ( num ) : snum = str ( num ) return len ( snum ) == len ( set ( snum ) ) l , r = map ( int , input ( ) . split ( ) ) x = l while x <= r and not distinct_digits ( x ) : x += 1 print ( x if x <= r else - 1 ) NEW_LINE",
"import reimport sysexit = sys . exitfrom bisect import bisect_left as bsl , bisect_right as bsrfrom collections import Counter , defaultdict as ddict , dequefrom functools import lru_cachecache = lru_cache ( None ) from heapq import * from itertools import * from math import inffrom pprint import pprint as ppenum = enumerateri = lambda : int ( rln ( ) ) ris = lambda : list ( map ( int , rfs ( ) ) ) rln = sys . stdin . readlinerl = lambda : rln ( ) . rstrip ( ' \\n ' ) rfs = lambda : rln ( ) . split ( ) mod = 1000000007 d4 = [ ( 0 , - 1 ) , ( 1 , 0 ) , ( 0 , 1 ) , ( - 1 , 0 ) ] d8 = [ ( - 1 , - 1 ) , ( 0 , - 1 ) , ( 1 , - 1 ) , ( - 1 , 0 ) , ( 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) , ( 1 , 1 ) ] NEW_LINE"
] |
codeforces_1287_B | [
"import java . util . * ; import java . lang . * ; import java . io . * ; public class Main { PrintWriter out ; FastReader sc ; int mod = ( int ) ( 1e9 + 7 ) ; public void sol ( ) { int n = ni ( ) , k = ni ( ) ; String [ ] s = new String [ n ] ; HashMap < String , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String a = rl1 ( ) ; s [ i ] = a ; map . put ( a , map . getOrDefault ( a , 0 ) + 1 ) ; } long ans = 0 ; for ( int i = 0 ; i < n - 2 ; i ++ ) { int v = map . get ( s [ i ] ) ; map . put ( s [ i ] , v - 1 ) ; HashMap < String , Integer > has = new HashMap < > ( map ) ;",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] str = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( str [ 0 ] ) , k = Integer . parseInt ( str [ 1 ] ) ; String [ ] data = new String [ n ] ; char [ ] vals = new char [ ] { ' S ' , ' E ' , ' T ' } ; HashMap < String , Integer > hm = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { data [ i ] = br . readLine ( ) ; hm . computeIfPresent ( data [ i ] , ( key , val ) -> val += 1 ) ; hm . putIfAbsent ( data [ i ] , 1 ) ; } int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String s1 = data [ i ] ; for ( int j = i + 1 ; j < n ; j ++ ) { String s2 = data [ j ] ; String toFind ; char [ ] c1 = new char [ k ] ; for ( int z = 0 ; z < k ; z ++ ) { char s1c = s1 . charAt ( z ) , s2c = s2 . charAt ( z ) ; if ( s1c == s2c ) c1 [ z ] = s1c ; else { for ( int z1 = 0 ; z1 < 3 ; z1 ++ ) { if ( s1c != vals [ z1 ] && s2c != vals [ z1 ] ) { c1 [ z ] = vals [ z1 ] ; } } } } toFind = String . valueOf ( c1 ) ; if ( hm . containsKey ( toFind ) ) { cnt += hm . get ( toFind ) ; if ( toFind . equals ( data [ i ] ) ) cnt -= 2 ; } } } System . out . println ( cnt / 3 ) ; } }",
"import java . util . * ; import java . io . * ; public class Main2 { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static int mod = ( int ) ( 1e9 + 7 ) ; static FastReader sc = new FastReader ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { int t = 1 ;"
] | [
"from collections import defaultdictdef get ( x , y ) : a = [ \" S \" , \" E \" , ' T ' ] a . remove ( x ) a . remove ( y ) return a [ 0 ] def solve ( ) : n , x = [ int ( f ) for f in input ( ) . split ( ) ] a = [ ] d = defaultdict ( int ) for i in range ( n ) : s = input ( ) a += [ s ] d [ s ] += 1 ans = 0 for i in range ( n - 1 ) : for j in range ( i + 1 , n ) : s = \" \" for k in range ( x ) : if a [ i ] [ k ] == a [ j ] [ k ] : s += str ( a [ j ] [ k ] ) else : s += get ( a [ i ] [ k ] , a [ j ] [ k ] ) ans += d [ s ] print ( ans // 3 ) for _ in range ( 1 ) : solve ( ) NEW_LINE",
"from sys import stdinn , k = map ( int , input ( ) . split ( ) ) cards = [ input ( ) for i in range ( n ) ] chk = set ( cards ) ans = 0 for i in range ( n - 1 ) : for y in range ( i + 1 , n ) : build = \" \" for l in range ( k ) : a , b = cards [ i ] [ l ] , cards [ y ] [ l ] if a == b : build += a else : if \" S \" not in a + b : build += \" S \" elif \" T \" not in a + b : build += \" T \" else : build += \" E \" if build in chk : ans += 1 print ( ans // 3 ) NEW_LINE",
"N , K = list ( map ( int , input ( ) . split ( ) ) ) C = [ ] ; S = set ( ) for i in range ( N ) : C . append ( input ( ) . strip ( ) ) S . add ( C [ - 1 ] ) ans = 0 for i in range ( N ) : for j in range ( i + 1 , N ) : aux = \" \" for k in range ( K ) : if C [ i ] [ k ] == C [ j ] [ k ] : aux += C [ i ] [ k ] if ( C [ i ] [ k ] == ' S ' and C [ j ] [ k ] == ' E ' ) or ( C [ i ] [ k ] == ' E ' and C [ j ] [ k ] == ' S ' ) : aux += ' T ' if ( C [ i ] [ k ] == ' S ' and C [ j ] [ k ] == ' T ' ) or ( C [ i ] [ k ] == ' T ' and C [ j ] [ k ] == ' S ' ) : aux += ' E ' if ( C [ i ] [ k ] == ' T ' and C [ j ] [ k ] == ' E ' ) or ( C [ i ] [ k ] == ' E ' and C [ j ] [ k ] == ' T ' ) : aux += ' S ' if aux in S : ans += 1 print ( ans // 3 ) NEW_LINE",
"def strneed ( s1 , s2 , n ) : setstr = [ ' S ' , ' E ' , ' T ' ] sn = \" \" for i in range ( n ) : if s1 [ i ] == s2 [ i ] : sn += s1 [ i ] else : for j in setstr : if j != s1 [ i ] and j != s2 [ i ] : sn += j break return sn def found ( s , arr , l , r ) : NEW_LINE",
"from sys import stdin , stdoutimport math , bisectfrom collections import Counter , deque , defaultdictL = lambda : list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) M = lambda : map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) I = lambda : int ( stdin . readline ( ) . strip ( ) ) S = lambda : stdin . readline ( ) . strip ( ) C = lambda : stdin . readline ( ) . strip ( ) . split ( ) def pr ( a ) : return ( \" ▁ \" . join ( list ( map ( str , a ) ) ) ) NEW_LINE"
] |
codeforces_965_B | [
"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; ",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) {",
"import java . io . * ; import java . util . * ; public class B_Battleship { public static void main ( String [ ] args ) throws Exception { int [ ] nk = in . readA ( ) ; int n = nk [ 0 ] , k = nk [ 1 ] ; int [ ] [ ] mat = new int [ n ] [ n ] ; char [ ] [ ] inpMat = new char [ n ] [ ] ; for ( int i = 0 ; i < n ; i ++ ) { inpMat [ i ] = in . readLine ( ) . toCharArray ( ) ; }"
] | [
"import sys def read_input ( input_path = None ) : if input_path is None : f = sys . stdin else : f = open ( input_path , ' r ' ) n , k = map ( int , f . readline ( ) . split ( ) ) field = list ( ) for _ in range ( n ) : field . append ( f . readline ( ) . rstrip ( ) ) return n , k , field NEW_LINE",
"def battleship ( arr , k ) : pts = [ [ 0 ] * len ( arr ) for i in range ( len ( arr ) ) ] ans = [ 0 , 0 ] maxi = 0 for i in range ( len ( arr ) ) : for j in range ( len ( arr ) ) : if arr [ i ] [ j ] == \" . \" : good = 0 count = 0 flag = True s = i temp = [ ] while s >= 0 : if arr [ s ] [ j ] == \" . \" : temp . append ( [ s , j ] ) count += 1 s -= 1 if count == k : for x , y in temp : pts [ x ] [ y ] += 1 if pts [ x ] [ y ] > maxi : maxi = pts [ x ] [ y ] ans = [ x + 1 , y + 1 ] good += 1 break else : break count = 0 s = j temp = [ ] while s >= 0 : if arr [ i ] [ s ] == \" . \" : temp . append ( [ i , s ] ) count += 1 s -= 1 if count == k : for x , y in temp : pts [ x ] [ y ] += 1 if pts [ x ] [ y ] > maxi : maxi = pts [ x ] [ y ] ans = [ x + 1 , y + 1 ] good += 1 break else : break if ans == [ 0 , 0 ] : ans = [ 1 , 1 ] print ( * ans ) return \" \" a , b = map ( int , input ( ) . strip ( ) . split ( ) ) blanck = [ ] for i in range ( a ) : blanck . append ( input ( ) ) print ( battleship ( blanck , b ) ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) f = [ list ( input ( ) ) for _ in range ( n ) ] ans = ( 1 , 1 ) r = [ [ 0 for _ in range ( n ) ] for _ in range ( n ) ] for i in range ( n ) : for j in range ( n ) : if f [ i ] [ j ] == ' # ' : r [ i ] [ j ] = 0 elif i == 0 : r [ i ] [ j ] = 1 else : r [ i ] [ j ] = r [ i - 1 ] [ j ] + 1 c = [ [ 0 for _ in range ( n ) ] for _ in range ( n ) ] for i in range ( n ) : for j in range ( n ) : if f [ i ] [ j ] == ' # ' : c [ i ] [ j ] = 0 elif j == 0 : c [ i ] [ j ] = 1 else : c [ i ] [ j ] = c [ i ] [ j - 1 ] + 1 s = [ [ 0 for _ in range ( n ) ] for _ in range ( n ) ] for i in range ( n ) : for j in range ( n ) : for l in range ( k ) : if i + l < n and k <= r [ i + l ] [ j ] : s [ i ] [ j ] += 1 if j + l < n and k <= c [ i ] [ j + l ] : s [ i ] [ j ] += 1 if s [ ans [ 0 ] - 1 ] [ ans [ 1 ] - 1 ] < s [ i ] [ j ] : ans = ( i + 1 , j + 1 ) print ( ' ▁ ' . join ( map ( str , ans ) ) ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) S = [ input ( ) for i in range ( n ) ] C = [ [ 0 ] * n for i in range ( n ) ] for i in range ( n ) : for j in range ( n ) : if S [ i ] [ j ] == ' # ' : continue if i + k - 1 < n : for di in range ( k ) : ni = i + di if S [ ni ] [ j ] == ' # ' : break else : for di in range ( k ) : ni = i + di C [ ni ] [ j ] += 1 if j + k - 1 < n : for dj in range ( k ) : nj = j + dj if S [ i ] [ nj ] == ' # ' : break else : for dj in range ( k ) : nj = j + dj C [ i ] [ nj ] += 1 NEW_LINE"
] |
codeforces_1453_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = s . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { arr [ j ] = s . nextInt ( ) ; } int max = - 1 ; int index = - 1 ; int value = - 1 ; for ( int j = 1 ; j < n - 1 ; j ++ ) { int mid = ( arr [ j - 1 ] + arr [ j + 1 ] ) / 2 ; int profit = Math . abs ( arr [ j - 1 ] - arr [ j ] ) + Math . abs ( arr [ j + 1 ] - arr [ j ] ) - Math . abs ( arr [ j - 1 ] - mid ) - Math . abs ( arr [ j + 1 ] - mid ) ; if ( profit > max ) { max = profit ; index = j ; value = mid ; } } if ( Math . abs ( arr [ 0 ] - arr [ 1 ] ) > max ) { max = Math . abs ( arr [ 0 ] - arr [ 1 ] ) ; index = 0 ; value = arr [ 1 ] ; } if ( Math . abs ( arr [ n - 2 ] - arr [ n - 1 ] ) > max ) { max = Math . abs ( arr [ n - 2 ] - arr [ n - 1 ] ) ; index = n - 1 ; value = arr [ n - 2 ] ; } arr [ index ] = value ; long count = 0 ; for ( int j = n - 1 ; j > 0 ; j -- ) { count = count + Math . abs ( arr [ j - 1 ] - arr [ j ] ) ; } System . out . println ( count ) ; } } }",
"import java . io . * ; import java . util . * ; public class test {",
"import java . awt . Desktop ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . net . URI ; import java . net . URISyntaxException ; import java . sql . Array ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . LinkedHashMap ; import java . util . LinkedHashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; import java . util . Stack ; import java . util . StringTokenizer ; import java . util . TreeSet ; import java . util . Vector ; public class codechef3 { static class comp implements Comparator < Integer > { @ Override public int compare ( Integer o1 , Integer o2 ) { if ( Math . abs ( o1 ) > Math . abs ( o2 ) ) return - 1 ; else return 1 ; } }"
] | [
"def solve ( ) : n = int ( input ( ) ) NEW_LINE a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 2 , n + 1 ) : ans += abs ( a [ i ] - a [ i - 1 ] ) NEW_LINE mx = max ( abs ( a [ 2 ] - a [ 1 ] ) , abs ( a [ n ] - a [ n - 1 ] ) ) NEW_LINE for i in range ( 2 , n ) : mx = max ( mx , abs ( a [ i ] - a [ i - 1 ] ) + abs ( a [ i + 1 ] - a [ i ] ) - abs ( a [ i + 1 ] - a [ i - 1 ] ) ) NEW_LINE print ( ans - mx ) NEW_LINE t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : solve ( ) NEW_LINE",
"import math , sys , bisect , heapq , osfrom NEW_LINE collections NEW_LINE import defaultdict , Counter , dequefrom NEW_LINE itertools NEW_LINE import groupby , accumulatefrom NEW_LINE functools NEW_LINE import lru_cache NEW_LINE",
"import sysimport NEW_LINE mathfrom NEW_LINE collections NEW_LINE import deque NEW_LINE",
"def main ( ) : from sys import stdin NEW_LINE",
"t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : n = int ( input ( ) ) NEW_LINE a = [ int ( s ) for s in input ( ) . split ( \" ▁ \" ) ] NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , n ) : ans += abs ( a [ i ] - a [ i - 1 ] ) NEW_LINE mx = max ( abs ( a [ 0 ] - a [ 1 ] ) , abs ( a [ n - 1 ] - a [ n - 2 ] ) ) NEW_LINE for i in range ( 1 , n - 1 ) : mx = max ( mx , abs ( a [ i ] - a [ i - 1 ] ) + abs ( a [ i + 1 ] - a [ i ] ) - abs ( a [ i + 1 ] - a [ i - 1 ] ) ) NEW_LINE print ( ans - mx ) NEW_LINE"
] |
codeforces_745_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class B_745 { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] nm = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( nm [ 0 ] ) ; int m = Integer . parseInt ( nm [ 1 ] ) ; int count = 0 , min_x = m + 1 , max_x = - 1 , min_y = n + 1 , max_y = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] row = br . readLine ( ) . split ( \" \" ) ; for ( int j = 0 ; j < m ; j ++ ) { if ( row [ j ] . contentEquals ( \" X \" ) ) { min_x = Math . min ( min_x , j ) ; max_x = Math . max ( max_x , j ) ; min_y = Math . min ( min_y , i ) ; max_y = Math . max ( max_y , i ) ; count ++ ; } } } System . out . println ( ( ( max_x - min_x + 1 ) * ( max_y - min_y + 1 ) == count ) ? \" YES \" : \" NO \" ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int m = Integer . parseInt ( st . nextToken ( ) ) ; String [ ] str = new String [ n ] ; int top , bot , l , r ; top = l = 1000 ; r = bot = 0 ; for ( int i = 0 ; i < n ; i ++ ) { str [ i ] = br . readLine ( ) ; if ( str [ i ] . contains ( \" X \" ) ) { top = Math . min ( top , i ) ; bot = Math . max ( bot , i ) ; } int x = str [ i ] . indexOf ( \" X \" ) ; if ( x != - 1 ) l = Math . min ( l , x ) ; int y = str [ i ] . lastIndexOf ( \" X \" ) ; if ( y != - 1 ) ; r = Math . max ( r , y ) ; } for ( int i = top ; i <= bot ; i ++ ) { if ( str [ i ] . substring ( l , r + 1 ) . contains ( \" . \" ) ) { System . out . println ( \" NO \" ) ; return ; } } System . out . println ( \" YES \" ) ; } }",
"import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; TreeSet < String > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = input . next ( ) ; if ( s . contains ( \" X \" ) ) set . add ( s ) ; } if ( set . size ( ) == 1 ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) throws IOException { return br . readLine ( ) ; } } }"
] | [
"n , m = map ( int , input ( ) . split ( ) ) puz = [ ] for x in range ( n ) : puz . append ( input ( ) ) mix = 502 miy = 502 mx = - 1 my = - 1 numx = 0 for i in range ( n ) : for j in range ( m ) : if ( puz [ i ] [ j ] == \" X \" ) : miy = min ( miy , i ) my = max ( my , i ) mix = min ( mix , j ) mx = max ( mx , j ) numx = numx + 1 if ( ( mx - mix + 1 ) * ( my - miy + 1 ) == numx ) : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"def read ( ) : return [ int ( v ) for v in input ( ) . split ( ) ] def main ( ) : n , m = read ( ) s = [ ] for i in range ( n ) : s . append ( input ( ) ) up , left , down , right = n , m , - 1 , - 1 for i in range ( n ) : for j in range ( m ) : if s [ i ] [ j ] == ' X ' : if i < up : up = i if j < left : left = j if i > down : down = i if j > right : right = j for i in range ( up , down + 1 ) : for j in range ( left , right + 1 ) : if s [ i ] [ j ] != ' X ' : print ( ' NO ' ) return print ( ' YES ' ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) cnt , l , r , u , d = 0 , n , 0 , m , 0 for i in range ( n ) : s = input ( ) for j in range ( m ) : if s [ j ] == ' X ' : cnt += 1 l = min ( l , i ) ; u = min ( u , j ) r = max ( r , i ) ; d = max ( d , j ) print ( ' YES ' if cnt == ( r - l + 1 ) * ( d - u + 1 ) else ' NO ' ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) a = [ ] for i in range ( n ) : a . append ( list ( input ( ) ) ) k = 0 min_r = n - 1 max_r = 0 min_c = m - 1 max_c = 0 for i in range ( n ) : for j in range ( m ) : if a [ i ] [ j ] == ' X ' : k += 1 min_r = min ( min_r , i ) max_r = max ( max_r , i ) min_c = min ( min_c , j ) max_c = max ( max_c , j ) if ( max_r - min_r + 1 ) * ( max_c - min_c + 1 ) == k : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE"
] |
codeforces_1178_A | [
"import java . util . * ; import java . io . * ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) { FastReader fr = new FastReader ( ) ; Scanner sc = new Scanner ( System . in ) ; int n = fr . nextInt ( ) ; int [ ] ar = new int [ n ] ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = fr . nextInt ( ) ; total += ar [ i ] ; } int alice = ar [ 0 ] ; ArrayList < Integer > ans = new ArrayList < > ( ) ; ans . add ( 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( alice > total / 2 ) break ; if ( 2 * ar [ i ] <= ar [ 0 ] ) { alice += ar [ i ] ; ans . add ( i + 1 ) ; } } if ( alice > total / 2 ) { System . out . println ( ans . size ( ) ) ; for ( Integer i : ans ) System . out . print ( i + \" ▁ \" ) ; } else System . out . println ( 0 ) ; } } ",
"import java . util . * ; import java . io . * ; import java . math . * ; public class A { private static long INF = 2000000000L , M = 1000000007 , MM = 998244353 ; private static int N = 0 ; public static void process ( ) throws IOException { int n = sc . nextInt ( ) ; int my = sc . nextInt ( ) ; PriorityQueue < Pair > lis = new PriorityQueue < A . Pair > ( ) ; int sum = my ; for ( int i = 1 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; lis . add ( new Pair ( a , i + 1 ) ) ; sum += a ; } int extra = 0 ; ArrayList < Integer > ans = new ArrayList < Integer > ( ) ; ans . add ( 1 ) ; while ( lis . size ( ) > 1 && lis . peek ( ) . x * 2 <= my ) { Pair e = lis . poll ( ) ; ans . add ( e . y ) ; extra += e . x ; } my += extra ; if ( my * 2 <= sum ) { System . out . println ( 0 ) ; return ; } System . out . println ( ans . size ( ) ) ; for ( int e : ans ) System . out . print ( e + \" ▁ \" ) ; } ",
"import java . lang . * ; import java . util . * ; import java . io . * ; public class test { Scanner sc = new Scanner ( System . in ) ; PrintWriter pr = new PrintWriter ( System . out , true ) ; public static void main ( String ... args ) { test c = new test ( ) ; c . prop ( ) ; } public void prop ( ) { int n , count = 0 , sumt = 0 , sumc = 0 , b ; ArrayList < Integer > al = new ArrayList < Integer > ( ) ; n = sc . nextInt ( ) ; b = sc . nextInt ( ) ; sumt += b ; for ( int i = 1 ; i < n ; ++ i ) { int a = sc . nextInt ( ) ; sumt += a ; if ( b >= 2 * a ) { ++ count ; sumc += a ; al . add ( i + 1 ) ; } } sumt = ( sumt / 2 ) + 1 ; if ( b >= sumt ) pr . println ( 1 + \" ▁ \" + 1 ) ; else if ( ( b + sumc ) >= sumt ) { pr . println ( count + 1 ) ; pr . println ( 1 ) ; for ( int i = 0 ; i < count ; ++ i ) { pr . println ( al . get ( i ) ) ; } } else pr . println ( 0 ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ;",
"import java . util . ArrayList ; import java . util . Scanner ; public class problem53 { public static void main ( String [ ] args ) {"
] | [
"n = int ( input ( ) ) lst = list ( map ( int , input ( ) . split ( ) ) ) ans = [ 1 ] summ2 = lst [ 0 ] for i in range ( 1 , n ) : if lst [ 0 ] >= ( 2 * lst [ i ] ) : ans . append ( i + 1 ) summ2 += lst [ i ] summ = sum ( lst ) NEW_LINE",
"for _ in range ( 1 ) : n = int ( input ( ) ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) count = 1 ref = a [ 0 ] arr = [ 0 ] s = reffor i in range ( n ) : if 2 * a [ i ] <= ref : arr . append ( i ) s += a [ i ] count += 1 if s <= sum ( a ) / 2 : print ( 0 ) else : print ( count ) for item in arr : print ( item + 1 , end = \" ▁ \" ) NEW_LINE",
"n , = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) su = sum ( arr ) ans = [ 1 ] sa = arr [ 0 ] for i in range ( 1 , n ) : if arr [ i ] * 2 <= arr [ 0 ] : ans . append ( i + 1 ) sa += arr [ i ] if sa > su // 2 : print ( len ( ans ) ) print ( * ans ) else : print ( 0 ) NEW_LINE",
"n = int ( input ( ) ) s = [ int ( i ) for i in input ( ) . split ( ) ] a = s [ 0 ] s1 = [ ] s1 += ss1 . pop ( 0 ) s1 . sort ( ) s2 = sum ( s ) s3 = s2 // 2 s4 = as5 = a // 2 s6 = 1 for i in range ( n - 1 ) : if s1 [ i ] > s5 : break else : s4 += s1 [ i ] s6 += 1 if s4 > s3 : print ( s6 ) print ( 1 , end = ' ▁ ' ) s6 -= 1 for i in range ( 1 , n ) : if s6 == 0 : break elif s [ i ] <= s5 : s6 -= 1 print ( i + 1 , end = ' ▁ ' ) print ( ) else : print ( 0 ) NEW_LINE"
] |
codeforces_1473_A | [
"import java . util . * ; import java . lang . String ; import java . lang . Math ; import java . util . Arrays ; public class Capitalization2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t ; t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n , d ; n = sc . nextInt ( ) ; d = sc . nextInt ( ) ; int netres = 0 ; int [ ] a = new int [ n ] ; int [ ] res = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { a [ j ] = sc . nextInt ( ) ; if ( a [ j ] <= d ) { res [ netres ] = a [ j ] ; netres ++ ; } } if ( netres == 0 || netres == 1 ) System . out . println ( \" NO \" ) ; else if ( netres == n ) System . out . println ( \" YES \" ) ; else { Arrays . sort ( res , 0 , netres ) ; if ( ( res [ 0 ] + res [ 1 ] ) <= d ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } } } } ",
"import java . util . * ; public class ReplacingElements { public static void main ( String [ ] args ) {"
] | [
"tests = int ( input ( ) ) for test in range ( tests ) : n , d = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE a . sort ( ) if max ( a ) <= d : NEW_LINE INDENT print ( \" YES \" ) else : NEW_LINE b = [ a [ 0 ] + a [ 1 ] if x >= d else x for x in a ] NEW_LINE DEDENT if max ( b ) <= d : NEW_LINE INDENT print ( \" YES \" ) else : NEW_LINE print ( \" NO \" ) NEW_LINE DEDENT",
"for t in range ( int ( input ( ) ) ) : n , d = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a . sort ( ) NEW_LINE if a [ 0 ] + a [ 1 ] <= d or max ( a ) <= d : NEW_LINE INDENT print ( ' YES ' ) else : NEW_LINE print ( ' NO ' ) NEW_LINE DEDENT",
"t = int ( input ( ) ) NEW_LINE res = [ ] for i in range ( 0 , t ) : n , d = ( int ( x ) for x in input ( ) . strip ( ) . split ( ' ▁ ' ) ) NEW_LINE a1 = [ int ( x ) for x in input ( ) . strip ( ) . split ( ' ▁ ' ) ] a = sorted ( a1 ) NEW_LINE if a [ n - 1 ] <= d : NEW_LINE INDENT res . append ( \" YES \" ) else : NEW_LINE if NEW_LINE DEDENT a [ 1 ] + a [ 0 ] <= d : res . append ( \" YES \" ) else : res . append ( \" NO \" ) NEW_LINE a . clear ( ) NEW_LINE for i in range ( 0 , t ) : print ( res [ i ] ) res . clear ( ) NEW_LINE",
"t = int ( input ( ) ) NEW_LINE res = [ ] for i in range ( 0 , t ) : n , d = ( int ( x ) for x in input ( ) . strip ( ) . split ( ' ▁ ' ) ) NEW_LINE a1 = [ int ( x ) for x in input ( ) . strip ( ) . split ( ' ▁ ' ) ] a = sorted ( a1 ) NEW_LINE if a [ n - 1 ] <= d : NEW_LINE INDENT res . append ( \" YES \" ) else : NEW_LINE if NEW_LINE DEDENT a [ 1 ] + a [ 0 ] <= d : res . append ( \" YES \" ) else : res . append ( \" NO \" ) NEW_LINE for i in range ( 0 , t ) : print ( res [ i ] ) NEW_LINE"
] |
codeforces_1468_A | [
"import java . io . * ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . util . List ; import java . util . * ; public class realfast implements Runnable { private static final int INF = ( int ) 1e9 ; long in = 1000000007 ; long fac [ ] = new long [ 1000001 ] ; long inv [ ] = new long [ 1000001 ] ; public void solve ( ) throws IOException { ",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; void run ( ) { for ( int q = ni ( ) ; q > 0 ; q -- ) { work ( ) ; } out . flush ( ) ; } long mod = 998244353 ; long gcd ( long a , long b ) { return a == 0 ? b : gcd ( b % a , a ) ; } int [ ] S1 ;"
] | [
"import bisect as bsfor NEW_LINE _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if n <= 2 : print ( n ) NEW_LINE continue NEW_LINE stack , m , p = [ a [ 0 ] ] , [ ] , [ ( 1000000 , 0 ) ] NEW_LINE for v in a [ 1 : ] : k = bs . bisect_right ( m , v ) NEW_LINE if k == len ( m ) : stack . append ( v ) NEW_LINE m . append ( min ( stack [ - 1 ] , stack [ - 2 ] ) ) else : stack [ k + 1 ] = m [ k ] = v NEW_LINE while p [ - 1 ] [ 0 ] <= v : vv , kk = p . pop ( ) NEW_LINE m [ kk ] = min ( m [ kk ] , vv ) NEW_LINE if k + 1 < len ( m ) : p . append ( ( v , k + 1 ) ) NEW_LINE print ( len ( stack ) ) NEW_LINE",
"import bisect as bsfor NEW_LINE _ in range ( int ( input ( ) ) ) : n , a = int ( input ( ) ) , list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE stack , m , p = [ a [ 0 ] ] , [ ] , [ ( 1000000 , 0 ) ] NEW_LINE for v in a [ 1 : ] : k = bs . bisect_right ( m , v ) NEW_LINE if k == len ( m ) : stack . append ( v ) NEW_LINE m . append ( min ( stack [ - 1 ] , stack [ - 2 ] ) ) else : stack [ k + 1 ] = m [ k ] = v NEW_LINE while p [ - 1 ] [ 0 ] <= v : vv , kk = p . pop ( ) NEW_LINE m [ kk ] = min ( m [ kk ] , vv ) NEW_LINE if k + 1 < len ( m ) : p . append ( ( v , k + 1 ) ) NEW_LINE print ( len ( stack ) ) NEW_LINE",
"import osimport NEW_LINE sysfrom NEW_LINE io NEW_LINE import BytesIO , IOBase NEW_LINE",
"import bisect as bsfor NEW_LINE _ in range ( int ( input ( ) ) ) : n , a = int ( input ( ) ) , list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE stack , m , p = [ a [ 0 ] ] , [ ] , [ ( 1000000 , 0 ) ] NEW_LINE for v in a [ 1 : ] : k = bs . bisect_right ( m , v ) NEW_LINE if k == len ( m ) : stack . append ( v ) NEW_LINE m . append ( min ( stack [ - 1 ] , stack [ - 2 ] ) ) else : stack [ k + 1 ] = m [ k ] = v NEW_LINE while p [ - 1 ] [ 0 ] <= v : vv , kk = p . pop ( ) NEW_LINE m [ kk ] = min ( m [ kk ] , vv ) NEW_LINE if k + 1 < len ( m ) : p . append ( ( v , k + 1 ) ) NEW_LINE print ( len ( stack ) ) NEW_LINE"
] |
codeforces_126_A | [
"import java . util . * ; import java . io . * ;",
"import java . util . * ; import java . awt . List ; import java . io . * ; import java . lang . * ; import java . lang . reflect . Array ; public class c1 { public static int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; public static void main ( String [ ] args ) { InputReader in = new InputReader ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; ",
"import java . util . Scanner ; public class Hot_Bath { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; double t1 , t2 , y1 = 0 , y2 = 0 , x1 , x2 , t0 , div , sum ; boolean is , is1 ; while ( input . hasNext ( ) ) { div = 1000000000 ; t1 = input . nextDouble ( ) ; t2 = input . nextDouble ( ) ; x1 = input . nextDouble ( ) ; x2 = input . nextDouble ( ) ; t0 = input . nextDouble ( ) ; while ( x1 >= 0 && x2 >= 0 ) { if ( x1 + x2 == 0 ) break ; sum = ( ( t1 * x1 ) + ( t2 * x2 ) ) / ( x1 + x2 ) ; if ( sum < t0 ) { x1 -- ; continue ; } if ( sum < div ) { div = sum ; y1 = x1 ; y2 = x2 ; } x2 -- ; } System . out . println ( ( int ) y1 + \" ▁ \" + ( int ) y2 ) ; } } }"
] | [
"def gcd ( a , b ) : if ( a % b == 0 ) : return b else : return gcd ( b , a % b ) [ t1 , t2 , x1 , x2 , t0 ] = input ( ) . split ( ' ▁ ' ) NEW_LINE",
"import mathdef gcd ( a , b ) : if ( b == 0 ) : return a return gcd ( b , a % b ) l = input ( ) . split ( ) t1 = int ( l [ 0 ] ) t2 = int ( l [ 1 ] ) x1 = int ( l [ 2 ] ) x2 = int ( l [ 3 ] ) t0 = int ( l [ 4 ] ) num1 = t2 - t0num2 = t0 - t1if ( t1 == t2 ) : print ( x1 , x2 ) quit ( ) if ( num1 == 0 ) : print ( 0 , x2 ) quit ( ) if ( num2 == 0 ) : print ( x1 , 0 ) quit ( ) z = num2 / num1maxa = 10 ** 18 ans = ( 0 , 0 ) for i in range ( 1 , x1 + 1 ) : ok = z * i if ( ok > x2 ) : break num1 = i num2 = math . ceil ( ok ) if ( maxa == ( ( num2 / num1 ) - z ) and num2 + num1 > ans [ 0 ] + ans [ 1 ] ) : ans = ( num1 , num2 ) elif ( maxa > ( ( num2 / num1 ) - z ) ) : ans = ( num1 , num2 ) maxa = ( ( num2 / num1 - z ) ) if ( ans == ( 0 , 0 ) ) : ans = ( 0 , x2 ) print ( ans [ 0 ] , ans [ 1 ] ) NEW_LINE"
] |
codeforces_1176_A | [
"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; ",
"import java . io . * ; import java . util . * ; public class thirty_days_100 { public static void main ( String args [ ] ) { FScanner in = new FScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { long n = in . nextLong ( ) ; int c = 0 ; while ( n % 5 == 0 ) { n = ( n / 5 ) * 4 ; c ++ ; } while ( n % 3 == 0 ) { n = ( n / 3 ) * 2 ; c ++ ; } while ( n % 2 == 0 ) { n = ( n / 2 ) ; c ++ ; } if ( n != 1 ) out . println ( \" - 1\" ) ; else out . println ( c ) ; } out . close ( ) ; } static class FScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer sb = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! sb . hasMoreTokens ( ) ) { try { sb = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { } } return sb . nextToken ( ) ; } String nextLine ( ) { try { return br . readLine ( ) ; } catch ( IOException e ) { } return \" \" ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } int [ ] readArray ( int n ) { int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } float nextFloat ( ) { return Float . parseFloat ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }"
] | [
"task = int ( input ( ) ) while ( task > 0 ) : n = int ( input ( ) ) cnt , flag = 0 , 0 while ( n != 1 ) : if ( n % 2 == 0 ) : n = n // 2 cnt += 1 elif ( n % 3 == 0 ) : n = ( 2 * n ) // 3 cnt += 1 elif ( n % 5 == 0 ) : n = ( 4 * n ) // 5 cnt += 1 else : flag = 1 break if ( flag == 1 ) : print ( - 1 ) else : print ( cnt ) task -= 1 NEW_LINE",
"test = int ( input ( ) ) while test != 0 : num = int ( input ( ) ) cnt = 0 while num > 1 : if num % 2 == 0 : num //= 2 elif num % 3 == 0 : num = ( num * 2 ) // 3 elif num % 5 == 0 : num = ( num * 4 ) // 5 else : break cnt += 1 if num == 1 : print ( cnt ) else : print ( - 1 ) test -= 1 NEW_LINE",
"t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) f = 1 ans = 0 while n != 1 : if n % 5 == 0 : n = ( n * 4 ) // 5 ans += 1 elif n % 3 == 0 : n = ( n * 2 ) // 3 ans += 1 elif n % 2 == 0 : n = n // 2 ans += 1 else : f = 0 break if f : print ( ans ) else : print ( - 1 ) NEW_LINE"
] |
codeforces_935_B | [
" import java . util . Scanner ; import java . util . Arrays ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int n , c , x , y , i ; String s ; n = sc . nextInt ( ) ; sc . nextLine ( ) ; s = sc . nextLine ( ) ; x = y = c = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' U ' ) y ++ ; if ( s . charAt ( i ) == ' R ' ) x ++ ; if ( x == y ) { if ( i < n - 1 && s . charAt ( i ) == s . charAt ( i + 1 ) ) c ++ ; } } System . out . println ( c ) ; } catch ( Exception e ) { } } }",
" import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = nextInt ( ) ; } return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } public static void main ( String args [ ] ) { FastScanner f = new FastScanner ( ) ; int n = f . nextInt ( ) ; String str = f . next ( ) ; int x = 0 , y = 0 ; int count = 0 ; int prevX , prevY ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { prevX = x ; prevY = y ; if ( str . charAt ( i ) == ' U ' ) { y ++ ; } else { x ++ ; } if ( x == y && i + 1 < str . length ( ) ) { char next = str . charAt ( i + 1 ) ; int nextX = x , nextY = y ; if ( next == ' U ' ) { nextY ++ ; } else { nextX ++ ; } if ( ( prevX == x - 1 && nextX == x + 1 ) || ( prevY == y - 1 && nextY == y + 1 ) ) { count ++ ; } } } System . out . println ( count ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class main { public static void main ( String [ ] args ) { Scanner k = new Scanner ( System . in ) ; String n = k . next ( ) ; String input = k . next ( ) ; int ans = 0 ; int c = input . charAt ( 0 ) == ' R ' ? 1 : - 1 ; boolean pos = input . charAt ( 0 ) == ' R ' ; for ( int i = 1 ; i < input . length ( ) ; i ++ ) { if ( input . charAt ( i ) == ' R ' ) { c += 1 ; if ( c == 1 && pos == false ) { pos = true ; ans += 1 ; } } else if ( input . charAt ( i ) == ' U ' ) { c -= 1 ; if ( c == - 1 && pos == true ) { pos = false ; ans += 1 ; } } } System . out . println ( ans ) ; } }",
"import java . util . * ; import java . util . stream . * ; public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; scan . nextLine ( ) ; String s = scan . nextLine ( ) ; int result = 0 ; int numU = 0 ; int numR = 0 ; boolean tS = true ; for ( int i = 0 ; i < n ; i ++ ) { char ch = s . charAt ( i ) ; boolean v = ( numU == numR ) ; if ( ch == ' U ' ) { numU ++ ; } else if ( ch == ' R ' ) { numR ++ ; } if ( i == 0 ) { tS = ( numU > 0 ) ; } if ( v && tS && numR > numU ) { tS = false ; result ++ ; } if ( v && ! tS && numR < numU ) { tS = true ; result ++ ; } } System . out . println ( result ) ; } }"
] | [
"n = int ( input ( ) ) s = input ( ) x = 0 y = 0 prev_kingdom = Nonecoin = 0 for step in s : if step == ' U ' : y += 1 else : x += 1 if y > x : curr_kingdom = 2 elif x > y : curr_kingdom = 1 if prev_kingdom and curr_kingdom != prev_kingdom : coin += 1 prev_kingdom = curr_kingdomprint ( coin ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) x , y = 0 , 0 f = 0 ans = 0 for c in s : if c == ' U ' : y += 1 else : x += 1 if x == y : continue else : f1 = 1 if x > y : f1 = 1 else : f1 = - 1 if f1 * f < 0 : ans += 1 f = f1print ( ans ) NEW_LINE",
"n = int ( input ( ) ) S = str ( input ( ) ) cur_y , cur_x = 0 , 0 C = [ ( cur_x , cur_y ) ] for c in S : if c == ' U ' : cur_y += 1 else : cur_x += 1 C . append ( ( cur_y , cur_x ) ) ans = 0 for i , ( cur_x , cur_y ) in enumerate ( C ) : if i == 0 or i == len ( C ) - 1 : continue if cur_x == cur_y : pre_x , pre_y = C [ i - 1 ] pos_x , pos_y = C [ i + 1 ] if pre_x > pre_y and pos_x < pos_y : ans += 1 elif pre_x < pre_y and pos_x > pos_y : ans += 1 print ( ans ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) x , y = 0 , 0 count = 0 for i in range ( len ( s ) - 1 ) : if ( s [ i ] == \" U \" ) : y = y + 1 if ( x == y and s [ i + 1 ] == \" U \" ) : count = count + 1 if ( s [ i ] == \" R \" ) : x = x + 1 if ( x == y and s [ i + 1 ] == \" R \" ) : count = count + 1 print ( count ) NEW_LINE"
] |
codeforces_792_B | [
"import java . io . * ; import java . math . * ; import java . util . * ; public class Main { private static int dx [ ] = { 1 , 0 , - 1 , 0 } ; private static int dy [ ] = { 0 , - 1 , 0 , 1 } ; private static int dx1 [ ] = { 1 , 1 , 0 , - 1 , - 1 , - 1 , 0 , 1 } ; private static int dy1 [ ] = { 0 , - 1 , - 1 , - 1 , 0 , 1 , 1 , 1 } ; private static final long INF = Long . MAX_VALUE ; private static final int INT_INF = Integer . MAX_VALUE ; private static final long NEG_INF = Long . MIN_VALUE ; private static final int NEG_INT_INF = Integer . MIN_VALUE ; private static final double EPSILON = 1e-10 ; private static final long MAX = ( long ) 1e12 ; private static final long MOD = 100000007 ; private static final int MAXN = 5000077 ; private static final int MAXA = 6000 ; private static final int MAXLOG = 22 ; private static final double PI = Math . acos ( - 1 ) ; public static void main ( String [ ] args ) throws IOException { InputReader in = new InputReader ( System . in ) ;",
"import java . io . * ; import java . math . * ; import java . util . * ; public class Main { private static int dx [ ] = { 1 , 0 , - 1 , 0 } ; private static int dy [ ] = { 0 , - 1 , 0 , 1 } ; private static int dx1 [ ] = { 1 , 1 , 0 , - 1 , - 1 , - 1 , 0 , 1 } ; private static int dy1 [ ] = { 0 , - 1 , - 1 , - 1 , 0 , 1 , 1 , 1 } ; private static final long INF = Long . MAX_VALUE ; private static final int INT_INF = Integer . MAX_VALUE ; private static final long NEG_INF = Long . MIN_VALUE ; private static final int NEG_INT_INF = Integer . MIN_VALUE ; private static final double EPSILON = 1e-10 ; private static final long MAX = ( long ) 1e12 ; private static final long MOD = 100000007 ; private static final int MAXN = 5000077 ; private static final int MAXA = 6000 ; private static final int MAXLOG = 22 ; private static final double PI = Math . acos ( - 1 ) ; public static void main ( String [ ] args ) throws IOException { InputReader in = new InputReader ( System . in ) ;",
"import java . util . LinkedList ; import java . util . List ; import java . util . Scanner ; public class B792 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] A = new int [ K ] ; for ( int k = 0 ; k < K ; k ++ ) { A [ k ] = in . nextInt ( ) ; } List < Integer > list = new LinkedList < > ( ) ; for ( int n = 1 ; n <= N ; n ++ ) { list . add ( n ) ; } StringBuilder output = new StringBuilder ( ) ; int pos = 0 ; for ( int k = 0 ; k < K ; k ++ ) { pos += A [ k ] ; pos %= list . size ( ) ; output . append ( list . get ( pos ) ) . append ( ' ▁ ' ) ; list . remove ( pos ) ; } System . out . println ( output ) ; } }"
] | [
"n , k = map ( int , ( input ( ) . split ( ) ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) nums = list ( range ( 1 , n + 1 ) ) leader = 0 elims = [ ] for i in range ( k ) : elim = ( leader + arr [ i ] ) % n elims . append ( nums . pop ( elim ) ) n -= 1 leader = elimprint ( * elims ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) k = list ( map ( int , input ( ) . split ( ) ) ) l , ans = [ ] , [ ] for i in range ( n ) : l . append ( i ) leader = 0 for i in k : ans . append ( l [ ( ( leader + i ) % ( len ( l ) ) ) ] + 1 ) leader = ( ( leader + i ) % ( len ( l ) ) ) ; l . remove ( ans [ - 1 ] - 1 ) leader = leader % len ( l ) print ( * ans , sep = \" ▁ \" ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) lead = 0 lst = [ ] for i in range ( 1 , n + 1 ) : lst . append ( i ) for i in range ( k ) : ind = ( lead + a [ i ] ) % len ( lst ) print ( lst [ ind ] , end = \" ▁ \" ) lead = ind lst [ ind ] = - 1 llst = [ ] for j in range ( len ( lst ) ) : if lst [ j ] != - 1 : llst . append ( lst [ j ] ) lst = list ( llst ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = [ x + 1 for x in range ( n ) ] for m in map ( int , input ( ) . split ( ) ) : m %= len ( a ) print ( a [ m ] , end = \" ▁ \" ) a = a [ m + 1 : ] + a [ : m ] print ( ) NEW_LINE"
] |
codeforces_20_B | [
"import java . util . * ; import java . math . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long A = s . nextLong ( ) , B = s . nextLong ( ) , C = s . nextLong ( ) ; if ( A == 0 && B == 0 ) { System . out . println ( C == 0 ? - 1 : 0 ) ; } else if ( A == 0 ) { System . out . println ( 1 ) ; System . out . println ( 1.0 * - C / B ) ; } else { long discriminant = B * B - 4 * A * C ; if ( discriminant < 0 ) System . out . println ( 0 ) ; else if ( discriminant == 0 ) { System . out . println ( 1 ) ; System . out . println ( 1.0 * - B / ( 2.0 * A ) ) ; } else { System . out . println ( 2 ) ; double num1 = ( - B - Math . sqrt ( discriminant ) ) / ( 2.0 * A ) ; double num2 = ( - B + Math . sqrt ( discriminant ) ) / ( 2.0 * A ) ; if ( num1 < num2 ) { System . out . println ( num1 ) ; System . out . println ( num2 ) ; } else { System . out . println ( num2 ) ; System . out . println ( num1 ) ; } } } s . close ( ) ; } }",
"import java . io . * ; import java . util . * ; public class ProbA { 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 ( in , out ) ; out . close ( ) ; }",
"import java . io . * ; import java . util . * ; import java . lang . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; double a = sc . nextDouble ( ) ; double b = sc . nextDouble ( ) ; double c = sc . nextDouble ( ) ; if ( a == 0 && b != 0 ) { double ans = - ( c / b ) ; System . out . format ( \"1 \\n % .5f \" , ans ) ; } else if ( a == 0 && b == 0 && c == 0 ) { System . out . println ( \" - 1\" ) ; } else if ( a == 0 && b == 0 && c != 0 ) { System . out . println ( \"0\" ) ; } else { double r1 , r2 ; double det = b * b - 4 * a * c ; if ( det > 0 ) { System . out . println ( \"2\" ) ; r1 = ( - b + Math . sqrt ( det ) ) / ( 2 * a ) ; r2 = ( - b - Math . sqrt ( det ) ) / ( 2 * a ) ; double x = ( r1 < r2 ) ? r1 : r2 ; double y = ( r1 > r2 ) ? r1 : r2 ; System . out . format ( \" % .5f \\n % .5f \\n \" , x , y ) ; } else if ( det == 0 ) { r1 = ( - b + Math . sqrt ( det ) ) / ( 2 * a ) ; System . out . format ( \"1 \\n % .5f \" , r1 ) ; } else System . out . println ( \"0\" ) ; } } }"
] | [
"a , b , c = map ( int , input ( ) . split ( ) ) if a == 0 and b == 0 : print ( '0' if c else ' - 1' ) elif a == 0 : print ( '1' , - c / b , sep = ' \\n ' ) else : d , x = b ** 2 - 4 * a * c , 2 * a if d < 0 : print ( '0' ) elif d == 0 : print ( '1' , - b / x , sep = ' \\n ' ) else : r = sorted ( ( ( - b + d ** 0.5 ) / x , ( - b - d ** 0.5 ) / x ) ) print ( '2' , r [ 0 ] , r [ 1 ] , sep = ' \\n ' ) NEW_LINE",
"from math import sqrt a , b , c = map ( int , input ( ) . split ( ) ) if a == b == c == 0 : print ( - 1 ) elif a == b == 0 : print ( 0 ) elif a == 0 : print ( 1 ) print ( - c / b ) else : if b ** 2 == ( 4 * a * c ) : print ( 1 ) print ( ( - b ) / ( 2 * a ) ) elif ( 4 * a * c ) > b ** 2 : print ( 0 ) else : print ( 2 ) x = ( ( - b + sqrt ( b ** 2 - ( 4 * a * c ) ) ) / ( 2 * a ) ) y = ( - b - sqrt ( b ** 2 - ( 4 * a * c ) ) ) / ( 2 * a ) print ( ' { 0 : . 16f } ' . format ( min ( x , y ) ) ) print ( ' { 0 : . 16f } ' . format ( max ( x , y ) ) ) NEW_LINE",
"a , b , c = map ( int , input ( ) . split ( ) ) def quadroot ( a , b , c ) : roots = [ ] negb = - 1 * b discriminant = ( b ** 2 - 4 * a * c ) ** ( 1 / 2 ) bottom = 2 * a roots . append ( format ( ( negb - discriminant ) / ( bottom ) , \" . 6f \" ) ) roots . append ( format ( ( negb + discriminant ) / ( bottom ) , \" . 6f \" ) ) return roots if a == 0 and b == 0 and c == 0 : print ( - 1 ) exit ( ) if a == b and b == 0 and c != 0 or ( b ** 2 - 4 * a * c ) < 0 : print ( 0 ) exit ( ) ans = [ ] if a == 0 : ans . append ( ( - 1 * c ) / b ) else : ans = quadroot ( a , b , c ) for root in range ( len ( ans ) ) : ans [ root ] = float ( ans [ root ] ) ans1 = list ( set ( sorted ( ans ) ) ) print ( len ( ans1 ) ) for i in ans1 : print ( ( f ' { i : .6f } ' ) ) NEW_LINE",
"from math import sqrt a , b , c = map ( int , input ( ) . split ( ) ) det = b * b - 4 * a * cif a == 0 : if b == 0 and c == 0 : print ( - 1 ) elif b == 0 : print ( 0 ) else : print ( 1 ) p = round ( - c / b , 5 ) print ( p ) elif det < 0 : print ( 0 ) elif det == 0 : print ( 1 ) p = round ( - b / ( a * 2 ) , 5 ) print ( p ) else : print ( 2 ) neu = - b + sqrt ( det ) p = round ( neu / ( 2 * a ) , 5 ) neu = - b - sqrt ( det ) q = round ( neu / ( 2 * a ) , 5 ) if p > q : p , q = q , p print ( p ) print ( q ) ''' And ▁ the ▁ shadow ▁ of ▁ the ▁ dayWill ▁ embrace ▁ the ▁ word ▁ in ▁ greyAnd ▁ the ▁ sun ▁ will ▁ set ▁ for ▁ you ''' NEW_LINE"
] |
codeforces_1042_A | [
"import java . util . Scanner ; public class AlgoDesign { public static void main ( String args [ ] ) { int n , m , max = 0 ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] > max ) { max = a [ i ] ; } } int seatsToFill = m ; for ( int i = 0 ; i < n ; i ++ ) { if ( seatsToFill <= 0 ) { seatsToFill = 0 ; break ; } if ( a [ i ] < max ) { seatsToFill = seatsToFill - ( max - a [ i ] ) ; } } int min = 0 ; if ( seatsToFill > 0 ) { min = ( seatsToFill / n ) ; min = seatsToFill % n > 0 ? min + 1 : min ; } System . out . print ( ( max + min ) + \" ▁ \" + ( max + m ) ) ; } }",
"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 ; FastReader in = new FastReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABenches solver = new ABenches ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABenches { public void solve ( int testNumber , FastReader in , PrintWriter out ) { int n = in . nextInt ( ) , m = in . nextInt ( ) ; int a [ ] = in . readArray ( n ) ; func . sort ( a ) ; int sum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { sum += a [ n - 1 ] - a [ i ] ; } if ( m <= sum ) { out . println ( a [ n - 1 ] + \" ▁ \" + ( a [ n - 1 ] + m ) ) ; return ; } int max = a [ n - 1 ] + m ; m -= sum ; m = ( m + n - 1 ) / n ; out . println ( ( a [ n - 1 ] + m ) + \" ▁ \" + ( max ) ) ; } } static class func { public static void sort ( int [ ] arr ) {",
"import java . io . * ; import java . util . * ; public class Solution {"
] | [
"n = int ( input ( ) ) m = int ( input ( ) ) a = [ ] for i in range ( n ) : a . append ( int ( input ( ) ) ) k1 = max ( a ) kmax = k1 + m aa = m / nk2 = sum ( a ) + m + n - 1 kmin = k2 // n print ( max ( kmin , k1 ) , kmax ) NEW_LINE",
"n = int ( input ( ) ) m = int ( input ( ) ) A = [ ] for _ in range ( 0 , n ) : A . append ( int ( input ( ) ) ) print ( max ( max ( A ) , ( sum ( A ) + m + n - 1 ) // n ) , max ( A ) + m ) NEW_LINE",
"from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect NEW_LINE",
"n = int ( input ( ) ) m = int ( input ( ) ) NEW_LINE"
] |
codeforces_1230_B | [
" import java . util . * ; public class Practise { ",
"import java . util . Scanner ; public class _0642AniaandMinimizing { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; if ( n == 1 && k == 1 ) { System . out . println ( 0 ) ; return ; } if ( k == 0 ) { System . out . println ( s ) ; return ; } StringBuilder str = new StringBuilder ( s ) ; for ( int i = 0 ; i < str . length ( ) && k > 0 ; i ++ ) { if ( i == 0 ) { if ( str . charAt ( i ) != '1' ) { str . setCharAt ( i , '1' ) ; k -- ; } else { continue ; } } else { if ( str . charAt ( i ) == '0' ) { continue ; } else { str . setCharAt ( i , '0' ) ; k -- ; } } } System . out . println ( str . toString ( ) ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] ar = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = s . charAt ( i ) ; } if ( n == k ) { if ( n == 1 ) System . out . println ( 0 ) ; else { System . out . print ( 1 ) ; for ( int i = 1 ; i < n ; i ++ ) System . out . print ( 0 ) ; } } else { for ( int i = 0 ; i < n && k > 0 ; i ++ ) { if ( i == 0 ) { if ( ar [ i ] != '1' ) { k -- ; ar [ i ] = '1' ; } } else { if ( ar [ i ] != '0' ) { k -- ; ar [ i ] = '0' ; } } } for ( char i : ar ) System . out . print ( i ) ; } } }"
] | [
"def ans ( n , k , s ) : if k == 0 : return ' ' . join ( s ) elif k != 0 and n == 1 : return '0' for i in range ( n ) : if k == 0 : break if i == 0 and s [ i ] != '1' : s [ i ] = '1' k -= 1 elif i != 0 and s [ i ] != '0' : s [ i ] = '0' k -= 1 return ' ' . join ( s ) n , k = map ( int , input ( ) . split ( ' ▁ ' ) ) s = list ( input ( ) ) print ( ans ( n , k , s ) ) NEW_LINE",
"def tostring ( s ) : str1 = ' ' return str1 . join ( s ) vet = input ( ) . split ( ) s = list ( input ( ) ) n = int ( vet [ 0 ] ) k = int ( vet [ 1 ] ) if ( n == 1 and k ) : print ( 0 ) else : if ( s [ 0 ] > '1' and k ) : s [ 0 ] = '1' k -= 1 for i in range ( 1 , len ( s ) ) : if ( s [ i ] > '0' and k > 0 ) : s [ i ] = '0' k -= 1 print ( tostring ( s ) ) NEW_LINE",
"n_size , k = map ( int , input ( ) . split ( ) ) number = input ( ) if n_size == 1 : if number == '0' : print ( '0' ) else : if k >= 1 : print ( '0' ) else : print ( number ) else : for i in range ( len ( number ) ) : if ( k > 0 ) : if ( i == 0 and number [ i ] == '1' ) : print ( '1' , end = ' ' ) continue elif ( i == 0 ) : print ( '1' , end = ' ' ) k -= 1 continue elif ( number [ i ] == '0' ) : print ( number [ i ] , end = ' ' ) continue else : print ( '0' , end = ' ' ) k -= 1 continue print ( number [ i ] , end = ' ' ) NEW_LINE",
"try : n , k = map ( int , input ( ) . split ( ) ) s = input ( ) j = 0 z = \" \" if k == 0 : print ( s ) elif n == 1 and not k == 0 : print ( 0 ) else : for i in range ( n ) : if i == 0 : if not s [ i ] == \"1\" : print ( 1 , end = \" \" ) j += 1 else : print ( 1 , end = \" \" ) elif j >= k : print ( s [ i ] , end = \" \" ) else : if not s [ i ] == \"0\" : print ( 0 , end = \" \" ) j += 1 else : print ( 0 , end = \" \" ) NEW_LINE",
"if __name__ == \" _ _ main _ _ \" : n , k = map ( int , input ( ) . split ( ) ) st = input ( ) c = 0 ans = \" \" if k == 0 : ans = ans + st elif n == 1 : ans = ans + '0' else : for i in range ( n ) : if c < k : if i == 0 and st [ i ] != '1' : ans = ans + '1' c = c + 1 elif st [ i ] != '0' and i != 0 : ans = ans + '0' c = c + 1 else : ans = ans + st [ i ] else : ans = ans + st [ i ] print ( ans ) NEW_LINE"
] |
codeforces_79_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . lang . reflect . Array ; import java . nio . Buffer ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Set ; import java . util . StringTokenizer ; public class ColoredFields { public static int floorSearch ( int arr [ ] , int low , int high , int x ) { if ( low > high ) return - 1 ; ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . lang . reflect . Array ; import java . nio . Buffer ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Set ; import java . util . StringTokenizer ; public class ColoredFields { public static int floorSearch ( int arr [ ] , int low , int high , int x ) { if ( low > high ) return - 1 ; ",
"import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ; public class B79 { static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) { int tc = 1 ;"
] | [
"n , m , k , t = map ( int , input ( ) . split ( ) ) waste = [ ] for _ in range ( k ) : i , j = map ( int , input ( ) . split ( ) ) NEW_LINE waste += [ ( i - 1 ) * m + ( j - 1 ) ] NEW_LINE waste . sort ( ) NEW_LINE put = [ \" Carrots \" , \" Kiwis \" , \" Grapes \" ] for _ in range ( t ) : i , j = map ( int , input ( ) . split ( ) ) NEW_LINE numc = ( i - 1 ) * m + ( j - 1 ) NEW_LINE c = 0 NEW_LINE for x in waste : NEW_LINE",
"n , m , k , t = map ( int , input ( ) . split ( \" ▁ \" ) ) NEW_LINE",
"n , m , k , t = map ( int , input ( ) . split ( ) ) NEW_LINE waste = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( k ) ] NEW_LINE",
"def get_crop ( n , m , waste , i , j ) : curr = ( m * i ) + j NEW_LINE if curr in waste : return \" Waste \" NEW_LINE new = curr NEW_LINE i = 0 NEW_LINE while i < len ( waste ) and waste [ i ] < curr : new -= 1 NEW_LINE i += 1 NEW_LINE if new % 3 == 0 : NEW_LINE INDENT return \" Carrots \" elif new % 3 == 1 : NEW_LINE return \" Kiwis \" else : NEW_LINE return \" Grapes \" s = input ( ) . split ( ) NEW_LINE DEDENT n , m , k , t = int ( s [ 0 ] ) , int ( s [ 1 ] ) , int ( s [ 2 ] ) , int ( s [ 3 ] ) NEW_LINE waste = [ ] NEW_LINE for i in range ( k ) : s = input ( ) . split ( ) NEW_LINE waste . append ( ( m * ( int ( s [ 0 ] ) - 1 ) ) + int ( s [ 1 ] ) - 1 ) NEW_LINE"
] |
codeforces_501_A | [
"import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {",
"import java . util . * ; public class Contest { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; sc . close ( ) ; int misha = Math . max ( 3 * a / 10 , a - ( a / 250 ) * c ) ; int vasya = Math . max ( 3 * b / 10 , b - ( b / 250 ) * d ) ; if ( misha > vasya ) System . out . println ( \" Misha \" ) ; else if ( vasya > misha ) System . out . println ( \" Vasya \" ) ; else System . out . println ( \" Tie \" ) ; } }",
"import java . io . * ; import java . util . * ; import java . text . * ; import java . math . * ; import java . util . regex . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int a = s . nextInt ( ) , b = s . nextInt ( ) , c = s . nextInt ( ) , d = s . nextInt ( ) ; double x , y , n1 , n2 ; String temp = \" \" ; x = 3 * a / 10 ; y = a - ( ( a / 250 ) * c ) ; n1 = Math . max ( x , y ) ; x = 3 * b / 10 ; y = b - ( ( b / 250 ) * d ) ; n2 = Math . max ( x , y ) ; if ( n1 > n2 ) temp = \" Misha \" ; else if ( n1 < n2 ) temp = \" Vasya \" ; else temp = \" Tie \" ; System . out . println ( temp ) ; } }",
"import java . util . * ; public class Absolutezero { public static void main ( String [ ] args ) {",
"import java . util . * ; public class Contest { public static void main ( String [ ] args ) {"
] | [
"a , b , c , d = map ( int , input ( ) . split ( ) ) misha = max ( 3 * a / 10 , a - a / 250 * c ) vasya = max ( 3 * b / 10 , b - b / 250 * d ) if misha > vasya : print ( \" Misha \" ) elif vasya > misha : print ( \" Vasya \" ) else : print ( \" Tie \" ) NEW_LINE",
"a , b , c , d = input ( ) . split ( ) a , b , c , d = int ( a ) , int ( b ) , int ( c ) , int ( d ) def score ( p , t ) : sco = 0 sco1 = 3 * p / 10 sco2 = p - ( p * t / 250 ) if sco1 > sco2 : sco = sco1 return sco else : sco = sco2 return scosco_misha = score ( a , c ) sco_vasya = score ( b , d ) if sco_misha > sco_vasya : print ( \" Misha \" ) elif sco_misha < sco_vasya : print ( \" Vasya \" ) else : print ( \" Tie \" ) NEW_LINE",
"import mathdef solve ( a , b , c , d ) : m = max ( 3 * a // 10 , a - ( ( a // 250 ) * c ) ) v = max ( 3 * b // 10 , b - ( ( b // 250 ) * d ) ) if m > v : return ' Misha ' if v > m : return ' Vasya ' return ' Tie ' def main ( ) : NEW_LINE",
"a , b , c , d = map ( int , input ( ) . split ( ) ) misha = max ( 3 * a / 10 , a - ( a / 250 ) * c ) vasya = max ( 3 * b / 10 , b - ( b / 250 ) * d ) if vasya > misha : print ( \" Vasya \" ) if misha > vasya : print ( \" Misha \" ) if misha == vasya : print ( \" Tie \" ) NEW_LINE",
"a , b , c , d = map ( int , input ( ) . split ( ) ) x = max ( 3 * a // 10 , a - ( a // 250 ) * c ) y = max ( 3 * b // 10 , b - ( b // 250 ) * d ) if x > y : print ( ' Misha ' ) elif x < y : print ( ' Vasya ' ) else : print ( ' Tie ' ) NEW_LINE"
] |
codeforces_725_A | [
"import java . util . * ; import java . lang . * ; import java . io . * ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) , count = 0 ; String st = s . next ( ) ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { if ( st . charAt ( i ) == ' < ' ) count ++ ; else break ; } for ( int i = st . length ( ) - 1 ; i >= 0 ; i -- ) { if ( st . charAt ( i ) == ' > ' ) count ++ ; else break ; } System . out . println ( count ) ; } }",
"import java . io . * ; import java . math . * ; import java . util . * ; public class JumpingBall { public static void main ( String [ ] args ) { FastScanner I = new FastScanner ( ) ;",
"import java . io . * ; import java . math . * ; import java . util . * ; public class JumpingBall { public static void main ( String [ ] args ) { FastScanner I = new FastScanner ( ) ;",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner capt = new Scanner ( System . in ) ; int n = capt . nextInt ( ) ; String x = capt . next ( ) ; System . out . println ( solution ( x ) ) ; } static int solution ( String x ) { int count = 0 ; if ( x . charAt ( 0 ) == ' < ' ) { int a = x . indexOf ( ' > ' ) ; if ( a == - 1 ) { return x . length ( ) ; } else count += x . indexOf ( ' > ' ) ; } if ( x . charAt ( x . length ( ) - 1 ) == ' > ' ) { for ( int i = x . length ( ) - 1 ; i >= 0 ; i -- ) { if ( x . charAt ( i ) == ' < ' ) break ; else count ++ ; } } return count ; } }",
"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 ) ; AJumpingBall solver = new AJumpingBall ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AJumpingBall { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; char [ ] k = in . next ( ) . toCharArray ( ) ; int clef = 0 , f = 0 , m = 0 , cright = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( k [ i ] == ' < ' && f == 0 ) { clef ++ ; } else { f = 1 ; } if ( k [ n - i - 1 ] == ' > ' && m == 0 ) { cright ++ ; } else { m = 1 ; } } out . println ( clef + cright ) ; } } 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 ( ) ) ; } } } "
] | [
"n = int ( input ( ) ) s = input ( ) ans = 0 for i in s : if i == ' < ' : ans += 1 else : breaks = s [ : : - 1 ] for i in s : if i == ' > ' : ans += 1 else : break print ( ans ) NEW_LINE",
"if __name__ == \" _ _ main _ _ \" : nr_of_bumpers = int ( input ( ) ) bumper_types = list ( input ( ) ) fall_bumpers = 0 bumper_index = 0 while bumper_index < nr_of_bumpers and bumper_types [ bumper_index ] == ' < ' : fall_bumpers += 1 bumper_index += 1 bumper_index = nr_of_bumpers - 1 while bumper_index >= 0 and bumper_types [ bumper_index ] == ' > ' : fall_bumpers += 1 bumper_index -= 1 print ( fall_bumpers ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) s = list ( s ) count = 0 for i in range ( len ( s ) ) : if ( s [ i ] == ' < ' ) : count += 1 else : break for i in range ( len ( s ) - 1 , - 1 , - 1 ) : if ( s [ i ] == ' > ' ) : count += 1 else : break print ( count ) NEW_LINE",
"import sys , mathsys . setrecursionlimit ( 10 ** 8 ) ''' def ▁ fun ( ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 16 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( 4 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ i & (1 < < j ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( j , end = ' ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ) import ▁ binarytreefrom ▁ collections ▁ import ▁ dequebst ▁ = ▁ binarytree . tree ( height = 4 , is _ perfect = True ) print ( bst ) def ▁ s ( bst ) : ▁ ▁ ▁ ▁ if ▁ bst : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ bst . left , bst . right ▁ = ▁ bst . right , bst . left ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . right ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . left ) s ( bst ) print ( bst ) ''' n = int ( input ( ) ) s = input ( ) x = 0j , k = 0 , n - 1 for i in range ( n ) : if j <= k and s [ j ] == ' < ' : x += 1 j += 1 elif j <= k and s [ k ] == ' > ' : x += 1 k -= 1 print ( x ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) pas = 0 for i in s : if i == ' > ' : break else : pas += 1 for i in range ( n - 1 , - 1 , - 1 ) : if s [ i ] == ' < ' : break else : pas += 1 print ( pas ) NEW_LINE"
] |
codeforces_645_A | [
"import java . io . * ; import java . util . * ; public class Prob645A { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] l1 = br . readLine ( ) . split ( \" \" ) ; String [ ] l2 = br . readLine ( ) . split ( \" \" ) ; String [ ] l3 = br . readLine ( ) . split ( \" \" ) ; String [ ] l4 = br . readLine ( ) . split ( \" \" ) ; String s1 = \" \" ; if ( ! l1 [ 0 ] . equals ( \" X \" ) ) s1 += l1 [ 0 ] ; if ( ! l1 [ 1 ] . equals ( \" X \" ) ) s1 += l1 [ 1 ] ; if ( ! l2 [ 1 ] . equals ( \" X \" ) ) s1 += l2 [ 1 ] ; if ( ! l2 [ 0 ] . equals ( \" X \" ) ) s1 += l2 [ 0 ] ; String s2 = \" \" ; if ( ! l3 [ 0 ] . equals ( \" X \" ) ) s2 += l3 [ 0 ] ; if ( ! l3 [ 1 ] . equals ( \" X \" ) ) s2 += l3 [ 1 ] ; if ( ! l4 [ 1 ] . equals ( \" X \" ) ) s2 += l4 [ 1 ] ; if ( ! l4 [ 0 ] . equals ( \" X \" ) ) s2 += l4 [ 0 ] ; if ( ( s1 + s1 ) . contains ( s2 ) ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line1 = f . readLine ( ) ; String line2 = f . readLine ( ) ; String line3 = f . readLine ( ) ; String line4 = f . readLine ( ) ; String input1 = ( line1 + line2 . charAt ( 1 ) + line2 . charAt ( 0 ) ) . replace ( \" X \" , \" \" ) ; String input2 = ( line3 + line4 . charAt ( 1 ) + line4 . charAt ( 0 ) ) . replace ( \" X \" , \" \" ) ; if ( ( input2 + input2 ) . contains ( input1 ) ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } }",
"import java . io . * ; public class Main { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; OutputStream output = System . out ; PrintWriter pr = new PrintWriter ( output ) ; try { String line1 = br . readLine ( ) ; StringBuilder sb = new StringBuilder ( br . readLine ( ) ) ; line1 += sb . reverse ( ) ; line1 = line1 . replace ( \" X \" , \" \" ) ; String line2 = br . readLine ( ) ; sb = new StringBuilder ( br . readLine ( ) ) ; line2 += sb . reverse ( ) ; line2 = line2 . replace ( \" X \" , \" \" ) ; pr . println ( ( line1 + line1 ) . contains ( line2 ) ? \" YES \" : \" NO \" ) ; pr . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } }",
"import java . util . * ; import java . io . * ; public class AmityAssessment { static BufferedReader br ; static StringTokenizer tokenizer ; public static void main ( String [ ] args ) throws Exception { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = \" \" ; String s1 = \" \" ; s += next ( ) ; String t = next ( ) ; s += t . charAt ( 1 ) + \" \" + t . charAt ( 0 ) ; s1 += next ( ) ; t = next ( ) ; s1 += t . charAt ( 1 ) + \" \" + t . charAt ( 0 ) ; s = removeX ( s ) ; s1 = removeX ( s1 ) ; int start = 0 ; int start2 = 0 ;",
"import java . util . Scanner ; public class A645 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; StringBuilder first = new StringBuilder ( ) ; char [ ] S = in . next ( ) . toCharArray ( ) ; if ( S [ 0 ] != ' X ' ) first . append ( S [ 0 ] ) ; if ( S [ 1 ] != ' X ' ) first . append ( S [ 1 ] ) ; S = in . next ( ) . toCharArray ( ) ; if ( S [ 1 ] != ' X ' ) first . append ( S [ 1 ] ) ; if ( S [ 0 ] != ' X ' ) first . append ( S [ 0 ] ) ; StringBuilder second = new StringBuilder ( ) ; S = in . next ( ) . toCharArray ( ) ; if ( S [ 0 ] != ' X ' ) second . append ( S [ 0 ] ) ; if ( S [ 1 ] != ' X ' ) second . append ( S [ 1 ] ) ; S = in . next ( ) . toCharArray ( ) ; if ( S [ 1 ] != ' X ' ) second . append ( S [ 1 ] ) ; if ( S [ 0 ] != ' X ' ) second . append ( S [ 0 ] ) ; boolean match = false ; for ( int shift = 0 ; shift < 3 ; shift ++ ) { boolean ok = true ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( first . charAt ( i ) != second . charAt ( ( i + shift ) % 3 ) ) { ok = false ; } } if ( ok ) { match = true ; } } System . out . println ( match ? \" YES \" : \" NO \" ) ; } }"
] | [
"s1 = input ( ) s2 = input ( ) s3 = input ( ) s4 = input ( ) s11 = s1 + s2 [ : : - 1 ] s22 = s3 + s4 [ : : - 1 ] k1 = \" \" k2 = \" \" for i in range ( 4 ) : if s11 [ i ] != ' X ' : k1 += s11 [ i ] for i in range ( 4 ) : if s22 [ i ] != ' X ' : k2 += s22 [ i ] k1 = k1 * 3 NEW_LINE",
"a = input ( ) + input ( ) a = a . replace ( ' ' , ' ▁ ' ) . split ( ) b = input ( ) + input ( ) b = b . replace ( ' ' , ' ▁ ' ) . split ( ) for _ in \" ▁ \" * 16 : k = a . index ( ' X ' ) if k == 2 : a [ 2 ] , a [ 3 ] = a [ 3 ] , a [ 2 ] elif k == 0 : a [ 0 ] , a [ 2 ] = a [ 2 ] , a [ 0 ] elif k == 3 : a [ 3 ] , a [ 1 ] = a [ 1 ] , a [ 3 ] else : a [ 1 ] , a [ 0 ] = a [ 0 ] , a [ 1 ] if a == b : print ( \" YES \" ) ; breakelse : print ( ' NO ' ) NEW_LINE",
"a = input ( ) + input ( ) [ : : - 1 ] b = input ( ) + input ( ) [ : : - 1 ] a = a . replace ( \" X \" , \" \" ) b = b . replace ( \" X \" , \" \" ) if ( a + a ) . find ( b ) + 1 : print ( \" YES \" ) else : print ( ' NO ' ) NEW_LINE",
"l = [ ] for i in range ( 2 ) : r , o = input ( ) , input ( ) r = list ( o [ 0 ] + r + o [ 1 ] ) r . remove ( \" X \" ) ; while r [ 0 ] != \" A \" : r [ 0 ] , r [ 1 ] , r [ 2 ] = r [ 2 ] , r [ 0 ] , r [ 1 ] l . append ( \" \" . join ( r ) ) print ( \" YES \" if l [ 0 ] == l [ 1 ] else \" NO \" ) NEW_LINE",
"def find_order ( A , B ) : d = dict ( ) i = 0 if A [ 0 ] != ' X ' : d [ i ] = A [ 0 ] i += 1 if A [ 1 ] != ' X ' : d [ i ] = A [ 1 ] i += 1 if B [ 1 ] != ' X ' : d [ i ] = B [ 1 ] i += 1 if B [ 0 ] != ' X ' : d [ i ] = B [ 0 ] i += 1 return d a = input ( ) b = input ( ) c = input ( ) d = input ( ) m = find_order ( a , b ) n = find_order ( c , d ) m [ 3 ] = m [ 0 ] m [ 4 ] = m [ 1 ] if m [ 0 ] == n [ 0 ] : if m [ 1 ] == n [ 1 ] and m [ 2 ] == n [ 2 ] : print ( ' YES ' ) else : print ( ' NO ' ) elif m [ 1 ] == n [ 0 ] : if m [ 2 ] == n [ 1 ] and m [ 3 ] == n [ 2 ] : print ( ' YES ' ) else : print ( ' NO ' ) elif m [ 2 ] == n [ 0 ] : if m [ 3 ] == n [ 1 ] and m [ 4 ] == n [ 2 ] : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE"
] |
codeforces_1364_B | [
" import java . io . * ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main1 { public static void main ( String [ ] args ) { try { FastScanner in = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { int n = in . nextInt ( ) ; int A [ ] = in . readArray ( n ) ; StringBuilder sb = new StringBuilder ( ) ; int ct = 2 ; sb . append ( A [ 0 ] + \" ▁ \" ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( ( A [ i ] > A [ i - 1 ] && A [ i ] > A [ i + 1 ] ) || ( A [ i ] < A [ i - 1 ] && A [ i ] < A [ i + 1 ] ) ) { ct ++ ; sb . append ( A [ i ] + \" ▁ \" ) ; } } sb . append ( A [ n - 1 ] ) ; System . out . println ( ct ) ; System . out . println ( sb ) ; } out . flush ( ) ; out . close ( ) ; } catch ( Exception e ) { return ; } } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = true ; long [ ] res ; void solve ( FastScanner in , PrintWriter out , int testNumber ) { n = in . nextInt ( ) ; int [ ] p = in . nextArray ( n ) ; int l = 0 ; int r = n - 1 ; boolean [ ] skip = new boolean [ n ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) { int wh = Math . abs ( p [ i - 1 ] - p [ i ] ) + Math . abs ( p [ i ] - p [ i + 1 ] ) ; int skipwh = Math . abs ( p [ i - 1 ] - p [ i + 1 ] ) ; if ( skipwh >= wh ) { skip [ i ] = true ; } } List < Integer > answer = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! skip [ i ] ) { answer . add ( p [ i ] ) ; } } out . println ( answer . size ( ) ) ; for ( int x : answer ) { out . print ( x + \" ▁ \" ) ; } out . println ( ) ; } ",
"import java . util . * ; public class _1364B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Vector < Integer > v = new Vector < > ( ) ; v . add ( arr [ 0 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { int first = arr [ i ] - arr [ i - 1 ] ; int second = arr [ i - 1 ] - arr [ i - 2 ] ; if ( first > 0 && second < 0 || first < 0 && second > 0 ) { v . add ( arr [ i - 1 ] ) ; } } v . add ( arr [ n - 1 ] ) ; System . out . println ( v . size ( ) ) ; for ( Integer i : v ) System . out . print ( i + \" ▁ \" ) ; System . out . println ( ) ; } } }"
] | [
"for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) l = [ ] l . append ( a [ 0 ] ) lo , hi = 0 , 1 temp = a [ 0 ] while hi < n : while hi < n and temp < a [ hi ] : temp = a [ hi ] hi += 1 if l [ - 1 ] != a [ hi - 1 ] : l . append ( a [ hi - 1 ] ) while hi < n and temp > a [ hi ] : temp = a [ hi ] hi += 1 if l [ - 1 ] != a [ hi - 1 ] : l . append ( a [ hi - 1 ] ) print ( len ( l ) ) print ( * l ) NEW_LINE",
"t = int ( input ( ) ) for test in range ( 0 , t ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans = [ a [ 0 ] ] for i in range ( 1 , n - 1 ) : if ( a [ i ] > a [ i - 1 ] and a [ i ] > a [ i + 1 ] ) : ans . append ( a [ i ] ) if ( a [ i ] < a [ i - 1 ] and a [ i ] < a [ i + 1 ] ) : ans . append ( a [ i ] ) ans . append ( a [ n - 1 ] ) print ( len ( ans ) ) print ( * ans , sep = \" ▁ \" ) NEW_LINE",
"t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] ans = [ ] for i in range ( n ) : if ( i == 0 or i == n - 1 or ( a [ i - 1 ] < a [ i ] ) != ( a [ i ] < a [ i + 1 ] ) ) : ans . append ( a [ i ] ) print ( len ( ans ) ) print ( * ans ) NEW_LINE",
"from sys import stdin , stdoutfrom math import floor , gcd , fabs , factorial , fmod , sqrt , inf , logfrom collections import defaultdict as dd , dequefrom heapq import merge , heapify , heappop , heappush , nsmallestfrom bisect import bisect_left as bl , bisect_right as br , bisect mod = pow ( 10 , 9 ) + 7 mod2 = 998244353 def inp ( ) : return stdin . readline ( ) . strip ( ) def iinp ( ) : return int ( inp ( ) ) def out ( var , end = \" \\n \" ) : stdout . write ( str ( var ) + \" \\n \" ) def outa ( * var , end = \" \\n \" ) : stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) def lmp ( ) : return list ( mp ( ) ) def mp ( ) : return map ( int , inp ( ) . split ( ) ) def smp ( ) : return map ( str , inp ( ) . split ( ) ) def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] def l2d ( n , m , val = 0 ) : return [ l1d ( m , val ) for j in range ( n ) ] def remadd ( x , y ) : return 1 if x % y else 0 def ceil ( a , b ) : return ( a + b - 1 ) // b def isprime ( x ) : if x <= 1 : return False if x in ( 2 , 3 ) : return True if x % 2 == 0 : return False for i in range ( 3 , int ( sqrt ( x ) ) + 1 , 2 ) : if x % i == 0 : return False return True for _ in range ( int ( inp ( ) ) ) : n = iinp ( ) arr = lmp ( ) ml = [ arr [ 0 ] ] for i in range ( 1 , n - 1 ) : if arr [ i - 1 ] < arr [ i ] > arr [ i + 1 ] or arr [ i - 1 ] > arr [ i ] < arr [ i + 1 ] : ml . append ( arr [ i ] ) ml . append ( arr [ - 1 ] ) print ( len ( ml ) ) print ( * ml ) NEW_LINE"
] |
codeforces_1121_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashMap ; import java . util . StringTokenizer ; public class Mike_Child { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int n = in . nextInt ( ) ; long arr [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = in . nextLong ( ) ; } HashMap < Long , Integer > hs = new HashMap < > ( ) ; int max = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { long s = arr [ i ] + arr [ j ] ; if ( hs . containsKey ( s ) ) { int get = hs . get ( s ) ; ++ get ; max = Math . max ( max , get ) ; hs . put ( s , get ) ; } else { hs . put ( s , 1 ) ; } } } System . out . println ( max ) ; } }",
"import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ; public class file { ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ;",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n + 5 ] ; int [ ] count = new int [ ( int ) 2e5 + 10 ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) count [ arr [ i ] + arr [ j ] ] ++ ; int max = 0 ; for ( int i = 0 ; i < ( int ) 2e5 + 10 ; i ++ ) max = Math . max ( count [ i ] , max ) ; System . out . print ( max ) ; } }"
] | [
"import operatorfrom collections import defaultdict n = int ( input ( ) ) lst = [ int ( i ) for i in input ( ) . split ( ) ] add = [ ] for i in range ( n ) : for j in range ( i + 1 , n ) : add . append ( lst [ i ] + lst [ j ] ) occ = defaultdict ( lambda : 0 ) for i in add : occ [ i ] += 1 MaxKey = max ( occ . items ( ) , key = operator . itemgetter ( 1 ) ) [ 1 ] print ( MaxKey ) NEW_LINE",
"x = int ( input ( ) ) s = list ( map ( int , input ( ) . split ( ) ) ) d = { } for n in range ( x ) : for k in range ( n + 1 , x ) : j = s [ n ] + s [ k ] if j in d . keys ( ) : d [ j ] += 1 else : d [ j ] = 1 print ( max ( d . values ( ) ) ) NEW_LINE",
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) ; k = 2 * ( 10 ** 5 + 1 ) dp = [ 0 ] * kfor i in range ( n ) : for j in range ( n ) : if i != j : dp [ arr [ i ] + arr [ j ] ] += 1 print ( max ( dp ) // 2 ) NEW_LINE",
"from collections import Counterfrom itertools import combinations if __name__ == ' _ _ main _ _ ' : cin = input n = int ( cin ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] print ( max ( Counter ( map ( sum , combinations ( a , 2 ) ) ) . values ( ) ) ) NEW_LINE"
] |
codeforces_802_A | [
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; StringTokenizer s = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( s . nextToken ( ) ) ; int k = Integer . parseInt ( s . nextToken ( ) ) ; s = new StringTokenizer ( br . readLine ( ) ) ; int ar [ ] = new int [ n ] ; int freq [ ] = new int [ n + 1 ] ; int last [ ] = new int [ n + 1 ] ; int next [ ] = new int [ n + 1 ] ; for ( int i = 0 ; i < ar . length ; i ++ ) { ar [ i ] = Integer . parseInt ( s . nextToken ( ) ) ; freq [ ar [ i ] ] ++ ; } Arrays . fill ( last , 82 ) ; int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( freq [ i ] > 0 ) count ++ ; } if ( count <= k ) { pw . println ( count ) ; pw . close ( ) ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { next [ i ] = last [ ar [ i ] ] ; last [ ar [ i ] ] = i ; }"
] | [
"import sysinput = sys . stdin . readlinefrom collections import deque , defaultdictn , k = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) dic = defaultdict ( deque ) for i , a in enumerate ( A ) : dic [ a ] . append ( i ) S = set ( ) ans = 0 for i , a in enumerate ( A ) : for d in dic : while dic [ d ] and dic [ d ] [ 0 ] <= i : dic [ d ] . popleft ( ) if a not in S : if len ( S ) < k : S . add ( a ) ans += 1 else : day = i for s in S : if s not in dic or not dic [ s ] : idx = s break else : if dic [ s ] [ 0 ] > day : day = dic [ s ] [ 0 ] idx = s S . remove ( idx ) S . add ( a ) ans += 1 print ( ans ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) z = [ 0 ] * 81 kz , ans = 0 , 0 for i in range ( n ) : if z [ a [ i ] ] : continue ans += 1 if k > kz : z [ a [ i ] ] = 1 ; kz += 1 else : h = - 1 for j in range ( 1 , n + 1 ) : if z [ j ] : m = n + 1 for p in range ( i , n ) : if j == a [ p ] : m = p break if m > h : h = m ; t = j z [ t ] = 0 z [ a [ i ] ] = 1 print ( ans ) NEW_LINE",
"R = lambda : map ( int , input ( ) . split ( ) ) n , k = R ( ) a = list ( R ( ) ) l = [ ] m = 0 for i in range ( n ) : if a [ i ] not in l : m += 1 if len ( l ) < k : l . append ( a [ i ] ) else : curmin = n curindex = 0 found = [ n ] * len ( l ) for j in range ( len ( a [ i + 1 : : ] ) ) : if ( a [ i + j + 1 ] in l ) and ( found [ l . index ( a [ i + j + 1 ] ) ] == n ) : found [ l . index ( a [ i + j + 1 ] ) ] = j l [ found . index ( max ( found ) ) ] = a [ i ] print ( m ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) inventory = set ( ) bought = 0 for i in range ( n ) : if a [ i ] not in inventory : if len ( inventory ) == k : farthest_time = 0 farthest = 0 for v in inventory : try : far = a . index ( v , i + 1 ) if far > farthest_time : farthest_time = far farthest = v except ValueError : farthest_time = 10000 farthest = v inventory . remove ( farthest ) inventory . add ( a [ i ] ) bought += 1 print ( bought ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) + [ - 1 ] cost = 0 lib = [ ] for i in range ( n ) : if a [ i ] in lib : continue if len ( lib ) < k : lib . append ( a [ i ] ) cost += 1 else : far = 0 for ind , j in enumerate ( lib ) : o = i + 1 while o < n + 1 and a [ o ] != j : o += 1 if o > far : far = min ( o , n - 1 ) maxindex = ind maxele = j if o == n : break lib [ maxindex ] = a [ i ] cost += 1 print ( cost ) NEW_LINE"
] |
codeforces_491_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int h = m + n + 1 ; h = h - n ; System . out . print ( h + \" ▁ \" ) ; for ( int i = 0 ; i < n ; i ++ ) { h ++ ; System . out . print ( h + \" ▁ \" ) ; } h = m + 1 ; for ( int j = 0 ; j < m ; j ++ ) { h -- ; System . out . print ( h + \" ▁ \" ) ; } } }",
"import java . util . Scanner ; public class A491 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int up = in . nextInt ( ) ; int down = in . nextInt ( ) ; int N = up + down + 1 ; StringBuilder sb = new StringBuilder ( ) ; if ( up >= down ) { for ( int h = 0 ; h < up ; h ++ ) { sb . append ( h + 1 ) . append ( ' ▁ ' ) ; } for ( int h = 0 ; h <= down ; h ++ ) { sb . append ( N - h ) . append ( ' ▁ ' ) ; } } else { for ( int h = 0 ; h < down ; h ++ ) { sb . append ( N - h ) . append ( ' ▁ ' ) ; } for ( int h = 0 ; h <= up ; h ++ ) { sb . append ( h + 1 ) . append ( ' ▁ ' ) ; } } System . out . println ( sb ) ; } }",
"import java . io . BufferedReader ; import java . io . File ; import java . io . FileReader ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class a_491 { public static void main ( String [ ] args ) throws Exception {"
] | [
"up = int ( input ( ) ) down = int ( input ( ) ) maxim = up + down + 1 res = [ ] if up > down : res . append ( 1 ) curr = maxim - up + 1 downCurr = curr - 1 while curr <= maxim : res . append ( curr ) curr += 1 while downCurr > 1 : res . append ( downCurr ) downCurr -= 1 else : res . append ( maxim ) curr = maxim - up - 1 upCurr = curr + 1 while curr >= 1 : res . append ( curr ) curr -= 1 while upCurr < maxim : res . append ( upCurr ) upCurr += 1 print ( * res ) NEW_LINE",
"a = int ( input ( ) ) b = int ( input ( ) ) l = list ( range ( b + 1 , 0 , - 1 ) ) if a == 0 : for i in l : print ( i , end = \" ▁ \" ) else : q = list ( range ( b + 2 , a + b + 2 ) ) print ( 1 , end = \" ▁ \" ) for i in q : print ( i , end = \" ▁ \" ) for i in l [ : - 1 ] : print ( i , end = \" ▁ \" ) NEW_LINE",
"A = int ( input ( ) ) B = int ( input ( ) ) N = A + B + 1 i = 0 c = [ 0 ] * Nwhile i < A : c [ i ] = str ( i + 1 ) i += 1 c [ i ] = str ( N ) i += 1 while i < N : c [ i ] = str ( N - i + A ) i += 1 print ( \" ▁ \" . join ( c ) ) NEW_LINE",
"a = int ( input ( ) ) b = int ( input ( ) ) l = list ( range ( 1 , ( a + b + 2 ) ) ) if ( a == 0 ) : print ( * l [ : : - 1 ] ) else : p = l [ 1 : 1 + b ] del l [ 1 : 1 + b ] print ( * l + p [ : : - 1 ] ) NEW_LINE",
" a = int ( input ( ) ) b = int ( input ( ) ) n = a + b + 1 t = [ ] for k in range ( 1 , n + 1 ) : t . append ( k ) print ( * ( t [ : a ] + t [ a : ] [ : : - 1 ] ) ) NEW_LINE"
] |
codeforces_252_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Unsorting_Array { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int i , j , k , n , a , b = 0 , c = 0 , a1 , b1 = 0 , c1 = 0 , a_count , b_count ; boolean is = false , is1 = false ; n = in . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ; if ( n == 1 || n == 2 ) { System . out . println ( - 1 ) ; return ; } a = arr [ 0 ] ; a1 = 1 ; a_count = 1 ; b_count = 0 ; for ( i = 1 ; i < n ; i ++ ) { if ( a == arr [ i ] ) a_count ++ ; else if ( ! is ) { b = arr [ i ] ; b_count ++ ; b1 = i + 1 ; is = true ; } else if ( b == arr [ i ] ) b_count ++ ; else if ( ! is1 ) { c = arr [ i ] ; c1 = i + 1 ; is1 = true ; } }",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; } public static long mod = 17352642619633L ; int [ ] a ; void run ( FastScanner in , PrintWriter out ) { int N = in . nextInt ( ) ; a = new int [ N ] ; boolean allEq = true ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = in . nextInt ( ) ; allEq &= a [ i ] == a [ 0 ] ; } if ( allEq || N <= 2 ) { out . println ( - 1 ) ; return ; } Map < Integer , Integer > p = new HashMap < > ( ) ; int n = 0 ; List < List < Integer > > pp = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! p . containsKey ( a [ i ] ) ) { pp . add ( new ArrayList < > ( ) ) ; p . put ( a [ i ] , n ++ ) ; } pp . get ( p . get ( a [ i ] ) ) . add ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int p1 : pp . get ( i ) ) { for ( int p2 : pp . get ( j ) ) { swap ( p1 , p2 ) ; if ( check ( ) ) { out . println ( ( p1 + 1 ) + \" ▁ \" + ( p2 + 1 ) ) ; return ; } swap ( p1 , p2 ) ; } } } } out . println ( - 1 ) ; } void swap ( int p1 , int p2 ) { int tmp = a [ p1 ] ; a [ p1 ] = a [ p2 ] ; a [ p2 ] = tmp ; } boolean check ( ) { "
] | [
"import sys n = int ( input ( ) ) a = [ int ( s ) for s in input ( ) . split ( ) ] for i in range ( 0 , 2 ) : for j in range ( i + 1 , n ) : if a [ i ] != a [ j ] : r = a [ j ] a [ j ] = a [ i ] a [ i ] = r lol = True lol1 = True for h in range ( 1 , n ) : if a [ h - 1 ] > a [ h ] : lol = False if a [ h - 1 ] < a [ h ] : lol1 = False if not ( lol ) and not ( lol1 ) : print ( i + 1 , j + 1 ) sys . exit ( ) else : r = a [ j ] a [ j ] = a [ i ] a [ i ] = rprint ( - 1 ) NEW_LINE",
"n = int ( input ( ) ) lis = list ( map ( int , input ( ) . split ( ) ) ) sor = sorted ( lis ) res = sor [ : : - 1 ] for i in range ( 1 , n ) : if lis [ i - 1 ] == lis [ i ] : continue for j in range ( i - 1 , n ) : NEW_LINE",
"def solve ( arr ) : if len ( arr ) <= 2 or len ( set ( arr ) ) == 1 : return [ - 1 ] else : for i in range ( len ( arr ) ) : for j in range ( i + 1 , len ( arr ) ) : if arr [ i ] != arr [ j ] : arr [ i ] , arr [ j ] = arr [ j ] , arr [ i ] if arr != sorted ( arr ) and arr != list ( reversed ( sorted ( arr ) ) ) : return [ i + 1 , j + 1 ] else : arr [ i ] , arr [ j ] = arr [ j ] , arr [ i ] return [ - 1 ] if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) print ( * solve ( arr ) ) NEW_LINE"
] |
codeforces_998_B | [
"import java . util . * ; import java . io . * ; import java . math . * ; public class First { public static void process ( ) throws IOException { int n = ni ( ) ; int b = ni ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = ni ( ) ; } int odd = 0 ; int even = 0 ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == n - 1 ) { break ; } if ( a [ i ] % 2 == 0 ) { even ++ ; } else { odd ++ ; } if ( even == odd ) { int cost = Math . abs ( a [ i ] - a [ i + 1 ] ) ; list . add ( cost ) ; } } Collections . sort ( list ) ; int ans = 0 ; for ( Integer i : list ) { if ( b >= i ) { b -= i ; ans ++ ; } else { break ; } } pn ( ans ) ; } static AnotherReader sc ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( System . out ) ; sc = new AnotherReader ( ) ; boolean oj = true ; ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) { FastReader scan = new FastReader ( ) ; int no = scan . nextInt ( ) ; int bitcoins = scan . nextInt ( ) ; int ar [ ] = new int [ no ] ; ArrayList < Integer > diffs = new ArrayList < > ( ) ; for ( int i = 0 ; i < no ; i ++ ) { ar [ i ] = scan . nextInt ( ) ; } int odd = 0 , even = 0 ; for ( int i = 0 ; i < no ; i ++ ) { if ( i != 0 && odd == even ) { diffs . add ( Math . abs ( ar [ i ] - ar [ i - 1 ] ) ) ; } if ( ar [ i ] % 2 == 0 ) even ++ ; else odd ++ ; } Collections . sort ( diffs ) ; int count = 0 ; for ( int i = 0 ; i < diffs . size ( ) ; i ++ ) { int y = diffs . get ( i ) ; if ( bitcoins - y >= 0 ) { bitcoins -= y ; count ++ ; } } System . out . println ( count ) ; } }",
"import java . io . * ; import java . util . * ; public class cutting { public static void main ( String [ ] args ) throws IOException { BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( f . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( f . readLine ( ) ) ; ArrayList < Integer > cuts = new ArrayList < Integer > ( ) ; int numOdd = 0 ; int numEven = 0 ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] % 2 == 1 ) numOdd ++ ; else numEven ++ ; if ( numOdd == numEven ) cuts . add ( Math . abs ( arr [ i + 1 ] - arr [ i ] ) ) ; } Collections . sort ( cuts ) ; int price = 0 ; int ans = 0 ; for ( int i = 0 ; i < cuts . size ( ) ; i ++ ) { price += cuts . get ( i ) ; if ( price <= b ) ans ++ ; else break ; } System . out . println ( ans ) ; } }"
] | [
"import itertoolsimport sys n , b = map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ' ▁ ' ) ) cs = list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ' ▁ ' ) ) ) cs0 , cs1 = itertools . tee ( cs ) next ( cs1 ) rs = [ ] tc = 0 tn = 0 for c1 , c2 in zip ( cs0 , cs1 ) : if c1 % 2 == 0 : tc += 1 else : tn += 1 if tc == tn : rs . append ( abs ( c1 - c2 ) ) rs = sorted ( rs ) tr = 0 res = 0 for r in rs : tr += r if tr > b : break res += 1 print ( res ) NEW_LINE",
"n , bt = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) s = 0 b = [ ] for i in range ( n - 1 ) : s += ( 1 - 2 * ( arr [ i ] & 1 ) ) if s == 0 : b . append ( abs ( arr [ i ] - arr [ i + 1 ] ) ) b . sort ( ) ans = 0 i = 0 while i < len ( b ) : if b [ i ] <= bt : bt -= b [ i ] ans += 1 else : break i += 1 print ( ans ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) t = 0 cost = [ ] for i in range ( n - 1 ) : if l [ i ] % 2 == 0 : t = t + 1 else : t = t - 1 if t == 0 : cost . append ( abs ( l [ i + 1 ] - l [ i ] ) ) i = 0 cost . sort ( ) while i < len ( cost ) and k >= 0 : k = k - cost [ i ] if k >= 0 : i += 1 print ( i ) NEW_LINE",
"n , b = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) e , o = 0 , 0 lst = 0 temp = [ ] for i in a : if o == e : temp += [ abs ( i - lst ) ] o , e = 0 , 0 if i % 2 == 0 : o += 1 else : e += 1 lst = ic = 0 for i in sorted ( temp [ 1 : ] ) : b -= i if b >= 0 : c += 1 print ( c ) NEW_LINE"
] |
codeforces_585_B | [
"import java . io . BufferedReader ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . io . * ; public class codeforces { static class Student { int x , y ;"
] | [
"import osimport sysfrom io import BytesIO , IOBase BUFSIZE = 8192 class FastIO ( IOBase ) : newlines = 0 def __init__ ( self , file ) : self . _fd = file . fileno ( ) self . buffer = BytesIO ( ) self . writable = \" x \" in file . mode or \" r \" not in file . mode self . write = self . buffer . write if self . writable else None def read ( self ) : while True : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) if not b : break ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines = 0 return self . buffer . read ( ) def readline ( self ) : while self . newlines == 0 : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) self . newlines = b . count ( b \" \\n \" ) + ( not b ) ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines -= 1 return self . buffer . readline ( ) def flush ( self ) : if self . writable : os . write ( self . _fd , self . buffer . getvalue ( ) ) self . buffer . truncate ( 0 ) , self . buffer . seek ( 0 ) class IOWrapper ( IOBase ) : def __init__ ( self , file ) : self . buffer = FastIO ( file ) self . flush = self . buffer . flush self . writable = self . buffer . writable self . write = lambda s : self . buffer . write ( s . encode ( \" ascii \" ) ) self . read = lambda : self . buffer . read ( ) . decode ( \" ascii \" ) self . readline = lambda : self . buffer . readline ( ) . decode ( \" ascii \" ) sys . stdin , sys . stdout = IOWrapper ( sys . stdin ) , IOWrapper ( sys . stdout ) input = lambda : sys . stdin . readline ( ) . rstrip ( \" \\n \" ) NEW_LINE",
"import sys def minp ( ) : return sys . stdin . readline ( ) . strip ( ) def mint ( ) : return int ( minp ( ) ) def mints ( ) : return map ( int , minp ( ) . split ( ) ) def main ( ) : n , k = mints ( ) a = [ list ( minp ( ) ) for i in range ( 3 ) ] w = [ [ False ] * ( n + 1 ) for i in range ( 3 ) ] for j in range ( 3 ) : if a [ j ] [ 0 ] == ' s ' : a [ j ] [ 0 ] = ' . ' w [ j ] [ 0 ] = True for i in range ( n ) : for j in range ( 3 ) : if w [ j ] [ i ] : if i * 3 + 1 >= n or a [ j ] [ i * 3 + 1 ] == ' . ' : for z in range ( max ( j - 1 , 0 ) , min ( j + 2 , 3 ) ) : if ( i * 3 + 1 >= n or a [ z ] [ i * 3 + 1 ] == ' . ' ) and ( i * 3 + 2 >= n or a [ z ] [ i * 3 + 2 ] == ' . ' ) and ( i * 3 + 3 >= n or a [ z ] [ i * 3 + 3 ] == ' . ' ) : w [ z ] [ i + 1 ] = True can = w [ 0 ] [ n ] or w [ 1 ] [ n ] or w [ 2 ] [ n ] NEW_LINE",
"def safe ( mat , x , y , n ) : if not x in [ 0 , 1 , 2 ] : return False for i in range ( 1 , 4 ) : if y + i < n and mat [ x ] [ y + i ] != ' . ' : return False return True def dfs ( mat , n ) : pos = 0 for k in range ( 3 ) : if mat [ k ] [ 0 ] == ' s ' : pos = k vis = { } s = [ ( pos , 0 ) ] while s : x , y = s . pop ( ) if y >= n : return \" YES \" if ( x , y ) in vis : continue vis [ ( x , y ) ] = 1 for i in [ - 1 , 0 , 1 ] : if y + 1 >= n or ( y + 1 < n and mat [ x ] [ y + 1 ] == ' . ' and safe ( mat , x + i , y , n ) ) : s . append ( ( x + i , y + 3 ) ) return ' NO ' t = int ( input ( ) ) for _ in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) mat = [ input ( ) for i in range ( 3 ) ] print ( dfs ( mat , n ) ) NEW_LINE",
"t = int ( input ( ) ) for test in range ( t ) : n , k = [ int ( i ) for i in input ( ) . split ( ) ] grid = [ [ True for i in range ( 3 ) ] for i in range ( n ) ] ok = [ [ False for i in range ( 3 ) ] for i in range ( n ) ] NEW_LINE"
] |
codeforces_1312_B | [
"import java . util . * ; import java . io . * ; public class CFA { BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; private static final long MOD = 1000L * 1000L * 1000L + 7 ; private static final int [ ] dx = { 0 , - 1 , 0 , 1 } ; private static final int [ ] dy = { 1 , 0 , - 1 , 0 } ; private static final String yes = \" YES \" ; private static final String no = \" NO \" ; void solve ( ) { int T = nextInt ( ) ;",
"import java . util . * ; public class BogoSort { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { System . out . print ( a [ i ] + \" ▁ \" ) ; } } } }"
] | [
"N = int ( input ( ) ) for _ in range ( N ) : _ = int ( input ( ) ) a = sorted ( [ int ( ii ) for ii in input ( ) . split ( ' ▁ ' ) ] , reverse = True ) print ( * a , sep = ' ▁ ' ) NEW_LINE",
"t = int ( input ( ) ) for i in range ( t ) : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( reverse = True ) print ( * l , sep = \" ▁ \" ) NEW_LINE",
"def answer ( n , a ) : a . sort ( reverse = True ) return ' ▁ ' . join ( map ( str , a ) ) def main ( ) : t = int ( input ( ) ) n = [ 0 ] * t a = [ 0 ] * t for j in range ( t ) : n [ j ] = int ( input ( ) ) a [ j ] = [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( t ) : print ( answer ( n [ j ] , a [ j ] ) ) main ( ) NEW_LINE",
"t = int ( input ( ) ) for i in range ( t ) : n = int ( input ( ) ) v = list ( map ( int , input ( ) . split ( ) ) ) v . sort ( ) print ( * v [ : : - 1 ] , sep = \" ▁ \" ) NEW_LINE"
] |
codeforces_955_A | [
"import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ; import java . math . * ; public class Cat { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ; public static void main ( String args [ ] ) throws IOException { int hour = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int hungerLevel = sc . nextInt ( ) ; int hunger_level_in = sc . nextInt ( ) ; int cost = sc . nextInt ( ) ; int hungerstop = sc . nextInt ( ) ; int buns = ( int ) Math . ceil ( ( double ) hungerLevel / ( double ) hungerstop ) ; double costOfAll = buns * cost ; double discountedCost = ( ( 0.8 ) * costOfAll ) ; double fianl = 0 ; int time = ( 60 * hour ) + min ; if ( time > 1200 ) System . out . println ( discountedCost ) ; else { int bunss = ( int ) Math . ceil ( ( double ) hungerLevel / ( double ) hungerstop ) ; double costOf = bunss * cost ; int bunsafter8 = ( int ) ( Math . ceil ( ( double ) ( hungerLevel + hunger_level_in * ( 1200 - time ) ) / ( double ) hungerstop ) ) ; double costAfter8 = ( bunsafter8 * cost * ( 0.8 ) ) ; fianl = Math . min ( costOf , costAfter8 ) ; System . out . println ( fianl ) ; } } ",
"import java . io . PrintWriter ; import java . util . LinkedList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tc = 1 ; while ( tc -- > 0 ) { int hh = sc . nextInt ( ) ; int mm = sc . nextInt ( ) ; float h = sc . nextFloat ( ) ; float d = sc . nextFloat ( ) ; float c = sc . nextFloat ( ) ; float n = sc . nextFloat ( ) ; float ans = ( float ) ( Math . ceil ( h / n ) * c ) ; float ans1 ; if ( hh >= 20 ) { ans = 8 * ( ans ) / 10 ; } if ( hh < 20 ) { float points = ( 60 - mm + ( 19 - hh ) * 60 ) * d ; h += ( float ) points ; } ans1 = ( float ) Math . ceil ( h / n ) ; ans1 = c * ans1 * 8 / 10 ; System . out . println ( String . format ( \" % .4f \" , Math . min ( ans , ans1 ) ) ) ; } out . close ( ) ; sc . close ( ) ; } static void swap ( long ar [ ] , int i , int j ) { long temp = ar [ i ] ; ar [ i ] = ar [ j ] ; ar [ j ] = temp ; } static long gcd ( long ar , long ar2 ) { if ( ar2 == 0 ) return ar ; else return gcd ( ar2 , ar % ar2 ) ; } }",
"import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class cf1 { static long mod = ( long ) 1e9 + 7 ; static long mod1 = 998244353 ; static FastScanner f ; static PrintWriter pw = new PrintWriter ( System . out ) ; static Scanner S = new Scanner ( System . in ) ; static long x0 ; static long y0 ; static int inf = ( int ) ( 1e9 ) ; static long iinf = ( long ) ( 1e18 ) ; static void solve ( ) throws IOException { int hh = f . ni ( ) ; int mm = f . ni ( ) ; int hungerlvl = f . ni ( ) ; int inc = f . ni ( ) ; double cost = f . nd ( ) ; int dec = f . ni ( ) ; double curr = 0.0 , ans = 99999999.0 ; while ( hh < 24 ) { int num = ( hungerlvl + dec - 1 ) / dec ; if ( hh >= 20 ) { double copy = 0.8 * cost ; curr = num * copy ; } else curr = num * cost ; ans = Math . min ( ans , curr ) ;",
"import java . io . * ; import java . math . * ; import java . util . * ; import java . util . Arrays ; public class Test1 { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int hh = sc . nextInt ( ) ; int mm = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int time = hh * 60 + mm ; double res1 = 0 , res2 = 0 ; int buns = 0 ; buns = ( int ) Math . ceil ( ( double ) h / n ) ; res1 = buns * c ; double res3 = res1 * 0.8 ; int nh = h + ( 1200 - time ) * d ; buns = ( int ) Math . ceil ( ( double ) nh / n ) ; res2 = ( buns * c ) * 0.8 ; double res = 0.0 ; if ( time >= 1200 ) res = res3 ; else res = Math . min ( res1 , res2 ) ; System . out . println ( res ) ; } }"
] | [
"import mathdef solve ( ) : houro , mino = list ( map ( int , input ( ) . split ( ) ) ) hunger , inc , cost , dec = list ( map ( int , input ( ) . split ( ) ) ) t_l = 0 if houro < 20 : t_l = 20 - houro - 1 t_l *= 60 t_l += ( 60 - mino ) x , y = math . ceil ( ( t_l * inc + hunger ) / dec ) * 0.8 * cost , math . ceil ( hunger / dec ) * cost print ( ' % .5f ' % min ( x , y ) ) solve ( ) NEW_LINE",
"hh , mm = map ( int , input ( ) . split ( ) ) H , D , C , N = map ( int , input ( ) . split ( ) ) t = 20 * 60 - hh * 60 - mmt = max ( t , 0 ) H1 = H + D * tc1 = H1 // Nif ( H1 % N != 0 ) : c1 += 1 m1 = ( C * 0.8 ) * c1c2 = H // Nif ( H % N != 0 ) : c2 += 1 m2 = C * c2m1 = round ( m1 , 4 ) m2 = round ( m2 , 4 ) print ( ' % .4f ' % min ( m1 , m2 ) ) NEW_LINE",
"hh , mm = map ( int , input ( ) . split ( ) ) H , D , cost , nutr = map ( int , input ( ) . split ( ) ) hh = 60 * hh + mmif hh >= 1200 : print ( ' { : . 4f } ' . format ( ( H + nutr - 1 ) // nutr * cost * 0.8 ) ) else : print ( ' { : . 4f } ' . format ( min ( ( H + nutr - 1 ) // nutr * cost , ( H + ( 1200 - hh ) * D + nutr - 1 ) // nutr * cost * 0.8 ) ) ) NEW_LINE",
"import mathr , m = map ( int , input ( ) . split ( ) ) h , d , c , n = map ( int , input ( ) . split ( ) ) if r >= 20 : print ( math . ceil ( h / n ) * c * 0.8 ) else : print ( min ( math . ceil ( ( ( 20 * 60 - r * 60 - m ) * d + h ) / n ) * c * 0.8 , math . ceil ( h / n ) * c ) ) NEW_LINE",
"import sys , mathfrom collections import deque , defaultdictimport operator as opfrom functools import reducefrom itertools import permutations NEW_LINE"
] |
codeforces_30_A | [
"import java . io . File ; import java . io . FileNotFoundException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; import java . util . Stack ; public class test { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) , n = sc . nextInt ( ) ; int sol = - 1 ; for ( int x = - 1000 ; x <= 1000 ; x ++ ) { long p = ( long ) Math . pow ( x , n ) ; if ( a * p == b ) { System . out . println ( x ) ; return ; } } System . out . println ( \" No ▁ solution \" ) ; } }",
"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main implements Runnable { static long mod = ( long ) 1e9 + 7 ; static long lim = ( long ) 1e9 + 6 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static FastScanner f ; static PrintWriter pw = new PrintWriter ( System . out ) ; static Scanner S = new Scanner ( System . in ) ; static long x0 ; static long y0 ; static long oo = Long . MAX_VALUE ; static double eps = ( double ) 1e-6 ; public static void solve ( ) { long a = f . nl ( ) ; long b = f . nl ( ) ; int n = f . ni ( ) ; if ( a == 0 ) { if ( b == 0 ) { pn ( 0 ) ; return ; } pn ( \" No ▁ solution \" ) ; return ; } if ( b == 0 ) { if ( a == 0 ) { pn ( 0 ) ; return ; } pn ( 0 ) ; return ; } BigInteger aa = new BigInteger ( String . valueOf ( a ) ) ; BigInteger bb = new BigInteger ( String . valueOf ( b ) ) ; BigInteger nn = new BigInteger ( String . valueOf ( n ) ) ; BigInteger i = new BigInteger ( \" - 1000\" ) ; BigInteger j = new BigInteger ( \"1000\" ) ; BigInteger one = new BigInteger ( \"1\" ) ; for ( ; i . compareTo ( j ) <= 0 ; i = i . add ( one ) ) { BigInteger temp = i . pow ( n ) ; temp = temp . multiply ( aa ) ; if ( temp . compareTo ( bb ) == 0 ) { pn ( i ) ; return ; } } pn ( \" No ▁ solution \" ) ; } public static void main ( String [ ] args ) throws IOException { new Thread ( null , new Main ( ) , \" F * uckit \" , 1 << 28 ) . start ( ) ; } public void run ( ) { f = new FastScanner ( System . in ) ;",
" import java . io . * ; import java . util . * ; public class C30A { static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Kioken sc = new Kioken ( ) ; public static void main ( String args [ ] ) throws IOException { int t = 1 ;",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( new Scanner ( System . in ) ) ; } private void solve ( Scanner sc ) { int A = sc . nextInt ( ) , B = sc . nextInt ( ) , n = sc . nextInt ( ) ; if ( A == 0 ) { if ( B == 0 ) System . out . println ( 1 ) ; else System . out . println ( \" No ▁ solution \" ) ; return ; } if ( B % A != 0 ) { System . out . println ( \" No ▁ solution \" ) ; return ; } B /= A ; boolean neg = B < 0 ; if ( neg && n % 2 == 0 ) { System . out . println ( \" No ▁ solution \" ) ; return ; } if ( neg ) B = - B ; for ( int x = 0 ; x <= B ; x ++ ) { if ( Math . pow ( x , n ) == B ) { System . out . println ( neg ? - x : x ) ; return ; } } System . out . println ( \" No ▁ solution \" ) ; } }"
] | [
"import math A , B , n = [ float ( item ) for item in input ( ) . split ( ' ▁ ' ) ] helper = 0 if A == 0 and B != 0 : helper = 2 elif A == 0 and B == 0 : helper = 1 else : helper = B / A need_minus = helper < 0 if need_minus : helper = - helper result = pow ( helper , 1.0 / n ) if not need_minus : result += 0.000000001 NEW_LINE",
"datos = input ( ) . split ( ) a = int ( datos [ 0 ] ) b = int ( datos [ 1 ] ) n = int ( datos [ 2 ] ) if a == 0 and b == 0 : print ( n // 2 ) elif a == 0 : print ( ' No ▁ solution ' ) elif a == 1 and b == 1000 and n == 3 : print ( 10 ) else : base = ( b / a ) raiz = 1 / n if base < 0 and n % 2 == 0 : print ( ' No ▁ solution ' ) else : if base < 0 : rpta = abs ( base ) ** raiz rpta = rpta * - 1 else : rpta = base ** raiz if rpta == int ( rpta ) : print ( int ( rpta ) ) else : print ( ' No ▁ solution ' ) NEW_LINE",
"import math def is_Integer ( val ) : if math . ceil ( val ) - X < 0.000000001 : return True , math . ceil ( X ) elif X - math . floor ( X ) < 0.000000001 : return True , math . floor ( X ) else : return False , X A , B , n = [ int ( i ) for i in input ( ) . split ( ) ] ns = ' No ▁ solution ' if B == 0 : X = 0 elif A and B : if B / A < 0 : X = - math . pow ( abs ( B / A ) , 1 / n ) if n % 2 == 1 else ns else : X = math . pow ( B / A , 1 / n ) if not X == ns : F , X = is_Integer ( X ) X = int ( X ) if F else nselse : X = ns print ( X ) NEW_LINE",
"import math A , B , n = [ float ( item ) for item in input ( ) . split ( ' ▁ ' ) ] helper = 0 if A == 0 and B != 0 : helper = 2 elif A == 0 and B == 0 : helper = 1 else : helper = B / A needMinus = helper < 0 if needMinus : helper = - helper result = pow ( helper , 1 / n ) if not needMinus : NEW_LINE",
"a , b , n = list ( map ( int , input ( ) . split ( ) ) ) if a == 0 and b != 0 or n == 0 and a != b or a != 0 and b / a < 0 and n % 2 == 0 : print ( ' No ▁ solution ' ) elif n == 0 or a == 0 and b == 0 : print ( 1 ) else : z = 0 for i in range ( - abs ( round ( b / a ) ) - 1 , abs ( round ( b / a ) ) + 1 ) : if a * i ** n == b : z = 1 print ( i ) break else : print ( ' No ▁ solution ' ) NEW_LINE"
] |
codeforces_554_A | [
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; System . out . println ( 26 * ( s . length ( ) + 1 ) - s . length ( ) ) ; } }",
"import java . util . Scanner ; public class PhotoString { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; System . out . println ( 26 + 25 * scan . nextLine ( ) . length ( ) ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { static int x , y ; public static int euclid ( int a , int b ) { if ( b == 0 ) return a ; return euclid ( b , a % b ) ; } public static int extendedEuclid ( int a , int b ) { if ( b == 0 ) { x = 1 ; y = 0 ; return a ; } int f = extendedEuclid ( b , a % b ) ; int t = x ; x = y ; y = t - ( a / b ) * y ; return f ; } public static int binarySearch ( int a [ ] , int n ) { int i = 0 , j = a . length - 1 ; int k ; while ( true ) { k = ( i + j ) / 2 ; if ( k < n - 1 && n < a [ k + 1 ] && n > a [ k ] ) { return k ; } if ( k > 0 && a [ k - 1 ] > n ) j = k - 1 ; if ( a [ k ] < n ) i = k + 1 ; } } public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ;",
"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static int oo = ( int ) 1e7 ;"
] | [
"import sysfrom functools import lru_cache , cmp_to_keyfrom heapq import merge , heapify , heappop , heappushfrom math import * from collections import defaultdict as dd , deque , Counter as Cfrom itertools import combinations as comb , permutations as permfrom bisect import bisect_left as bl , bisect_right as br , bisect , insortfrom time import perf_counterfrom fractions import Fractionimport copyfrom copy import deepcopyimport timestarttime = time . time ( ) mod = int ( pow ( 10 , 9 ) + 7 ) mod2 = 998244353 def data ( ) : return sys . stdin . readline ( ) . strip ( ) def out ( * var , end = \" \\n \" ) : sys . stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) def L ( ) : return list ( sp ( ) ) def sl ( ) : return list ( ssp ( ) ) def sp ( ) : return map ( int , data ( ) . split ( ) ) def ssp ( ) : return map ( str , data ( ) . split ( ) ) def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] def l2d ( n , m , val = 0 ) : return [ l1d ( n , val ) for j in range ( m ) ] try : NEW_LINE",
"x = ( input ( ) ) s = len ( x ) s += 1 print ( 25 * s + 1 ) NEW_LINE",
"b = [ ] s = input ( ) b += sans = set ( ) for i in range ( len ( s ) + 1 ) : for j in range ( 26 ) : b . insert ( i , chr ( ord ( ' a ' ) + j ) ) now = 0 y = 37 for h in range ( len ( b ) ) : now += ( ord ( b [ h ] ) - ord ( ' a ' ) + 1 ) * y y *= 37 del b [ i ] ans . add ( now ) print ( len ( ans ) ) NEW_LINE",
"n = input ( ) a = 26 for i in range ( len ( n ) ) : a += 25 print ( a ) NEW_LINE",
"a = input ( ) print ( 26 * ( len ( a ) + 1 ) - len ( a ) ) NEW_LINE"
] |
codeforces_250_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Restoring_IPv6 { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int i , j , a , b , n , c , l , sum ; String [ ] s_array = new String [ 8 ] ; String ss , s1 , s2 , s_tem = \"0000\" ; StringBuilder s ; s_array [ 0 ] = s_tem ; for ( i = 1 ; i < 8 ; i ++ ) { s_array [ i ] = s_array [ i - 1 ] + \" : \" + s_tem ; } n = in . nextInt ( ) ; while ( n -- > 0 ) { String [ ] s_main = new String [ 8 ] ; s1 = \" \" ; sum = 0 ; ss = in . nextLine ( ) ; s = new StringBuilder ( ss ) ; l = s . length ( ) ; if ( ! ss . contains ( \" : \" ) ) { ss += \" : \" ; ss += s_array [ 7 ] ; s1 = ss ; } else if ( ss . contains ( \" : : \" ) ) { ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class _250B implements Runnable { private BufferedReader in ; private Object solve ( ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 , n = nextInt ( ) ; i < n ; i ++ ) { String [ ] s = nextToken ( ) . split ( \" : \" , - 1 ) ; int k = 0 , m = s . length - 1 ; if ( s [ k ] . isEmpty ( ) ) { k ++ ; } if ( s [ m ] . isEmpty ( ) ) { m -- ; } for ( int j = k ; j <= m ; j ++ ) { if ( s [ j ] . isEmpty ( ) ) { for ( int l = 1 , lim = 8 - m + k ; l <= lim ; l ++ ) { sb . append ( \"0000\" ) ; if ( l < lim ) { sb . append ( ' : ' ) ; } } } else { for ( int l = s [ j ] . length ( ) ; l < 4 ; l ++ ) { sb . append ( '0' ) ; } sb . append ( s [ j ] ) ; } if ( j < m ) { sb . append ( ' : ' ) ; } } sb . append ( ' \\n ' ) ; } return sb ; } "
] | [
"for kk in range ( int ( input ( ) ) ) : str = input ( ) print ( ' : ' . join ( i . zfill ( 4 ) for i in str . replace ( ' : : ' , ' : ' * ( 9 - str . count ( ' : ' ) ) ) . split ( ' : ' ) ) ) NEW_LINE",
"n = eval ( input ( ) ) for i in range ( n ) : ans = ' ' k = ' ' s = input ( ) . split ( ' : ' ) c = 0 m = 0 for g in range ( len ( s ) ) : if s [ g ] != ' ' : c += 1 if c == 8 : for j in range ( c ) : s [ j ] = ( 4 - len ( s [ j ] ) ) * '0' + s [ j ] ans += s [ j ] + ' : ' else : k = ( 8 - c ) * '0000 : ' for j in range ( len ( s ) ) : if s [ j ] == ' ' : ans += k k = ' ' m = 1 else : s [ j ] = ( 4 - len ( s [ j ] ) ) * '0' + s [ j ] ans += s [ j ] + ' : ' ans += k ans = ans [ : - 1 ] print ( ans ) NEW_LINE",
"for kk in range ( int ( input ( ) ) ) : str = input ( ) print ( ' : ' . join ( i . zfill ( 4 ) for i in str . replace ( ' : : ' , ' : ' * ( 9 - str . count ( ' : ' ) ) ) . split ( ' : ' ) ) ) NEW_LINE",
"def f ( s ) : res = [ ] sp = s . split ( \" : \" ) if not sp [ 0 ] : sp [ 0 ] = \"0\" if not sp [ - 1 ] : sp [ - 1 ] = \"0\" for b in sp : if b : res . append ( \" { :0 > 4 } \" . format ( b ) ) if not b : res . extend ( ( \"0000\" for i in range ( 8 - len ( sp ) + 1 ) ) ) return ( \" : \" . join ( res ) ) t = int ( input ( ) ) for i in range ( t ) : ip = input ( ) print ( f ( ip ) ) NEW_LINE",
"def f ( s ) : res = [ ] sp = s . split ( \" : \" ) if not sp [ 0 ] : sp [ 0 ] = \"0\" if not sp [ - 1 ] : sp [ - 1 ] = \"0\" for b in sp : if b : res . append ( \" { :0 > 4 } \" . format ( b ) ) if not b : res . extend ( ( \"0000\" for i in range ( 8 - len ( sp ) + 1 ) ) ) return ( \" : \" . join ( res ) ) t = int ( input ( ) ) for i in range ( t ) : ip = input ( ) print ( f ( ip ) ) NEW_LINE"
] |
codeforces_49_B | [
"import java . math . BigInteger ; import java . util . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String n = in . next ( ) ; String m = in . next ( ) ; int base = max ( n . chars ( ) . max ( ) . getAsInt ( ) , m . chars ( ) . max ( ) . getAsInt ( ) ) - '0' + 1 ; System . out . println ( new BigInteger ( n , base ) . add ( new BigInteger ( m , base ) ) . toString ( base ) . length ( ) ) ; } }",
"import java . util . * ; import static java . lang . Math . * ; public class Main { static int largest ( int x ) { int ret = 0 ; while ( x > 0 ) { ret = max ( ret , x % 10 ) ; x /= 10 ; } return ret ; } static int tobase ( int x , int base ) { int ret = 0 , p = 1 ; while ( x > 0 ) { ret += ( x % 10 ) * p ; p *= base ; x /= 10 ; } return ret ; } static int digitsNum ( int x , int base ) { int ret = 0 ; while ( x > 0 ) { ret ++ ; x /= base ; } return ret ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int base = max ( largest ( n ) , largest ( m ) ) + 1 ; int x = tobase ( n , base ) + tobase ( m , base ) ; System . out . println ( digitsNum ( x , base ) ) ; } }",
" import java . io . BufferedInputStream ; import java . math . BigInteger ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( new BufferedInputStream ( System . in ) ) ; int a = cin . nextInt ( ) ; int b = cin . nextInt ( ) ; int n = a , m = b ; int maxx = 0 ; while ( a != 0 ) { maxx = Math . max ( maxx , a % 10 ) ; a /= 10 ; } while ( b != 0 ) { maxx = Math . max ( maxx , b % 10 ) ; b /= 10 ; }",
"import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String a = scan . next ( ) ; String b = scan . next ( ) ; int max = 0 ; for ( char c : ( a + b ) . toCharArray ( ) ) { max = Math . max ( c - '0' , max ) ; } int len = Integer . toString ( Integer . parseInt ( a , max + 1 ) + Integer . parseInt ( b , max + 1 ) , max + 1 ) . length ( ) ; System . out . println ( len ) ; } }"
] | [
"a , b = input ( ) . split ( ) d = '0' y , z = len ( a ) , len ( b ) for i in range ( y ) : d = max ( d , a [ i ] ) for i in range ( z ) : d = max ( d , b [ i ] ) d = int ( d ) + 1 c = 0 for i in range ( y ) : c += int ( a [ y - 1 - i ] ) * ( d ** i ) for i in range ( z ) : c += int ( b [ z - 1 - i ] ) * ( d ** i ) e = 0 while c > 0 : e += 1 c //= dprint ( e ) NEW_LINE",
"def basechange ( n , base ) : new_number = [ ] q = n while ( q >= base ) : new_number . append ( q % base ) q = q // base new_number . append ( q ) return new_number def to_base_10 ( n , base ) : string_n = str ( n ) total = 0 for i , number in enumerate ( string_n [ : : - 1 ] ) : total += ( base ** i ) * int ( number ) return total number1 , number2 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) max_n = max ( max ( str ( number1 ) ) , max ( str ( number2 ) ) ) NEW_LINE",
"def any2dec ( num_original , base_original ) : num_original = str ( num_original ) base_original = int ( base_original ) dic = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' , ' G ' , ' H ' , ' I ' , ' J ' , ' K ' , ' L ' , ' M ' , ' N ' , ' O ' , ' P ' , ' Q ' , ' R ' , ' S ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' , ' Z ' ] dec = 0 dec_temp = list ( num_original ) dec_temp . reverse ( ) for x , i in enumerate ( dec_temp ) : dec += dic . index ( i ) * base_original ** ( x ) return str ( dec ) def dec2any ( dec , base_final ) : base_final = int ( base_final ) dec = int ( dec ) dic = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' , ' G ' , ' H ' , ' I ' , ' J ' , ' K ' , ' L ' , ' M ' , ' N ' , ' O ' , ' P ' , ' Q ' , ' R ' , ' S ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' , ' Z ' ] numero_final_temp = [ ] numero_final = ' ' while True : temp_numero_final = dec % base_final numero_final_temp . append ( temp_numero_final ) if int ( dec / base_final ) == 0 : break dec = int ( dec / base_final ) numero_final_temp . reverse ( ) for i in numero_final_temp : numero_final += dic [ i ] return numero_final def main ( ) : v = input ( ) . split ( ) a = [ int ( i ) for i in list ( v [ 0 ] ) ] b = [ int ( i ) for i in list ( v [ 1 ] ) ] base = max ( max ( a ) , max ( b ) ) + 1 va = any2dec ( v [ 0 ] , base ) vb = any2dec ( v [ 1 ] , base ) ans = int ( va ) + int ( vb ) print ( len ( dec2any ( ans , base ) ) ) main ( ) NEW_LINE",
"def map2 ( r , b ) : d = dict ( zip ( [ i for i in range ( 0 , 16 ) ] , list ( \"0123456789ABCDEF \" ) ) ) return ( d [ r ] ) def xb ( x , b ) : x = list ( map ( int , list ( str ( x ) ) ) ) [ : : - 1 ] ans = 0 for i , d in enumerate ( x ) : ans += d * b ** i return ans def xb2 ( x , b ) : xinbase = str ( ) while x > 0 : remainder = x % b x = x // b xinbase += map2 ( remainder , b ) return ( xinbase [ : : - 1 ] ) def encontrarbase ( a , b ) : return max ( list ( map ( int , list ( str ( a ) + str ( b ) ) ) ) ) a , b = list ( map ( int , input ( ) . split ( ) ) ) base = encontrarbase ( a , b ) + 1 x = xb2 ( xb ( a , base ) + xb ( b , base ) , base ) print ( len ( x ) ) NEW_LINE",
"def map2 ( r , b ) : d = dict ( zip ( [ i for i in range ( 0 , 16 ) ] , list ( \"0123456789ABCDEF \" ) ) ) return ( d [ r ] ) def xb ( x , b ) : x = list ( map ( int , list ( str ( x ) ) ) ) [ : : - 1 ] ans = 0 for i , d in enumerate ( x ) : ans += d * b ** i return ans def xb2 ( x , b ) : xinbase = str ( ) while x > 0 : remainder = x % b x = x // b xinbase += map2 ( remainder , b ) return ( xinbase [ : : - 1 ] ) def encontrarbase ( a , b ) : return max ( list ( map ( int , list ( str ( a ) + str ( b ) ) ) ) ) a , b = list ( map ( int , input ( ) . split ( ) ) ) base = encontrarbase ( a , b ) + 1 x = xb2 ( xb ( a , base ) + xb ( b , base ) , base ) print ( len ( x ) ) NEW_LINE"
] |
codeforces_1480_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tc = sc . nextInt ( ) ; while ( tc -- > 0 ) { long ha = sc . nextInt ( ) ; long hb = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } long x , max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { x = ( b [ i ] + ha - 1 ) / ha ; hb -= x * a [ i ] ; max = Math . max ( max , a [ i ] ) ; } if ( hb + max > 0 ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } sc . close ( ) ; } }",
"import java . util . * ; import java . io . * ; public class HelloWorld { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; for ( int j = 0 ; j < t ; j ++ ) { long x = input . nextLong ( ) ; long y = input . nextLong ( ) ; int n = input . nextInt ( ) ; long [ ] a = new long [ n ] ; long [ ] b = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextLong ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = input . nextLong ( ) ; } int i = 0 ; long max = 0 ; while ( i < n ) { long times = ( b [ i ] + x - 1 ) / x ; y -= times * a [ i ] ; max = Math . max ( max , a [ i ] ) ; i ++ ; } System . out . println ( y + max > 0 ? \" YES \" : \" NO \" ) ; } } }",
"import java . util . Scanner ; public class B1480 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int AH = in . nextInt ( ) ; long DH = in . nextInt ( ) ; int N = in . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] D = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { A [ n ] = in . nextInt ( ) ; } for ( int n = 0 ; n < N ; n ++ ) { D [ n ] = in . nextInt ( ) ; } int max = 0 ; for ( int n = 0 ; n < N ; n ++ ) { long attacks = ( D [ n ] + AH - 1 ) / AH ; DH -= attacks * A [ n ] ; max = Math . max ( max , A [ n ] ) ; } DH += max ; System . out . println ( DH > 0 ? \" YES \" : \" NO \" ) ; } } }",
"import java . util . * ; import java . lang . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int a , b , c ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; int p [ ] = new int [ c ] ; int q [ ] = new int [ c ] ; A z [ ] = new A [ c ] ; for ( int i = 0 ; i < c ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < c ; i ++ ) { q [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < c ; i ++ ) { A y = new A ( p [ i ] , q [ i ] ) ; z [ i ] = y ; } Arrays . sort ( z , new nc ( ) ) ; boolean flag = true ; for ( int i = 0 ; i < c ; i ++ ) { int hm = z [ i ] . b ; int am = z [ i ] . a ; int r = hm / a ; if ( hm % a != 0 ) r ++ ; int s = b / am ; if ( b % am != 0 ) s ++ ; if ( s < r || b < 0 ) { flag = false ; break ; } else { b -= ( r * am ) ; } } if ( flag ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } } } class A { int a , b ; A ( int a , int b ) { this . a = a ; this . b = b ; } } class nc implements Comparator < A > { public int compare ( A s1 , A s2 ) { if ( s1 . a == s2 . a ) return 0 ; else if ( s1 . a > s2 . a ) return 1 ; else return - 1 ; } }",
" import java . util . * ; import java . lang . * ; import java . io . * ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { FastReader in = new FastReader ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int t = 1 ; t = in . nextInt ( ) ; while ( t > 0 ) { -- t ; int A = in . nextInt ( ) ;"
] | [
"from math import ceil for t in range ( int ( input ( ) ) ) : A , B , n = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE damage = 0 NEW_LINE for i in range ( n ) : damage = damage + ceil ( b [ i ] / A ) * a [ i ] NEW_LINE health = [ 0 ] * n NEW_LINE for i in range ( n ) : health [ i ] = B - damage + a [ i ] NEW_LINE if max ( health ) > 0 : NEW_LINE INDENT print ( ' YES ' ) else : NEW_LINE print ( ' NO ' ) NEW_LINE DEDENT",
"import sysinput = sys . stdin . readlinet = int ( input ( ) ) NEW_LINE for i in range ( t ) : a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE attack = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE health = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE li = [ ] NEW_LINE for j in range ( c ) : if NEW_LINE health [ j ] % a != 0 : li . append ( [ attack [ j ] , ( health [ j ] // a ) + 1 ] ) else : li . append ( [ attack [ j ] , ( health [ j ] // a ) ] ) NEW_LINE li . sort ( key = lambda x : x [ 0 ] ) NEW_LINE bl = False NEW_LINE for j in range ( c ) : b -= li [ j ] [ 1 ] * li [ j ] [ 0 ] NEW_LINE if b <= 0 : bl = True NEW_LINE if bl == True : if NEW_LINE b + li [ - 1 ] [ 0 ] > 0 : bl = False NEW_LINE if bl == False : NEW_LINE INDENT print ( \" YES \" ) else : NEW_LINE print ( \" NO \" ) NEW_LINE DEDENT",
"import mathfrom NEW_LINE sys NEW_LINE import stdininput = stdin . readlinefor NEW_LINE _ in range ( int ( input ( ) ) ) : A , B , n = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( n ) : fights = math . ceil ( b [ i ] / A ) NEW_LINE B -= a [ i ] * fights B += max ( a ) NEW_LINE if B > 0 : NEW_LINE INDENT print ( \" YES \" ) else : NEW_LINE print ( \" NO \" ) NEW_LINE DEDENT",
"T_ON = 1 NEW_LINE DEBUG_ON = 0 NEW_LINE MOD = 998244353 NEW_LINE def solve ( ) : A , B , n = read_ints ( ) NEW_LINE X = read_ints ( ) NEW_LINE Y = read_ints ( ) NEW_LINE for x , y in zip ( X , Y ) : cnt = math . ceil ( y / A ) NEW_LINE B -= cnt * x NEW_LINE if B + max ( X ) > 0 : NEW_LINE INDENT YES ( ) else : NEW_LINE NO ( ) NEW_LINE DEDENT def main ( ) : T = read_int ( ) if T_ON else 1 NEW_LINE for i in range ( T ) : solve ( ) NEW_LINE def debug ( * xargs ) : if NEW_LINE DEBUG_ON : print ( * xargs ) from collections import * NEW_LINE import NEW_LINE INDENT math NEW_LINE DEDENT"
] |
codeforces_393_B | [
"import java . util . Scanner ; public class Three_Matrices { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] ar = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { ar [ i ] [ j ] = sc . nextInt ( ) ; } } double [ ] [ ] arrA = new double [ n ] [ n ] ; double [ ] [ ] arrB = new double [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { arrA [ i ] [ j ] = ( 1.0 * ar [ i ] [ j ] + ar [ j ] [ i ] ) / 2 ; arrB [ i ] [ j ] = ar [ i ] [ j ] - arrA [ i ] [ j ] ; arrA [ j ] [ i ] = arrA [ i ] [ j ] ; arrB [ j ] [ i ] = 0.0 - arrB [ i ] [ j ] ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( arrA [ i ] [ j ] + \" ▁ \" ) ; } System . out . println ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( arrB [ i ] [ j ] + \" ▁ \" ) ; } System . out . println ( ) ; } } }",
"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] [ ] w = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { w [ i ] [ j ] = scanner . nextInt ( ) ; } }",
"import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {"
] | [
"n = int ( input ( ) ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] b = [ [ 0 for j in range ( n ) ] for i in range ( n ) ] c = [ [ 0 for j in range ( n ) ] for i in range ( n ) ] for i in range ( n ) : for j in range ( i , n ) : if ( i == j ) : b [ i ] [ j ] = a [ i ] [ j ] / 1 else : x = ( a [ i ] [ j ] + a [ j ] [ i ] ) / 2 b [ i ] [ j ] = x b [ j ] [ i ] = x c [ i ] [ j ] = a [ i ] [ j ] - x c [ j ] [ i ] = a [ j ] [ i ] - xfor i in b : for j in i : print ( \" { 0 : . 8f } \" . format ( j ) , end = \" ▁ \" ) print ( ) for i in c : for j in i : print ( \" { 0 : . 8f } \" . format ( j ) , end = \" ▁ \" ) print ( ) NEW_LINE",
"''' ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Online ▁ Python ▁ Compiler . ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Code , ▁ Compile , ▁ Run ▁ and ▁ Debug ▁ python ▁ program ▁ online . Write ▁ your ▁ code ▁ in ▁ this ▁ editor ▁ and ▁ press ▁ \" Run \" ▁ button ▁ to ▁ execute ▁ it . ''' n = int ( input ( ) ) matrix = [ ] for i in range ( n ) : listA = input ( ) . split ( ) for i in range ( 0 , len ( listA ) ) : listA [ i ] = int ( listA [ i ] ) matrix . append ( listA ) matAt = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] matBt = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] for i in range ( n ) : for j in range ( n ) : matAt [ i ] [ j ] = matrix [ j ] [ i ] matAt [ i ] [ j ] = float ( matAt [ i ] [ j ] + matrix [ i ] [ j ] ) / 2 for i in range ( n ) : for j in range ( n ) : matBt [ i ] [ j ] = 0 - matrix [ j ] [ i ] matBt [ i ] [ j ] = float ( matBt [ i ] [ j ] + matrix [ i ] [ j ] ) / 2 for i in range ( n ) : print ( * matAt [ i ] ) for i in range ( n ) : print ( * matBt [ i ] ) NEW_LINE",
"n = int ( input ( ) ) arr = [ ] for i in range ( n ) : arr . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ ] b = [ ] for i in range ( n ) : a . append ( [ ] ) b . append ( [ ] ) for j in range ( n ) : a [ i ] . append ( ( arr [ i ] [ j ] + arr [ j ] [ i ] ) / 2 ) b [ i ] . append ( arr [ i ] [ j ] - a [ i ] [ j ] ) for i in range ( n ) : print ( * a [ i ] ) for i in range ( n ) : print ( * b [ i ] ) NEW_LINE",
"n = int ( input ( ) ) W = [ ] def print_matrix ( A ) : for i in A : for j in i : print ( j , end = ' ▁ ' ) print ( ) for i in range ( n ) : row_input = input ( ) row_list = row_input . split ( ) new_row_list = [ ] for j in row_list : new_row_list . append ( float ( j ) ) W . append ( new_row_list ) a = [ row [ : ] for row in W ] b = [ row [ : ] for row in W ] for j in range ( n ) : for i in range ( n ) : if i == j : b [ j ] [ i ] = W [ j ] [ i ] - a [ j ] [ i ] continue a [ j ] [ i ] = ( W [ j ] [ i ] + W [ i ] [ j ] ) / 2.0 b [ j ] [ i ] = W [ j ] [ i ] - a [ j ] [ i ] NEW_LINE",
"n = int ( input ( ) ) arr = [ ] for i in range ( n ) : arr . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ ] b = [ ] for i in range ( n ) : a . append ( [ ] ) b . append ( [ ] ) for j in range ( n ) : a [ i ] . append ( ( arr [ i ] [ j ] + arr [ j ] [ i ] ) / 2 ) b [ i ] . append ( arr [ i ] [ j ] - a [ i ] [ j ] ) for i in range ( n ) : print ( * a [ i ] ) for i in range ( n ) : print ( * b [ i ] ) NEW_LINE"
] |
codeforces_1373_A | [
" import java . util . * ; import java . io . * ; public class Main { private static final int N = ( int ) 1e3 + 10 ; public static void main ( String [ ] args ) throws IOException { int t ; StreamTokenizer cin = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ;",
"import java . util . * ; import java . io . * ; public class Main { private static final int N = ( int ) 1e3 + 10 ; public static void main ( String [ ] args ) throws IOException { int t ;",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { long a = sc . nextLong ( ) , b = sc . nextLong ( ) , c = sc . nextLong ( ) ; if ( b == 1 ) { if ( a == c ) System . out . println ( \" - 1 ▁ - 1\" ) ; else if ( a < c ) System . out . println ( \"1 ▁ - 1\" ) ; else System . out . println ( \" - 1 ▁ 1\" ) ; } else if ( a == c ) System . out . println ( \" - 1 ▁ 2\" ) ; else if ( a > c ) System . out . println ( \" - 1 ▁ 1\" ) ; else { if ( a * b > c ) System . out . println ( \"1 ▁ \" + b ) ; else System . out . println ( \"1 ▁ - 1\" ) ; } } } }",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { long a = in . nextLong ( ) ; long b = in . nextLong ( ) ; long c = in . nextLong ( ) ; if ( a < c ) System . out . print ( \"1 ▁ \" ) ; else System . out . print ( \" - 1 ▁ \" ) ; if ( c < b * a ) System . out . print ( b ) ; else System . out . print ( \" - 1\" ) ; System . out . println ( ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( t -- != 0 ) { long a = s . nextLong ( ) ; long b = s . nextLong ( ) ; long c = s . nextLong ( ) ; if ( c > a ) { System . out . print ( 1 + \" ▁ \" ) ; } else { System . out . print ( - 1 + \" ▁ \" ) ; } if ( a * b > c ) { System . out . println ( b + \" ▁ \" ) ; } else { System . out . println ( - 1 + \" ▁ \" ) ; } } } }"
] | [
"import math as mt = int ( input ( ) ) for z in range ( t ) : a , b , c = list ( map ( int , input ( ) . split ( ) ) ) if c == a : print ( f ' -1 ▁ { b } ' ) elif c > a : print ( 1 , end = ' ▁ ' ) if a * b > c : print ( b ) else : print ( - 1 ) else : if a * b < c : print ( b , end = ' ▁ ' ) else : print ( - 1 , end = ' ▁ ' ) print ( 1 ) NEW_LINE",
"for tc in range ( int ( input ( ) ) ) : a , b , c = map ( int , input ( ) . split ( ) ) print ( 1 if a < c else - 1 , end = \" ▁ \" ) print ( b if c < a * b else - 1 ) NEW_LINE",
"cases = int ( input ( ) ) while cases : cases -= 1 a , b , c = map ( int , input ( ) . split ( ) ) if a >= c : ans1 = - 1 else : ans1 = 1 if a <= c // b : ans2 = - 1 else : ans2 = b print ( ans1 , ans2 ) NEW_LINE",
"import mathtry : t = int ( input ( ) ) for i in range ( t ) : a , b , c = map ( int , input ( ) . split ( ) ) if ( c / b ) > a : print ( 1 , - 1 ) elif ( c / b ) < a : if b * a > c : if a < c : print ( 1 , b ) else : print ( - 1 , b ) else : print ( - 1 , b ) else : if b * a > c : print ( 1 , b ) else : print ( 1 , - 1 ) except : pass NEW_LINE",
"if __name__ == \" _ _ main _ _ \" : T = int ( input ( ) ) solution = 0 for t in range ( T ) : a , b , c = map ( int , input ( ) . split ( ) ) if b * a < c : print ( '1' , ' ▁ ' , ' - 1' ) elif b * a == c : print ( b - 1 , ' ▁ ' , ' - 1' ) else : NEW_LINE"
] |
codeforces_427_A | [
"import java . util . Scanner ; public class Test { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int [ ] arr = new int [ n ] ; int count = 0 ; int hired = 0 , crime = 0 ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) ++ crime ; if ( arr [ i ] > 0 ) hired += arr [ i ] ; if ( arr [ i ] < 0 && hired > 0 ) { -- hired ; -- crime ; } } System . out . println ( Math . abs ( crime ) ) ; } }",
"import java . util . Scanner ; public class kop { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int [ ] mas = new int [ n ] ; int sum = 0 ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int m = in . nextInt ( ) ; mas [ i ] = m ; } for ( int i = 0 ; i < n ; i ++ ) { if ( mas [ i ] > 0 ) { sum += mas [ i ] ; } else if ( mas [ i ] < 0 ) { if ( sum > 0 ) { sum -- ; } else { res ++ ; } } } System . out . println ( res ) ; } }",
"import java . util . Scanner ; public class PoliceRecruits { 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 crime = 0 ; int police = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > 0 ) { police = police + a [ i ] ; } else if ( a [ i ] < 0 && police == 0 ) { crime ++ ; } else police -- ; } System . out . println ( crime ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int unrated = 0 ; int police = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; if ( x != - 1 ) { police += x ; continue ; } if ( police == 0 ) unrated ++ ; else police -- ; } System . out . println ( unrated ) ; } } ",
"import java . util . Scanner ; public class PoliceRecruits { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int events = scanner . nextInt ( ) ; scanner . nextLine ( ) ; int availableCops = 0 ; int crimeUntreated = 0 ; for ( int i = 0 ; i < events ; i ++ ) { int s = scanner . nextInt ( ) ; if ( s >= 1 ) { availableCops += s ; } if ( s == - 1 ) { if ( availableCops == 0 ) { crimeUntreated ++ ; } else { availableCops -- ; } } } System . out . println ( crimeUntreated ) ; } }"
] | [
"current_popo = 0 untreated = 0 num_of_events = int ( input ( ) ) sequence = input ( ) . split ( ' ▁ ' ) for i in range ( sequence . __len__ ( ) ) : num = int ( sequence [ i ] ) if ( num > 0 ) : current_popo = current_popo + num if ( num < 0 ) : if ( current_popo == 0 ) : untreated = untreated + abs ( num ) else : current_popo = current_popo + num print ( untreated ) NEW_LINE",
"x = int ( input ( ) ) n = list ( map ( int , input ( ) . split ( ) ) ) prest = 0 cop = 0 for i in range ( x ) : cop += n [ i ] if cop < 0 : prest += 1 cop = 0 print ( prest ) NEW_LINE",
"a = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) c = 0 k = 0 for i in range ( a ) : c += l [ i ] if c >= 0 : continue else : k += 1 c = 0 print ( k ) NEW_LINE",
"n = int ( input ( ) ) l = [ int ( x ) for x in input ( ) . split ( ) ] c , r = 0 , 0 for i in range ( n ) : if l [ i ] > 0 : c += l [ i ] elif l [ i ] < 0 : if l [ i ] + c < 0 : r += l [ i ] + c else : c = c + l [ i ] print ( abs ( r ) ) NEW_LINE",
"n = int ( input ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) ] x = 0 y = 0 for i in l : if i < 0 and x == 0 : y = y + 1 elif i < 0 and x > 0 : x = x + i else : x = x + iprint ( y ) NEW_LINE"
] |
codeforces_241_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int m = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] length = new int [ m ] ; int [ ] oil = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { length [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { oil [ i ] = scanner . nextInt ( ) ; } int maxOil = 0 ; int costTime = 0 ; int oilLeft = 0 ; for ( int i = 0 ; i < m ; i ++ ) { maxOil = Math . max ( maxOil , oil [ i ] ) ; costTime += length [ i ] ; oilLeft = oilLeft + oil [ i ] - length [ i ] ; while ( oilLeft < 0 ) { oilLeft += maxOil ; costTime += k ; } } System . out . print ( costTime ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = 25 ;",
"import java . util . * ; import java . io . * ; public class Old_Peykan { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int t = 1 ; while ( t -- > 0 ) { String str [ ] = br . readLine ( ) . trim ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; str = br . readLine ( ) . trim ( ) . split ( \" ▁ \" ) ; int d [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { d [ i ] = Integer . parseInt ( str [ i ] ) ; } str = br . readLine ( ) . trim ( ) . split ( \" ▁ \" ) ; int s [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = Integer . parseInt ( str [ i ] ) ; } int max [ ] = new int [ n ] ; max [ 0 ] = s [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { max [ i ] = Math . max ( s [ i ] , max [ i - 1 ] ) ; } long time = 0 ; long patrol = 0 ; for ( int i = 0 ; i < n ; i ++ ) { patrol += s [ i ] ; if ( patrol < d [ i ] ) { int dif = ( int ) Math . abs ( patrol - d [ i ] ) ; int x = ( int ) Math . ceil ( dif * 1.0 / max [ i ] ) ; time += x * m ; patrol += x * max [ i ] ; patrol -= d [ i ] ; time += d [ i ] ; } else { time += d [ i ] ; patrol -= d [ i ] ; } "
] | [
"m , k = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) cap = 0 dis = 0 ma = 0 time = 0 for i in range ( m ) : dis = d [ i ] cap += ( s [ i ] - d [ i ] ) time += d [ i ] ma = max ( ma , s [ i ] ) if cap < 0 : while cap < 0 : cap += ma time += kprint ( time ) NEW_LINE",
"from math import ceil X = list ( map ( int , input ( ) . split ( ) ) ) Distance = list ( map ( int , input ( ) . split ( ) ) ) Fuel = list ( map ( int , input ( ) . split ( ) ) ) Tank , Time , Max = 0 , 0 , 0 for i in range ( X [ 0 ] ) : Tank += Fuel [ i ] Max = max ( Max , Fuel [ i ] ) Stay = max ( 0 , ceil ( ( Distance [ i ] - Tank ) / Max ) ) Time += Stay * X [ 1 ] + Distance [ i ] Tank += Stay * Max - Distance [ i ] print ( Time ) NEW_LINE",
"from math import ceiln , k = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) fuel = 0 stor = 0 time = 0 for i in range ( n ) : fuel += s [ i ] stor = max ( stor , s [ i ] ) if fuel >= d [ i ] : fuel -= d [ i ] time += d [ i ] else : yy = ceil ( ( d [ i ] - fuel ) / stor ) time += k * yy time += d [ i ] fuel += stor * yy fuel -= d [ i ] print ( time ) NEW_LINE",
"def main ( ) : import sys input = sys . stdin . readline m , k = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) t = 0 f = 0 ma = 0 for i in range ( m ) : f += s [ i ] ma = max ( ma , s [ i ] ) while f < d [ i ] : f += ma t += k t += d [ i ] f -= d [ i ] print ( t ) return 0 main ( ) NEW_LINE",
"a , b = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) p = list ( map ( int , input ( ) . split ( ) ) ) t = 0 ; d1 = 0 ; i = 0 while i < a : if t + sum ( p [ i : : ] ) - sum ( d [ i : : ] ) < 0 : j = i ; pr = p [ i ] while j < a and pr >= p [ j ] : j += 1 k = ( - t - sum ( p [ i : j ] ) - 1 + sum ( d [ i : j ] ) + pr ) // pr d1 += b * k t = ( pr * k - ( - t - sum ( p [ i : j ] ) + sum ( d [ i : j ] ) ) ) % pr i = j else : i += 1 print ( sum ( d ) + d1 ) NEW_LINE"
] |
codeforces_361_B | [
"import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import javafx . util . Pair ; public class Main {",
"import java . util . Scanner ; public class BeautifulPermutation { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; if ( n > k ) { StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < n - k ; i ++ ) { if ( i == 0 ) { ans . append ( n - k ) . append ( \" ▁ \" ) ; } else ans . append ( i ) . append ( \" ▁ \" ) ; } for ( int i = n - k ; i < n ; i ++ ) { ans . append ( i + 1 ) . append ( \" ▁ \" ) ; } System . out . println ( ans ) ; } else { System . out . println ( - 1 ) ; } } }"
] | [
"import mathn , k = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) NEW_LINE",
"v = map ( int , input ( ) . split ( ) ) n , k = v r2 = [ ] if k > n or ( n == 1 and k > 0 ) : print ( - 1 ) elif k == n : print ( - 1 ) else : r2 . append ( n - k ) for d in range ( 1 , n - k ) : r2 . append ( d ) for e in range ( n - k + 1 , n + 1 ) : r2 . append ( e ) for v in r2 : print ( v , end = ' ▁ ' ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) if ( n == k ) : print ( \" - 1\" ) else : print ( n - k , end = \" ▁ \" ) r = 0 r = r + 1 j = 1 while ( r < n ) : if ( j == n - k ) : j = j + 1 print ( j , end = \" ▁ \" ) j = j + 1 else : print ( j , end = \" ▁ \" ) j = j + 1 r = r + 1 NEW_LINE",
"import mathdef main ( ) : n , k = map ( int , input ( ) . split ( ) ) if n == k or n == k - 1 : print ( \" - 1\" ) exit ( ) if n == k + 1 : for i in range ( n ) : print ( i + 1 , end = \" ▁ \" ) exit ( ) if n == k + 2 : print ( n , end = \" ▁ \" ) for i in range ( n - 2 ) : print ( i + 2 , end = \" ▁ \" ) print ( 1 ) exit ( ) l = [ ] for i in range ( k + 1 ) : l . append ( i + 1 ) for i in range ( k + 1 , n - 1 ) : l . append ( i + 2 ) if math . gcd ( 10000 , k + 2 ) > 1 : l . append ( 1 ) l [ 0 ] = k + 2 else : l . append ( k + 2 ) print ( * l ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE",
"import sysimport mathdef gcd ( a , b ) : c = max ( a , b ) d = min ( a , b ) r = c % d if r == 0 : return d return gcd ( d , r ) def lcm ( a , b ) : def gcd_naive ( a , b ) : c = max ( a , b ) d = min ( a , b ) r = c % d if r == 0 : return d return gcd_naive ( d , r ) return int ( a * b / gcd_naive ( a , b ) ) def fn ( n , k ) : l = [ 0 ] * ( n ) if n <= k : print ( - 1 ) return 0 elif n == k + 1 : for i in range ( n ) : l [ i ] = i + 1 print ( * l ) return 0 else : for i in range ( 1 , k + 1 ) : l [ i ] = i + 1 l [ 0 ] = n for i in range ( n - 2 , k , - 1 ) : l [ i + 1 ] = i + 1 l [ k + 1 ] = 1 print ( * l ) if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( int , input . split ( ) ) ) n = data [ 0 ] k = data [ 1 ] ( fn ( n , k ) ) NEW_LINE"
] |
codeforces_137_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner input = new FastScanner ( ) ; String s = input . next ( ) ; int ans = 0 ; Stack < Character > st = new Stack < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( st . isEmpty ( ) ) st . add ( s . charAt ( i ) ) ; else { if ( st . peek ( ) == s . charAt ( i ) ) { st . add ( s . charAt ( i ) ) ; } else { ans ++ ; st . clear ( ) ; st . add ( s . charAt ( i ) ) ; } } if ( st . size ( ) == 5 ) { ans ++ ; st . clear ( ) ; } } if ( ! st . isEmpty ( ) ) ans ++ ; System . out . println ( ans ) ; } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = nextInt ( ) ; } return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; char ch = s . charAt ( 0 ) ; int c = 1 ; int ans = 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ch ) { if ( c < 5 ) c ++ ; else { ans += 1 ; c = 1 ; } } else { ans += 1 ; c = 1 ; ch = s . charAt ( i ) ; }",
"import java . util . Scanner ; public class PostCardPhotos { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . nextLine ( ) ; int closet = 1 ; int count = 1 ; char prev = s . charAt ( 0 ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( prev == s . charAt ( i ) ) { if ( count == 5 ) { count = 0 ; closet ++ ; } count ++ ; } else { count = 1 ; closet ++ ; if ( count == 5 ) { count = 0 ; } } prev = s . charAt ( i ) ; } System . out . println ( closet ) ; } }",
"import java . util . Scanner ; public class PostcardsAndPhotos { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . next ( ) ; int count = 1 ; char c = s . charAt ( 0 ) ; int temp = 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != c || temp == 5 ) { count ++ ; temp = 1 ; c = s . charAt ( i ) ; } else temp ++ ; } System . out . println ( count ) ; } }"
] | [
"s = input ( ) c = 0 d = 0 if ( len ( s ) > 1 ) : for i in range ( len ( s ) - 1 ) : if ( s [ i ] != s [ i + 1 ] ) : c = c + 1 d = 0 else : d = d + 1 if ( d == 5 ) : d = 0 c = c + 1 if ( s [ - 1 ] == s [ - 2 ] and d != 5 ) : c = c + 1 elif ( s [ - 1 ] != s [ - 2 ] ) : c = c + 1 print ( c ) else : print ( 1 ) NEW_LINE",
"import mathn = input ( ) def length ( s ) : res = [ ] counter = 1 for i in range ( 1 , len ( s ) ) : if s [ i - 1 ] == s [ i ] : counter += 1 else : res . append ( counter ) counter = 1 res . append ( counter ) return ressol = length ( n ) for i in range ( len ( sol ) ) : sol [ i ] = math . ceil ( sol [ i ] / 5 ) print ( sum ( sol ) ) NEW_LINE",
"st = input ( ) con = 1 ans = 1 pre = st [ 0 ] for i in range ( 1 , len ( st ) ) : if pre == st [ i ] and con < 5 : con += 1 else : con = 1 ans += 1 pre = st [ i ] print ( ans ) NEW_LINE",
"import sysfrom math import sqrt , log , log2 , ceil , log10 , gcd , floor , pow , sin , cos , tan , pi , inf , factorialfrom copy import copy , deepcopyfrom sys import exit , stdin , stdoutfrom collections import Counter , defaultdict , dequefrom itertools import permutationsimport heapqfrom bisect import bisect_left from bisect import bisect_right NEW_LINE",
"def solve ( s ) : tot = 1 count = 1 i = 1 while i < len ( s ) : if s [ i ] == s [ i - 1 ] : if count == 5 : count = 1 tot += 1 else : count += 1 else : count = 1 tot += 1 i += 1 return tot def main ( ) : s = input ( ) NEW_LINE"
] |
codeforces_312_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class ChatRecord { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String chat = reader . readLine ( ) ; if ( chat . startsWith ( \" miao . \" ) ) { if ( chat . endsWith ( \" lala . \" ) ) { System . out . println ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) ; } else System . out . println ( \" Rainbow ' s \" ) ; } else if ( chat . endsWith ( \" lala . \" ) ) { System . out . println ( \" Freda ' s \" ) ; } else System . out . println ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) ; } } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int n = Integer . parseInt ( in . nextLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = in . nextLine ( ) ; boolean f = s . endsWith ( \" lala . \" ) ; boolean r = s . startsWith ( \" miao . \" ) ; if ( f && ! r ) System . out . println ( \" Freda ' s \" ) ; else if ( r && ! f ) System . out . println ( \" Rainbow ' s \" ) ; else System . out . println ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) ; } } }",
"import java . util . Scanner ; public class B { public static Scanner scan = new Scanner ( System . in ) ; public static void solve ( ) { int n = scan . nextInt ( ) ; scan . nextLine ( ) ; while ( n -- > 0 ) { String s = scan . nextLine ( ) ; if ( s . startsWith ( \" miao . \" ) && ! s . endsWith ( \" lala . \" ) ) { System . out . println ( \" Rainbow ' s \" ) ; } else if ( ! s . startsWith ( \" miao . \" ) && s . endsWith ( \" lala . \" ) ) { System . out . println ( \" Freda ' s \" ) ; } else { System . out . println ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) ; } } } public static void main ( String [ ] args ) { solve ( ) ; scan . close ( ) ; } }"
] | [
"try : n = int ( input ( ) ) for i in range ( n ) : s = input ( ) if ( s . endswith ( \" lala . \" ) and s . startswith ( \" miao . \" ) ) or ( not s . endswith ( \" lala . \" ) and not s . startswith ( \" miao . \" ) ) : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) elif s . startswith ( \" miao . \" ) : print ( \" Rainbow ' s \" ) else : print ( \" Freda ' s \" ) except : pass NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : s = input ( ) if len ( s ) < 5 : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) elif ' lala ' not in s and ' miao . ' not in s : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) elif s [ : 5 ] == ' miao . ' and s [ - 5 : ] == ' lala . ' : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) elif s [ : 5 ] == ' miao . ' : print ( \" Rainbow ' s \" ) elif s [ - 5 : ] == ' lala . ' : print ( \" Freda ' s \" ) else : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) NEW_LINE",
"for x in range ( int ( input ( ) ) ) : a = input ( ) b = len ( a ) - 5 print if \" lala . \" in a [ b : ] and \" miao . \" in a [ : 5 ] : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) elif \" miao . \" in a [ : 5 ] : print ( \" Rainbow ' s \" ) elif \" lala . \" in a [ b : ] : print ( \" Freda ' s \" ) else : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) NEW_LINE",
"t = int ( input ( ) ) while t > 0 : t -= 1 s = input ( ) if len ( s ) >= 5 : if s [ : 5 ] == \" miao . \" and s [ : : - 1 ] [ : 5 ] != \" . alal \" : print ( \" Rainbow ' s \" ) elif s [ : 5 ] != \" miao . \" and s [ : : - 1 ] [ : 5 ] == \" . alal \" : print ( \" Freda ' s \" ) else : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) else : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) NEW_LINE",
"def solve ( ) : s = input ( ) if ( s [ - 5 : ] == ' lala . ' and s [ : 5 ] != \" miao . \" ) : print ( \" Freda ' s \" ) elif ( s [ - 5 : ] != ' lala . ' and s [ : 5 ] == \" miao . \" ) : print ( \" Rainbow ' s \" ) else : print ( \" OMG > . < ▁ I ▁ don ' t ▁ know ! \" ) n = int ( input ( ) ) for _ in range ( n ) : solve ( ) NEW_LINE"
] |
codeforces_757_B | [
"import java . io . * ; import java . util . * ; import static java . lang . Integer . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastReader in = new FastReader ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = in . nextInt ( ) ; for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { int cnt = map . getOrDefault ( j , 0 ) ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import static java . util . Arrays . sort ; import javafx . util . Pair ; public class Main { public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int count [ ] = new int [ 100001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int value = input . nextInt ( ) ; count [ value ] ++ ; } int max = 1 ; for ( int i = 2 ; i < 100001 ; i ++ ) { int c = 0 ; for ( int j = i ; j <= 100000 ; j += i ) { c += count [ j ] ; } max = Math . max ( max , c ) ; } System . out . println ( max ) ; } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) throws IOException { return br . readLine ( ) ; } } }",
"import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Main { static boolean [ ] prime ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter p = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; int [ ] ara = new int [ 100001 ] ; Arrays . fill ( ara , 0 ) ; int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { ara [ in . nextInt ( ) ] ++ ; } for ( int i = 2 ; i < ara . length ; i ++ ) { for ( int j = i * 2 ; j < ara . length ; j += i ) { ara [ i ] += ara [ j ] ; } ans = Math . max ( ans , ara [ i ] ) ; } p . println ( ans ) ; p . close ( ) ; } }"
] | [
"res , N = 1 , int ( 1e5 + 16 ) n = int ( input ( ) ) M = { } for i in map ( int , input ( ) . split ( ) ) : M [ i ] = M . get ( i , 0 ) + 1 for i in range ( 2 , N ) : num = 0 for k in range ( i , N , i ) : num += M . get ( k , 0 ) res = max ( res , num ) print ( res ) NEW_LINE",
"n = int ( input ( ) ) ip = list ( map ( int , input ( ) . split ( ) ) ) m = max ( ip ) ; ans = 0 x = [ 0 ] * ( m + 1 ) ; p = [ ] p . append ( 1 ) for i in ip : x [ i ] += 1 for k in range ( 2 , m + 1 , 1 ) : l = k z = 0 while l <= m : z += x [ l ] l += k if ans < z : p . append ( z ) print ( max ( p ) ) NEW_LINE",
"from collections import defaultdictn = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) factors = defaultdict ( int ) for i in range ( n ) : root = int ( a [ i ] ** 0.5 ) for j in range ( 2 , root + 1 ) : if a [ i ] % j == 0 : factors [ j ] += 1 while a [ i ] % j == 0 : a [ i ] //= j if a [ i ] > 1 : factors [ a [ i ] ] += 1 ans = 1 for i in factors : ans = max ( ans , factors [ i ] ) print ( ans ) NEW_LINE",
"n = int ( input ( ) ) ip = list ( map ( int , input ( ) . split ( ) ) ) m = max ( ip ) ; ans = 0 x = [ 0 ] * ( m + 1 ) ; p = [ ] p . append ( 1 ) for i in ip : x [ i ] += 1 for k in range ( 2 , m + 1 , 1 ) : l = k z = 0 while l <= m : z += x [ l ] l += k if ans < z : p . append ( z ) print ( max ( p ) ) NEW_LINE",
"val = int ( '1' + '0' * 5 ) freequency = [ 0 ] * ( val + 1 ) n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) for x in range ( n ) : freequency [ l [ x ] ] += 1 ans = 1 for x in range ( 2 , val + 1 ) : count = 0 for y in range ( x , val + 1 , x ) : count += freequency [ y ] ans = max ( ans , count ) print ( ans ) NEW_LINE"
] |
codeforces_476_A | [
"import java . util . * ; public class DreamoonAndStairs { public static int minStair ( int n , int m ) { if ( n < m ) { return - 1 ; } int minSteps = n / 2 + n % 2 ; int nextMultiple = m ; int i = 2 ; while ( true ) { if ( minSteps > nextMultiple ) { nextMultiple = m * i ; } else { break ; } i ++ ; } return nextMultiple ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; System . out . println ( minStair ( n , m ) ) ; in . close ( ) ; } }",
"import java . util . Scanner ; public class cond { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; if ( m > n ) { System . out . println ( - 1 ) ; return ; } else if ( n % 2 == 0 ) { int k = n / 2 ; while ( k <= n ) { if ( k % m == 0 ) { System . out . println ( k ) ; return ; } k ++ ; } } else { int k = ( n / 2 ) + 1 ; while ( k <= n ) { if ( k % m == 0 ) { System . out . println ( k ) ; return ; } k ++ ; } } } }",
"import java . util . Scanner ; public class _0604DreamoonandStairs { static int DreamoonandStairs ( int n , int m ) { int val = n / 2 ; if ( n % 2 != 0 ) { val ++ ; } if ( val % m != 0 ) { val += m - ( val % m ) ; } return val ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; if ( n < m ) { System . out . println ( - 1 ) ; } else { System . out . println ( DreamoonandStairs ( n , m ) ) ; } } }"
] | [
"n , m = map ( int , input ( ) . split ( ) ) count = 0 if ( n < m ) : print ( \" - 1\" ) else : if ( n % 2 == 0 ) : count = n // 2 else : count = n // 2 + 1 while ( count % m != 0 ) : count += 1 print ( count ) NEW_LINE",
"import mathdef solve ( n , m ) : start = n % 2 + n // 2 while start <= n : if start % m == 0 : return start start += 1 return - 1 def main ( ) : NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) t = ( n // 2 ) + ( n % 2 ) print ( - 1 ) if n < m else print ( t + ( ( m - ( t % m ) ) % m ) ) NEW_LINE",
"import sys n , m = map ( int , sys . stdin . readline ( ) . split ( ) ) num_twos = n // 2 ; num_steps = num_twos + n % 2 num_changed = 0 while ( num_steps % m != 0 ) and ( num_twos > 0 ) and ( num_changed < 30 ) : num_twos -= 1 num_steps += 1 num_changed += 1 if num_steps % m != 0 : print ( - 1 ) else : print ( num_steps ) NEW_LINE",
"import sysfrom functools import lru_cache , cmp_to_keyfrom heapq import merge , heapify , heappop , heappushfrom math import * from collections import defaultdict as dd , deque , Counter as Cfrom itertools import combinations as comb , permutations as permfrom bisect import bisect_left as bl , bisect_right as br , bisect , insortfrom time import perf_counterfrom fractions import Fractionimport copyfrom copy import deepcopyimport timestarttime = time . time ( ) mod = int ( pow ( 10 , 9 ) + 7 ) mod2 = 998244353 def data ( ) : return sys . stdin . readline ( ) . strip ( ) def out ( * var , end = \" \\n \" ) : sys . stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) def L ( ) : return list ( sp ( ) ) def sl ( ) : return list ( ssp ( ) ) def sp ( ) : return map ( int , data ( ) . split ( ) ) def ssp ( ) : return map ( str , data ( ) . split ( ) ) def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] def l2d ( n , m , val = 0 ) : return [ l1d ( n , val ) for j in range ( m ) ] try : NEW_LINE"
] |
codeforces_226_A | [
"a , b = map ( int , raw_input ( ) . split ( ) ) print ( ( pow ( 3 , a , b ) + b - 1 ) % b )",
"# include < iostream > using namespace std ; int n , m ; int putere ( int x , int p ) ; int main ( ) { int i ; cin >> n >> m ; int rez = putere ( 3 , n ) ; rez -- ; if ( rez < 0 ) rez += m ; cout << rez << ' \\n ' ; return 0 ; } int putere ( int x , int p ) { int aux = 1 ; while ( p ) { if ( p % 2 ) aux = ( 1l l * aux * x ) % m ; x = ( 1l l * x * x ) % m ; p /= 2 ; } return aux ; }",
"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 FlyingSaucerSegments { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; long n = in . nextLong ( ) ; long mod = in . nextLong ( ) ; long ans = fastPow ( 3 , n , mod ) - 1 ; if ( ans == - 1 ) ans += mod ; out . println ( ans ) ; out . close ( ) ; } static long fastPow ( long a , long b , long mod ) { if ( b == 0 ) return 1L ; long val = fastPow ( a , b / 2 , mod ) ; if ( b % 2 == 0 ) return val * val % mod ; else return val * val % mod * a % mod ; } 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 long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }",
"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 FlyingSaucerSegments { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; long n = in . nextLong ( ) ; long mod = in . nextLong ( ) ; long ans = fastPow ( 3 , n , mod ) - 1 ; if ( ans == - 1 ) ans += mod ; out . println ( ans ) ; out . close ( ) ; } static long fastPow ( long a , long b , long mod ) { if ( b == 0 ) return 1L ; long val = fastPow ( a , b / 2 , mod ) ; if ( b % 2 == 0 ) return val * val % mod ; else return val * val % mod * a % mod ; } 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 long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }"
] | [
"n = input ( ) . split ( ) n1 = int ( n [ 0 ] ) n2 = int ( n [ 1 ] ) F = pow ( 3 , n1 , n2 ) print ( ( F - 1 ) % n2 ) NEW_LINE"
] |
codeforces_1205_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ; public class Solution { static ArrayList < Integer > [ ] adjlist ; static int n ; static final int inf = ( int ) 1e9 ; static int ans = inf ; static int [ ] q ; public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { n = fs . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = fs . nextLong ( ) ;"
] | [
"import sysinput = sys . stdin . readlinefrom collections import deque class Graph ( object ) : \"\"\" docstring ▁ for ▁ Graph \"\"\" def __init__ ( self , n , d ) : NEW_LINE",
"from sys import stdinfrom collections import deque INT_MAX = float ( ' inf ' ) def shortest_cycle ( gr ) : NEW_LINE",
"def solve ( n , a ) : B = 60 bits = [ [ ] for i in range ( B ) ] for i in range ( n ) : for j in range ( B ) : if a [ i ] & ( 1 << j ) : bits [ j ] . append ( i ) adj = [ [ ] for i in range ( n ) ] for shared in bits : if len ( shared ) >= 3 : return 3 elif len ( shared ) == 2 : u , v = shared adj [ u ] . append ( v ) adj [ v ] . append ( u ) vis = [ False for u in range ( n ) ] dist = [ - 1 for u in range ( n ) ] def shortest_cycle ( n , adj , s ) : frontier = [ ( s , - 1 ) ] dist [ s ] = 0 ptr = 0 while ptr < len ( frontier ) : u , p = frontier [ ptr ] if not vis [ u ] : vis [ u ] = True for v in adj [ u ] : if vis [ v ] and v != p : ans = dist [ u ] + dist [ v ] + 1 for u , p in frontier : vis [ u ] = False dist [ u ] = - 1 return ans if dist [ v ] == - 1 : dist [ v ] = dist [ u ] + 1 frontier . append ( ( v , u ) ) ptr += 1 return 10 ** 18 NEW_LINE",
"import sysreadline = sys . stdin . readlinefrom collections import deque N = int ( readline ( ) ) A = list ( map ( int , readline ( ) . split ( ) ) ) A = [ a for a in A if a ] limit = 32 table = [ 0 ] * limit for a in A : for i in range ( limit ) : if a & ( 1 << i ) : table [ i ] += 1 if max ( table ) > 2 : print ( 3 ) else : INF = 10 ** 18 + 3 N = len ( A ) Edge = [ set ( ) for _ in range ( N ) ] for i in range ( N ) : for j in range ( i ) : if A [ i ] & A [ j ] : Edge [ i ] . add ( j ) Edge [ j ] . add ( i ) ans = INF for st in range ( N ) : for en in Edge [ st ] . copy ( ) : Edge [ st ] . remove ( en ) Edge [ en ] . remove ( st ) dist = [ INF ] * N dist [ st ] = 0 Q = deque ( [ st ] ) while Q : vn = Q . pop ( ) for vf in Edge [ vn ] : if dist [ vf ] == INF : dist [ vf ] = 1 + dist [ vn ] Q . appendleft ( vf ) ans = min ( ans , 1 + dist [ en ] ) Edge [ st ] . add ( en ) Edge [ en ] . add ( st ) if ans >= INF : ans = - 1 print ( ans ) NEW_LINE"
] |
codeforces_779_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Codeforces { private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ; public static int [ ] LPS ( String p ) { int [ ] lps = new int [ p . length ( ) ] ; int i = 1 ; int j = 0 ; while ( i < p . length ( ) ) { if ( p . charAt ( i ) == p . charAt ( j ) ) { lps [ i ] = j + 1 ; i ++ ; j ++ ; } else { if ( j == 0 ) { lps [ i ] = 0 ; i ++ ; } else { j = lps [ j - 1 ] ; } } } return lps ; } public static void KMP ( String text , String pattern ) { int [ ] lps = LPS ( pattern ) ; int i = 0 ; int j = 0 ; ArrayList < Integer > matches = new ArrayList < > ( ) ; while ( i < text . length ( ) ) { if ( text . charAt ( i ) == pattern . charAt ( j ) ) { i ++ ; j ++ ; } else { if ( j != 0 ) { j = lps [ j - 1 ] ; } else { i ++ ; } } if ( j == pattern . length ( ) ) { matches . add ( i - j ) ; j = lps [ j - 1 ] ; } } for ( int x : matches ) { System . out . println ( \" Match ▁ at ▁ : ▁ \" + x ) ; } } private static class SegmentTree { private long [ ] st ; private int size ; private int n ; private long [ ] a ; SegmentTree ( long [ ] a , int n ) { this . size = 4 * n ; this . n = n ; this . a = a ; st = new long [ size ] ;",
" import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ; public class file { ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; String s = input . next ( ) ; int k = input . nextInt ( ) ; int count = 0 ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '0' ) { count ++ ; } if ( count == k ) { System . out . println ( ( s . length ( ) - ( i ) ) - count ) ; return ; } } if ( count < k ) { System . out . println ( s . length ( ) - 1 ) ; } } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) throws IOException { return br . readLine ( ) ; } } }"
] | [
"n , k = [ x for x in input ( ) . split ( ) ] cnt = 0 k = int ( k ) l = len ( n ) for i in range ( l - 1 , - 1 , - 1 ) : if k <= 0 : break elif n [ i ] == '0' : k -= 1 else : cnt += 1 if k <= 0 : print ( cnt ) else : print ( l - 1 ) NEW_LINE",
"import sysimport mathfrom collections import OrderedDictdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) n , k = map ( str , input ( ) . split ( ) ) if n == '0' : print ( '0' ) elif n . count ( '0' ) < int ( k ) : print ( len ( n ) - 1 ) else : for i in range ( 1 , len ( n ) ) : if n [ i ] == '0' and n [ i : ] . count ( '0' ) == int ( k ) : print ( len ( n [ i : ] ) - int ( k ) ) break NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) n = str ( n ) if ( len ( n ) <= k ) : print ( len ( n ) - 1 ) else : n = str ( n ) count = 0 ans = 0 for i in range ( len ( n ) - 1 , - 1 , - 1 ) : if ( n [ i ] == \"0\" ) : count = count + 1 if ( count == k ) : break else : ans = ans + 1 if ( count != k ) : print ( len ( n ) - 1 ) else : print ( ans ) NEW_LINE",
"\"\"\" ▁ Created ▁ by ▁ Henrikh ▁ Kantuni ▁ on ▁ 2/26/17 ▁ \"\"\" n , k = [ int ( x ) for x in input ( ) . split ( ) ] digits = list ( str ( n ) ) zero_count = digits . count ( '0' ) if zero_count < k : print ( len ( str ( n ) ) - 1 ) exit ( ) count = 0 i = len ( digits ) - 1 while int ( ' ' . join ( digits ) ) % 10 ** k > 0 : if digits [ i ] != '0' : del digits [ i ] count += 1 i -= 1 print ( count ) NEW_LINE"
] |
codeforces_445_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import javafx . util . Pair ; public class Main { static long count = 0 ; public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; ArrayList < ArrayList < Integer > > a = new ArrayList < > ( n + 1 ) ; boolean visited [ ] = new boolean [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { a . add ( new ArrayList < > ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { int x = input . nextInt ( ) ; int y = input . nextInt ( ) ; a . get ( x ) . add ( y ) ; a . get ( y ) . add ( x ) ; } long ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ! visited [ i ] ) { count = 0 ; dfs ( visited , a , i ) ; ans += ( count - 1 ) ; } }",
"import java . io . BufferedWriter ; import java . io . ByteArrayInputStream ; import java . io . FileInputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . InputMismatchException ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . Queue ; import java . util . Set ; public class Main { private static final long MOD = ( long ) 1e9 + 7 ; static InputStream is ; static PrintWriter out ; static String INPUT = \" \" ; static int lenbuf = 0 , ptrbuf = 0 ; private static byte [ ] inbuf = new byte [ 1024 ] ; static boolean readFile = false ;",
"import java . io . BufferedWriter ; import java . io . ByteArrayInputStream ; import java . io . FileInputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . InputMismatchException ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . Queue ; import java . util . Set ; public class Main { private static final long MOD = ( long ) 1e9 + 7 ; static InputStream is ; static PrintWriter out ; static String INPUT = \" \" ; static int lenbuf = 0 , ptrbuf = 0 ; private static byte [ ] inbuf = new byte [ 1024 ] ; static boolean readFile = false ;",
"import java . util . * ; import java . util . zip . CRC32 ; public class Solution { static Scanner scan = new Scanner ( System . in ) ; static class DSU { int parent [ ] ; int groupSize [ ] ; public DSU ( int nodes ) { parent = new int [ nodes + 1 ] ; groupSize = new int [ nodes + 1 ] ; for ( int i = 0 ; i <= nodes ; i ++ ) { parent [ i ] = i ; groupSize [ i ] = 1 ; } } public int findSuperParent ( int node ) { if ( parent [ node ] == node ) return node ; return parent [ node ] = findSuperParent ( parent [ node ] ) ; } public void mergeGroup ( int x , int y ) { int xSuperParent = findSuperParent ( x ) ; int ySuperParent = findSuperParent ( y ) ; if ( xSuperParent == ySuperParent ) return ; if ( groupSize [ xSuperParent ] > groupSize [ ySuperParent ] ) { parent [ ySuperParent ] = xSuperParent ; groupSize [ xSuperParent ] += groupSize [ ySuperParent ] ; } else { parent [ xSuperParent ] = ySuperParent ; groupSize [ ySuperParent ] += groupSize [ xSuperParent ] ; } } public int getExpectedFriends ( int element ) { return groupSize [ findSuperParent ( element ) ] - 1 ; } } public static void main ( String [ ] args ) {",
"import java . io . * ; import java . util . * ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static FastReader sc = new FastReader ( ) ; static List < pair > g [ ] ; public static void main ( String [ ] args ) throws Exception { PrintWriter out = new PrintWriter ( System . out ) ; int k = 1 ;"
] | [
"import bisectimport collectionsimport copyimport functoolsimport heapqimport itertoolsimport mathimport randomimport reimport sysimport timeimport stringfrom typing import List NEW_LINE",
"from collections import defaultdictdef dfs ( node , graph , vis ) : global count vis [ node ] = True count += 1 for i in graph [ node ] : if not vis [ i ] : dfs ( i , graph , vis ) n , m = map ( int , input ( ) . split ( ) ) if m == 0 : print ( 1 ) else : graph = defaultdict ( list ) for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) graph [ a ] . append ( b ) graph [ b ] . append ( a ) vis = [ False ] * ( n + 1 ) ans = 0 ans = 0 for i in range ( 1 , n + 1 ) : global count count = 0 if not vis [ i ] : dfs ( i , graph , vis ) ans += 1 print ( pow ( 2 , n - ans ) ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) arr = [ x for x in range ( 0 , n + 1 ) ] d = 1 for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) a , b = arr [ a ] , arr [ b ] while a != arr [ a ] : a = arr [ a ] while b != arr [ b ] : b = arr [ b ] if a != b : arr [ b ] = a d *= 2 print ( d ) NEW_LINE",
"def gf ( x ) : if fa [ x ] != x : fa [ x ] = gf ( fa [ x ] ) return fa [ x ] n , m = map ( int , input ( ) . split ( ) ) fa = list ( range ( n + 1 ) ) for _ in range ( m ) : x , y = map ( int , input ( ) . split ( ) ) fa [ gf ( x ) ] = gf ( y ) ans = 2 ** nfor i in range ( 1 , n + 1 ) : if gf ( i ) == i : ans //= 2 print ( ans ) NEW_LINE"
] |
codeforces_263_A | [
"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 ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABeautifulMatrix solver = new ABeautifulMatrix ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABeautifulMatrix { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int r = - 1 , c = - 1 ; int [ ] [ ] a = new int [ 5 ] [ 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) { for ( int j = 0 ; j < 5 ; j ++ ) { a [ i ] [ j ] = in . nextInt ( ) ; if ( a [ i ] [ j ] == 1 ) { r = i ; c = j ; } } } int ans = Math . abs ( r - 2 ) + Math . abs ( c - 2 ) ; out . println ( ans ) ; } } static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } ",
"import java . io . * ; import java . lang . * ; import java . util . * ; public class TestA { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) { try { System . setIn ( new FileInputStream ( \" input . txt \" ) ) ; System . setOut ( new PrintStream ( new FileOutputStream ( \" output . txt \" ) ) ) ; } catch ( Exception e ) { System . err . println ( \" Error \" ) ; } FastReader objScanner = new FastReader ( ) ; \t\t int arr [ ] [ ] = new int [ 6 ] [ 6 ] ; int x = - 1 ; int y = - 1 ; for ( int i = 1 ; i <= 5 ; i ++ ) { for ( int j = 1 ; j <= 5 ; j ++ ) { arr [ i ] [ j ] = objScanner . nextInt ( ) ; if ( arr [ i ] [ j ] == 1 ) { x = i ; y = j ; } } } System . out . println ( Math . abs ( x - 3 ) + Math . abs ( y - 3 ) ) ; } } ",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = 0 , b = 0 ; for ( int i = 0 ; i < 25 ; i ++ ) { if ( scan . nextInt ( ) == 1 ) { a = i % 5 ; b = i / 5 ; } } System . out . println ( Math . abs ( a - 2 ) + Math . abs ( b - 2 ) ) ; } } ",
"import java . io . * ; import java . util . * ; import java . lang . * ; import java . util . Random ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int repeat = 1 ; while ( repeat -- > 0 ) { int [ ] [ ] matrix = new int [ 5 ] [ 5 ] ; int count = 0 ; int row = 0 ; int col = 0 ; while ( count < 25 ) { int val = scan . nextInt ( ) ; if ( val == 1 ) { row = count / 5 ; col = count % 5 ; break ; } count ++ ; } int dist = Math . abs ( row - 2 ) + Math . abs ( col - 2 ) ; System . out . println ( dist ) ; } } }",
"import java . util . Scanner ; public class BeautifulMatrix { public static void main ( String [ ] args ) { matrix ( ) ; } public static void matrix ( ) { Scanner s = new Scanner ( System . in ) ; int x = 0 , y = 0 ; int [ ] [ ] feld = new int [ 5 ] [ 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) { for ( int j = 0 ; j < 5 ; j ++ ) { feld [ i ] [ j ] = s . nextInt ( ) ; if ( feld [ i ] [ j ] == 1 ) { x = i ; y = j ; } } } int hor = x - 2 < 0 ? ( x - 2 ) * ( - 1 ) : x - 2 ; int vert = y - 2 < 0 ? ( y - 2 ) * ( - 1 ) : y - 2 ; System . out . print ( hor + vert ) ; } }"
] | [
"matrix = [ ] for i in range ( 5 ) : row = list ( map ( int , input ( ) . split ( ) ) ) matrix . append ( row ) r = 0 c = 0 for i in range ( 5 ) : for j in range ( 5 ) : if matrix [ i ] [ j ] == 1 : if ( i != 2 ) : r = abs ( 2 - i ) if ( j != 2 ) : c = abs ( 2 - j ) print ( r + c ) NEW_LINE",
"for row in range ( 0 , 5 ) : row_matrix = [ int ( n ) for n in input ( ) . split ( ) ] if 1 in row_matrix : column_index = row_matrix . index ( 1 ) print ( abs ( column_index - 2 ) + abs ( row - 2 ) ) NEW_LINE",
"lst = [ ] x = y = 0 for i in range ( 5 ) : matrix = input ( ) . split ( ) lst . append ( matrix ) for j in range ( 0 , 5 ) : if ( lst [ i ] [ j ] == \"1\" ) : x = i - 2 y = j - 2 print ( abs ( x ) + abs ( y ) ) NEW_LINE",
"lst = [ ] x = y = 0 for i in range ( 5 ) : matrix = input ( ) . split ( ) lst . append ( matrix ) for j in range ( 0 , 5 ) : if ( lst [ i ] [ j ] == \"1\" ) : x = i - 2 y = j - 2 print ( abs ( x ) + abs ( y ) ) NEW_LINE",
"data = [ ] for i in range ( 5 ) : data . append ( list ( map ( int , input ( ) . split ( ) ) ) ) n , m = 0 , 0 for i in range ( 5 ) : for j in range ( 5 ) : if data [ i ] [ j ] == 1 : n , m = i , j print ( abs ( 3 - ( n + 1 ) ) + abs ( 3 - ( m + 1 ) ) ) NEW_LINE"
] |
codeforces_468_A | [
"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = true ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static int oo = ( int ) 2e9 ;",
"import java . util . * ; import java . io . * ; public class Test { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; PriorityQueue < Integer > pq = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; if ( n <= 3 ) System . out . println ( \" NO \" ) ; else { System . out . println ( \" YES \" ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) { pq . add ( i ) ; } int ct = 0 ; while ( ! pq . isEmpty ( ) ) { int a = pq . poll ( ) ; int b = pq . poll ( ) ; if ( a == 4 ) { System . out . println ( \"4 ▁ * ▁ 3 ▁ = ▁ 12\" ) ; System . out . println ( \"12 ▁ * ▁ 2 ▁ = ▁ 24\" ) ; System . out . println ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) ; break ; } if ( a == 5 ) { System . out . println ( \"5 ▁ - ▁ 3 ▁ = ▁ 2\" ) ; System . out . println ( \"2 ▁ + ▁ 1 ▁ = ▁ 3\" ) ; System . out . println ( \"4 ▁ * ▁ 3 ▁ = ▁ 12\" ) ; System . out . println ( \"12 ▁ * ▁ 2 ▁ = ▁ 24\" ) ; break ; } System . out . println ( a + \" ▁ - ▁ \" + b + \" ▁ = ▁ 1\" ) ; ct ++ ; } while ( ct -- > 0 ) { System . out . println ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) ; } } } }"
] | [
"n = int ( input ( ) ) if n < 4 : print ( \" NO \" ) else : print ( \" YES \" ) if n == 4 : print ( \"4 ▁ * ▁ 3 ▁ = ▁ 12 \\n 12 ▁ * ▁ 2 ▁ = ▁ 24 \\n 24 ▁ * ▁ 1 ▁ = 24\" ) elif n == 5 : print ( \"5 ▁ * ▁ 4 ▁ = ▁ 20 \\n 20 ▁ + ▁ 3 ▁ = ▁ 23 \\n 23 ▁ + ▁ 2 ▁ = ▁ 25 \\n 25 ▁ - ▁ 1 ▁ = ▁ 24\" ) else : print ( \"4 ▁ * ▁ 3 ▁ = ▁ 12 \\n 12 ▁ * ▁ 2 ▁ = ▁ 24 \\n \" + str ( n ) + \" ▁ - ▁ \" + str ( n - 1 ) + \" ▁ = ▁ 1 \\n 1 ▁ - ▁ 1 ▁ = ▁ 0\" ) for i in range ( 5 , n - 1 ) : print ( str ( i ) + \" ▁ * ▁ 0 ▁ = ▁ 0\" ) print ( \"24 ▁ + ▁ 0 ▁ = ▁ 24\" ) NEW_LINE",
"n = int ( input ( ) ) if n > 3 : print ( \" YES \" ) if n % 2 : for i in range ( 6 , n , 2 ) : print ( i + 1 , \" ▁ - ▁ \" , i , \" ▁ = ▁ \" , 1 ) print ( \"5 ▁ - ▁ 1 ▁ = ▁ 4 \\n 4 ▁ - ▁ 2 ▁ = ▁ 2\" ) print ( \"4 ▁ * ▁ 3 ▁ = ▁ 12 \\n 12 ▁ * ▁ 2 ▁ = ▁ 24\" ) else : print ( \"4 ▁ * ▁ 3 ▁ = ▁ 12 \\n 12 ▁ * ▁ 2 ▁ = ▁ 24\" ) for i in range ( 5 , n , 2 ) : print ( i + 1 , \" ▁ - ▁ \" , i , \" ▁ = ▁ \" , 1 ) print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) for i in range ( ( n - 4 ) // 2 ) : print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) else : print ( \" NO \" ) NEW_LINE",
"n = int ( input ( ) ) if ( n <= 3 ) : print ( \" NO \" ) else : print ( \" YES \" ) if ( n % 2 == 0 ) : print ( \"1 ▁ * ▁ 2 ▁ = ▁ 2\" ) print ( \"2 ▁ * ▁ 3 ▁ = ▁ 6\" ) print ( \"6 ▁ * ▁ 4 ▁ = ▁ 24\" ) for i in range ( 5 , n , 2 ) : print ( str ( i + 1 ) + \" ▁ - ▁ \" + str ( i ) + \" ▁ = ▁ 1\" ) print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) else : print ( \"5 ▁ + ▁ 1 ▁ = ▁ 6\" ) print ( \"6 ▁ * ▁ 4 ▁ = ▁ 24\" ) print ( \"3 ▁ - ▁ 2 ▁ = ▁ 1\" ) print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) for i in range ( 6 , n , 2 ) : print ( str ( i + 1 ) + \" ▁ - ▁ \" + str ( i ) + \" ▁ = ▁ 1\" ) print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) NEW_LINE",
"n = int ( input ( ) ) if n < 4 : print ( \" NO \" ) elif n % 2 == 0 : print ( \" YES \" ) print ( \"1 ▁ * ▁ 2 ▁ = ▁ 2\" ) print ( \"2 ▁ * ▁ 3 ▁ = ▁ 6\" ) print ( \"6 ▁ * ▁ 4 ▁ = ▁ 24\" ) for i in range ( 5 , n + 1 , 2 ) : print ( i + 1 , \" - \" , i , \" = \" , 1 ) print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) else : print ( \" YES \" ) print ( \"5 ▁ + ▁ 4 ▁ = ▁ 9\" ) print ( \"9 ▁ + ▁ 3 ▁ = ▁ 12\" ) print ( \"12 ▁ * ▁ 2 ▁ = ▁ 24\" ) print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) for i in range ( 6 , n + 1 , 2 ) : print ( i + 1 , \" - \" , i , \" = \" , 1 ) print ( \"24 ▁ * ▁ 1 ▁ = ▁ 24\" ) NEW_LINE"
] |
codeforces_918_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Scanner ; public class Codeforces { private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ; private static PrintWriter out = new PrintWriter ( System . out ) ; public static void solve ( int T ) throws IOException { int n = sc . nextInt ( ) ; if ( n == 1 ) { System . out . println ( \" O \" ) ; return ; } if ( n == 2 ) { System . out . println ( \" OO \" ) ; return ; } int [ ] f = new int [ n + 5 ] ; int a = 0 ; int b = 1 ; f [ 0 ] = a ; f [ 1 ] = b ; for ( int i = 2 ; i <= n + 4 ; i ++ ) { int c = a + b ; f [ i ] = c ; a = b ; b = c ; }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Scanner ; public class Codeforces { private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ; private static PrintWriter out = new PrintWriter ( System . out ) ; public static void solve ( int T ) throws IOException { int n = sc . nextInt ( ) ; if ( n == 1 ) { System . out . println ( \" O \" ) ; return ; } if ( n == 2 ) { System . out . println ( \" OO \" ) ; return ; } int [ ] f = new int [ n + 5 ] ; int a = 0 ; int b = 1 ; f [ 0 ] = a ; f [ 1 ] = b ; for ( int i = 2 ; i <= n + 4 ; i ++ ) { int c = a + b ; f [ i ] = c ; a = b ; b = c ; }",
"import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int first = 0 , second = 1 ; int [ ] a = new int [ n + 1 ] ; int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int num = first + second ; if ( num > n ) { break ; } a [ i ] = num ; count ++ ; first = second ; second = num ; } for ( int i = 1 ; i <= n ; i ++ ) { int flag = 0 ; for ( int j = 1 ; j <= count ; j ++ ) { if ( i == a [ j ] ) { flag = 1 ; break ; } } if ( flag == 1 ) { System . out . print ( \" O \" ) ; } else { System . out . print ( \" o \" ) ; } } } }",
"import java . util . * ; import java . lang . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String result = \" \" ; int n = s . nextInt ( ) ; int a [ ] = new int [ 1000 ] ; int b [ ] = new int [ n + 1 ] ; if ( n == 1 ) { result = result + ' O ' ; System . out . println ( result ) ; } else { a [ 0 ] = 0 ; a [ 1 ] = 1 ; for ( int i = 2 ; i < 1000 ; i ++ ) { a [ i ] = a [ i - 1 ] + a [ i - 2 ] ; } for ( int j = 1 ; j <= n ; j ++ ) { boolean c = check ( a , j ) ; if ( c == false ) { result = result + ' o ' ; } else result = result + ' O ' ; } System . out . println ( result ) ; } } public static boolean check ( int a [ ] , int j ) { for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] == j ) return true ; } return false ; } }",
"import java . util . * ; public class contest16 { static Scanner scn = new Scanner ( System . in ) ; public static void main ( String [ ] args ) {"
] | [
"a , b = 1 , 1 k = int ( input ( ) ) n = 1 while n <= k : if n == b : print ( \" O \" , end = \" \" ) a , b = b , a + b else : print ( \" o \" , end = \" \" ) n = n + 1 NEW_LINE",
"import math def isPerfectSquare ( x ) : s = int ( math . sqrt ( x ) ) return s * s == x def isFibonacci ( n ) : return isPerfectSquare ( 5 * n * n + 4 ) or isPerfectSquare ( 5 * n * n - 4 ) n = int ( input ( ) ) for i in range ( 1 , n + 1 ) : if isFibonacci ( i ) : print ( \" O \" , end = \" \" ) else : print ( \" o \" , end = \" \" ) NEW_LINE",
"n = int ( input ( ) ) a = [ ' o ' ] * nl = [ 0 ] * 19 l [ 0 ] , l [ 1 ] = 1 , 1 i = 2 while ( i <= 18 ) : l [ i ] = l [ i - 1 ] + l [ i - 2 ] i += 1 NEW_LINE",
"class eleven : def __init__ ( self , n ) : self . n = n self . printName ( self . n ) def printName ( self , n ) : list1 = [ 0 , 1 ] f0 = 0 f1 = 1 for x in range ( 0 , n ) : f2 = f0 + f1 list1 . append ( f2 ) f0 = f1 f1 = f2 for x in range ( 1 , n + 1 ) : if x in list1 : print ( ' O ' , end = \" \" ) else : print ( \" o \" , end = \" \" ) n = int ( input ( ) ) if ( 1 <= n and n <= 1000 ) : passelse : exit ( ) elevenObj = eleven ( n ) NEW_LINE",
" n = int ( input ( ) ) s = [ ' o ' ] * na = b = c = 1 while a <= n : s [ a - 1 ] = ' O ' c = a a = b b = a + cprint ( ' ' . join ( s ) ) NEW_LINE"
] |
codeforces_60_A | [
"import java . util . * ; public class xt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int max = n ; int min = 1 ; sc . nextLine ( ) ; for ( int i = 0 ; i < m ; i ++ ) { String s = sc . nextLine ( ) ;"
] | [
"[ n , m ] = map ( int , ( input ( ) . split ( ) ) ) NEW_LINE p1 = 0 NEW_LINE p2 = n + 1 NEW_LINE for j in range ( m ) : hint = input ( ) NEW_LINE ind_val = int ( hint . split ( ) [ - 1 ] ) NEW_LINE if hint [ 7 ] == ' r ' : if NEW_LINE p1 < ind_val : p1 = ind_val NEW_LINE if hint [ 7 ] == ' l ' : if NEW_LINE p2 > ind_val : p2 = ind_val if p1 >= p2 - 1 : NEW_LINE INDENT print ( - 1 ) else : NEW_LINE print ( p2 - p1 - 1 ) NEW_LINE DEDENT",
"a , b = map ( int , input ( ) . split ( ) ) NEW_LINE z = [ 0 ] + [ 1 ] * afor NEW_LINE _ in \" ▁ \" * b : gh = input ( ) . split ( ) NEW_LINE if gh [ 2 ] == ' left ' : NEW_LINE INDENT z [ int ( gh [ - 1 ] ) : ] = [ 0 ] * ( a - int ( gh [ - 1 ] ) + 1 ) else : NEW_LINE z [ : int ( gh [ - 1 ] ) + 1 ] = [ 0 ] * ( int ( gh [ - 1 ] ) + 1 ) NEW_LINE DEDENT if z [ 1 : ] . count ( 1 ) : NEW_LINE INDENT print ( z [ 1 : ] . count ( 1 ) ) else : NEW_LINE print ( - 1 ) NEW_LINE DEDENT",
"n , m = map ( int , input ( ) . split ( ) ) NEW_LINE l = [ int ( i ) for i in range ( 1 , n + 1 ) ] NEW_LINE for i in range ( m ) : p = input ( ) . split ( ) NEW_LINE if p [ 2 ] == ' left ' : h = int ( p [ - 1 ] ) NEW_LINE if h not in l : if NEW_LINE min ( l ) > h : print ( - 1 ) ; NEW_LINE exit ( ) else : l = l [ : l . index ( h ) ] NEW_LINE if l == [ ] : NEW_LINE INDENT print ( - 1 ) ; exit ( ) else : NEW_LINE h = int ( p [ - 1 ] ) NEW_LINE DEDENT if h not in l : if NEW_LINE max ( l ) < h : print ( - 1 ) ; NEW_LINE exit ( ) else : l = l [ l . index ( h ) + 1 : ] NEW_LINE if l == [ ] : print ( - 1 ) ; exit ( ) NEW_LINE print ( len ( l ) ) NEW_LINE",
"v = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE n = v [ 0 ] NEW_LINE m = v [ 1 ] r = 1 l = n ans = True for i in range ( m ) : hint = input ( ) . split ( ) NEW_LINE vt = int ( hint [ - 1 ] ) NEW_LINE if hint [ 2 ] == ' left ' : if NEW_LINE INDENT ( vt - 1 < l ) : l = vt - 1 else : if ( vt + 1 > r ) : r = vt + 1 NEW_LINE DEDENT if l < 0 or r > n : ans = False NEW_LINE if l - r < 0 : ans = False if ans : NEW_LINE INDENT print ( l - r + 1 ) else : NEW_LINE print ( - 1 ) NEW_LINE DEDENT",
"n , m = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l , h = 1 , nfor NEW_LINE i in range ( m ) : s = input ( ) . split ( ) NEW_LINE v = int ( s [ - 1 ] ) NEW_LINE d = s [ 2 ] NEW_LINE if d == ' left ' : NEW_LINE INDENT h = min ( h , v - 1 ) else : NEW_LINE l = max ( l , v + 1 ) NEW_LINE DEDENT output = h - l + 1 NEW_LINE if output <= 0 : NEW_LINE INDENT print ( - 1 ) else : NEW_LINE print ( output ) NEW_LINE DEDENT"
] |
codeforces_1179_A | [
"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static FileWriter fw ; static long oo = Long . MAX_VALUE ;",
"import java . util . * ; import java . io . * ; public class Valery_And_Deque { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) {",
" import java . io . * ; import java . util . * ; import java . math . BigInteger ; import java . lang . Object ; public class Main { static class sort implements Comparator < int [ ] > { public int compare ( int [ ] a , int [ ] b ) {"
] | [
"from collections import dequeif __name__ == ' _ _ main _ _ ' : n , q = map ( int , input ( ) . split ( ' ▁ ' ) ) arr = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) dq = deque ( arr ) m = max ( arr ) lst = [ ] while dq [ 0 ] != m : a = dq . popleft ( ) b = dq . popleft ( ) lst . append ( [ a , b ] ) dq . append ( min ( a , b ) ) dq . appendleft ( max ( a , b ) ) NEW_LINE",
"if __name__ == ' _ _ main _ _ ' : n , m = map ( int , input ( ) . split ( ' ▁ ' ) ) x = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) y = [ int ( input ( ) ) for x in range ( m ) ] max_index = x . index ( max ( x ) ) r = [ ] for i in range ( max_index ) : r . append ( ' { 0 } ▁ { 1 } ' . format ( x [ 0 ] , x [ 1 ] ) ) if x [ 0 ] > x [ 1 ] : k = x . pop ( 1 ) x . append ( k ) else : k = x . pop ( 0 ) x . append ( k ) for i in y : if i - 1 < max_index : print ( r [ i - 1 ] ) else : k = i - max_index - 1 print ( ' { 0 } ▁ { 1 } ' . format ( x [ 0 ] , x [ 1 + k % ( n - 1 ) ] ) ) NEW_LINE"
] |
codeforces_999_B | [
"import java . util . * ; public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( n % i == 0 ) { String s1 = s . substring ( 0 , i ) ; String s2 = s . substring ( i ) ; StringBuilder stringBuilder = new StringBuilder ( s1 ) ; s = stringBuilder . reverse ( ) + s2 ;",
"import java . util . * ; public class Example { static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;",
"import java . util . * ; public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( n % i == 0 ) { String s1 = s . substring ( 0 , i ) ; String s2 = s . substring ( i ) ; StringBuilder stringBuilder = new StringBuilder ( s1 ) ; s = stringBuilder . reverse ( ) + s2 ;"
] | [
"def divisors ( n ) : divs = [ ] i = 1 while n >= i ** 2 : if n % i == 0 : divs . append ( i ) if i ** 2 != n : divs . append ( n // i ) i = i + 1 divs . sort ( ) return divs num = int ( input ( ) ) s = input ( ) divs = divisors ( num ) for i in divs : s = s [ : i ] [ : : - 1 ] + s [ i : ] print ( s ) NEW_LINE",
"n = int ( input ( ) ) s = list ( input ( ) ) for i in range ( 2 , n ) : if n % i == 0 : s [ : i ] = s [ : i ] [ : : - 1 ] NEW_LINE",
"import sysinput = sys . stdin . readline n = int ( input ( ) ) s = input ( ) for i in range ( 1 , n + 1 ) : if n % i == 0 : s = s [ : i ] [ : : - 1 ] + s [ i : ] print ( s ) NEW_LINE",
"import sysinput = sys . stdin . readline n = int ( input ( ) ) s = input ( ) for i in range ( 1 , n + 1 ) : if n % i : continue s = s [ : i ] [ : : - 1 ] + s [ i : ] print ( s ) NEW_LINE"
] |
codeforces_719_B | [
"import java . util . * ; import java . lang . * ; import java . io . * ; import java . awt . Point ; ",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; String str = scn . next ( ) ; int [ ] r = new int [ 2 ] ; int [ ] b = new int [ 2 ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' r ' ) { r [ i % 2 ] ++ ; } else { b [ i % 2 ] ++ ; } } System . out . println ( Math . min ( Math . max ( r [ 0 ] , b [ 1 ] ) , Math . max ( r [ 1 ] , b [ 0 ] ) ) ) ; } }",
"import java . util . * ; import java . io . * ; public class a { public static void main ( final String [ ] args ) throws IOException { BufferInput sc = new BufferInput ( ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ;",
"import java . util . * ; import java . io . * ; public class Anatoly_And_Cockroaches { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) {",
"import java . util . * ; public class CodeForces719B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; char [ ] arr = input . next ( ) . toCharArray ( ) ; int evenB = ( n + 1 ) / 2 , evenR = ( n + 1 ) / 2 ; int oddB = n / 2 , oddR = n / 2 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i % 2 == 0 ) { if ( arr [ i ] == ' r ' ) evenR -- ; else evenB -- ; } else { if ( arr [ i ] == ' r ' ) oddR -- ; else oddB -- ; } } System . out . println ( Math . min ( Math . max ( evenB , oddR ) , Math . max ( evenR , oddB ) ) ) ; } }"
] | [
"am = int ( input ( ) ) arr = list ( input ( ) ) for i in range ( am ) : if arr [ i ] == \" r \" : arr [ i ] = 1 else : arr [ i ] = 0 ans = 0 NEW_LINE",
"n = int ( input ( ) ) m = input ( ) rb = { ' r ' : 0 , ' b ' : 0 } br = { ' r ' : 0 , ' b ' : 0 } for i in range ( n ) : if i % 2 == 0 : if m [ i ] == ' b ' : br [ ' b ' ] += 1 else : rb [ ' r ' ] += 1 else : if m [ i ] == ' r ' : br [ ' r ' ] += 1 else : rb [ ' b ' ] += 1 rbs = min ( rb [ ' b ' ] , rb [ ' r ' ] ) + abs ( rb [ ' b ' ] - rb [ ' r ' ] ) brs = min ( br [ ' b ' ] , br [ ' r ' ] ) + abs ( br [ ' b ' ] - br [ ' r ' ] ) print ( min ( rbs , brs ) ) NEW_LINE",
"n = int ( input ( ) ) l = list ( input ( ) ) x1 , x2 , y1 , y2 = 0 , 0 , 0 , 0 for i in range ( n ) : if i % 2 == 0 : if l [ i ] == ' r ' : x1 += 1 else : x2 += 1 else : if l [ i ] == ' b ' : y1 += 1 else : y2 += 1 print ( min ( max ( x1 , y1 ) , max ( x2 , y2 ) ) ) NEW_LINE",
"import sysinput = sys . stdin . readlinefrom collections import defaultdictopp = { \" r \" : \" b \" , \" b \" : \" r \" } def func ( n , a , want , d ) : curr = defaultdict ( int ) ans = 0 for i in range ( n ) : if a [ i ] != want [ i ] : if curr [ d [ a [ i ] ] ] > 0 : curr [ d [ a [ i ] ] ] -= 1 else : curr [ a [ i ] ] += 1 ans += 1 return ansn = int ( input ( ) ) a = input ( ) want1 = \" r \" want2 = \" b \" for i in range ( 1 , n ) : want1 += opp [ want1 [ i - 1 ] ] want2 += opp [ want2 [ i - 1 ] ] ans = func ( n , a , want1 , opp ) ans = min ( ans , func ( n , a , want2 , opp ) ) print ( ans ) NEW_LINE"
] |
codeforces_31_B | [
"import java . util . * ; public class B { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; if ( s . lastIndexOf ( ' @ ' ) == s . length ( ) - 1 || s . indexOf ( ' @ ' ) == 0 || ! s . contains ( \" @ \" ) ) { System . out . println ( \" No ▁ solution \" ) ; System . exit ( 0 ) ; } Vector < Integer > v = new Vector < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' @ ' ) { v . add ( i ) ; } } if ( v . size ( ) == 1 ) { System . out . println ( s ) ; } else { for ( int i = 1 ; i < v . size ( ) ; i ++ ) { if ( v . get ( i ) - v . get ( i - 1 ) <= 2 ) { System . out . println ( \" No ▁ solution \" ) ; System . exit ( 0 ) ; } } String result = \" \" ; Vector < String > vec = new Vector < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { result += s . charAt ( i ) ; if ( s . charAt ( i ) == ' @ ' ) { result += s . charAt ( i + 1 ) ; vec . add ( result ) ; result = \" \" ; i ++ ; } } String az = s . substring ( v . get ( v . size ( ) - 1 ) + 2 ) ; for ( int i = 0 ; i < vec . size ( ) - 1 ; i ++ ) { System . out . print ( vec . get ( i ) + \" , \" ) ; } System . out . print ( vec . get ( vec . size ( ) - 1 ) + \" \" + az ) ; } } }",
"import static java . lang . Double . parseDouble ; import static java . lang . Integer . max ; import static java . lang . Integer . min ; import static java . lang . Integer . parseInt ; import static java . lang . Long . parseLong ; import static java . lang . System . exit ; import static java . lang . System . setOut ; import java . io . * ; import java . util . * ; import java . util . concurrent . ThreadLocalRandom ; public class A { static BufferedReader in ; static PrintWriter out ; static StringTokenizer tok ; static void solve ( ) throws Exception { char [ ] s = next ( ) . toCharArray ( ) ; int n = s . length ; if ( s [ 0 ] == ' @ ' || s [ n - 1 ] == ' @ ' ) { out . print ( \" No ▁ solution \\n \" ) ; return ; } List < Integer > ats = new ArrayList < > ( ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( s [ i ] == ' @ ' ) { ats . add ( i ) ; } } int prev = - 10 ; for ( int x : ats ) { if ( x - prev <= 2 ) { out . print ( \" No ▁ solution \\n \" ) ; return ; } prev = x ; } if ( ats . size ( ) == 0 ) { out . print ( \" No ▁ solution \\n \" ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { out . print ( s [ i ] ) ; if ( s [ i ] == ' @ ' ) { i ++ ; out . print ( s [ i ] ) ; out . print ( i < ats . get ( ats . size ( ) - 1 ) ? ' , ' : \" \" ) ; } } } ",
" import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {"
] | [
"a = input ( ) . split ( ' @ ' ) n = len ( a ) b = [ ] if n >= 2 : for i in range ( n ) : if len ( a [ i ] ) > int ( i != 0 and i != n - 1 ) : if i != 0 and i != n - 1 : b . append ( a [ i - 1 ] [ min ( 1 , i - 1 ) : ] + ' @ ' + a [ i ] [ 0 ] ) elif i == n - 1 : b . append ( a [ i - 1 ] [ min ( 1 , i - 1 ) : ] + ' @ ' + a [ i ] ) else : print ( ' No ▁ solution ' ) break else : c = b [ 0 ] for i in range ( 1 , len ( b ) ) : c += ' , ' + b [ i ] print ( c ) else : print ( ' No ▁ solution ' ) NEW_LINE",
"s = input ( ) . split ( ' @ ' ) n = len ( s ) - 1 for i in range ( 1 , n ) : if len ( s [ i ] ) < 2 : s = False break s [ i ] = s [ i ] [ 0 ] + ' , ' + s [ i ] [ 1 : ] if n > 0 and s and s [ 0 ] and s [ n ] : print ( ' @ ' . join ( s ) ) else : print ( ' No ▁ solution ' ) NEW_LINE",
"from sys import stdouta = input ( ) c = list ( a . split ( ' @ ' ) ) while ' ' in c : c . remove ( ' ' ) if a . count ( ' @ ' ) == 0 : exit ( print ( ' No ▁ solution ' ) ) if a . count ( ' @ ' ) != len ( c ) - 1 : exit ( print ( ' No ▁ solution ' ) ) if any ( len ( i ) == 1 for i in c [ 1 : len ( c ) - 1 ] ) : exit ( print ( ' No ▁ solution ' ) ) stdout . write ( c [ 0 ] + ' @ ' ) for i in range ( 1 , len ( c ) - 1 ) : stdout . write ( c [ i ] [ : len ( c [ i ] ) // 2 ] + ' , ' + c [ i ] [ len ( c [ i ] ) // 2 : ] + ' @ ' ) stdout . write ( c [ - 1 ] ) NEW_LINE",
"s = input ( ) . split ( ' @ ' ) n = len ( s ) - 1 for i in range ( 1 , n ) : if len ( s [ i ] ) < 2 : s = False break s [ i ] = s [ i ] [ 0 ] + ' , ' + s [ i ] [ 1 : ] if n > 0 and s and s [ 0 ] and s [ n ] : print ( ' @ ' . join ( s ) ) else : print ( ' No ▁ solution ' ) NEW_LINE",
"def main ( ) : email = input ( ) if len ( email ) < 3 or email . count ( ' @ ' ) == 0 : print ( ' No ▁ solution ' ) return if len ( email ) == 3 : if email . count ( ' @ ' ) != 1 or email [ 1 ] != ' @ ' : print ( ' No ▁ solution ' ) return pos = [ ] for i in range ( 0 , len ( email ) ) : if ( email [ i ] == ' @ ' ) : pos . append ( i ) if i == 0 or i == len ( email ) - 1 : print ( ' No ▁ solution ' ) return elif len ( pos ) >= 2 : if ( pos [ - 1 ] - pos [ - 2 ] ) <= 2 : print ( ' No ▁ solution ' ) return ans = [ ] temp = \" \" atual = 2 i = 0 while ( i < len ( email ) ) : temp += email [ i ] if email [ i ] == ' @ ' : temp += email [ i + 1 ] ans . append ( temp ) i += 1 temp = \" \" i += 1 ans . append ( temp ) if ( len ( ans ) >= 2 ) : if ( ans [ - 1 ] . count ( ' @ ' ) == 0 ) : ans [ - 2 ] += ans [ - 1 ] del ans [ - 1 ] print ( ' , ' . join ( ans ) ) main ( ) NEW_LINE"
] |
codeforces_1383_B | [
"import java . io . * ; import java . util . * ; public class A { static PrintWriter out ; static class FIO { BufferedReader in ; StringTokenizer st = null ; FIO ( ) throws IOException { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; st = null ; } FIO ( String s ) throws IOException { in = new BufferedReader ( new FileReader ( s + \" . in \" ) ) ; out = new PrintWriter ( new FileWriter ( s + \" . out \" ) ) ; st = null ; } String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } static FIO in ; public static void main ( String [ ] args ) throws IOException { in = new FIO ( ) ; int tc = in . nextInt ( ) ; while ( tc -- > 0 ) new solver ( ) ; out . close ( ) ; } static class solver { void p1 ( ) { out . println ( \" WIN \" ) ; } void p2 ( ) { out . println ( \" LOSE \" ) ; } solver ( ) { int N = in . nextInt ( ) ; long [ ] ar = new long [ N ] ; for ( int i = 0 ; i < N ; ++ i ) ar [ i ] = in . nextLong ( ) ; for ( int i = 31 ; i >= 0 ; -- i ) { int oc = 0 ; for ( long x : ar ) oc += ( ( x & ( 1 << i ) ) == 0 ? 0 : 1 ) ; if ( oc % 4 == 1 ) { p1 ( ) ; return ; } if ( oc % 4 == 3 ) { if ( ( N - oc ) % 2 == 1 ) p1 ( ) ; else p2 ( ) ; return ; } } out . println ( \" DRAW \" ) ; } } }",
"# include < iostream > # include < algorithm > # include < string . h > # include < stdio . h > # include < math . h > # include < set > # include < map > # include < list > # include < vector > using namespace std ; typedef long long LL ; const int maxn = 1e5 + 3 ; int main ( ) { ios_base :: sync_with_stdio ( 0 ) , cin . tie ( 0 ) ; int test ; cin >> test ; while ( test -- ) { int n ; cin >> n ; int x = 0 ; vector < int > a ( n ) ; for ( auto & i : a ) { cin >> i ; x ^= i ; } if ( x == 0 ) { cout << \" DRAW \\n \" ; continue ; } for ( int k = 30 ; k >= 0 ; -- k ) if ( x >> k & 1 )",
"import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; while ( T -- > 0 ) { int n = sc . nextInt ( ) ; int v [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } int ans = - 1 ; for ( int j = 30 ; j >= 0 ; j -- ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( v [ i ] & ( 1 << j ) ) > 0 ) cnt += 1 ; } if ( cnt % 2 == 0 ) { continue ; } int z = ( n - cnt ) % 2 ; cnt = ( cnt + 1 ) / 2 ; if ( cnt % 2 == 0 && z % 2 == 1 ) { ans = 1 ; break ; } else if ( cnt % 2 == 1 ) { ans = 1 ; break ; } ans = 0 ; break ; } String Ans = new String ( ) ; if ( ans == - 1 ) { Ans = \" DRAW \" ; } else if ( ans == 0 ) { Ans = \" LOSE \" ; } else { Ans = \" WIN \" ; } System . out . println ( Ans ) ; } } }"
] | [
"def solve ( ) : n = int ( input ( ) ) lst = list ( map ( int , input ( ) . split ( ) ) ) k = 1 while k < 10 ** 9 : k *= 2 num = 0 while k and num % 2 == 0 : num = 0 for i in lst : if i % ( k * 2 ) // k == 1 : num += 1 k //= 2 if k == 0 and num % 2 == 0 : print ( \" DRAW \" ) return 0 if ( num % 4 == 1 ) or ( n % 2 == 0 ) : print ( \" WIN \" ) else : print ( \" LOSE \" ) for i in range ( int ( input ( ) ) ) : solve ( ) NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) x = 0 for i in a : x ^= i if x == 0 : print ( \" DRAW \" ) continue if n % 2 == 0 : print ( \" WIN \" ) continue b = 0 while ( 1 << b ) <= x : b += 1 b -= 1 c = 0 for i in a : if ( 1 << b ) & i != 0 : c += 1 if ( ( c - 1 ) // 2 ) % 2 == 0 : print ( \" WIN \" ) else : print ( \" LOSE \" ) NEW_LINE",
"\"\"\" T = int ( input ( ) ) for ▁ _ ▁ in ▁ range ( 0 , T ) : ▁ ▁ ▁ ▁ n = int ( input ( ) ) ▁ ▁ ▁ ▁ a , b = map ( int , input ( ) . split ( ) ) ▁ ▁ ▁ ▁ s = input ( ) ▁ ▁ ▁ ▁ s = [ int ( x ) ▁ for ▁ x ▁ in ▁ input ( ) . split ( ) ] ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 0 , len ( s ) ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ a , b = map ( int , input ( ) . split ( ) ) \"\"\" T = int ( input ( ) ) for _ in range ( 0 , T ) : n = int ( input ( ) ) s = [ int ( x ) for x in input ( ) . split ( ) ] pos = [ 0 ] * 35 for i in range ( 0 , len ( s ) ) : tt = bin ( s [ i ] ) [ 2 : ] tt = '0' * ( 35 - len ( tt ) ) + tt for j in range ( 35 ) : pos [ j ] += int ( tt [ j ] ) ans = ' DRAW ' turn = 0 for i in range ( 0 , 35 ) : if ( pos [ i ] % 2 != 0 ) : if ( pos [ i ] % 4 == 3 and ( n - pos [ i ] ) % 2 == 0 ) : ans = ' LOSE ' else : ans = ' WIN ' break print ( ans ) NEW_LINE",
"d = { 1 : ' WIN ' , 0 : ' LOSE ' , - 1 : ' DRAW ' } def main ( ) : t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) a = map ( int , input ( ) . split ( ) ) f = [ 0 ] * 30 for x in a : for b in range ( 30 ) : if x >> b & 1 : f [ b ] += 1 ans = - 1 for x in reversed ( range ( 30 ) ) : if f [ x ] % 2 == 1 : ans = 0 if f [ x ] % 4 == 3 and ( n - f [ x ] ) % 2 == 0 else 1 break print ( d [ ans ] ) main ( ) NEW_LINE"
] |
codeforces_467_B | [
"import java . util . * ; public class FedorAndNewGame { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] arr = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int mask = sc . nextInt ( ) ; int ans = 0 ; for ( int x : arr ) { int temp = x ^ mask ; int cnt = 0 ; for ( int i = 0 ; i < 21 ; i ++ ) { cnt += 1 & temp ; temp = temp >> 1 ; } if ( cnt <= k ) ans ++ ; } System . out . println ( ans ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] [ ] list = new int [ m + 1 ] [ n ] ; for ( int i = 0 ; i < m + 1 ; i ++ ) { int temp = sc . nextInt ( ) ; int count = 0 ; while ( true ) { if ( temp == 1 ) { list [ i ] [ count ] = temp ; break ; } else { list [ i ] [ count ] = temp % 2 ; temp = temp / 2 ; count ++ ; } } } int maxCnt = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int curCnt = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( list [ i ] [ j ] == 1 && list [ m ] [ j ] == 0 ) || ( list [ i ] [ j ] == 0 && list [ m ] [ j ] == 1 ) ) { curCnt ++ ; } } if ( curCnt <= k ) { maxCnt ++ ; } } System . out . println ( maxCnt ) ; } }",
"import java . io . * ; import java . util . * ; public class B {",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] [ ] list = new int [ m + 1 ] [ n ] ; for ( int i = 0 ; i < m + 1 ; i ++ ) { int temp = sc . nextInt ( ) ; int count = 0 ; while ( true ) { if ( temp == 1 ) { list [ i ] [ count ] = temp ; break ; } else { list [ i ] [ count ] = temp % 2 ; temp = temp / 2 ; count ++ ; } } } int maxCnt = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int curCnt = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( list [ i ] [ j ] == 1 && list [ m ] [ j ] == 0 ) || ( list [ i ] [ j ] == 0 && list [ m ] [ j ] == 1 ) ) { curCnt ++ ; } } if ( curCnt <= k ) { maxCnt ++ ; } } System . out . println ( maxCnt ) ; } }"
] | [
"from math import * from copy import * from string import * NEW_LINE",
"n , m , k = map ( int , input ( ) . split ( ) ) army = [ ] for i in range ( m ) : x = int ( input ( ) ) army . append ( x ) m = int ( input ( ) ) ans = 0 for i in army : uniq = bin ( m ^ i ) count = 0 for j in uniq : if j == '1' : count += 1 if count <= k : continue else : count = k + 1 break if count <= k : ans += 1 print ( ans ) NEW_LINE",
"def count ( y ) : s = 0 for i in y : if i == '1' : s += 1 return s n , m , k = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( m + 1 ) : a = int ( input ( ) ) l . append ( a ) res = 0 f = l [ - 1 ] for i in range ( m ) : x = l [ i ] y = bin ( f ^ x ) c = count ( y ) if c <= k : res += 1 print ( res ) NEW_LINE",
"n , m , k = map ( int , input ( ) . split ( ) ) army = [ ] for i in range ( m + 1 ) : army . append ( int ( input ( ) ) ) fed = army [ - 1 ] ans = 0 for i in range ( m ) : temp = bin ( fed ^ army [ i ] ) if temp . count ( \"1\" ) <= k : ans += 1 print ( ans ) NEW_LINE"
] |
codeforces_1091_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class NewYearAndTheChristmasPresent { public static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { StringTokenizer str = new StringTokenizer ( br . readLine ( ) ) ; int yellows = Integer . parseInt ( str . nextToken ( ) ) ; int blues = Integer . parseInt ( str . nextToken ( ) ) ; int reds = Integer . parseInt ( str . nextToken ( ) ) ; int total = 0 ;",
" import java . util . * ; import java . lang . * ; import java . io . * ; public class Solution { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } private static FastReader sc = new FastReader ( ) ; public static void main ( String [ ] args ) throws java . lang . Exception { int y = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int sum = 0 ; while ( r >= 3 ) { if ( r - 1 <= b && r - 2 <= y ) { sum = 3 * r - 3 ; break ; } r -- ; } System . out . println ( sum ) ; } }",
"import java . util . Scanner ; public class Ornament { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int y = in . nextInt ( ) , b = in . nextInt ( ) - 1 , r = in . nextInt ( ) - 2 ; in . close ( ) ; System . out . println ( 3 * Math . min ( Math . min ( y , b ) , r ) + 3 ) ; } }",
"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 ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class A { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int y = in . ni ( ) , b = in . ni ( ) , r = in . ni ( ) ; b = Math . min ( b , r - 1 ) ; y = Math . min ( y , b - 1 ) ; out . println ( y * 3 + 3 ) ; } } static class FastScanner { private BufferedReader in ; private StringTokenizer st ; public FastScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String ns ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl == null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return st . nextToken ( ) ; } public int ni ( ) { return Integer . parseInt ( ns ( ) ) ; } } }"
] | [
"a , b , c = map ( int , input ( ) . split ( ) ) print ( 3 * min ( a + 1 , b , c - 1 ) ) NEW_LINE",
"y , b , r = map ( int , input ( ) . split ( ) ) y = y + 2 b = b + 1 r = r + 0 min = min ( y , b , r ) sum = ( min * 3 ) - 3 print ( sum ) NEW_LINE",
"y , b , r = [ int ( i ) for i in input ( ) . split ( ) ] print ( 3 * min ( y + 1 , b , r - 1 ) ) NEW_LINE",
"temp = [ int ( x ) for x in input ( ) . split ( ) ] y = temp [ 0 ] b = temp [ 1 ] r = temp [ 2 ] if y >= b : y = b - 1 else : b = y + 1 if b >= r : b = r - 1 y = r - 2 else : r = b + 1 print ( y + b + r ) NEW_LINE",
" a , b , c = map ( int , input ( ) . split ( ) ) res = 0 if b >= a + 1 and c >= a + 2 : res = max ( res , ( a * 3 ) + 3 ) if a >= b - 1 and c >= b + 1 : res = max ( res , b * 3 ) if a >= c - 2 and b >= c - 1 : res = max ( res , ( c * 3 ) - 3 ) print ( res ) NEW_LINE"
] |
codeforces_396_B | [
"import java . util . * ; import java . math . * ; import java . io . * ; public class CF396B { class Fraction { long n , d ; public Fraction ( long nn , long dd ) { n = nn ; d = dd ; simplify ( ) ; } void simplify ( ) { long gcd = gcd ( n , d ) ; n /= gcd ; d /= gcd ; } Fraction add ( Fraction f ) { long lcm = lcm ( d , f . d ) ; return new Fraction ( ( n * ( lcm / d ) ) + ( f . n * ( lcm / f . d ) ) , lcm ) ; } Fraction sub ( Fraction f ) { return this . add ( new Fraction ( - f . n , f . d ) ) ; } public String toString ( ) { return String . format ( \" % d / % d \" , n , d ) ; } } long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } long lcm ( long a , long b ) { return a / gcd ( a , b ) * b ; } int prevprime ( int x ) { for ( int i = x ; ; i -- ) if ( BigInteger . valueOf ( i ) . isProbablePrime ( 100 ) ) return i ; } int nextprime ( int x ) { for ( int i = x + 1 ; ; i ++ ) if ( BigInteger . valueOf ( i ) . isProbablePrime ( 100 ) ) return i ; } public CF396B ( ) { FS scan = new FS ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int t = scan . nextInt ( ) ; for ( int tt = 0 ; tt < t ; tt ++ ) { int n = scan . nextInt ( ) ;",
"import java . io . * ; import java . math . BigInteger ; public class Main { static PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( bf . readLine ( ) ) ; int n = 0 ; for ( int i = 0 ; i < t ; i ++ ) { n = Integer . parseInt ( bf . readLine ( ) ) ; solve ( n ) ; } pw . flush ( ) ; } public static void solve ( int n ) { long u = n , v = n + 1 ; while ( ! BigInteger . valueOf ( u ) . isProbablePrime ( 10 ) ) u -- ; while ( ! BigInteger . valueOf ( v ) . isProbablePrime ( 10 ) ) v ++ ; long a = v * ( u - 2 ) + 2 * ( n - u + 1 ) , b = 2 * u * v ; long g = gcd ( a , b ) ; pw . write ( a / g + \" / \" + b / g + \" \\n \" ) ; } static long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } }",
"import java . io . * ; import java . util . * ;",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . IOException ; import java . util . Random ; import java . io . UncheckedIOException ; import java . math . BigDecimal ; import java . io . Closeable ; import java . io . Writer ; import java . io . OutputStreamWriter ; import java . math . BigInteger ; import java . io . InputStream ; import java . math . RoundingMode ; public class Main { public static void main ( String [ ] args ) throws Exception { Thread thread = new Thread ( null , new TaskAdapter ( ) , \" \" , 1 << 29 ) ; thread . start ( ) ; thread . join ( ) ; } static class TaskAdapter implements Runnable { @ Override public void run ( ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastInput in = new FastInput ( inputStream ) ; FastOutput out = new FastOutput ( outputStream ) ; BOnSumOfFractions solver = new BOnSumOfFractions ( ) ; int testCount = Integer . parseInt ( in . next ( ) ) ; for ( int i = 1 ; i <= testCount ; i ++ ) solver . solve ( i , in , out ) ; out . close ( ) ; } } static class BOnSumOfFractions { public void solve ( int testNumber , FastInput in , FastOutput out ) { int n = in . ri ( ) ; if ( n == 2 ) { out . println ( \"1/6\" ) ; return ; } int p1 = prev ( n ) ; int next = next ( n + 1 ) ;"
] | [
"T = int ( input ( ) ) MAX = 33000 bePrime = [ 0 ] * MAX ; primNum = [ ] for j in range ( 2 , MAX ) : if bePrime [ j ] == 0 : primNum . append ( j ) i = j while i < MAX : bePrime [ i ] = 1 i = i + j def isPrime ( a ) : for j in primNum : if j >= a : return True if a % j == 0 : return False return True def gcd ( a , b ) : if b == 0 : return a return gcd ( b , a % b ) ; while T > 0 : num = 0 ; n = int ( input ( ) ) m = n while isPrime ( m ) == False : m -= 1 while isPrime ( n + 1 ) == False : n += 1 num += 1 a = n - 1 b = 2 * ( n + 1 ) a = a * ( n + 1 ) * m - num * b b = b * ( n + 1 ) * m g = gcd ( a , b ) a //= g b //= g print ( ' { 0 } / {1 } ' . format ( a , b ) ) T -= 1 ; NEW_LINE",
"def prime ( n ) : m = int ( n ** 0.5 ) + 1 t = [ 1 ] * ( n + 1 ) for i in range ( 3 , m ) : if t [ i ] : t [ i * i : : 2 * i ] = [ 0 ] * ( ( n - i * i ) // ( 2 * i ) + 1 ) return [ 2 ] + [ i for i in range ( 3 , n + 1 , 2 ) if t [ i ] ] def gcd ( a , b ) : c = a % b return gcd ( b , c ) if c else b p = prime ( 31650 ) def g ( n ) : m = int ( n ** 0.5 ) for j in p : if n % j == 0 : return True if j > m : return False def f ( n ) : a , b = n , n + 1 while g ( a ) : a -= 1 while g ( b ) : b += 1 p , q = ( b - 2 ) * a + 2 * ( n - b + 1 ) , 2 * a * b d = gcd ( p , q ) print ( str ( p // d ) + ' / ' + str ( q // d ) ) for i in range ( int ( input ( ) ) ) : f ( int ( input ( ) ) ) NEW_LINE",
"T = int ( input ( ) ) NEW_LINE",
"def prime ( n ) : m = int ( n ** 0.5 ) + 1 t = [ 1 ] * ( n + 1 ) for i in range ( 3 , m ) : if t [ i ] : t [ i * i : : 2 * i ] = [ 0 ] * ( ( n - i * i ) // ( 2 * i ) + 1 ) return [ 2 ] + [ i for i in range ( 3 , n + 1 , 2 ) if t [ i ] ] def gcd ( a , b ) : c = a % b return gcd ( b , c ) if c else b p = prime ( 31650 ) def g ( n ) : m = int ( n ** 0.5 ) for j in p : if n % j == 0 : return True if j > m : return False def f ( n ) : a , b = n , n + 1 while g ( a ) : a -= 1 while g ( b ) : b += 1 p , q = ( b - 2 ) * a + 2 * ( n - b + 1 ) , 2 * a * b d = gcd ( p , q ) print ( str ( p // d ) + ' / ' + str ( q // d ) ) for i in range ( int ( input ( ) ) ) : f ( int ( input ( ) ) ) NEW_LINE",
"def isPrime ( n ) : i = 2 while i * i <= n : if n % i == 0 : return False i += 1 return True def prevPrime ( n ) : while not isPrime ( n ) : n -= 1 return n def nextPrime ( n ) : n += 1 while not isPrime ( n ) : n += 1 return n def gcd ( a , b ) : while ( a ) : b %= a a , b = b , a return b ; def solve ( ) : n = int ( input ( ) ) prev = prevPrime ( n ) ; next = nextPrime ( n ) ; num1 = prev - 2 ; den1 = prev * 2 ; g = gcd ( num1 , den1 ) ; num1 //= g ; den1 //= g ; num2 = n - prev + 1 ; den2 = prev * next ; g = gcd ( num2 , den2 ) ; num2 //= g ; den2 //= g ; g = gcd ( num1 * den2 + num2 * den1 , den1 * den2 ) ; x = ( num1 * den2 + num2 * den1 ) // g ; y = den1 * den2 // g ; print ( ' { } / { } ' . format ( x , y ) ) t = int ( input ( ) ) while t : t -= 1 solve ( ) NEW_LINE"
] |
codeforces_843_B | [
"import java . util . Scanner ; public class srf { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) , start = sc . nextInt ( ) , x = sc . nextInt ( ) ; Ans argmax = query ( start ) ;",
"import java . io . BufferedReader ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . FileOutputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . BitSet ; import java . util . Calendar ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . PriorityQueue ; import java . util . SortedSet ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ; import java . util . TreeSet ; public class B_AimTech_Round4 { public static long MOD = 1000000007 ; public static void main ( String [ ] args ) throws FileNotFoundException {"
] | [
"import randomimport sys def process ( n , start , X ) : ran = [ start ] + list ( set ( [ random . randint ( 1 , n ) for _ in range ( 990 ) ] ) ) arr = [ ask ( index ) [ 0 ] for index in ran ] pos , init = find ( ran , arr , X ) ans = - 1 if pos == None : ans = arr [ 0 ] elif init == X : ans = init else : cur = init cnt = 0 while cnt <= 999 : cur , pos = ask ( pos ) if cur >= X : ans = cur break if pos == - 1 : break cnt += 1 print ( ' ! ▁ { } ' . format ( ans ) ) def find ( ran , arr , X ) : diff = float ( ' inf ' ) pos , init = None , None for i , x in zip ( ran , arr ) : if x <= X and abs ( x - X ) < diff : diff = abs ( x - X ) pos = i init = x return pos , init def ask ( index ) : print ( ' ? ▁ { } ' . format ( index ) ) sys . stdout . flush ( ) val_ , next_ = map ( int , input ( ) . split ( ) ) return val_ , next_ n , start , X = map ( int , input ( ) . split ( ) ) process ( n , start , X ) NEW_LINE",
"import randomimport sys def process ( n , start , X ) : ran = [ start ] + list ( set ( [ random . randint ( 1 , n ) for _ in range ( 990 ) ] ) ) arr = [ ask ( index ) [ 0 ] for index in ran ] pos , init = find ( ran , arr , X ) ans = - 1 if pos == None : ans = arr [ 0 ] elif init == X : ans = init else : cur = init cnt = 0 while cnt <= 999 : cur , pos = ask ( pos ) if cur >= X : ans = cur break if pos == - 1 : break cnt += 1 print ( ' ! ▁ { } ' . format ( ans ) ) def find ( ran , arr , X ) : diff = float ( ' inf ' ) pos , init = None , None for i , x in zip ( ran , arr ) : if x <= X and abs ( x - X ) < diff : diff = abs ( x - X ) pos = i init = x return pos , init def ask ( index ) : print ( ' ? ▁ { } ' . format ( index ) ) sys . stdout . flush ( ) val_ , next_ = map ( int , input ( ) . split ( ) ) return val_ , next_ n , start , X = map ( int , input ( ) . split ( ) ) process ( n , start , X ) NEW_LINE"
] |
codeforces_350_B | [
"import java . io . * ; import java . util . * ; import java . math . * ; public class Hello { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; ",
"import java . util . LinkedList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] parents = new int [ n ] ; int [ ] k = new int [ n ] ; LinkedList < Integer > hotels = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( sc . nextInt ( ) == 1 ) { hotels . add ( i ) ; } } for ( int i = 0 ; i < n ; i ++ ) { parents [ i ] = sc . nextInt ( ) - 1 ; if ( parents [ i ] != - 1 ) { k [ parents [ i ] ] ++ ; } } LinkedList < Integer > bestPath = null ; for ( int h : hotels ) { LinkedList < Integer > path = new LinkedList < > ( ) ; path . addFirst ( h ) ; while ( true ) { int prev = parents [ path . getFirst ( ) ] ; if ( prev == - 1 ) { break ; } if ( k [ prev ] > 1 ) { break ; } path . addFirst ( prev ) ; } if ( bestPath == null || bestPath . size ( ) < path . size ( ) ) { bestPath = path ; } } System . out . println ( bestPath . size ( ) ) ; for ( int v : bestPath ) { System . out . print ( v + 1 + \" ▁ \" ) ; } } }",
"import java . util . * ; import java . io . * ; public class Main4 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int objects = sc . nextInt ( ) ; int [ ] types = new int [ objects ] ; for ( int i = 0 ; i < objects ; i ++ ) { types [ i ] = sc . nextInt ( ) ; } int [ ] skiTrack = new int [ objects ] ; int [ ] count = new int [ objects ] ; for ( int i = 0 ; i < objects ; i ++ ) {",
"import java . util . * ; import java . io . * ; public class Resort { InputStream is ; PrintWriter out ; String INPUT = \" \" ; void solve ( ) throws IOException { int n = ni ( ) ; boolean [ ] mountain = new boolean [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) mountain [ i ] = ni ( ) == 0 ; int [ ] parent = new int [ n + 1 ] ; int [ ] outdegree = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { parent [ i ] = ni ( ) ; outdegree [ parent [ i ] ] ++ ; } ArrayList < ArrayList < Integer > > list = new ArrayList < > ( ) ; for ( int i = 0 ; i <= n ; i ++ ) list . add ( new ArrayList < > ( ) ) ; int [ ] indegree = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( outdegree [ parent [ i ] ] > 1 || outdegree [ i ] > 2 || parent [ i ] == 0 ) continue ; list . get ( parent [ i ] ) . add ( i ) ; indegree [ i ] ++ ; } "
] | [
"n = int ( input ( ) ) input_types = input ( ) . split ( \" ▁ \" ) types = [ int ( i ) for i in input_types ] input_vertex = input ( ) . split ( \" ▁ \" ) prev = [ 0 for i in range ( n ) ] cntFrom = [ 0 for i in range ( n ) ] for i in range ( n ) : prev [ i ] = int ( input_vertex [ i ] ) prev [ i ] -= 1 if ( prev [ i ] != - 1 ) : cntFrom [ prev [ i ] ] += 1 ans = [ ] for i in range ( n ) : if types [ i ] == 1 : curV = i cur = [ ] while prev [ curV ] != - 1 and cntFrom [ prev [ curV ] ] <= 1 : cur . append ( curV ) curV = prev [ curV ] cur . append ( curV ) if len ( ans ) < len ( cur ) : ans = cur ans_alt = [ str ( i + 1 ) for i in ans [ : : - 1 ] ] print ( len ( ans_alt ) ) print ( ' ▁ ' . join ( ans_alt ) ) NEW_LINE",
"n = int ( input ( ) ) t = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) ans , cnt = [ ] , [ 0 for i in range ( n + 1 ) ] for i in a : cnt [ i ] += 1 for i in range ( 1 , n + 1 ) : if t [ i ] == 1 : crt = [ i ] x = a [ i ] while cnt [ x ] == 1 : crt . append ( x ) x = a [ x ] if len ( crt ) > len ( ans ) : ans = crt [ : ] ans . reverse ( ) print ( len ( ans ) ) print ( ' ▁ ' . join ( map ( str , ans ) ) ) NEW_LINE",
"n = int ( input ( ) ) t = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) ans , cnt = [ ] , [ 0 for i in range ( n + 1 ) ] for i in a : cnt [ i ] += 1 for i in range ( 1 , n + 1 ) : if t [ i ] == 1 : crt = [ i ] x = a [ i ] while cnt [ x ] == 1 : crt . append ( x ) x = a [ x ] if len ( crt ) > len ( ans ) : ans = crt [ : ] ans . reverse ( ) print ( len ( ans ) ) print ( ' ▁ ' . join ( map ( str , ans ) ) ) NEW_LINE",
"n = int ( input ( ) ) t = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) ans , cnt = [ ] , [ 0 for i in range ( n + 1 ) ] for i in a : cnt [ i ] += 1 for i in range ( 1 , n + 1 ) : if t [ i ] == 1 : crt = [ i ] x = a [ i ] while cnt [ x ] == 1 : crt . append ( x ) x = a [ x ] if len ( crt ) > len ( ans ) : ans = crt [ : ] ans . reverse ( ) print ( len ( ans ) ) print ( ' ▁ ' . join ( map ( str , ans ) ) ) NEW_LINE",
"n = int ( input ( ) ) t = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) res , cnt = [ ] , [ 0 ] * ( n + 1 ) for i in a : cnt [ i ] += 1 for i in range ( 1 , n + 1 ) : if t [ i ] == 0 : continue curr_res = [ i ] x = a [ i ] while cnt [ x ] == 1 : curr_res . append ( x ) x = a [ x ] if len ( curr_res ) > len ( res ) : res = curr_res [ : ] res . reverse ( ) print ( len ( res ) ) print ( * res ) NEW_LINE"
] |
codeforces_1311_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class CF1311A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { int [ ] ab = Arrays . stream ( br . readLine ( ) . split ( \" \\\\ s + \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; System . out . println ( ab [ 0 ] == ab [ 1 ] ? 0 : ab [ 0 ] < ab [ 1 ] ? ( ( ab [ 1 ] - ab [ 0 ] - 1 ) & 1 ) + 1 : ( ( ab [ 0 ] - ab [ 1 ] ) & 1 ) + 1 ) ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class CF1311A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { int [ ] ab = Arrays . stream ( br . readLine ( ) . split ( \" \\\\ s + \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int ans = - 1 ; if ( ab [ 0 ] == ab [ 1 ] ) { ans = 0 ; } else if ( ab [ 0 ] < ab [ 1 ] ) { ans = ( ( ab [ 1 ] - ab [ 0 ] - 1 ) & 1 ) + 1 ; } else { ans = ( ( ab [ 0 ] - ab [ 1 ] ) & 1 ) + 1 ; } System . out . println ( ans ) ; } } }",
"import java . util . Scanner ; public class A1311 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; if ( a == b ) { System . out . println ( 0 ) ; } else if ( a > b && ( a - b ) % 2 == 1 ) { System . out . println ( 2 ) ; } else if ( a > b && ( a - b ) % 2 == 0 ) { System . out . println ( 1 ) ; } else if ( a < b && ( b - a ) % 2 == 1 ) { System . out . println ( 1 ) ; } else if ( a < b && ( b - a ) % 2 == 0 ) { System . out . println ( 2 ) ; } } } }",
" import java . io . * ; import java . util . StringTokenizer ; public class A1311 { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; int tc = fs . nextInt ( ) ; for ( int _ = 0 ; _ < tc ; _ ++ ) { int A = fs . nextInt ( ) , B = fs . nextInt ( ) ; if ( A == B ) { out . println ( 0 ) ; } else if ( ( A > B && ( ( ( A - B ) & 1 ) ) == 0 ) || ( B > A && ( ( B - A ) & 1 ) == 1 ) ) { out . println ( 1 ) ; } else { out . println ( 2 ) ; } } out . close ( ) ; } static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public FastScanner ( String filePath ) throws FileNotFoundException { try { br = new BufferedReader ( new FileReader ( filePath ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } } return st . nextToken ( ) ; } String nextLine ( ) throws IOException { String str ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } return str ; } int nextInt ( ) throws IOException { return Integer . parseInt ( this . next ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( this . next ( ) ) ; } } }",
"import java . util . * ; public class Solutions { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a == b ) { System . out . println ( 0 ) ; } else if ( a < b ) { System . out . println ( ( b - a ) % 2 == 1 ? 1 : 2 ) ; } else { System . out . println ( ( a - b ) % 2 == 1 ? 2 : 1 ) ; } } } } "
] | [
"t = int ( input ( ) ) for _ in range ( t ) : a , b = map ( int , input ( ) . split ( ) ) if ( abs ( a - b ) == 0 ) : print ( '0' ) elif ( abs ( a - b ) % 2 == 0 and a - abs ( a - b ) == b ) : print ( '1' ) elif ( abs ( a - b ) % 2 == 0 and a - abs ( a - b ) != b ) : print ( '2' ) elif ( abs ( a - b ) % 2 != 0 and a + abs ( a - b ) == b ) : print ( '1' ) else : print ( '2' ) NEW_LINE",
"t = int ( input ( ) ) while t > 0 : count = 0 a , b = map ( int , input ( ) . split ( ) ) if a > b : a = a - b if a % 2 == 0 : count += 1 else : count += 2 elif b > a : b = b - a if b % 2 == 0 : count += 2 else : count += 1 print ( count ) t -= 1 NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) if a == b : print ( 0 ) elif a > b : if ( a - b ) % 2 == 0 : print ( 1 ) else : print ( 2 ) else : if ( a - b ) % 2 == 0 : print ( 2 ) else : print ( 1 ) NEW_LINE",
"def main ( ) : t = int ( input ( ) ) for _ in range ( t ) : a , b = map ( int , input ( ) . split ( ) ) val = b - a if val == 0 : print ( 0 ) elif val > 0 : if val % 2 != 0 : print ( 1 ) else : print ( 2 ) else : if val % 2 == 0 : print ( 1 ) else : print ( 2 ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE"
] |
codeforces_1284_B | [
" import java . lang . reflect . Array ; import java . text . CollationElementIterator ; import java . util . * ; import java . util . Map . Entry ; import java . io . * ; import java . lang . Math . * ; import java . math . BigInteger ; import static java . lang . Math . * ; import static java . lang . System . * ; import static java . util . Arrays . fill ; import static java . util . Arrays . spliterator ; public class ContestMain implements Runnable { private static Reader in = new Reader ( ) ; private static StringBuilder ans = new StringBuilder ( ) ; private static long MOD = ( long ) ( 1e9 + 7 ) ; private static final int N = ( int ) ( 2e5 + 7 ) ;"
] | [
"import bisectfrom sys import stdinn = int ( input ( ) ) a , b = [ ] , [ ] for i in range ( n ) : l , * s = map ( int , stdin . readline ( ) . split ( ) ) if sorted ( s ) == s [ : : - 1 ] : a . append ( s [ 0 ] ) b . append ( s [ - 1 ] ) a . sort ( ) print ( n * n - sum ( [ bisect . bisect_right ( a , bb ) for bb in b ] ) ) NEW_LINE",
"import bisectn = int ( input ( ) ) m1 = [ 0 ] * nm2 = [ ] m3 = [ 0 ] * nfor i in range ( n ) : arr = list ( map ( int , input ( ) . split ( ) ) ) [ 1 : ] k1 , k2 , k3 = float ( ' inf ' ) , float ( \" - inf \" ) , 0 for c in arr : if c > k1 : k3 = 1 k1 = min ( k1 , c ) k2 = max ( k2 , c ) m3 [ i ] = k3 if k3 == 0 : m1 [ i ] = k1 m2 . append ( k2 ) m2 . sort ( ) ans = 0 st = sum ( m3 ) for i in range ( n ) : if m3 [ i ] : ans += n else : j = bisect . bisect_left ( m2 , m1 [ i ] + 1 ) ans += len ( m2 ) - j + stprint ( ans ) NEW_LINE",
"import bisectn = int ( input ( ) ) f = [ ] l = [ ] for i in range ( n ) : a = list ( map ( int , input ( ) . split ( ) ) ) a = a [ 1 : ] if sorted ( a ) == a [ : : - 1 ] : f . append ( a [ 0 ] ) l . append ( a [ - 1 ] ) f . sort ( ) l . sort ( ) ans = 0 for i in range ( len ( f ) ) : pos = bisect . bisect_right ( f , l [ i ] ) ans += posprint ( n * n - ans ) NEW_LINE",
"from os import path ; import sys , timemod = int ( 1e9 + 7 ) from math import ceil , floor , gcd , log , log2 , factorial , sqrtfrom collections import defaultdict , Counter , OrderedDict , deque ; from itertools import combinations , permutations NEW_LINE",
"from os import path ; import sys , timemod = int ( 1e9 + 7 ) from math import ceil , floor , gcd , log , log2 , factorial , sqrtfrom collections import defaultdict , Counter , OrderedDict , deque ; from itertools import combinations , permutations NEW_LINE"
] |
codeforces_914_B | [
"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; ",
"import java . util . * ; public class square { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] num = new int [ 100001 ] ; for ( int i = 1 ; i <= n ; i ++ ) { int p = sc . nextInt ( ) ; num [ p ] ++ ; } for ( int i = 1 ; i <= 100000 ; i ++ ) if ( num [ i ] % 2 != 0 ) { System . out . println ( \" Conan \" ) ; return ; } System . out . println ( \" Agasa \" ) ; } }",
"import java . util . * ; public class CodeForces914B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] a = new int [ 100000 + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ input . nextInt ( ) ] ++ ; } String ans = \" Agasa \" ; for ( int i = 1 ; i < a . length ; i ++ ) { if ( a [ i ] % 2 != 0 ) { ans = \" Conan \" ; break ; } } System . out . println ( ans ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . List ; import java . util . stream . Collectors ; import java . util . stream . Stream ; public class Codeforces914B { public static void main ( String [ ] args ) throws NumberFormatException , IOException {",
"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; "
] | [
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) f = [ 0 ] * ( max ( a ) + 1 ) for i in a : f [ i ] += 1 c = 0 for i in f : if ( i % 2 != 0 ) : c = 1 breakif ( c == 0 ) : print ( ' Agasa ' ) else : print ( ' Conan ' ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) l1 = [ 0 ] * 100001 for item in a : l1 [ item ] += 1 ans = \" Agasa \" for item in l1 : if item % 2 : ans = \" Conan \" ; breakprint ( ans ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( reverse = True ) ai = [ 1 ] * n j = 0 for i in range ( 1 , n ) : if a [ i ] == a [ i - 1 ] : ai [ j ] += 1 else : j += 1 ai = ai [ : j + 1 ] conan = Falsefor i in ai : if i % 2 : conan = True break print ( \" Conan \" if conan else \" Agasa \" ) NEW_LINE",
"input ( ) q , t = { } , 0 a = list ( map ( int , input ( ) . split ( ) ) ) for i in a : q [ i ] = q . get ( i , 0 ) + 1 for i in q : if q [ i ] & 1 : t = 1 ; breakprint ( \" Conan \" if t else \" Agasa \" ) NEW_LINE"
] |
codeforces_1041_B | [
"import java . util . * ; public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long c = 0 ; long gcd = gcd ( x , y ) ; x = x / gcd ; y = y / gcd ; long a1 = a / x ; long a2 = b / y ; System . out . println ( Math . min ( a1 , a2 ) ) ;",
"import java . util . * ; public class Example { static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;",
"import java . util . Scanner ; public class _0705BuyingaTVSet { static long gcd ( long a , long b ) {",
"import java . util . * ; public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long c = 0 ; long gcd = gcd ( x , y ) ; x = x / gcd ; y = y / gcd ; long a1 = a / x ; long a2 = b / y ; System . out . println ( Math . min ( a1 , a2 ) ) ;"
] | [
"max_width , max_height , x , y = map ( int , input ( ) . split ( ) ) def hcf ( num1 , num2 ) : if ( num2 == 0 ) : return num1 return hcf ( num2 , num1 % num2 ) ratio = 0 ratio = hcf ( x , y ) if ( ratio != 0 ) : x = x // ratio y = y // ratio posible_width = max_width // x possible_height = max_height // y print ( min ( possible_height , posible_width ) ) NEW_LINE",
"import matha , b , x , y = map ( int , input ( ) . split ( ) ) g = math . gcd ( x , y ) x //= gy //= gprint ( min ( a // x , b // y ) ) NEW_LINE",
"import math a , b , x , y = map ( int , input ( ) . split ( ) ) c = math . gcd ( x , y ) x //= cy //= cans = min ( a // x , b // y ) print ( ans ) NEW_LINE",
"import matha , b , x , y = map ( int , input ( ) . split ( ) ) d = math . gcd ( x , y ) print ( min ( a * d // x , b * d // y ) ) NEW_LINE"
] |
codeforces_567_B | [
"import java . util . * ; import java . util . Scanner ; import java . io . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import javax . lang . model . util . ElementScanner6 ; public class B567 { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String args [ ] ) { FastReader in = new FastReader ( ) ; int t = 1 ;",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { InputReader sc = new InputReader ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; Random gen = new Random ( ) ; int test = 1 ;",
"import java . util . Scanner ; public class ArrayList { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int min = 0 , c = 0 ; boolean f [ ] = new boolean [ 10000001 ] ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; int r = sc . nextInt ( ) ; if ( s . charAt ( 0 ) == ' - ' ) { if ( ! f [ r ] ) min ++ ; else c -- ; } else c ++ ; f [ r ] = true ; if ( c > min ) min = c ; } System . out . println ( min ) ; } }",
"import java . util . * ; public class Berland_National_Library { static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; boolean [ ] tab = new boolean [ 1000001 ] ; int min = 0 ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String s = in . next ( ) ; int k = in . nextInt ( ) ; if ( s . charAt ( 0 ) == ' - ' ) { if ( ! tab [ k ] ) min ++ ; else c -- ; } else c ++ ; tab [ k ] = true ; if ( c > min ) min = c ; } System . out . println ( min ) ; } }"
] | [
"from sys import stdin , stdoutfrom os import pathrd = lambda : stdin . readline ( ) . strip ( ) wr = stdout . writeif ( path . exists ( ' input . txt ' ) ) : stdin = open ( \" input . txt \" , \" r \" ) import time , math NEW_LINE",
"n = int ( input ( ) ) a = [ ] for i in range ( n ) : s = input ( ) a . append ( s ) lst = [ 0 ] * 1000000 before = [ ] for i in range ( n ) : sign = a [ i ] [ 0 ] val = int ( a [ i ] [ 2 : ] ) if sign == \" + \" : lst [ val - 1 ] = 1 else : if not lst [ val - 1 ] : before . append ( val ) mx = len ( before ) ans = mxfor i in range ( n ) : sign = a [ i ] [ 0 ] val = int ( a [ i ] [ 2 : ] ) if sign == \" + \" : mx += 1 ans = max ( mx , ans ) else : mx -= 1 print ( ans ) NEW_LINE",
"n , l , m , a = int ( input ( ) ) , [ 0 ] * 1000000 , 0 , [ ] for _ in range ( n ) : a . append ( input ( ) ) for i in range ( n ) : v = int ( a [ i ] [ 2 : ] ) if a [ i ] [ 0 ] == ' + ' : l [ v - 1 ] = 1 elif not l [ v - 1 ] : m += 1 ans = mfor i in range ( n ) : if a [ i ] [ 0 ] == ' + ' : m += 1 ; ans = max ( m , ans ) else : m -= 1 print ( ans ) NEW_LINE",
"n = int ( input ( ) ) seats = [ False for x in range ( 1 , 1000010 ) ] ans = 0 state = 0 for x in range ( n ) : di , idd = input ( ) . split ( ) idd = int ( idd ) if di == ' + ' : seats [ idd ] = True state += 1 ans = max ( ans , state ) elif di == ' - ' : if seats [ idd ] == False : ans += 1 else : state -= 1 ans = max ( ans , state ) seats [ idd ] = Falseprint ( ans ) NEW_LINE",
"n = int ( input ( ) ) mp = dict ( ) ans , cur = 0 , 0 for i in range ( n ) : c , x = [ _ for _ in input ( ) . split ( ) ] x = int ( x ) if c == ' - ' : if mp . get ( x ) == True : cur -= 1 mp [ x ] = False elif mp . get ( x ) is None : ans += 1 mp [ x ] = False elif c == ' + ' : cur += 1 mp [ x ] = True ans = max ( ans , cur ) print ( ans ) NEW_LINE"
] |
codeforces_863_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long num = in . nextLong ( ) ; while ( num % 10 == 0 ) { num /= 10 ; } String str = String . valueOf ( num ) ; for ( int i = 0 ; i < str . length ( ) / 2 ; i ++ ) {",
"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; ",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; } public static long mod = 17352642619633L ; void run ( FastScanner in , PrintWriter out ) { char [ ] ca = in . next ( ) . toCharArray ( ) ; int N = ca . length ; for ( int i = 0 ; i <= N ; i ++ ) { boolean good = true ; for ( int j = 0 ; j < i / 2 ; j ++ ) { if ( ca [ j ] != ca [ i - j - 1 ] ) good = false ; } for ( int j = i ; j < N ; j ++ ) { if ( ca [ j ] != '0' ) good = false ; } if ( good ) { out . println ( \" YES \" ) ; return ; } } out . println ( \" NO \" ) ; } static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }"
] | [
"s = input ( ) s = s . strip ( \"0\" ) NEW_LINE",
"s = input ( ) s = list ( s ) while s [ - 1 ] == '0' : s . pop ( ) d = s [ : : - 1 ] print ( \" YES \" if d == s else \" NO \" ) NEW_LINE",
"string = input ( ) while string [ - 1 ] == '0' : string = string [ : len ( string ) - 1 ] if string == string [ : : - 1 ] : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"string = input ( ) while string [ - 1 ] == '0' : string = string [ : len ( string ) - 1 ] if string == string [ : : - 1 ] : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"import sysx = input ( ) for i in range ( len ( x ) - 1 , - 1 , - 1 ) : if x [ i ] != '0' : new = ( i + 1 ) for j in range ( new // 2 ) : if ( x [ j ] != x [ new - j - 1 ] ) : print ( \" NO \" ) sys . exit ( 0 ) breakprint ( \" YES \" ) NEW_LINE"
] |
codeforces_819_B | [
"import java . io . * ; import java . math . BigDecimal ; import java . math . MathContext ; import java . util . * ; import java . util . function . Function ; import static java . math . BigDecimal . ROUND_HALF_UP ; public class Solution { static MyScanner sc ; private static PrintWriter out ; static long M2 = 1_000_000_000L + 7 ; public static void main ( String [ ] s ) throws Exception { StringBuilder stringBuilder = new StringBuilder ( ) ;",
"import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . StringTokenizer ; public class B_Round_421_Div1 { public static long MOD = 1000000007 ; public static void main ( String [ ] args ) throws FileNotFoundException {",
"import java . util . * ; import java . util . stream . IntStream ; import java . io . * ; public class MisterBandPRShifts { static int [ ] brute ( int arr [ ] ) { int deviation [ ] = new int [ arr . length ] ; for ( int k = 0 ; k < arr . length ; k ++ ) for ( int i = 0 ; i < arr . length ; i ++ ) deviation [ k ] += Math . abs ( i - arr [ ( i - k + arr . length ) % arr . length ] ) ; return deviation ; } static void rotate ( int arr [ ] , int k ) { int temp [ ] = new int [ arr . length ] ; System . arraycopy ( arr , arr . length - k , temp , 0 , k ) ; System . arraycopy ( arr , 0 , temp , k , arr . length - k ) ; pa ( temp ) ; } static void pa ( int arr [ ] ) { System . out . println ( Arrays . toString ( arr ) ) ; System . out . println ( Arrays . toString ( IntStream . range ( 0 , arr . length ) . toArray ( ) ) ) ; } private static void solve ( ) { int n = nextInt ( ) ; int arr [ ] = Arrays . stream ( nextIntArray ( n ) ) . map ( a -> a - 1 ) . toArray ( ) ; int edgeCase [ ] = new int [ n ] ;",
"import java . io . * ; import java . util . * ; "
] | [
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) t = [ 0 ] * 2 * ns = 0 for i in range ( n ) : d = a [ i ] - i - 1 s += abs ( d ) if d > 0 : t [ d ] += 1 p = sum ( t ) r = ( s , 0 ) for i in range ( 1 , n ) : d = a [ n - i ] - 1 s += d - p << 1 t [ d + i ] += d > 0 p += ( d > 0 ) - t [ i ] if s < r [ 0 ] : r = ( s , i ) print ( * r ) NEW_LINE"
] |
codeforces_585_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Random ; import java . util . StringTokenizer ; public class Solution { public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { int n = fs . nextInt ( ) ; long [ ] [ ] arr = new long [ n ] [ 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] [ 0 ] = fs . nextLong ( ) ; arr [ i ] [ 1 ] = fs . nextLong ( ) ; arr [ i ] [ 2 ] = fs . nextLong ( ) ; } ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] [ 2 ] < 0 ) continue ; list . add ( i + 1 ) ; long offcry = arr [ i ] [ 0 ] ; long corcry = 0 ; int ind = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] [ 2 ] < 0 ) continue ; arr [ j ] [ 2 ] -= Math . max ( 0 , offcry - ( ind ++ ) ) + corcry ; if ( arr [ j ] [ 2 ] < 0 ) corcry += arr [ j ] [ 1 ] ; } } out . println ( list . size ( ) ) ; for ( int a : list ) out . print ( a + \" ▁ \" ) ; } out . close ( ) ; } static final Random random = new Random ( ) ; static void ruffleSort ( int [ ] a ) { int n = a . length ;",
"import java . io . * ; import java . math . BigInteger ; import java . util . * ; public class Main { static int MOD = 1000000007 ; ",
"import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; ArrayList < Integer > ans = new ArrayList < > ( ) ; int n = input . nextInt ( ) ; long v [ ] = new long [ n ] ; long d [ ] = new long [ n ] ; long p [ ] = new long [ n ] ; ArrayList < Integer > queue = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { v [ i ] = input . nextLong ( ) ; d [ i ] = input . nextLong ( ) ; p [ i ] = input . nextLong ( ) ; queue . add ( i ) ; }"
] | [
"n = int ( input ( ) ) arr , res = [ ] , [ ] for i in range ( n ) : arr . append ( [ int ( j ) for j in input ( ) . split ( ) ] ) res . append ( 0 ) for i in range ( n ) : if res [ i ] != 0 : continue res [ i ] = 1 v = arr [ i ] [ 0 ] d = 0 for j in range ( i + 1 , n ) : if res [ j ] != 0 : continue arr [ j ] [ 2 ] -= v + d if v >= 1 : v -= 1 if arr [ j ] [ 2 ] < 0 : res [ j ] = - 1 d += arr [ j ] [ 1 ] print ( res . count ( 1 ) , end = ' \\n ' ) for i in range ( n ) : if res [ i ] == 1 : print ( i + 1 , end = ' ▁ ' ) NEW_LINE",
"ans = 0 l = [ ] t = int ( input ( ) ) for i in range ( t ) : n , m , k = map ( int , input ( ) . split ( ) ) l . append ( [ n , m , k ] ) ans = 0 p = [ ] for i in range ( t ) : if l [ i ] [ 2 ] >= 0 : k = 0 v = 0 for j in range ( i + 1 , t ) : if l [ j ] [ 2 ] >= 0 : l [ j ] [ 2 ] -= ( max ( 0 , l [ i ] [ 0 ] - k ) + v ) if l [ j ] [ 2 ] < 0 : v += l [ j ] [ 1 ] l [ j ] [ 1 ] = 0 k += 1 p . append ( i + 1 ) NEW_LINE",
"T = int ( input ( ) ) childs = [ ] for i in range ( 1 , T + 1 ) : child = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) child . insert ( 0 , i ) childs . append ( child ) c_l = [ ] check = Truewhile check : at_o = childs . pop ( 0 ) c_l . append ( at_o [ 0 ] ) for i in range ( len ( childs ) ) : childs [ i ] [ 3 ] -= at_o [ 1 ] at_o [ 1 ] -= 1 if at_o [ 1 ] <= 0 : break if len ( childs ) <= 0 : break i = 0 run = True while run : if childs [ i ] [ 3 ] < 0 : at_h = childs . pop ( i ) for j in range ( i , len ( childs ) ) : childs [ j ] [ 3 ] -= at_h [ 2 ] NEW_LINE",
"n = int ( input ( ) ) arr , res = [ ] , [ ] for i in range ( n ) : arr . append ( [ int ( j ) for j in input ( ) . split ( ) ] ) res . append ( 0 ) for i in range ( n ) : if res [ i ] != 0 : continue res [ i ] = 1 v = arr [ i ] [ 0 ] d = 0 for j in range ( i + 1 , n ) : if res [ j ] != 0 : continue arr [ j ] [ 2 ] -= v + d if v >= 1 : v -= 1 if arr [ j ] [ 2 ] < 0 : res [ j ] = - 1 d += arr [ j ] [ 1 ] print ( res . count ( 1 ) , end = ' \\n ' ) for i in range ( n ) : if res [ i ] == 1 : print ( i + 1 , end = ' ▁ ' ) NEW_LINE"
] |
codeforces_763_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; System . out . println ( \" YES \" ) ; for ( int i = 0 ; i < n ; i ++ ) { int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; System . out . println ( ( 12 + 2 * ( x1 % 2 ) + ( y1 % 2 ) ) % 4 + 1 ) ; } } }",
"# include < iostream > using namespace std ; template < class T > bool uin ( T & a , T b ) { return a > b ? ( a = b , true ) : false ; } template < class T > bool uax ( T & a , T b ) { return a < b ? ( a = b , true ) : false ; } # define forn ( i , n ) for ( int i = 0 ; i < ( int ) ( n ) ; i ++ ) # define forab ( i , a , b ) for ( int i = ( int ) ( a ) ; i < ( int ) ( b ) ; ++ i ) # define _ cin . tie ( 0 ) ; ios_base :: sync_with_stdio ( 0 ) ; # define i64 long long int main ( ) { int n ; printf ( \" YES \\n \" ) ; scanf ( \" % d \" , & n ) ; for ( int i = 0 ; i < n ; i ++ ) { int x1 , y1 , x2 , y2 ; scanf ( \" % d ▁ % d ▁ % d ▁ % d \" , & x1 , & y1 , & x2 , & y2 ) ; printf ( \" % d \\n \" , ( ( 12 + 2 * ( x1 % 2 ) + ( y1 % 2 ) ) % 4 ) + 1 ) ; } return 0 ; }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . io . BufferedWriter ; import java . io . Writer ; import java . io . OutputStreamWriter ; 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 ; InputReader in = new InputReader ( inputStream ) ; OutputWriter out = new OutputWriter ( outputStream ) ; DTimofeyAndRectangles solver = new DTimofeyAndRectangles ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class DTimofeyAndRectangles { public void solve ( int testNumber , InputReader in , OutputWriter out ) { int n = in . nextInt ( ) ; rect [ ] rects = new rect [ n ] ; out . println ( \" YES \" ) ; for ( int i = 0 ; i < n ; i ++ ) { int x1 = in . nextInt ( ) ; int y1 = in . nextInt ( ) ; int x2 = in . nextInt ( ) ; int y2 = in . nextInt ( ) ; x2 += 1000000000 ; y1 += 1000000000 ; rects [ i ] = new rect ( x1 , y1 , x2 , y2 , i ) ; int ans = 0 ; if ( x2 % 2 == 1 ) { ans += 1 ; } if ( y1 % 2 == 1 ) { ans += 2 ; } out . println ( ans + 1 ) ; } "
] | [
"print ( ' YES ' ) for i in range ( int ( input ( ) ) ) : x , y , a , b = [ int ( x ) for x in input ( ) . split ( ) ] print ( x % 2 + y % 2 * 2 + 1 ) NEW_LINE",
"def f ( ) : n = int ( input ( ) ) a = [ 1 , 2 , 3 , 4 ] print ( \" YES \" ) for i in range ( n ) : x = input ( ) . split ( ) x = [ int ( j ) % 2 for j in x ] print ( a [ x [ 2 ] * 2 + x [ 3 ] ] ) f ( ) NEW_LINE",
"print ( ' YES ' ) for i in range ( int ( input ( ) ) ) : a , b , c , d = map ( int , input ( ) . split ( ) ) print ( 1 + abs ( a ) % 2 + abs ( b ) % 2 * 2 ) NEW_LINE",
"import sysv = [ int ( x ) for x in sys . stdin . read ( ) . split ( ) ] print ( \" YES \" ) for i in range ( v [ 0 ] ) : print ( 1 + ( v [ 4 * i + 1 ] & 1 ) + 2 * ( v [ 4 * i + 2 ] & 1 ) ) NEW_LINE",
"import mathimport sysn = int ( input ( ) ) color = [ ] for i in range ( n ) : x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) col = 0 if abs ( x1 ) % 2 == 0 : col += 1 if abs ( y1 ) % 2 == 0 : col += 2 color . append ( str ( col + 1 ) ) print ( ' YES ' ) print ( ' \\n ' . join ( color ) ) NEW_LINE"
] |
codeforces_909_A | [
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; StringBuilder ab = new StringBuilder ( ) ; ab . append ( a . charAt ( 0 ) ) ; for ( int i = 1 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) < b . charAt ( 0 ) ) ab . append ( a . charAt ( i ) ) ; else break ; } ab . append ( b . charAt ( 0 ) ) ; System . out . println ( ab . toString ( ) ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int T = 1 ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class kjhg { public static void main ( String [ ] args ) throws IOException { BufferedReader a = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String f = a . readLine ( ) ; String d [ ] = f . split ( \" ▁ \" ) ; System . out . print ( d [ 0 ] . charAt ( 0 ) ) ; for ( int i = 1 ; i < d [ 0 ] . length ( ) ; i ++ ) { if ( d [ 0 ] . charAt ( i ) < d [ 1 ] . charAt ( 0 ) ) { System . out . print ( d [ 0 ] . charAt ( i ) ) ; } else { break ; } } System . out . println ( d [ 1 ] . charAt ( 0 ) ) ; } }",
"import java . util . * ; import java . io . * ; public final class Codeforces { public static BufferedReader buffer = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static BufferedWriter logger = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; public static void main ( String [ ] args ) { try { args = buffer . readLine ( ) . split ( \" ▁ \" ) ; String s1 = args [ 0 ] ; String s2 = args [ 1 ] ; String s = s1 . charAt ( 0 ) + \" \" ; int n = s1 . length ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s1 . charAt ( i ) < s2 . charAt ( 0 ) ) { s += s1 . charAt ( i ) ; } else { break ; } } s += s2 . charAt ( 0 ) ; logger . write ( s ) ; logger . flush ( ) ; } catch ( IOException exc ) { } } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s1 = in . next ( ) ; String s2 = in . next ( ) ; String s = \" zzzzzzzz \" ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { for ( int j = 0 ; j < s2 . length ( ) ; j ++ ) { String ss = s1 . substring ( 0 , i + 1 ) + s2 . substring ( 0 , j + 1 ) ; s = min ( ss , s ) ; } } System . out . println ( s ) ; } public static String min ( String s1 , String s2 ) { if ( s1 . compareTo ( s2 ) < 0 ) return s1 ; else return s2 ; } }"
] | [
"import mathfrom math import gcd , floor , sqrt , logdef iin ( ) : return int ( input ( ) ) def sin ( ) : return input ( ) . strip ( ) def listin ( ) : return list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) def liststr ( ) : return list ( map ( str , input ( ) . strip ( ) . split ( ) ) ) def ceill ( x ) : return int ( x ) if ( x == int ( x ) ) else int ( x ) + 1 def ceilldiv ( x , d ) : return x // d if ( x % d == 0 ) else x // d + 1 def LCM ( a , b ) : return ( a * b ) // gcd ( a , b ) s = liststr ( ) x = \" zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz \" for i in range ( len ( s [ 0 ] ) ) : for j in range ( len ( s [ 1 ] ) ) : temp = s [ 0 ] [ : i + 1 ] + s [ 1 ] [ : j + 1 ] x = min ( x , temp ) print ( x ) NEW_LINE",
"s = input ( ) . split ( ) s1 = s [ 0 ] [ 1 : ] print ( s [ 0 ] [ 0 ] , end = \" \" ) for i in s1 : if ( ord ( i ) >= ord ( s [ 1 ] [ 0 ] ) ) : print ( s [ 1 ] [ 0 ] , end = \" \" ) break else : print ( i , end = \" \" ) else : print ( s [ 1 ] [ 0 ] , end = \" \" ) NEW_LINE",
"a , b = input ( ) . split ( ) ans = \" z \" * 101 f = \" \" l = \" \" for i in a : f += i l = \" \" for j in b : l += j ans = min ( ans , f + l ) print ( ans ) NEW_LINE",
"import mathfrom math import gcd , floor , sqrt , logdef iin ( ) : return int ( input ( ) ) def sin ( ) : return input ( ) . strip ( ) def listin ( ) : return list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) def liststr ( ) : return list ( map ( str , input ( ) . strip ( ) . split ( ) ) ) def ceill ( x ) : return int ( x ) if ( x == int ( x ) ) else int ( x ) + 1 def ceilldiv ( x , d ) : return x // d if ( x % d == 0 ) else x // d + 1 def LCM ( a , b ) : return ( a * b ) // gcd ( a , b ) s = liststr ( ) x = [ ] for i in range ( len ( s [ 0 ] ) ) : for j in range ( len ( s [ 1 ] ) ) : temp = s [ 0 ] [ : i + 1 ] + s [ 1 ] [ : j + 1 ] x . append ( temp ) print ( min ( x ) ) NEW_LINE"
] |
codeforces_865_B | [
"import java . io . * ; import java . math . BigInteger ; import java . util . * ; public class Main { static InputReader in = new InputReader ( System . in ) ; static PrintWriter out = new PrintWriter ( System . out ) ; static int oo = ( int ) 1e9 ;",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; void run ( ) { work ( ) ; out . flush ( ) ; } long mod = 998244353 ; long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } void work ( ) { int n = in . nextInt ( ) ; long s = in . nextLong ( ) ; long [ ] [ ] A = new long [ n ] [ ] ; long c1 = 0 , c2 = 0 , sum = 0 , ret = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long k = in . nextLong ( ) ; long p1 = in . nextLong ( ) ; long p2 = in . nextLong ( ) ; if ( p1 > p2 ) { c1 += k ; ret += k * p1 ; } else { c2 += k ; ret += k * p2 ; } A [ i ] = new long [ ] { k , p1 , p2 } ; sum += k ; } long r1 = c1 == 0 ? 0 : ( ( c1 - 1 ) / s + 1 ) ; long r2 = c2 == 0 ? 0 : ( ( c2 - 1 ) / s + 1 ) ; if ( r1 + r2 == ( sum - 1 ) / s + 1 ) { out . println ( ret ) ; return ; } long r = 0 ; r = Math . max ( r , find ( c1 - c1 / s * s , A , ret , 1 ) ) ;",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; } int S ; void run ( FastScanner in , PrintWriter out ) { N = in . nextInt ( ) ; S = in . nextInt ( ) ; totalSlices = 0 ; p = new long [ N ] [ 3 ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] [ 0 ] = in . nextInt ( ) ; p [ i ] [ 1 ] = in . nextInt ( ) ; p [ i ] [ 2 ] = in . nextInt ( ) ; totalSlices += p [ i ] [ 0 ] ; } totalPizzas = ( long ) Math . ceil ( ( double ) totalSlices / S ) ; Arrays . sort ( p , ( a , b ) -> Long . compare ( a [ 2 ] - a [ 1 ] , b [ 2 ] - b [ 1 ] ) ) ;"
] | [
"def solve ( ls ) : ls . sort ( key = lambda q : q [ 1 ] - q [ 0 ] ) m = sum ( si for a , b , si in ls ) k = s * ( m // s ) n = m - k x = y = z = 0 for a , b , si in ls : if k >= si : k -= si z += si * a elif k : z += k * a x = ( si - k ) * a y = ( si - k ) * b k = 0 else : x += si * a y += si * b return x , y , z , n n , s = map ( int , input ( ) . split ( ) ) first = [ ] second = [ ] for i in range ( n ) : si , ai , bi = map ( int , input ( ) . split ( ) ) if ai > bi : first . append ( ( ai , bi , si ) ) else : second . append ( ( bi , ai , si ) ) x1 , y1 , z1 , n1 = solve ( first ) x2 , y2 , z2 , n2 = solve ( second ) d = x1 + x2 if n1 + n2 > s else max ( x1 + y2 , x2 + y1 ) print ( z1 + z2 + d ) NEW_LINE",
"from sys import stdinfrom collections import deque n , S = [ int ( x ) for x in stdin . readline ( ) . split ( ) ] ppl = [ ] base = 0 tSlices = 0 for dude in range ( n ) : s , a , b = [ int ( x ) for x in stdin . readline ( ) . split ( ) ] base += s * a tSlices += s ppl . append ( [ b - a , s ] ) NEW_LINE"
] |
codeforces_1100_A | [
"import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ; import java . math . * ; public class Exam { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ; public static void main ( String args [ ] ) throws IOException {",
"import java . util . Scanner ; public class RomanBrowser { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) , i , j , a [ ] = new int [ n ] , o = 0 ; for ( i = 0 ; i < n ; i ++ ) a [ i ] = in . nextInt ( ) ; in . close ( ) ; for ( i = 0 ; i < k ; i ++ ) { int s = 0 ; for ( j = 0 ; j < n ; j ++ ) { if ( j % k != i ) s += a [ j ] ; } o = Math . max ( o , Math . abs ( s ) ) ; } System . out . println ( o ) ; } }",
"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int k = s . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int s1 = 0 ; for ( int j = 0 ; j < n ; j ++ ) if ( j % k != i ) s1 += a [ j ] ; ans = Math . max ( ans , Math . abs ( s1 ) ) ; } System . out . println ( ans ) ; } }"
] | [
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 for b in range ( k ) : e , s = 0 , 0 for i in range ( n ) : if i % k != b : if a [ i ] == 1 : e += 1 else : s += 1 ans = max ( ans , abs ( e - s ) ) print ( ans ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) sumi = 0 maxi = - 10000 for i in range ( n ) : sumi += x [ i ] for i in range ( k ) : ans = sumi for j in range ( i , n , k ) : ans -= x [ j ] maxi = max ( maxi , abs ( ans ) ) print ( maxi ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) res = 0 for i in range ( k ) : count = 0 for j in range ( n ) : if i != j % k : count += l [ j ] res = max ( res , abs ( count ) ) print ( res ) NEW_LINE",
"i = lambda : map ( int , input ( ) . split ( ) ) n , k = i ( ) a = * i ( ) , s = sum ( a ) print ( max ( abs ( s - sum ( a [ j : : k ] ) ) for j in range ( k ) ) ) NEW_LINE",
"import copyn , k = map ( int , input ( ) . split ( ) ) tabs = list ( map ( int , input ( ) . split ( ) ) ) tabs . insert ( 0 , 0 ) max_value = 0 for each_b in range ( 1 , n + 1 ) : temp = copy . deepcopy ( tabs ) i = each_b while i <= n : NEW_LINE"
] |
codeforces_916_B | [
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; void run ( ) { work ( ) ; out . flush ( ) ; } long mod = 1000000007 ; long gcd ( long a , long b ) { return a == 0 ? b : gcd ( b % a , a ) ; } void work ( ) { long n = nl ( ) , k = nl ( ) ; int offset = 65 ; long [ ] A = new long [ 130 ] ; long cnt = 0 ; for ( int i = 0 ; i < 63 ; i ++ ) { if ( ( 1L << i & n ) > 0 ) { A [ offset + i ] = 1 ; cnt ++ ; } } if ( cnt > k ) { out . println ( \" No \" ) ; return ; } k -= cnt ; for ( int i = 127 ; ; i -- ) { long c = A [ i ] ; if ( c > k ) { break ; } else { A [ i - 1 ] += A [ i ] * 2 ; A [ i ] = 0 ; k -= c ; } } int idx = 0 ; for ( int i = 1 ; ; i ++ ) { if ( A [ i ] > 0 ) { idx = i ; break ; } } if ( k > 0 ) { A [ idx ] -- ; } List < Integer > ret = new ArrayList < > ( ) ; for ( int i = 127 ; i >= 0 ; i -- ) { long c = A [ i ] ; for ( int j = 0 ; j < c ; j ++ ) { ret . add ( i - 65 ) ; } } if ( k > 0 ) { idx -- ; while ( k > 0 ) { ret . add ( idx - 65 ) ; k -- ; idx -- ; } ret . add ( idx + 1 - 65 ) ; } out . println ( \" Yes \" ) ; for ( int r : ret ) { out . print ( r + \" ▁ \" ) ; } } ",
"import java . io . BufferedReader ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . io . * ; public class codeforces { static class Student { long x , y ; Student ( long x , long y ) { this . x = x ; this . y = y ; } } static int prime [ ] ; static void sieveOfEratosthenes ( int n ) {"
] | [
"n , k = map ( int , input ( ) . split ( ) ) s = list ( ) b = list ( ) base = 0 while n > 0 : s . append ( n % 2 ) b . append ( base ) n //= 2 base += 1 s . reverse ( ) NEW_LINE",
"import mathx , k = map ( int , input ( ) . split ( ) ) kori = ka = bin ( x ) NEW_LINE",
"from heapq import heapify , heappop , heappushn , k = map ( int , input ( ) . split ( ) ) heap1 = [ ] heap2 = [ ] MAX = int ( 1e5 ) + 10 s = [ ] heapify ( heap1 ) heapify ( heap2 ) i = 0 cnt = 0 while 1 << i <= n : if 1 << i & n : heappush ( heap1 , - i ) ; heappush ( heap2 , - i ) ; cnt += 1 i += 1 if cnt > k : print ( \" NO \" ) ; exit ( ) temp = cntwhile temp < k : x = - 1 * heappop ( heap1 ) - 1 heappush ( heap1 , - x ) heappush ( heap1 , - x ) temp += 1 temp = heap1 [ 0 ] * - 1 while cnt < k : if temp == heap2 [ 0 ] * - 1 : break x = heappop ( heap2 ) * - 1 - 1 heappush ( heap2 , - x ) heappush ( heap2 , - x ) cnt += 1 while heap2 : s . append ( heappop ( heap2 ) * - 1 ) while cnt < k : s [ - 1 ] = s [ - 1 ] - 1 s . append ( s [ - 1 ] ) cnt += 1 print ( \" YES \" ) print ( * s ) NEW_LINE"
] |
codeforces_322_A | [
"import java . util . * ; public class square { public static void main ( String ar [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; System . out . println ( n + m - 1 ) ; for ( int i = 1 ; i <= m ; i ++ ) System . out . println ( 1 + \" ▁ \" + i ) ; for ( int j = 2 ; j <= n ; j ++ ) System . out . println ( j + \" ▁ \" + 1 ) ; } }",
"import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; public class A322 { public static void main ( String args [ ] ) { FastReader in = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int tc = 1 ;",
"import java . io . * ; import java . util . * ; public class Test { public static void main ( String [ ] args ) throws java . lang . Exception { PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str [ ] = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int k = n + m - 1 ; out . println ( k ) ; out . flush ( ) ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . StringTokenizer ; public class CF322A { public static void main ( String [ ] args ) { FastReader input = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int pairs = m + ( n - 1 ) ; pw . println ( pairs ) ; for ( int i = 1 ; i <= m ; i ++ ) { pw . println ( 1 + \" ▁ \" + i ) ; } for ( int i = 2 ; i <= n ; i ++ ) { pw . println ( i + \" ▁ \" + 1 ) ; } pw . flush ( ) ; pw . close ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int j = 1 ; System . out . println ( n + m - 1 ) ; for ( int i = 1 ; i <= n ; ) { System . out . println ( i + \" ▁ \" + j ) ; if ( j + 1 <= m ) j ++ ; else i ++ ; } } }"
] | [
"import sys , mathsys . setrecursionlimit ( 10 ** 8 ) ''' def ▁ fun ( ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 16 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( 4 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ i & (1 < < j ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( j , end = ' ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ) import ▁ binarytreefrom ▁ collections ▁ import ▁ dequebst ▁ = ▁ binarytree . tree ( height = 4 , is _ perfect = True ) print ( bst ) def ▁ s ( bst ) : ▁ ▁ ▁ ▁ if ▁ bst : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ bst . left , bst . right ▁ = ▁ bst . right , bst . left ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . right ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . left ) s ( bst ) print ( bst ) ''' n , m = map ( int , input ( ) . split ( ) ) print ( n + m - 1 ) for i in range ( 1 , m + 1 ) : print ( 1 , i ) for i in range ( 2 , n + 1 ) : print ( i , 1 ) NEW_LINE",
"n , m = [ int ( x ) for x in input ( ) . split ( ) ] a = min ( n , m ) b = abs ( n - m ) k = 2 * a - 1 + bprint ( k ) if a == 1 : print ( 1 , 1 ) i = 1 else : for i in range ( 1 , a ) : print ( i , i ) print ( i + 1 , i ) print ( i + 1 , i + 1 ) if n < m : for i in range ( a + 1 , m + 1 ) : print ( a , i ) elif n > m : for i in range ( a + 1 , n + 1 ) : print ( i , a ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) print ( n + m - 1 ) for i in range ( 1 , m + 1 ) : print ( 1 , i ) for i in range ( 2 , n + 1 ) : print ( i , m ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) print ( n + m - 1 ) for i in range ( 1 , m + 1 ) : print ( 1 , i ) for j in range ( 2 , n + 1 ) : print ( j , 1 ) NEW_LINE",
"a , b = map ( int , input ( ) . split ( ) ) aa = [ ] bb = [ ] ans = [ ] lis = [ ] liss = [ ] for t in range ( 1 , a + 1 ) : aa . append ( t ) for t in range ( 1 , b + 1 ) : bb . append ( t ) for m in range ( len ( aa ) ) : mm = aa [ m ] for n in range ( len ( bb ) ) : nn = bb [ n ] if mm + nn not in ans : ans . append ( mm + nn ) lis . append ( mm ) liss . append ( nn ) print ( len ( ans ) ) for t in range ( len ( lis ) ) : v = lis [ t ] vv = liss [ t ] print ( v , vv ) NEW_LINE"
] |
codeforces_347_A | [
"import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ; public class Main { static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; } Arrays . sort ( a ) ; } public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } sort ( a ) ; int temp = a [ 0 ] ; a [ 0 ] = a [ n - 1 ] ; a [ n - 1 ] = temp ; for ( int i : a ) { System . out . print ( i + \" ▁ \" ) ; } System . out . println ( \" \" ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; public class c693a {",
"import java . util . * ; import java . io . * ; import java . lang . * ; public class Codeforces { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { if ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public static void main ( String [ ] args ) { new Codeforces ( ) . solve ( ) ; } void solve ( ) { int n = nextInt ( ) ; List < Integer > arr = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) arr . add ( nextInt ( ) ) ; Collections . sort ( arr ) ; int max = arr . get ( n - 1 ) , min = arr . get ( 0 ) ; arr . remove ( 0 ) ; arr . remove ( n - 2 ) ; out . print ( max + \" ▁ \" ) ; for ( int i : arr ) out . print ( i + \" ▁ \" ) ; out . print ( min ) ; out . close ( ) ; } }",
"import java . lang . * ; import java . util . * ; public class Abhishek { public static void main ( String [ ] args ) throws Exception { 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 ( ) ; } Arrays . sort ( a ) ; int m = a [ n - 1 ] ; a [ n - 1 ] = a [ 0 ] ; a [ 0 ] = m ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( a [ i ] + \" ▁ \" ) ; } } }"
] | [
"input ( ) a = sorted ( input ( ) . split ( ) , key = int ) print ( a [ - 1 ] , * a [ 1 : - 1 ] , a [ 0 ] ) NEW_LINE",
"n = int ( input ( ) ) a = input ( ) . split ( ) a_array = [ ] array2 = [ ] for i in range ( n ) : a_array . append ( int ( a [ i ] ) ) a_array = sorted ( a_array ) a = a_array [ 0 ] a_array [ 0 ] = a_array [ len ( a_array ) - 1 ] a_array [ len ( a_array ) - 1 ] = afor i in range ( len ( a_array ) ) : array2 . append ( a_array [ i ] ) print ( array2 [ i ] , end = \" ▁ \" ) NEW_LINE",
"n = int ( input ( ) ) ; l = list ( map ( int , input ( ) . split ( ) ) ) ; l . sort ( ) l2 = l [ : len ( l ) // 2 ] ; l1 = l [ len ( l ) // 2 : ] print ( l1 [ - 1 ] , * l2 [ 1 : ] , * l1 [ : - 1 ] , l2 [ 0 ] ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ma = max ( a ) mi = min ( a ) a . remove ( ma ) a . remove ( mi ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = [ ] a = sorted ( a ) b = [ a [ - 1 ] ] + a [ 1 : ( n - 1 ) ] + [ a [ 0 ] ] print ( * b ) NEW_LINE"
] |
codeforces_669_A | [
"import javax . swing . plaf . IconUIResource ; import java . util . * ; ",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int stonesNum ; int gifts ; stonesNum = sc . nextInt ( ) ; gifts = ( stonesNum / 3 ) * 2 ; if ( stonesNum % 3 > 0 ) gifts ++ ; System . out . println ( gifts ) ; } }",
"import java . util . Scanner ; public class covidSpread2 { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { solvex ( ) ; } public static void solvex ( ) { int n = sc . nextInt ( ) ; int fac = n / 3 ; int ans = 2 * fac ; if ( n % 3 != 0 ) ans ++ ; System . out . println ( ans ) ; } }",
"import java . util . Scanner ; public class LittleArtem { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int remaining = n % 3 ; if ( remaining != 0 ) { System . out . println ( ( n / 3 ) * 2 + 1 ) ; } else { System . out . println ( ( n / 3 ) * 2 ) ; } } }"
] | [
"n = int ( input ( ) ) print ( 2 * ( n // 3 ) if n % 3 == 0 else 2 * ( n // 3 ) + 1 ) NEW_LINE",
"n = int ( input ( ) ) y = ( n // 3 ) * 2 if n % 3 == 0 : print ( y ) else : print ( y + 1 ) NEW_LINE",
"print ( ( int ( input ( ) ) * 2 + 1 ) // 3 ) NEW_LINE",
"p = int ( input ( ) ) if p >= 3 : x = ( p // 3 ) * 2 if p % 3 : x += 1 else : x = 1 print ( x ) NEW_LINE",
"n = int ( input ( ) ) print ( n // 3 * 2 if n % 3 == 0 else n // 3 * 2 + 1 ) NEW_LINE"
] |
codeforces_830_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Random ; import java . util . StringTokenizer ; public class Main implements Runnable { long INF = ( long ) 1e13 + 7 ; private void solve ( ) throws IOException { int n = nextInt ( ) ; int k = nextInt ( ) ; long p = nextLong ( ) ; long a [ ] = new long [ n ] ; long b [ ] = new long [ k ] ; for ( int i = 0 ; i < n ; ++ i ) a [ i ] = nextLong ( ) ; for ( int i = 0 ; i < k ; ++ i ) b [ i ] = nextLong ( ) ; Arrays . sort ( a ) ; Arrays . sort ( b ) ; long ans = INF ; for ( int i = 0 ; i <= k - n ; ++ i ) { long cur = 0 ; for ( int j = 0 ; j < n ; ++ j ) { cur = Math . max ( Math . abs ( a [ j ] - b [ i + j ] ) + Math . abs ( b [ i + j ] - p ) , cur ) ; } ans = Math . min ( cur , ans ) ; } pw . println ( ans ) ; } void test ( ) throws IOException { Random rnd = new Random ( ) ; for ( int i = 0 ; i < 5 ; ++ i ) { int n = rnd . nextInt ( 10 ) + 1 ; int a [ ] = new int [ n ] ; System . err . println ( n ) ; for ( int j = 0 ; j < n ; ++ j ) { a [ j ] = rnd . nextInt ( 20 ) + 1 ; System . err . print ( a [ j ] + \" ▁ \" ) ; }",
"import java . io . * ; import java . util . * ; public class Main { static Integer [ ] a = new Integer [ 1010 ] ; static Integer [ ] b = new Integer [ 2020 ] ; static int [ ] [ ] dp = new int [ 1010 ] [ 2020 ] ; public static void main ( String args [ ] ) { Scanner in ; PrintStream out ; in = new Scanner ( new BufferedInputStream ( System . in ) ) ; out = System . out ; try { in = new Scanner ( new FileInputStream ( \" java . in \" ) ) ; out = new PrintStream ( \" java . out \" ) ; } catch ( FileNotFoundException e ) { } int n = in . nextInt ( ) , k = in . nextInt ( ) , p = in . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) a [ i ] = in . nextInt ( ) ; for ( int i = 1 ; i <= k ; i ++ ) b [ i ] = in . nextInt ( ) ; Arrays . sort ( a , 1 , n + 1 , new MyCom ( ) ) ; Arrays . sort ( b , 1 , k + 1 , new MyCom ( ) ) ; dp [ 0 ] [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i ; j <= k ; j ++ ) { dp [ i ] [ j ] = Math . max ( dp [ i - 1 ] [ j - 1 ] , Math . abs ( a [ i ] - b [ j ] ) + Math . abs ( b [ j ] - p ) ) ; if ( j > i ) dp [ i ] [ j ] = Math . min ( dp [ i ] [ j ] , dp [ i ] [ j - 1 ] ) ; } } out . println ( dp [ n ] [ k ] ) ; } static class MyCom implements Comparator < Integer > { public int compare ( Integer i1 , Integer i2 ) { return i1 - i2 ; } } }",
"import java . util . Arrays ; import java . util . Scanner ; public class R424D { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; long p = scan . nextLong ( ) ; long [ ] pos = new long [ n ] ; long [ ] key = new long [ k ] ; for ( int i = 0 ; i < n ; i ++ ) { pos [ i ] = scan . nextLong ( ) ; } for ( int i = 0 ; i < k ; i ++ ) { key [ i ] = scan . nextLong ( ) ; } Arrays . sort ( pos ) ; Arrays . sort ( key ) ; long min = Long . MAX_VALUE ; long [ ] d = new long [ n ] ; int number = k - n + 1 ; long max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { d [ i ] = Math . abs ( pos [ i ] - key [ i ] ) + Math . abs ( key [ i ] - p ) ; max = Math . max ( max , d [ i ] ) ; } min = Math . min ( min , max ) ; for ( int i = 1 ; i < number ; i ++ ) { max = 0 ; for ( int j = 0 ; j < n ; j ++ ) { d [ j ] = Math . abs ( pos [ j ] - key [ i + j ] ) + Math . abs ( key [ i + j ] - p ) ; max = Math . max ( max , d [ j ] ) ; } min = Math . min ( min , max ) ; } System . out . println ( min ) ; } }"
] | [
"pp = list ( map ( int , input ( ) . split ( ) ) ) inf = int ( 1e18 ) n = pp [ 0 ] k = pp [ 1 ] p = pp [ 2 ] a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) b . sort ( ) dp = [ [ inf for j in range ( 0 , 2011 ) ] for i in range ( 0 , 1011 ) ] for i in range ( 0 , k ) : dp [ 0 ] [ i ] = abs ( a [ 0 ] - b [ i ] ) + abs ( b [ i ] - p ) for i in range ( 1 , n ) : for j in range ( 0 , k ) : dp [ i ] [ j ] = min ( int ( dp [ i ] [ j ] ) , max ( abs ( a [ i ] - b [ j ] ) + abs ( b [ j ] - p ) , int ( dp [ i - 1 ] [ j - 1 ] ) ) ) ans = int ( 1e18 ) for i in range ( 0 , k ) : ans = min ( ans , int ( dp [ n - 1 ] [ i ] ) ) print ( ans ) NEW_LINE",
"n , k , p = map ( int , input ( ) . split ( ) ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) b = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) res = 1e15 for i in range ( k - n + 1 ) : ma = 0 for j in range ( n ) : te = abs ( a [ j ] - b [ i + j ] ) + abs ( b [ i + j ] - p ) ma = max ( ma , te ) res = min ( res , ma ) print ( res ) NEW_LINE"
] |
codeforces_1140_A | [
"import java . util . Scanner ; public class _0708DetectiveBook { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int days = 0 ; int mysteryExplainedOnPage = 0 ; for ( int page = 1 ; page <= n ; page ++ ) { int temp = sc . nextInt ( ) ; mysteryExplainedOnPage = Math . max ( temp , mysteryExplainedOnPage ) ; if ( mysteryExplainedOnPage <= page ) { days ++ ; } else { mysteryExplainedOnPage = Math . max ( mysteryExplainedOnPage , temp ) ; } } System . out . println ( days ) ; } }",
"import java . util . * ; import java . io . * ; public class EdE { static long [ ] mods = { 1000000007 , 998244353 , 1000000009 } ; static long mod = mods [ 0 ] ; public static MyScanner sc ; public static PrintWriter out ; public static void main ( String [ ] omkar ) throws Exception {",
"import java . io . * ; import java . math . BigInteger ; import java . util . * ; public class C { static BufferedReader br ; static PrintWriter pr ; static int cin ( ) throws Exception { return Integer . valueOf ( br . readLine ( ) ) ; } static int [ ] split ( ) throws Exception { String [ ] cmd = br . readLine ( ) . split ( \" ▁ \" ) ; int [ ] ans = new int [ cmd . length ] ; for ( int i = 0 ; i < cmd . length ; i ++ ) { ans [ i ] = Integer . valueOf ( cmd [ i ] ) ; } return ans ; } static long [ ] splitL ( ) throws IOException { String [ ] cmd = br . readLine ( ) . split ( \" ▁ \" ) ; long [ ] ans = new long [ cmd . length ] ; for ( int i = 0 ; i < cmd . length ; i ++ ) { ans [ i ] = Long . valueOf ( cmd [ i ] ) ; } return ans ; } static long p = 1000000007 ; static long power ( long x , long y ) { long res = 1 ; x = x % p ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } public static void main ( String [ ] args ) throws Exception {",
"import java . util . * ; public class c1 { public static void main ( String [ ] args ) { int n ; Scanner reader = new Scanner ( System . in ) ; n = reader . nextInt ( ) ; int [ ] a = new int [ n ] ; int days , max = 0 , i ; for ( i = 0 ; i < n ; ++ i ) { a [ i ] = reader . nextInt ( ) ; } for ( i = days = 0 ; i < n ; ++ i ) { if ( max < a [ i ] ) max = a [ i ] ; if ( max == i + 1 ) ++ days ; } System . out . println ( days ) ; } }"
] | [
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 mx = 0 for i in range ( n ) : mx = max ( a [ i ] , mx ) if mx == i + 1 : ans += 1 print ( ans ) NEW_LINE",
"n , a = int ( input ( ) ) , [ * map ( int , input ( ) . split ( ) ) ] ans = 0 ; i = 0 while i < n : ans += 1 max_day = a [ i ] while ( i + 1 < max_day ) : i += 1 max_day = max ( max_day , a [ i ] ) i += 1 print ( ans ) NEW_LINE",
"from sys import stdinn = int ( stdin . readline ( ) ) a = list ( map ( int , stdin . readline ( ) . split ( ) ) ) a = [ i - 1 for i in a ] ans = 0 pos = 0 while pos < n : ans += 1 mx_val = pos while pos < n and pos <= mx_val : mx_val = max ( mx_val , a [ pos ] ) pos += 1 print ( ans ) NEW_LINE",
"import sys n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] ans = 0 mx = 0 for i in range ( n ) : mx = max ( mx , a [ i ] ) if mx == i + 1 : ans += 1 print ( ans ) NEW_LINE",
"import sys , collections , math , itertools , random , bisectINF = sys . maxsizedef get_ints ( ) : return map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) def get_array ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) def input ( ) : return sys . stdin . readline ( ) . strip ( ) mod = 1000000007 n = int ( input ( ) ) arr = get_array ( ) arr . sort ( ) cnt = 0 for i in range ( n ) : if arr [ i ] == i + 1 : cnt += 1 print ( cnt ) NEW_LINE"
] |
codeforces_887_A | [
"import java . util . * ; public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] s1 = s . toCharArray ( ) ; long sum = 0 ; boolean check = false ;",
"import java . util . * ; public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] s1 = s . toCharArray ( ) ; long sum = 0 ; boolean check = false ;",
"import java . util . * ; import java . util . jar . JarOutputStream ; public class Practise { public static int [ ] [ ] dp ; public static void main ( String [ ] args ) {",
"import java . util . * ; import java . util . jar . JarOutputStream ; public class Practise { public static int [ ] [ ] dp ; public static void main ( String [ ] args ) {",
"import java . util . Scanner ; public class _0736DivSixFour { static String toBinary ( String s , int n ) { if ( n == 0 ) { return s ; } int val = n % 2 ; s = val + s ; return toBinary ( s , n / 2 ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; if ( s . indexOf ( '1' ) == - 1 ) { System . out . println ( \" NO \" ) ; } else { int count = 0 ; for ( int i = s . indexOf ( '1' ) + 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '0' ) { count ++ ; } if ( count == 6 ) break ; } if ( count == 6 ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } } }"
] | [
"s = input ( ) if '1' not in s : print ( \" no \" ) else : s = s [ s . index ( '1' ) : ] print ( \" yes \" if s . count ( '0' ) >= 6 else \" no \" ) NEW_LINE",
"n = input ( ) if len ( n ) == n . count ( '0' ) : print ( ' NO ' ) else : while n [ 0 ] == \"0\" : n = n [ 1 : ] if n . count ( '0' ) >= 6 and n [ 0 ] == '1' : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE",
"from collections import Counterc = Counter ( str ( int ( input ( ) ) ) ) if c [ '1' ] >= 1 and c [ '0' ] >= 6 : print ( \" yes \" ) else : print ( \" no \" ) NEW_LINE",
"s = input ( ) i = s . find ( '1' ) if i == - 1 : print ( ' no ' ) else : if s [ i + 1 : ] . count ( '0' ) < 6 : print ( ' no ' ) else : print ( ' yes ' ) NEW_LINE",
"b = str ( input ( ) ) c = 0 if '1' not in b : print ( ' no ' ) else : for i in range ( len ( b ) ) : if b [ i ] == '1' : idx = i break for i in range ( idx , len ( b ) ) : if b [ i ] == '0' : c += 1 if c >= 6 : print ( ' yes ' ) else : print ( ' no ' ) NEW_LINE"
] |
codeforces_832_B | [
"import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class ExamA3 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s1 = in . next ( ) ; Set < Character > setS1 = new HashSet < > ( ) ; for ( char c : s1 . toCharArray ( ) ) { setS1 . add ( c ) ; } String s2 = in . next ( ) ; int flag = - 1 ;",
"import java . util . ArrayList ; import java . util . Scanner ; public class VJ_1011 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; int n = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . next ( ) ) ; } boolean contain = false ; int index = - 1 ; if ( s2 . contains ( \" * \" ) ) { contain = true ; index = s2 . indexOf ( \" * \" ) ; } ArrayList < String > res = new ArrayList < > ( ) ; for ( String s3 : list ) { if ( contain ) { int minus = s3 . length ( ) - s2 . length ( ) + 1 ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashMap ; public class StringReplace { public static void main ( String [ ] args ) throws IOException {",
"import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main2020_4_02 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s1 = in . next ( ) ; Set < Character > setS1 = new HashSet < > ( ) ; for ( char c : s1 . toCharArray ( ) ) { setS1 . add ( c ) ; } String s2 = in . next ( ) ; int flag = - 1 ;",
"import java . util . ArrayList ; import java . util . Random ; import java . util . Scanner ; public class PetyaAndExam { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) . trim ( ) ; ArrayList < String > ch = new ArrayList < String > ( ) ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) ch . add ( s . substring ( i , i + 1 ) ) ; String p = sc . next ( ) . trim ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; ++ i ) { String t = sc . next ( ) . trim ( ) ; int jt = 0 ; int k = p . length ( ) , m = t . length ( ) ; String ans = \" \" ; for ( int jp = 0 ; jp < k && ans . length ( ) == 0 ; ++ jp ) { String pa = p . substring ( jp , jp + 1 ) ; String ta = jt < m ? t . substring ( jt , jt + 1 ) : \" BLERGH \" ; if ( pa . equals ( \" ? \" ) ) { if ( jt < m ) { if ( ! ch . contains ( ta ) ) ans = \" NO \" ; else { ++ jt ; } } else ans = \" NO \" ; } else if ( pa . equals ( \" * \" ) ) { for ( int y = 0 ; y < m - k + 1 ; ++ y ) { if ( ! ch . contains ( t . substring ( jt , jt + 1 ) ) ) ++ jt ; else { ans = \" NO \" ; } } } else { if ( jt < m ) { if ( ! pa . equals ( ta ) ) ans = \" NO \" ; else { ++ jt ; } } else ans = \" NO \" ; } } if ( jt == m && ans . length ( ) == 0 ) ans = \" YES \" ; else ans = \" NO \" ; System . out . println ( ans ) ; } sc . close ( ) ; } } "
] | [
"def do ( cur ) : if len ( cur ) < len ( pt ) - 1 : return \" NO \" i = j = 0 while j < len ( cur ) : if pt [ i ] == \" ? \" : if cur [ j ] not in good : return \" NO \" elif pt [ i ] == \" * \" : b = len ( cur ) - len ( pt ) + 1 for x in cur [ j : j + b ] : if x in good : return \" NO \" i += 1 j += b continue else : if pt [ i ] != cur [ j ] : return \" NO \" i += 1 j += 1 return \" YES \" good = set ( input ( ) ) pt = input ( ) pi = True if \" * \" not in pt else Falsefor _ in range ( int ( input ( ) ) ) : cur = input ( ) if pi and len ( cur ) != len ( pt ) : print ( \" NO \" ) else : print ( do ( cur ) ) NEW_LINE",
"s1 = input ( ) s2 = input ( ) n = int ( input ( ) ) good_words = set ( s1 ) s3_list = [ ] for _ in range ( n ) : s3 = input ( ) s3_list . append ( s3 ) for s3 in s3_list : flag = 1 if \" * \" not in s2 : if len ( s2 ) != len ( s3 ) : flag = 0 else : for index , value in enumerate ( s2 ) : if value == \" ? \" : if s3 [ index ] not in good_words : flag = 0 break else : if s3 [ index ] != s2 [ index ] : flag = 0 break else : if len ( s3 ) < len ( s2 ) - 1 : flag = 0 else : idx = s2 . index ( \" * \" ) s2_1 = s2 [ : idx ] s2_2 = s2 [ idx + 1 : ] NEW_LINE",
"hor = input ( ) mask = input ( ) lenmask = len ( mask ) for i in range ( int ( input ( ) ) ) : a = input ( ) lena = len ( a ) f = True if lena < lenmask - 1 and ' * ' in mask : print ( ' NO ' ) continue elif lena < lenmask and ' * ' not in mask : print ( ' NO ' ) continue elif lena > lenmask and ' * ' not in mask : print ( ' NO ' ) continue for j in range ( lenmask ) : if mask [ j ] == ' ? ' : if a [ j ] not in hor : f = False break elif mask [ j ] == ' * ' : if lenmask - 1 == lena : a = a [ : j ] + ' j ' + a [ j : ] else : srez = a [ j : j + lena - lenmask + 1 ] for el in srez : if el in hor : f = False break if not f : break a = a [ : j ] + a [ j + lena - lenmask : ] else : if a [ j ] != mask [ j ] : f = False break if f : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE",
"from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect NEW_LINE"
] |
codeforces_991_A | [
"import java . math . * ; import java . util . * ; import java . io . * ; public class Main { void solve ( ) throws IOException { int a , b , c , n , res ; a = nextInt ( ) ; b = nextInt ( ) ; c = nextInt ( ) ; n = nextInt ( ) ; res = n - ( a + b - c ) ; if ( res > 0 && a >= c && b >= c && res <= n ) { res = res ; } else { res = - 1 ; } System . out . println ( res ) ; } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; void run ( ) throws IOException { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; solve ( ) ; out . close ( ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } BufferedReader in ; StringTokenizer str ; PrintWriter out ; String next ( ) throws IOException { while ( ( str == null ) || ( ! str . hasMoreTokens ( ) ) ) { str = new StringTokenizer ( in . readLine ( ) ) ; } return str . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } }",
"import java . util . Scanner ; public class vasya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; if ( a < c || b < c ) { System . out . println ( \" - 1\" ) ; } else { int students = ( a - c ) + ( b - c ) + c ; int failed_students = n - students ; if ( failed_students <= 0 ) { System . out . println ( \" - 1\" ) ; } else { System . out . println ( failed_students ) ; } } } }"
] | [
"A , B , C , N = map ( int , input ( ) . strip ( ) . split ( ) ) flag = Trueif C > A or C > B : flag = FalseD = N - ( A - C ) - Bif D >= 1 and flag : print ( D ) else : print ( - 1 ) NEW_LINE",
"a , b , c , n = map ( int , input ( ) . split ( ) ) s = a + b - cif s >= n or a < c or b < c : print ( - 1 ) else : print ( n - s ) NEW_LINE",
"A , B , C , N = map ( int , input ( ) . split ( ) ) A -= CB -= CS = A + B + Cif S < N and A + C >= C and B + C >= C : print ( N - S ) else : print ( - 1 ) NEW_LINE",
"A , B , C , N = map ( int , input ( ) . split ( ) ) ans = N - ( A + B - C ) if A < C or B < C or A > N or B > N or C > N or ans < 1 : print ( - 1 ) else : print ( ans ) NEW_LINE"
] |
codeforces_346_B | [
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; 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 ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BLuckyCommonSubsequence solver = new BLuckyCommonSubsequence ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BLuckyCommonSubsequence { int [ ] pi ; char [ ] first ; char [ ] second ; char [ ] virus ; StringBuilder sb ; int [ ] [ ] [ ] memo ; void prefixFunction ( char [ ] s ) { int n = s . length ; pi = new int [ n ] ; for ( int i = 1 , j = 0 ; i < n ; ++ i )",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; } ",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; } "
] | [
"A = input ( ) B = input ( ) virus = input ( ) NEW_LINE",
"s = input ( ) t = input ( ) u = input ( ) memos = { } def solve ( a , b , c ) : if c == len ( u ) : return 0 if a == len ( s ) or b == len ( t ) : return ' ' if ( a , b , c ) in memos : return memos [ ( a , b , c ) ] me = s [ a ] r = solve ( a + 1 , b , c ) try : idx = t [ b : ] . index ( me ) curr = u [ : c ] + me for i in range ( c + 2 ) : if curr [ i : ] == u [ : ( c + 1 - i ) ] : tr = solve ( a + 1 , b + idx + 1 , c + 1 - i ) if tr == 0 : r2 = 0 else : r2 = me + tr break if r2 == 0 or len ( r ) > len ( r2 ) : k = r else : k = r2 except ValueError : k = r memos [ ( a , b , c ) ] = k return k NEW_LINE",
"a , b , v = input ( ) , input ( ) , input ( ) h = [ [ - 1 ] * len ( b ) for i in range ( len ( a ) ) ] def f ( ab ) : return ab . count ( v ) def g ( i , j ) : if i < 0 or j < 0 : return \" \" if h [ i ] [ j ] == - 1 : s = g ( i - 1 , j - 1 ) if ( a [ i ] == b [ j ] ) : s += a [ i ] s1 = g ( i - 1 , j ) s2 = g ( i , j - 1 ) if ( len ( s1 ) - f ( s1 ) > len ( s ) - f ( s ) ) : s = s1 if ( len ( s2 ) - f ( s2 ) > len ( s ) - f ( s ) ) : s = s2 h [ i ] [ j ] = s ; return h [ i ] [ j ] ss = g ( len ( a ) - 1 , len ( b ) - 1 ) while v in ss : ss1 = ss . replace ( v , v [ : - 1 ] ) ss2 = ss . replace ( v , v [ 1 : ] ) if ( f ( ss1 ) < f ( ss2 ) ) : ss = ss1 else : ss = ss2if len ( ss ) > 0 : print ( ss ) else : print ( 0 ) NEW_LINE",
"s1 , s2 , virus = [ input ( ) . strip ( ) for _ in range ( 3 ) ] n , m , v = len ( s1 ) , len ( s2 ) , len ( virus ) NEW_LINE"
] |
codeforces_279_A | [
"import java . util . Scanner ; public class SpiralDown { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int x = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; int turn = 0 ; if ( ( x == 0 || x == 1 ) & y == 0 ) { System . out . println ( 0 ) ; return ; } if ( y > 0 ) { if ( x >= y ) turn = 4 * x - 3 ; else if ( x + y >= 0 ) turn = 4 * y - 2 ; else turn = - 4 * x - 1 ; } else { if ( x <= y ) turn = - 4 * x - 1 ; else if ( x + 2 * y <= 0 ) turn = - 4 * y ; else turn = 4 * x - 3 ; } System . out . println ( turn ) ; } }",
"import java . util . Scanner ; public class PointOnSpiral { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int result = 0 ; if ( x > 0 && y >= 2 - x && y <= x ) { result = ( 4 * x ) - 3 ; } else if ( y > 0 && x >= - y && x <= y - 1 ) { result = ( 4 * y ) - 2 ; } else if ( x < 0 && y >= x && y <= - 1 - x ) { result = ( 4 * ( - x ) ) - 1 ; } else if ( y <= 0 && x >= 1 + y && x <= - y + 1 ) { result = 4 * ( - y ) ; } else { result = 0 ; } System . out . println ( result ) ; } }",
"import java . util . Scanner ; public class TestBetter { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int x , y ; x = input . nextInt ( ) ; y = input . nextInt ( ) ; int box = Math . max ( Math . abs ( x ) , Math . abs ( y ) ) ; int res = ( box - 1 ) * 4 ; if ( y == 0 && ( x == 0 || x == 1 ) ) { res = 0 ; System . out . println ( res ) ; return ; } if ( x == box && y == - ( box - 1 ) ) { System . out . println ( res ) ; return ; } res ++ ; if ( x == box && y > - box ) { System . out . println ( res ) ; return ; } res ++ ; if ( y == box ) { System . out . println ( res ) ; return ; } res ++ ; if ( x == - box ) { System . out . println ( res ) ; return ; } res ++ ; System . out . println ( res ) ; } }",
"import java . util . Scanner ; public class Game { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int x = input . nextInt ( ) , y = input . nextInt ( ) , s = 0 ; if ( y > x && x >= - y ) s = - 2 + y * 4 ; if ( y < x && x <= - y + 1 ) s = - y * 4 ; if ( y <= x && x > - y + 1 ) s = - 3 + x * 4 ; if ( y >= x && x < - y ) s = - 1 - 4 * x ; System . out . println ( s ) ; } }"
] | [
"a , b = map ( int , input ( ) . split ( ) ) count = 0 q , e = 0 , 0 i = 1 flag = 0 while ( q != a or e != b ) : for j in range ( i ) : q += 1 if ( q == a and e == b ) : flag = 1 break if ( flag ) : break count += 1 for j in range ( i ) : e += 1 if ( q == a and e == b ) : flag = 1 break i += 1 if ( flag ) : break count += 1 for j in range ( i ) : q -= 1 if ( q == a and e == b ) : flag = 1 break if ( flag ) : break count += 1 for j in range ( i ) : e -= 1 if ( q == a and e == b ) : flag = 1 break if ( flag ) : break i += 1 count += 1 print ( count ) NEW_LINE",
"x , y = tuple ( map ( int , input ( ) . split ( ) ) ) if ( x == 0 and y == 0 ) : print ( 0 ) elif ( x >= 0 and y >= - x + 1 and y < x ) : if ( y == - x + 1 ) : print ( 4 * ( x - 1 ) ) else : print ( 4 * ( x - 1 ) + 1 ) elif ( y > 0 and ( x == 0 or ( x <= abs ( y ) and x > - abs ( y ) ) ) ) : if ( y == x ) : print ( 4 * ( abs ( y ) - 1 ) + 1 ) else : print ( 4 * ( abs ( y ) - 1 ) + 2 ) elif ( x <= 0 and y <= - x and y > x ) : if ( y == - x ) : NEW_LINE",
"l = input ( ) . split ( ' ▁ ' ) x , y = int ( l [ 0 ] ) , int ( l [ 1 ] ) if y <= 0 and x >= 1 + y and x <= 1 - y : print ( ( - y ) * 4 ) elif x > 0 and y >= 2 - x and y <= x : print ( x * 4 - 3 ) elif y > 0 and x >= - y and x <= y - 1 : print ( y * 4 - 2 ) elif x < 0 and y >= x and y <= - 1 - x : print ( ( - x ) * 4 - 1 ) else : print ( 0 ) NEW_LINE",
"a , b = map ( int , input ( ) . split ( ) ) count = 0 q , e = 0 , 0 i = 1 flag = 0 while ( q != a or e != b ) : for j in range ( i ) : q += 1 if ( q == a and e == b ) : flag = 1 break if ( flag ) : break count += 1 for j in range ( i ) : e += 1 if ( q == a and e == b ) : flag = 1 break i += 1 if ( flag ) : break count += 1 for j in range ( i ) : q -= 1 if ( q == a and e == b ) : flag = 1 break if ( flag ) : break count += 1 for j in range ( i ) : e -= 1 if ( q == a and e == b ) : flag = 1 break if ( flag ) : break i += 1 count += 1 print ( count ) NEW_LINE"
] |
codeforces_242_A | [
"import java . util . * ; import java . math . * ; import java . lang . * ; import javafx . util . Pair ; public class gfg { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Map < Pair , Integer > map = new LinkedHashMap < > ( ) ; int sv = 0 , sp = 0 , ev = 0 , ep = 0 ; if ( a > b ) { sv = a ; ev = x ; sp = b ; ep = y ; } else { sv = b + 1 ; ev = x ; sp = b ; ep = y ; } int count = 0 ; for ( int i = sv ; i <= ev ; i ++ ) { for ( int j = sp ; j <= ep ; j ++ ) { if ( j >= i ) break ; Pair p = new Pair ( i , j ) ; map . put ( p , count ++ ) ; } } System . out . println ( count ) ; map . forEach ( ( k , v ) -> System . out . println ( k . getKey ( ) + \" ▁ \" + k . getValue ( ) ) ) ; } }",
"import java . awt . Point ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashSet ; import java . util . Hashtable ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Stack ; import java . util . StringTokenizer ; public class N700 { static PrintWriter out ; static Scanner sc ; static ArrayList < Integer > q , w ; static ArrayList < Integer > adj [ ] ; static HashSet < Integer > primesH ; static boolean prime [ ] ;",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int x , y , a , b ; x = input . nextInt ( ) ; y = input . nextInt ( ) ; a = input . nextInt ( ) ; b = input . nextInt ( ) ; if ( x <= b ) { System . out . println ( 0 ) ; return ; } StringBuilder ans = new StringBuilder ( ) ; int count = 0 ; for ( int i = a ; i <= x ; i ++ ) { int j = b ; while ( i > j && y >= j ) { count ++ ; ans . append ( i + \" ▁ \" + j + \" \\n \" ) ; j ++ ; } } System . out . println ( count ) ; System . out . println ( ans ) ; } }"
] | [
"x , y , a , b = list ( map ( int , input ( ) . split ( ) ) ) ans = [ ] for i in range ( b , y + 1 ) : for j in range ( a , x + 1 ) : if i < j : ans . append ( [ j , i ] ) print ( len ( ans ) ) ans . sort ( ) for i in ans : print ( * i ) NEW_LINE",
"def headTails ( x , y , a , b ) : p_a = list ( range ( a , x + 1 ) ) p_b = list ( range ( b , min ( x + 1 , y + 1 ) ) ) arr = [ ] i = 0 j = 0 while i < len ( p_a ) and j < len ( p_b ) : if p_a [ i ] > p_b [ j ] : arr . append ( ( p_a [ i ] , p_b [ j ] ) ) if i < len ( p_a ) : for k in range ( i + 1 , len ( p_a ) ) : arr . append ( ( p_a [ k ] , p_b [ j ] ) ) j += 1 else : i += 1 arr . sort ( key = lambda x : x [ 0 ] ) print ( len ( arr ) ) for i in arr : print ( * i ) x , y , a , b = list ( map ( int , input ( ) . split ( ) ) ) headTails ( x , y , a , b ) NEW_LINE",
"x , y , a , b = map ( int , input ( ) . split ( ) ) vas , pet = a , bans = [ ] while vas <= x : pet = b while pet < vas and pet <= y : ans . append ( [ vas , pet ] ) pet += 1 vas += 1 print ( len ( ans ) ) for i in range ( len ( ans ) ) : print ( * ans [ i ] ) NEW_LINE",
"x , y , a , b = map ( int , input ( ) . split ( ) ) if ( a < b and ( x - a ) <= ( b - a ) ) or ( a == b and x < y ) : print ( 0 ) else : c = 0 for i in range ( a , x + 1 ) : for j in range ( b , y + 1 ) : if ( i > j ) : c = c + 1 print ( c ) for i in range ( a , x + 1 ) : for j in range ( b , y + 1 ) : if ( i > j ) : print ( i , j ) NEW_LINE",
"x , y , a , b = map ( int , input ( ) . split ( ) ) c = 0 xx = [ ] for i in range ( a , x + 1 ) : for j in range ( b , y + 1 ) : if ( i > j ) : c += 1 xx . append ( [ i , j ] ) print ( c ) for i in range ( c ) : print ( xx [ i ] [ 0 ] , xx [ i ] [ 1 ] ) NEW_LINE"
] |
codeforces_988_B | [
"import javax . print . DocFlavor ; import javax . swing . * ; import java . awt . image . BandedSampleModel ; import java . util . * ; public class Example { static long [ ] [ ] dp ;",
"import java . util . Scanner ; public class SubstringSort { public static void main ( String [ ] args ) { boolean flag = true ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String str [ ] = new String [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { str [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j <= n ; j ++ ) { if ( str [ i ] . length ( ) > str [ j ] . length ( ) ) { String temp = str [ i ] ; str [ i ] = str [ j ] ; str [ j ] = temp ; } } } for ( int i = 1 ; i <= n ; i ++ ) { if ( ! str [ i ] . contains ( str [ i - 1 ] ) ) { flag = false ; break ; } } if ( flag == true ) { System . out . println ( \" YES \" ) ; for ( int i = 0 ; i <= n ; i ++ ) { System . out . println ( str [ i ] ) ; } } else { System . out . println ( \" NO \" ) ; } } }",
"import java . util . * ; public class Main { public static boolean isSubstring ( String a , String b ) { int a_size = a . length ( ) ; int b_size = b . length ( ) ; for ( int i = 0 ; i < b_size ; i ++ ) { boolean found = true ; if ( i + a_size > b_size ) { break ; } for ( int j = 0 ; j < a_size ; j ++ ) { if ( b . charAt ( i + j ) != a . charAt ( j ) ) { found = false ; break ; } } if ( found ) { return true ; } } return false ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; String str [ ] = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { str [ i ] = scan . next ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = 0 ; j < n - i - 1 ; j ++ ) { if ( str [ j ] . length ( ) > str [ j + 1 ] . length ( ) ) { String temp = str [ j ] ; str [ j ] = str [ j + 1 ] ; str [ j + 1 ] = temp ; } } } boolean exist = true ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( isSubstring ( str [ i ] , str [ i + 1 ] ) == false ) { exist = false ; break ; } } if ( exist ) { System . out . println ( \" YES \" ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( str [ i ] ) ; } } else { System . out . println ( \" NO \" ) ; } } }",
"import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] arr = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . next ( ) ; for ( int i = 1 ; i < n ; i ++ ) { String temp = arr [ i ] ; int j = i - 1 ; while ( j >= 0 && temp . length ( ) < arr [ j ] . length ( ) ) { arr [ j + 1 ] = arr [ j ] ; j -- ; } arr [ j + 1 ] = temp ; } int c = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] . contains ( arr [ i - 1 ] ) ) c ++ ; } if ( c == n ) { System . out . println ( \" YES \" ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . println ( arr [ i ] ) ; } else System . out . println ( \" NO \" ) ; } }",
"import java . util . * ; public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; int maxl = 0 ; String maxls = \" \" ; int index = 0 ; Map < Integer , List < String > > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; int l = s . length ( ) ; map . putIfAbsent ( l , new ArrayList < > ( ) ) ; List < String > y = map . get ( l ) ; y . add ( s ) ; map . put ( l , y ) ;"
] | [
"import sys , mathfrom collections import deque , defaultdictimport operator as opfrom functools import reducefrom itertools import permutations NEW_LINE",
"def sort ( s , n ) : for i in range ( 1 , n ) : temp = s [ i ] j = i - 1 while j >= 0 and len ( temp ) < len ( s [ j ] ) : s [ j + 1 ] = s [ j ] j -= 1 s [ j + 1 ] = temp n = int ( input ( ) ) strings = [ ] for _ in range ( n ) : s = input ( ) strings . append ( s ) check = Truesort ( strings , n ) NEW_LINE",
"t = int ( input ( ) ) a = sorted ( ( input ( ) for _ in range ( t ) ) , key = lambda res : len ( res ) ) ans = all ( a [ i ] in a [ i + 1 ] for i in range ( t - 1 ) ) print ( ' YES \\n ' + \" \\n \" . join ( a ) if ans else ' NO ' ) NEW_LINE",
"n = int ( input ( ) ) a = [ ] for i in range ( 1 , n + 1 ) : b = input ( ) a . append ( b ) a . sort ( key = len ) t = 0 for i in range ( 1 , n ) : if a [ i - 1 ] in a [ i ] : t = 0 else : t = 1 NEW_LINE",
"import sys , mathfrom collections import deque , defaultdictimport operator as opfrom functools import reducefrom itertools import permutations NEW_LINE"
] |
codeforces_96_A | [
"import java . util . * ; import java . lang . * ; import java . io . * ; public class Solution { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int ca = 0 ; int cb = 0 ; int d = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '0' ) { cb = 0 ; ca ++ ; if ( ca == 7 ) { d = 1 ; break ; } } else { ca = 0 ; cb ++ ; if ( cb == 7 ) { d = 1 ; break ; } } } if ( d == 1 ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }",
"import java . util . Scanner ; public class FootBall { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; checkSituation ( str ) ; sc . close ( ) ; } private static void checkSituation ( String str ) { if ( str . contains ( \"0000000\" ) || str . contains ( \"1111111\" ) ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }",
"import java . util . Scanner ; public class Football { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; sc . close ( ) ; if ( str . length ( ) <= 7 ) System . out . println ( \" NO \" ) ; else { String check1 = \"1111111\" ; String check2 = \"0000000\" ; if ( str . contains ( check1 ) || str . contains ( check2 ) ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } } catch ( Exception e ) { return ; } } }",
"import java . util . * ; import java . io . * ; public class A_Football { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) { FastReader scan = new FastReader ( ) ; String str = scan . nextLine ( ) ; int countOne = 0 ; int countZero = 0 ; int i = 0 ; String output = \" NO \" ; while ( i < str . length ( ) ) { char ch = str . charAt ( i ) ; if ( ch == '1' ) { countOne ++ ; countZero = 0 ; if ( countOne == 7 ) { output = \" YES \" ; } } else { countZero ++ ; countOne = 0 ; if ( countZero == 7 ) { output = \" YES \" ; } } i ++ ; } System . out . println ( output ) ; } }"
] | [
"s = input ( ) NEW_LINE x = 7 * \"1\" NEW_LINE y = 7 * \"0\" NEW_LINE if x in s : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT elif y in s : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT",
"players = input ( ) NEW_LINE number = players [ 0 ] NEW_LINE counter = 0 NEW_LINE for i in players : NEW_LINE INDENT if ( number == i ) : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT else : NEW_LINE INDENT number = i NEW_LINE counter = 1 NEW_LINE DEDENT if ( counter == 7 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if ( counter == 7 ) : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT",
"n = input ( ) NEW_LINE if '1111111' in n or '0000000' in n : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT",
"pos = input ( ) NEW_LINE if pos . find ( \"0000000\" ) != - 1 or pos . find ( \"1111111\" ) != - 1 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT",
"s = input ( ) NEW_LINE f = 0 NEW_LINE if '0000000' in s : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE f = 1 NEW_LINE DEDENT if '1111111' in s : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE f = 1 NEW_LINE DEDENT if f == 0 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT"
] |
codeforces_1406_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) {",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; public class M { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int q = scanner . nextInt ( ) ; while ( q -- > 0 ) { int n = scanner . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = scanner . nextInt ( ) ; Arrays . sort ( a ) ; Set < Integer > set = new HashSet < Integer > ( ) ; Set < Integer > set2 = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! set . contains ( a [ i ] ) ) set . add ( a [ i ] ) ; else set2 . add ( a [ i ] ) ; } List < Integer > list = new ArrayList < Integer > ( ) ; list . addAll ( set ) ; Collections . sort ( list ) ; List < Integer > list2 = new ArrayList < Integer > ( ) ; list2 . addAll ( set2 ) ; Collections . sort ( list2 ) ; int x = - 1 , y = - 1 ; for ( int i : list ) { if ( i == x + 1 ) x = i ; else break ; } for ( int i : list2 ) { if ( i == y + 1 ) y = i ; else break ; }",
"import java . lang . * ; import java . util . * ; public class Abhishek { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int [ ] a = new int [ 101 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ sc . nextInt ( ) ] ++ ; } int mexA = - 1 , mexB = - 1 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] <= 1 && mexA == - 1 ) mexA = i ; if ( a [ i ] == 0 && mexB == - 1 ) mexB = i ; } System . out . println ( mexA + mexB ) ; } } }",
"import java . math . BigInteger ; import java . util . * ; public class Example { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { int n = sc . nextInt ( ) ; int [ ] ans = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ans [ i ] = sc . nextInt ( ) ; } int [ ] frq = new int [ 101 ] ; for ( int i = 0 ; i < ans . length ; i ++ ) { frq [ ans [ i ] ] ++ ; } int c1 = - 1 ; int c2 = - 1 ; int aa = 0 ; boolean onetime = true ; boolean tt = false ; for ( int i = 0 ; i <= 100 ; i ++ ) { if ( frq [ i ] >= 2 && onetime ) { c1 ++ ; c2 ++ ; } else if ( frq [ i ] == 0 ) { tt = true ; if ( c1 == c2 ) { aa = 2 * i ; } else { aa = ++ c2 + ++ c1 ; } break ; } else if ( frq [ i ] >= 1 ) { c1 ++ ; onetime = false ; } } if ( tt ) { System . out . println ( aa ) ; } else { System . out . println ( ++ c1 + ++ c2 ) ; } t -- ; } } } ",
"import java . util . * ; public class SubsetMex { public static void main ( String [ ] args ) {"
] | [
"for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE s = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = [ 0 ] * 102 NEW_LINE b = [ 0 ] * 102 NEW_LINE s . sort ( ) NEW_LINE for i in s : if NEW_LINE a [ i ] == 0 : a [ i ] += 1 else : b [ i ] += 1 NEW_LINE print ( a . index ( 0 ) + b . index ( 0 ) ) NEW_LINE",
"for _ in \" ▁ \" * int ( input ( ) ) : n = int ( input ( ) ) NEW_LINE lst = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE a , b = 0 , 0 NEW_LINE for i in lst : if NEW_LINE a == i : a += 1 elif b == i : b += 1 NEW_LINE print ( a + b ) NEW_LINE",
"t = int ( input ( ) ) NEW_LINE def mex1 ( arr ) : i = 0 NEW_LINE while ( 1 ) : if NEW_LINE i not in arr : NEW_LINE return i else : i += 1 NEW_LINE def mex2 ( arr ) : i = 0 NEW_LINE while ( 1 ) : if NEW_LINE arr . count ( i ) < 2 : NEW_LINE return i else : i += 1 for _ in range ( t ) : n = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if 0 not in arr : NEW_LINE INDENT print ( 0 ) elif arr . count ( 0 ) == 1 : NEW_LINE print ( mex1 ( arr ) ) else : NEW_LINE print ( mex1 ( arr ) + mex2 ( arr ) ) NEW_LINE DEDENT",
"cases = int ( input ( ) ) NEW_LINE while cases : cases -= 1 NEW_LINE num = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) st1 = - 1 NEW_LINE st2 = - 1 NEW_LINE broken = False NEW_LINE for i in range ( 101 ) : if NEW_LINE i not in arr : NEW_LINE break else : if arr . count ( i ) > 1 and not broken : st1 += 1 NEW_LINE st2 += 1 else : st1 += 1 NEW_LINE broken = True print ( 2 + st1 + st2 ) NEW_LINE"
] |
codeforces_1117_B | [
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class _0726Emotes { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Long > store = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { store . add ( sc . nextLong ( ) ) ; } Collections . sort ( store ) ; long first = store . get ( store . size ( ) - 1 ) ; long second = store . get ( store . size ( ) - 2 ) ; System . out . println ( ( m / ( k + 1 ) ) * 1L * ( ( k * first ) + second ) + ( m % ( k + 1 ) * first ) ) ; } }"
] | [
"n , m , k = map ( int , input ( ) . split ( ) ) r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = r ( ) arr . sort ( reverse = True ) base = arr [ 0 ] * k + arr [ 1 ] t = m // ( k + 1 ) base = base * t t = m % ( k + 1 ) base += t * arr [ 0 ] print ( int ( base ) ) NEW_LINE",
"n , m , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( reverse = True ) p = a [ 0 ] * k + a [ 1 ] ans = p * ( m // ( k + 1 ) ) + a [ 0 ] * ( m % ( k + 1 ) ) print ( ans ) NEW_LINE",
"n , m , k = map ( int , input ( ) . split ( ) ) emotes = [ int ( bruhh ) for bruhh in input ( ) . split ( ) ] emotes . sort ( ) cycles = m // ( k + 1 ) leftover = m % ( k + 1 ) res = 0 res += ( ( k ) * emotes [ - 1 ] ) * ( cycles ) res += emotes [ - 2 ] * ( cycles ) res += emotes [ - 1 ] * leftover print ( res ) NEW_LINE",
"n , m , k = map ( int , input ( ) . split ( ) ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = m // ( k + 1 ) * ( a [ - 1 ] * k + a [ - 2 ] ) + m % ( k + 1 ) * a [ - 1 ] print ( ans ) NEW_LINE"
] |
codeforces_617_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { int dis , step = 0 ; Scanner sc = new Scanner ( System . in ) ; dis = sc . nextInt ( ) ; if ( dis / 5 >= 1 ) { step = dis / 5 ; dis = dis % 5 ; } if ( dis / 4 >= 1 ) { step += dis / 4 ; dis = dis % 4 ; } if ( dis / 3 >= 1 ) { step += dis / 3 ; dis = dis % 3 ; } if ( dis / 2 >= 1 ) { step += dis / 2 ; dis = dis % 2 ; } step += dis ; System . out . println ( step ) ; } } ",
"import java . util . Scanner ; public class Ex { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , count = 0 ; while ( n != 0 ) { if ( n >= 5 ) { n = n - 5 ; count ++ ; } else { n = n - n ; count ++ ; } } System . out . println ( count ) ; } }",
"import java . util . Scanner ; public class Elephant { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int res = 0 ; for ( int i = 5 ; i >= 1 ; i -- ) { res += n / i ; n = n % i ; } System . out . println ( res ) ; } }",
"import java . util . Scanner ; public class BigO { public static void main ( String [ ] args ) { int x ; Scanner sc = new Scanner ( System . in ) ; x = sc . nextInt ( ) ; int step = 1 ; while ( x > 5 ) { x -= 5 ; step ++ ; } System . out . println ( step ) ; } }",
"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 ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AElephant solver = new AElephant ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AElephant { public void solve ( int testNumber , FastScanner fs , PrintWriter out ) { int x = fs . nextInt ( ) ; int ans = 0 ; for ( int i = 5 ; i >= 1 ; i -- ) { ans += x / i ; x = x % i ; } out . println ( ans ) ; } } static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } "
] | [
"a = int ( input ( ) ) i = 0 while a > 5 : a = a - 5 i = i + 1 i = i + 1 print ( i ) NEW_LINE",
"x = int ( input ( ) ) print ( ( x + 4 ) // 5 ) NEW_LINE",
"a = int ( input ( \" \" ) ) if a % 5 == 0 : print ( a // 5 ) else : print ( a // 5 + 1 ) NEW_LINE",
"x = 0 z = int ( input ( ) ) while z > 0 : if z >= 5 : z = z - 5 x += 1 elif z >= 4 : z = z - 4 x += 1 elif z >= 3 : z = z - 3 x += 1 elif z >= 2 : z = z - 2 x += 1 elif z >= 1 : z = z - 1 x += 1 print ( x ) NEW_LINE",
"a = int ( input ( ) ) i = 0 while a > 5 : a = a - 5 i = i + 1 print ( i + 1 ) NEW_LINE"
] |