id
stringlengths 13
20
| java
sequence | python
sequence |
---|---|---|
codeforces_526_B | [
"import java . io . * ; import java . util . * ; public class C { public static void main ( String [ ] args ) throws IOException { BufferedReader ob = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( ob . readLine ( ) ) ; n = ( int ) Math . pow ( 2 , n + 1 ) ;",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; int t = ( int ) ( Math . pow ( 2 , n + 1 ) ) - 1 ; int arr [ ] = new int [ t + 1 ] ; for ( int i = 2 ; i <= t ; i ++ ) { arr [ i ] = scn . nextInt ( ) ; } int ans = 0 ; for ( int i = ( int ) Math . pow ( 2 , n ) - 1 ; i > 0 ; i -- ) { arr [ i ] += Math . max ( arr [ 2 * i ] , arr [ 2 * i + 1 ] ) ; ans += Math . abs ( arr [ 2 * i ] - arr [ 2 * i + 1 ] ) ; } System . out . println ( ans ) ; } }",
"import java . util . * ; public class a { static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; int [ ] a = new int [ ( int ) Math . pow ( 2 , n + 1 ) ] ; int [ ] c = new int [ ( int ) Math . pow ( 2 , n + 1 ) ] ; for ( int i = 2 ; i < Math . pow ( 2 , n + 1 ) ; i ++ ) { a [ i ] = in . nextInt ( ) ; } for ( int i = 2 ; i < Math . pow ( 2 , n + 1 ) ; i ++ ) { c [ i ] = a [ i ] + c [ Math . floorDiv ( i , 2 ) ] ; } long ans = 0 ; for ( int i = n ; i > 0 ; i -- ) { for ( int j = ( int ) Math . pow ( 2 , i ) ; j < Math . pow ( 2 , i + 1 ) ; j += 2 ) { c [ Math . floorDiv ( j , 2 ) ] = Math . max ( c [ j ] , c [ j + 1 ] ) ; ans += Math . abs ( c [ j ] - c [ j + 1 ] ) ; } } System . out . println ( ans ) ; } }"
] | [
"import math def add ( n , arr ) : sumlis = [ i for i in arr ] def sumdou ( i ) : if 2 * i + 2 >= len ( arr ) : return arr [ i ] else : return sumlis [ 2 * i + 2 ] + arr [ i ] tot = 0 p2 = len ( arr ) for j in reversed ( range ( n ) ) : p1 = p2 - int ( math . pow ( 2 , j + 1 ) ) for i in range ( p1 , p2 , 2 ) : s1 = sumdou ( i ) s2 = sumdou ( i + 1 ) tot += abs ( s2 - s1 ) sumlis [ i ] = max ( s1 , s2 ) sumlis [ i + 1 ] = max ( s1 , s2 ) p2 = p1 print ( tot ) n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) add ( n , arr ) NEW_LINE",
"n = 2 ** ( int ( input ( ) ) + 1 ) - 1 ; a = [ 0 , 0 ] + list ( map ( int , input ( ) . split ( ) ) ) r = 0 while n > 1 : a [ n // 2 ] += max ( a [ n ] , a [ n - 1 ] ) r += abs ( a [ n ] - a [ n - 1 ] ) n -= 2 print ( r ) NEW_LINE",
"n = int ( input ( ) ) lst = { i + 1 : int ( x ) for i , x in enumerate ( input ( ) . split ( ) ) } lst [ 0 ] = 0 x = 2 ** ( n + 1 ) - 1 res = 0 for i in range ( n , 0 , - 1 ) : for j in range ( x - 1 , x - 2 ** i - 1 , - 2 ) : ma = max ( lst [ j ] , lst [ j - 1 ] ) mi = min ( lst [ j ] , lst [ j - 1 ] ) res += ma - mi lst [ ( j + 1 ) // 2 - 1 ] += ma x -= 2 ** iprint ( res ) NEW_LINE",
"n = int ( input ( ) ) lis = [ 0 ] * 2 + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE",
"ans = [ ] def DFS ( x , n ) : count = 0 stack = [ ( x , count ) ] leaf = 0 ans = 0 max1 = 0 back_stack = [ ] NEW_LINE"
] |
codeforces_454_B | [
"import java . util . * ; public class Practice { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int k = 0 ; for ( int i = 0 ; i < arr . length - 1 ; i ++ ) { if ( arr [ i ] <= arr [ i + 1 ] ) k ++ ; else break ; } if ( k == arr . length - 1 ) System . out . println ( 0 ) ; else { boolean sorted = true ; for ( int i = k + 1 ; i < arr . length - 1 ; i ++ ) { if ( arr [ i ] <= arr [ i + 1 ] ) continue ; else { sorted = false ; break ; } } if ( ! sorted ) System . out . println ( - 1 ) ; else if ( arr [ 0 ] >= arr [ n - 1 ] ) System . out . println ( n - k - 1 ) ; else System . out . println ( - 1 ) ; } } } ",
"import java . util . * ; public class LittlePonyAndSortByShift_B { public static void main ( String [ ] args ) {",
"import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { static int lastBefore = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; int first_min_index = 0 ; int last_min_index = 0 ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < t ; i ++ ) { int toAdd = sc . nextInt ( ) ; if ( toAdd == min ) { min = toAdd ; if ( list . get ( i - 1 ) > min ) { lastBefore = i - 1 ; } last_min_index = i ; } else if ( toAdd < min ) { min = toAdd ; lastBefore = i - 1 ; first_min_index = i ; last_min_index = i ; } list . add ( toAdd ) ; } if ( canBeSorted ( list , first_min_index , last_min_index ) ) { if ( last_min_index != 0 ) { if ( last_min_index == list . size ( ) - 1 ) { if ( same ( list ) ) System . out . println ( 0 ) ; else System . out . println ( list . size ( ) - lastBefore - 1 ) ; } else { System . out . println ( list . size ( ) - first_min_index ) ; } } else { System . out . println ( 0 ) ; } } else { System . out . println ( - 1 ) ; } } private static boolean same ( List < Integer > list ) { for ( int i = 0 ; i < list . size ( ) - 1 ; i ++ ) { int a = list . get ( i ) ; int b = list . get ( i + 1 ) ; if ( a != b ) { return false ; } } return true ; } private static boolean canBeSorted ( List < Integer > list , int first_min_index , int last_min_index ) { if ( list . size ( ) <= 2 ) return true ;"
] | [
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) if ( arr == sorted ( arr ) ) : print ( 0 ) else : f = 0 for i in range ( n - 1 ) : if ( arr [ i ] > arr [ i + 1 ] ) : f = i break k = arr [ f + 1 : ] p = k + arr [ : f + 1 ] if ( p == sorted ( arr ) ) : print ( len ( k ) ) else : print ( - 1 ) NEW_LINE",
"n = int ( input ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n - 1 ) : if A [ i ] > A [ i + 1 ] : NEW_LINE",
"n = int ( input ( ' ' ) ) x = list ( map ( int , input ( ) . split ( ) ) ) if ( x == sorted ( x ) ) : print ( '0' ) else : for i in range ( 0 , len ( x ) ) : if ( x [ i ] > x [ i + 1 ] ) : c = i break b = x [ c + 1 : ] c = b + x [ : c + 1 ] if ( c == sorted ( x ) ) : print ( len ( b ) ) else : print ( ' - 1' ) NEW_LINE",
"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 ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) m = l [ 0 ] mx = l [ 0 ] k = 0j = 0 for i in range ( 1 , n ) : if l [ i ] > mx : mx = l [ i ] k = i if m < 0 or l [ i ] < m or ( l [ i ] <= m and k > j ) : m = l [ i ] j = i flag = 0 for i in range ( j , n - 1 ) : if flag == 1 : break if l [ i + 1 ] < l [ i ] : flag = 1 break for i in range ( j - 1 ) : if flag == 1 : break if l [ i + 1 ] < l [ i ] : flag = 1 break if l [ 0 ] < l [ n - 1 ] and l [ 0 ] > m : flag = 1 if flag == 1 : print ( - 1 ) elif j == 0 : print ( j ) else : print ( n - j ) NEW_LINE"
] |
codeforces_224_B | [
"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 maxN = ( int ) 1e6 ;",
" import java . io . IOException ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Scanner ; public class Main { ",
"import java . util . * ; import java . io . * ; import java . math . * ; public class Practice { static FastReader sc = new FastReader ( ) ; static int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; static long dp [ ] [ ] ;",
"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 + 1 ] ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; TreeSet < Integer > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; set . add ( a [ i ] ) ; } int count = 0 ; if ( set . size ( ) < k ) { System . out . println ( \" - 1 ▁ - 1\" ) ; return ; } int first = 1 ; int last = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! map . containsKey ( a [ i ] ) ) { count ++ ; } map . put ( a [ i ] , map . getOrDefault ( a [ i ] , 0 ) + 1 ) ; if ( count == k ) { last = i + 1 ; break ; } } int i = 0 ; while ( i < n && map . get ( a [ i ] ) > 1 && count == k ) { map . put ( a [ i ] , map . get ( a [ i ] ) - 1 ) ; i ++ ; } System . out . println ( ( i + 1 ) + \" ▁ \" + last ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < > ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int num = sc . nextInt ( ) ; set . add ( num ) ; a [ i ] = num ; } if ( set . size ( ) < k ) { System . out . println ( \" - 1 ▁ - 1\" ) ; return ; } if ( k == 1 ) { System . out . println ( \"1 ▁ 1\" ) ; return ; } int add = 0 , remove = 0 ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; int left = 0 , right = n ; while ( add < n ) { map . put ( a [ add ] , map . getOrDefault ( a [ add ] , 0 ) + 1 ) ; add ++ ; while ( map . size ( ) >= k ) { int tl = remove , tr = add - 1 ; if ( right - left > tr - tl ) { left = tl ; right = tr ; } map . put ( a [ remove ] , map . get ( a [ remove ] ) - 1 ) ; if ( map . get ( a [ remove ] ) == 0 ) { map . remove ( a [ remove ] ) ; } remove ++ ; } } left ++ ; right ++ ; System . out . println ( left + \" ▁ \" + right ) ; } }"
] | [
"n , k = map ( int , input ( ) . split ( ) ) a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) freq = [ 0 ] * ( 100001 ) dist = 0 for i in range ( 1 , n + 1 ) : if freq [ a [ i ] ] == 0 : dist += 1 freq [ a [ i ] ] += 1 l = 1 r = n if dist < k : print ( - 1 , - 1 ) else : while dist >= k and r >= l : freq [ a [ r ] ] -= 1 if freq [ a [ r ] ] == 0 : dist -= 1 r -= 1 r += 1 dist += 1 while dist >= k and l <= r : freq [ a [ l ] ] -= 1 if freq [ a [ l ] ] == 0 : dist -= 1 l += 1 l -= 1 print ( l , r ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) C = [ 0 ] * 100001 l = 0 r = 0 p = 0 while r < n and p < k : C [ A [ r ] ] += 1 if C [ A [ r ] ] == 1 : p += 1 r += 1 if p != k : print ( ' - 1' , ' - 1' ) else : while p == k : C [ A [ l ] ] -= 1 if C [ A [ l ] ] == 0 : p -= 1 l += 1 l -= 1 print ( l + 1 , r ) NEW_LINE",
"n , k = list ( map ( int , input ( ) . split ( ) ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) count = [ 0 ] * ( int ( 1e5 + 1 ) ) for i in arr : count [ i ] += 1 s = sum ( [ 1 if i > 0 else 0 for i in count ] ) if s < k : print ( ' - 1 ▁ - 1' ) exit ( ) r = n - 1 while True : if count [ arr [ r ] ] == 1 : s -= 1 if s < k : s += 1 break count [ arr [ r ] ] -= 1 r -= 1 l = 0 while True : if count [ arr [ l ] ] == 1 : s -= 1 if s < k : s += 1 break count [ arr [ l ] ] -= 1 l += 1 print ( l + 1 , r + 1 ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) q = { 0 } e = 0 l = [ ] for i in range ( n ) : if a [ i ] not in q : e += 1 q . add ( a [ i ] ) if e == k : e = 0 q = { 0 } l += [ i ] w = 10 ** 5 t = 0 for i in l : e = 0 q = { 0 } for j in range ( i , - 1 , - 1 ) : if a [ j ] not in q : e += 1 q . add ( a [ j ] ) if e == k : if w > len ( q ) : w = j + 1 t = i + 1 breakif len ( set ( a ) ) >= k : print ( w , t ) else : print ( - 1 , - 1 ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) d = { } i = 1 for x in arr : if len ( d ) == m : break d [ x ] = i i += 1 if len ( d ) == m : print ( min ( d . values ( ) ) , max ( d . values ( ) ) ) else : print ( - 1 , - 1 ) NEW_LINE"
] |
codeforces_268_B | [
"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 Example { static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;",
"import java . util . Scanner ; public class _0609Buttons { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = n ; int y = 1 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += x * y ; x -- ; y ++ ; } n -- ; sum -= ( n * ( n + 1 ) ) / 2 ; System . out . println ( sum ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int recibido = scanner . nextInt ( ) ; int suma = 0 ; int i ; for ( i = 1 ; i <= recibido ; i ++ ) { suma += 1 + ( recibido - i ) * i ; } System . out . printf ( \" % d \\n \" , suma ) ; } }",
"import java . util . * ; public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long sum = n ; for ( int j = 1 ; j <= ( n - 1 ) ; j ++ ) { sum = sum + j * ( n - j ) ; } System . out . println ( sum ) ; } public static int getAns ( String s , int k , int start1 , int end1 ) {"
] | [
"n = int ( input ( ) ) ans = 0 for a in range ( 1 , n ) : ans += ( n - a ) * aprint ( ans + n ) NEW_LINE",
"n = int ( input ( ) ) P = 0 for i in range ( n - 1 ) : P += ( n - i - 1 ) * ( i + 1 ) print ( P + n ) NEW_LINE",
"n = int ( input ( ) ) suma = ( 2 * n ) - 1 las = n - 2 fir = 2 for item in range ( 1 , n - 1 ) : suma += ( fir * las ) fir += 1 las -= 1 print ( suma ) NEW_LINE",
"n = int ( input ( ) ) result = n for i in range ( 1 , n ) : result += ( n - i ) * i print ( result ) NEW_LINE"
] |
codeforces_1202_A | [
"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 ) { String x = sc . next ( ) ; String y = sc . next ( ) ; StringBuilder s1 = new StringBuilder ( x ) ; StringBuilder s2 = new StringBuilder ( y ) ; s1 = s1 . reverse ( ) ; s2 = s2 . reverse ( ) ; int f = s2 . indexOf ( \"1\" ) ; int l = s1 . indexOf ( \"1\" , f ) ; int k = l - f ; System . out . println ( k ) ; } } }",
"import java . util . * ; import java . io . * ; import java . math . * ; public class x1202A { public static void main ( String hi [ ] ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int T = Integer . parseInt ( st . nextToken ( ) ) ; while ( T -- > 0 ) { char [ ] arr = infile . readLine ( ) . toCharArray ( ) ; char [ ] brr = infile . readLine ( ) . toCharArray ( ) ; int N = arr . length ; int M = brr . length ; int dist2 = 0 ; for ( int i = M - 1 ; i >= 0 ; i -- ) { if ( brr [ i ] == '1' ) break ; dist2 ++ ; } int dist = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == '1' && dist >= dist2 ) break ; dist ++ ; } int res = dist - dist2 ; System . out . println ( res ) ; } } }",
" import java . util . * ; import java . lang . * ; import java . io . * ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int T = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int t = 0 ; t < T ; t ++ ) { StringBuilder a = new StringBuilder ( sc . nextLine ( ) ) ; a . reverse ( ) ; StringBuilder b = new StringBuilder ( sc . nextLine ( ) ) ; b . reverse ( ) ; int y = b . indexOf ( \"1\" ) ; int x = a . indexOf ( \"1\" , y ) ; out . println ( x - y ) ; } out . flush ( ) ; } }",
" import java . util . * ; import java . lang . * ; import java . io . * ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int T = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int t = 0 ; t < T ; t ++ ) { StringBuilder a = new StringBuilder ( sc . nextLine ( ) ) ; a . reverse ( ) ; StringBuilder b = new StringBuilder ( sc . nextLine ( ) ) ; b . reverse ( ) ; int y = b . indexOf ( \"1\" ) ; int x = a . indexOf ( \"1\" , y ) ; out . println ( x - y ) ; } out . flush ( ) ; } }",
"import java . util . * ; import java . io . * ; import java . math . * ; public class Main { private static int MAX = Integer . MAX_VALUE ; private static int MIN = Integer . MIN_VALUE ; private static int MOD = 1000000007 ; static FastScanner sc = new FastScanner ( ) ; static StringBuilder sb = new StringBuilder ( ) ; public static void main ( String [ ] args ) throws IOException { int T = sc . nextInt ( ) ; while ( T -- > 0 ) { solve ( ) ; } System . out . print ( sb ) ; } static void solve ( ) throws IOException { String X = sc . next ( ) ; String Y = sc . next ( ) ; int offset = 0 ; while ( Y . charAt ( Y . length ( ) - 1 - offset ) == '0' ) offset ++ ; int K = 0 ; while ( X . charAt ( X . length ( ) - 1 - offset - K ) == '0' ) K ++ ; sb . append ( K + \" \\n \" ) ; } static class FastScanner { public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner ( ) { reader = new BufferedReader ( new InputStreamReader ( System . in ) , 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 ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } } }"
] | [
"for t in range ( int ( input ( ) ) ) : x = input ( ) [ : : - 1 ] y = input ( ) [ : : - 1 ] posy = 0 while y [ posy ] != \"1\" : posy += 1 posx = posy while x [ posx ] != \"1\" : posx += 1 ans = posx - posy print ( ans ) NEW_LINE",
"import sys def main ( ) : for _ in range ( int ( sys . stdin . readline ( ) . strip ( ) ) ) : x = sys . stdin . readline ( ) . strip ( ) y = sys . stdin . readline ( ) . strip ( ) pos = 0 for i in range ( len ( y ) - 1 , - 1 , - 1 ) : if y [ i ] == '1' : pos += 1 break else : pos += 1 count = 0 for i in range ( len ( x ) - pos , - 1 , - 1 ) : if x [ i ] == '1' : break else : count += 1 print ( count ) main ( ) NEW_LINE",
"import sys T = int ( sys . stdin . readline ( ) ) for _ in range ( T ) : x = sys . stdin . readline ( ) . rstrip ( ) y = sys . stdin . readline ( ) . rstrip ( ) x , y = x [ : : - 1 ] , y [ : : - 1 ] pos_y = y . find ( \"1\" ) pos_x = x . find ( \"1\" , pos_y ) print ( pos_x - pos_y ) NEW_LINE",
"from sys import stdininput = stdin . readline t = int ( input ( ) ) for _ in range ( t ) : x = input ( ) . rstrip ( ) y = input ( ) . rstrip ( ) for i in range ( len ( y ) - 1 , - 1 , - 1 ) : if y [ i ] == \"1\" : a = i break c = 0 for i in range ( len ( x ) - ( len ( y ) - a ) , - 1 , - 1 ) : if x [ i ] == \"1\" : break c += 1 print ( c ) NEW_LINE"
] |
codeforces_985_A | [
" import java . util . * ; import java . lang . * ; import java . io . * ; public class Ideone { public static void main ( String [ ] args ) throws java . lang . Exception {",
" import java . util . * ; import java . lang . * ; import java . io . * ; public class Ideone { public static void main ( String [ ] args ) throws java . lang . Exception {",
"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 . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; public class Ecr44A { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader sc = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Solver solver = new Solver ( ) ;"
] | [
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) n = len ( a ) a . sort ( ) ans1 = ans2 = 0 for i in range ( n ) : ans1 += abs ( a [ i ] - ( i + 1 ) * 2 ) ans2 += abs ( a [ i ] - ( 1 + i * 2 ) ) print ( min ( ans1 , ans2 ) ) NEW_LINE",
"n = int ( input ( ) ) * p , = map ( int , input ( ) . split ( ) ) p . sort ( ) black = sum ( abs ( i * 2 + 1 - x ) for i , x in enumerate ( p ) ) white = sum ( abs ( i * 2 + 2 - x ) for i , x in enumerate ( p ) ) print ( min ( black , white ) ) NEW_LINE",
"n = int ( input ( ) ) chess = list ( map ( int , input ( ) . split ( ) ) ) move1 = 0 move2 = 0 chess . sort ( ) for i in range ( len ( chess ) ) : move1 += abs ( chess [ i ] - ( i * 2 + 1 ) ) move2 += abs ( chess [ i ] - ( i * 2 + 2 ) ) print ( min ( move1 , move2 ) ) NEW_LINE",
"import sys , math , itertoolsfrom collections import Counter , deque , defaultdictfrom bisect import bisect_left , bisect_right from heapq import heappop , heappush , heapify , nlargestfrom copy import deepcopymod = 10 ** 9 + 7 INF = float ( ' inf ' ) def inp ( ) : return int ( sys . stdin . readline ( ) ) def inpl ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def inpl_1 ( ) : return list ( map ( lambda x : int ( x ) - 1 , sys . stdin . readline ( ) . split ( ) ) ) def inps ( ) : return sys . stdin . readline ( ) def inpsl ( x ) : tmp = sys . stdin . readline ( ) ; return list ( tmp [ : x ] ) def err ( x ) : print ( x ) ; exit ( ) n = inp ( ) p = inpl ( ) ; p . sort ( ) res = 0 for i in range ( n // 2 ) : res += abs ( p [ i ] - ( i * 2 + 2 ) ) res2 = 0 for i in range ( n // 2 ) : res2 += abs ( p [ i ] - ( i * 2 + 1 ) ) print ( min ( res , res2 ) ) NEW_LINE",
"n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 k = 0 p . sort ( ) for i in range ( 1 , n , 2 ) : ans += abs ( p [ i // 2 ] - i ) for i in range ( 2 , n + 1 , 2 ) : k += abs ( p [ i // 2 - 1 ] - i ) print ( min ( ans , k ) ) NEW_LINE"
] |
codeforces_1388_A | [
"import java . io . * ; import java . math . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { FastReader scan = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; Task solver = new Task ( ) ; ans = new StringBuilder ( ) ; int T = scan . nextInt ( ) ; for ( int tt = 0 ; tt < T ; tt ++ ) solver . solve ( tt , scan , out ) ; out . close ( ) ; } static StringBuilder ans ; static class Task { public void solve ( int testNumber , FastReader scan , PrintWriter out ) { int n = scan . nextInt ( ) ; if ( n <= 30 ) out . println ( \" NO \" ) ; else { out . println ( \" YES \" ) ; int x = n - 30 ; if ( x != 10 && x != 6 && x != 14 ) { out . println ( 6 + \" ▁ \" + 10 + \" ▁ \" + 14 + \" ▁ \" + x ) ; } else { out . println ( 6 + \" ▁ \" + 10 + \" ▁ \" + 15 + \" ▁ \" + ( x - 1 ) ) ; } } } } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public FastReader ( String s ) throws FileNotFoundException { br = new BufferedReader ( new FileReader ( new File ( s ) ) ) ; } 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 . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; int n ; for ( int i = 0 ; i < t ; i ++ ) { n = s . nextInt ( ) ; if ( n <= 30 ) { System . out . println ( \" NO \" ) ; } else { System . out . println ( \" YES \" ) ; if ( n == 36 || n == 40 || n == 44 ) { System . out . println ( \"6 ▁ \" + \"10 ▁ \" + \"15 ▁ \" + Integer . toString ( n - 31 ) ) ; } else { System . out . println ( \"6 ▁ \" + \"10 ▁ \" + \"14 ▁ \" + Integer . toString ( n - 30 ) ) ; } } } } }"
] | [
"t = int ( input ( ) ) NEW_LINE for i in range ( t ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE if n < 31 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE a = n - 30 NEW_LINE if a != 6 and a != 10 and a != 14 : NEW_LINE INDENT print ( 6 , 10 , 14 , a ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 6 , 10 , 15 , n - 31 ) NEW_LINE DEDENT DEDENT DEDENT",
"import math NEW_LINE for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT x = int ( input ( ) ) NEW_LINE if x <= 30 : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT elif x == 36 or x == 44 or x == 40 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE print ( 6 , 10 , 15 , x - 31 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE print ( 6 , 10 , 14 , x - 30 ) NEW_LINE DEDENT DEDENT",
"for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE if n <= 30 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT if n == 36 or n == 40 or n == 44 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE print ( 6 , 10 , 15 , n - 31 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE print ( 6 , 10 , 14 , n - 30 ) NEW_LINE DEDENT DEDENT DEDENT",
"t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE if ( n <= 30 ) : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE q = n - 30 NEW_LINE if ( q == 6 or q == 10 or q == 14 ) : NEW_LINE INDENT print ( 6 , 10 , 15 , q - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 6 , 10 , 14 , q ) NEW_LINE DEDENT DEDENT DEDENT",
"n = int ( input ( ) ) NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE if ( a < 31 ) : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT else : NEW_LINE INDENT k = a - 30 NEW_LINE if k != 6 and k != 14 and k != 10 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE print ( \"6 ▁ 10 ▁ 14\" , a - 30 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE print ( \"6 ▁ 10 ▁ 15\" , a - 31 ) NEW_LINE DEDENT DEDENT DEDENT"
] |
codeforces_312_B | [
"import java . io . * ; import java . math . BigInteger ; import java . util . * ; import java . util . StringTokenizer ; public class Main { static int MOD = ( int ) Math . pow ( 10 , 9 ) + 7 ; public static void main ( String [ ] args ) throws IOException { FastReader fr = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; double X = fr . nextDouble ( ) / fr . nextDouble ( ) ; double Y = fr . nextDouble ( ) / fr . nextDouble ( ) ; double multiplier = ( 1 - X ) * ( 1 - Y ) ; double sum = X * ( 1 ) / ( 1 - multiplier ) ; pw . println ( sum ) ; 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 ( ) ; } st = null ; return str ; } } }",
"import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {",
"import java . util . Scanner ; public class Archer { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double a = sc . nextInt ( ) ; double b = sc . nextInt ( ) ; double c = sc . nextInt ( ) ; double d = sc . nextInt ( ) ; double r = ( 1 - c / d ) * ( 1 - a / b ) ; System . out . println ( ( a / b ) / ( 1 - r ) ) ; } }",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { 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 ( ) ;"
] | [
"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",
"def common_common ( arr ) : commonstring = ' ' if len ( arr ) > 1 and len ( arr [ 0 ] ) > 0 : for i in range ( len ( arr [ 0 ] ) ) : for j in range ( len ( arr [ 0 ] ) - i + 1 ) : if j > len ( commonstring ) and is_commonstring ( arr [ 0 ] [ i : i + j ] , arr ) : commonstring = arr [ 0 ] [ i : i + j ] return commonstring def is_commonstring ( stringg , arr ) : if len ( arr ) < 1 and len ( stringg ) < 1 : return False for i in range ( len ( arr ) ) : if stringg not in arr [ i ] : return False return Truedef common_common ( arr ) : commonstring = ' ' if len ( arr ) > 1 and len ( arr [ 0 ] ) > 0 : for i in range ( len ( arr [ 0 ] ) ) : for j in range ( len ( arr [ 0 ] ) - i + 1 ) : if j > len ( commonstring ) and is_commonstring ( arr [ 0 ] [ i : i + j ] , arr ) : commonstring = arr [ 0 ] [ i : i + j ] return commonstring def is_commonstring ( stringg , arr ) : if len ( arr ) < 1 and len ( stringg ) < 1 : return False for i in range ( len ( arr ) ) : if stringg not in arr [ i ] : return False return Truet = ( input ( ) . split ( maxsplit = 4 ) ) ar = [ ] for i in t : i = float ( i ) ar . append ( i ) a = ar [ 0 ] b = ar [ 1 ] c = ar [ 2 ] d = ar [ 3 ] aa = c / daaa = ( a * c ) / ( b * d ) a1 = a / ba2 = 1 - aa - a1 + aaares = 0 ret = 0 for i in range ( 10000 ) : ret = ( a2 ** i ) res = res + ret * a1 NEW_LINE",
"a , b , c , d = map ( int , input ( ) . split ( ) ) result = ( a * d ) / ( b * c + a * d - a * c ) print ( result ) NEW_LINE",
"a , b , c , d = map ( int , input ( ) . split ( ) ) print ( ( a * d ) / ( b * c + a * d - a * c ) ) NEW_LINE",
"a , b , c , d = map ( int , input ( ) . split ( ) ) x = a / by = c / dxx = 1 - xyy = 1 - yf = x / ( 1 - ( xx * yy ) ) print ( f ) NEW_LINE"
] |
codeforces_204_B | [
"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 ( ) ; } void run ( FastScanner in , PrintWriter out ) { ",
"import java . io . * ; import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; HashSet < Integer > set = new HashSet < Integer > ( ) ; HashMap < Integer , Integer > fTotal = new HashMap < > ( ) ; HashMap < Integer , Integer > fUp = new HashMap < > ( ) ; HashMap < Integer , Integer > same = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int up = in . nextInt ( ) , down = in . nextInt ( ) ; set . add ( up ) ; set . add ( down ) ; add ( fUp , up ) ; add ( fTotal , up ) ; add ( fTotal , down ) ; if ( up == down ) add ( same , up ) ; } int ans = n ; for ( int ele : set ) { int cnt = fUp . getOrDefault ( ele , 0 ) ; if ( cnt >= ( n + 1 ) / 2 ) { ans = 0 ; break ; } int cntTot = fTotal . get ( ele ) ; int cntSame = same . getOrDefault ( ele , 0 ) ; if ( cntTot - cntSame >= ( n + 1 ) / 2 ) ans = Math . min ( ( ( n + 1 ) / 2 ) - cnt , ans ) ; } out . println ( ans == n ? - 1 : ans ) ; out . close ( ) ; } public static void add ( HashMap < Integer , Integer > map , int ele ) { int cnt = map . getOrDefault ( ele , 0 ) ; cnt ++ ; map . put ( ele , cnt ) ; return ; } static final Random random = new Random ( ) ;"
] | [
"from collections import defaultdictn = int ( input ( ) ) u , v = defaultdict ( int ) , defaultdict ( int ) for k in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) u [ a ] += 1 if b != a : v [ b ] += 1 k = ( n - 1 ) // 2 s = any ( v [ b ] > k for b in v ) t = [ u [ a ] for a in u if u [ a ] + v [ a ] > k ] if t : print ( max ( 0 , k + 1 - max ( t ) ) ) else : print ( k + 1 if s else - 1 ) NEW_LINE",
"from collections import defaultdictimport mathn = int ( input ( ) ) d = defaultdict ( int ) o = defaultdict ( int ) for i in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) o [ x ] += 1 d [ x ] += 1 if y != x : d [ y ] += 1 mi = 10 ** 5 + 1 for i in d : NEW_LINE",
"n = int ( input ( ) ) m = { } v = [ ] for i in range ( n ) : a = input ( ) . split ( ) v . append ( a ) m [ a [ 0 ] ] = [ 0 , 0 ] m [ a [ 1 ] ] = [ 0 , 0 ] for i in range ( n ) : m [ v [ i ] [ 0 ] ] [ 0 ] += 1 if v [ i ] [ 0 ] != v [ i ] [ 1 ] : m [ v [ i ] [ 1 ] ] [ 1 ] += 1 min = 99999999 for i in m : if sum ( m [ i ] ) >= ( n + 1 ) // 2 : if ( n + 1 ) // 2 - m [ i ] [ 0 ] < min : if ( n + 1 ) // 2 - m [ i ] [ 0 ] <= 0 : print ( 0 ) exit ( ) else : min = ( n + 1 ) // 2 - m [ i ] [ 0 ] print ( min if min != 99999999 else - 1 ) NEW_LINE",
"from collections import defaultdictn = int ( input ( ) ) u , v = defaultdict ( int ) , defaultdict ( int ) for k in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) u [ a ] += 1 if b != a : v [ b ] += 1 k = ( n - 1 ) // 2 s = any ( v [ b ] > k for b in v ) t = [ u [ a ] for a in u if u [ a ] + v [ a ] > k ] if t : print ( max ( 0 , k + 1 - max ( t ) ) ) else : print ( k + 1 if s else - 1 ) NEW_LINE"
] |
codeforces_896_A | [
"import java . io . * ; import java . util . * ; public class Main { static long len [ ] = new long [ ( int ) ( 1e5 + 1 ) ] ; static String stem = \" What ▁ are ▁ you ▁ doing ▁ at ▁ the ▁ end ▁ of ▁ the ▁ world ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ save ▁ us ? \" ; static String string = \" What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \\\" \\\" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \\\" \\\" ? \" ; static String p1 = \" What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \\\" \" ; static String p2 = \" \\\" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \\\" \" ; static String p3 = \" \\\" ? \" ; public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; len [ 0 ] = stem . length ( ) ; for ( int i = 1 ; i < 55 ; i ++ ) { len [ i ] = len [ i - 1 ] * 2 + string . length ( ) ;",
"import java . util . * ; public class CF597D { static String s1 = \" ▁ What ▁ are ▁ you ▁ doing ▁ at ▁ the ▁ end ▁ of ▁ the ▁ world ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ save ▁ us ? \" ; static String s2 = \" ▁ What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \\\" \\\" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \\\" \\\" ? \" ; static long lmit = ( long ) 1e18 ; static long [ ] f = new long [ 100005 ] ; public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int T = cin . nextInt ( ) ; long x , y ; f [ 0 ] = 75 ; for ( int i = 1 ; i <= 100000 ; i ++ ) f [ i ] = min ( 68 + f [ i - 1 ] * 2 , lmit ) ; while ( T -- > 0 ) { x = cin . nextLong ( ) ; y = cin . nextLong ( ) ; if ( y > f [ ( int ) x ] ) { System . out . print ( ' . ' ) ; } else { System . out . print ( get ( x , y ) ) ; } } } private static char get ( long x , long y ) { if ( x == 0 ) return s1 . charAt ( ( int ) y ) ; if ( y <= 34 ) return s2 . charAt ( ( int ) y ) ; if ( y <= 34 + f [ ( int ) ( x - 1 ) ] || ( f [ ( int ) x ] >= lmit && f [ ( int ) ( x - 1 ) ] >= lmit ) ) return get ( x - 1 , y - 34 ) ; if ( y <= 34 + f [ ( int ) ( x - 1 ) ] + 32 ) return s2 . charAt ( ( int ) ( y - f [ ( int ) ( x - 1 ) ] ) ) ; if ( y <= 34 + 2 * f [ ( int ) ( x - 1 ) ] + 32 ) return get ( x - 1 , y - 34 - f [ ( int ) ( x - 1 ) ] - 32 ) ; return s2 . charAt ( ( int ) ( y - f [ ( int ) ( x - 1 ) ] - f [ ( int ) ( x - 1 ) ] ) ) ; } private static long min ( long a , long b ) { if ( a < b ) return a ; return b ; } }"
] | [
"from functools import lru_cacheimport sys f0 = \" What ▁ are ▁ you ▁ doing ▁ at ▁ the ▁ end ▁ of ▁ the ▁ world ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ save ▁ us ? \" fnext = [ ' What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \" ' , ' \" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \" ' , ' \" ? ' ] BIG = 10 ** 20 @ lru_cache ( maxsize = None ) def flength ( n ) : if n == 0 : return len ( f0 ) else : sublen = flength ( n - 1 ) return min ( BIG , sum ( [ len ( part ) for part in fnext ] ) + 2 * sublen ) def get_char ( n , k ) : while True : if k >= flength ( n ) : return ' . ' if n == 0 : return f0 [ k ] for part in fnext : if k < len ( part ) : return part [ k ] else : k -= len ( part ) if k < flength ( n - 1 ) : n -= 1 break else : k -= flength ( n - 1 ) q = int ( input ( ) ) for i in range ( 2 * 10 ** 5 ) : flength ( i ) for _ in range ( q ) : n , k = map ( int , input ( ) . split ( ) ) print ( get_char ( n , k - 1 ) , end = \" \" ) print ( \" \" ) NEW_LINE",
"s0 = ' What ▁ are ▁ you ▁ doing ▁ at ▁ the ▁ end ▁ of ▁ the ▁ world ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ save ▁ us ? ' s1 = ' What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \" ' s2 = ' \" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \" ' def get ( h ) : if h > 55 : return 1 << 99 return ( 143 << h ) - 68 def solve ( n , k ) : if get ( n ) <= k : return ' . ' while True : if n == 0 : return s0 [ k ] if k < 34 : return s1 [ k ] k -= 34 if k < get ( n - 1 ) : n -= 1 continue k -= get ( n - 1 ) if k < 32 : return s2 [ k ] k -= 32 if k < get ( n - 1 ) : n -= 1 else : return ' \" ? ' [ k - get ( n - 1 ) ] for i in range ( int ( input ( ) ) ) : n , k = list ( map ( int , input ( ) . split ( ) ) ) print ( solve ( n , k - 1 ) , end = ' ' ) NEW_LINE",
"q = int ( input ( ) ) q1 = ' What ▁ are ▁ you ▁ doing ▁ at ▁ the ▁ end ▁ of ▁ the ▁ world ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ save ▁ us ? ' q2 = ' What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \" \" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \" \" ? ' q3 = ' What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \" ' q4 = ' \" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \" ' q5 = ' \" ? ' lq1 = len ( q1 ) lq2 = len ( q2 ) lq3 = len ( q3 ) lq4 = len ( q4 ) lq5 = len ( q5 ) lengths = [ 75 ] for i in range ( 100 ) : lengths . append ( lengths [ - 1 ] * 2 + 68 ) NEW_LINE",
"import syssys . setrecursionlimit ( 1500 ) s1 = \" What ▁ are ▁ you ▁ doing ▁ at ▁ the ▁ end ▁ of ▁ the ▁ world ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ save ▁ us ? \" a = \" What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \\ \" \" b = \" \\ \" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \\ \" \" c = \" \\ \" ? \" ans = \" \" def solve ( n , k ) : if n == 0 : if k >= len ( s1 ) : return \" . \" else : return s1 [ k ] if k < len ( a ) : return a [ k ] k -= len ( a ) prev_len = ( 2 ** ( n - 1 ) - 1 ) * ( len ( a ) + len ( b ) + len ( c ) ) + ( 2 ** ( n - 1 ) ) * len ( s1 ) if k < prev_len : return solve ( n - 1 , k ) k -= prev_len if k < len ( b ) : return b [ k ] k -= len ( b ) if k < prev_len : return solve ( n - 1 , k ) k -= prev_len if k < len ( c ) : return c [ k ] else : return \" . \" for _ in range ( int ( input ( ) ) ) : n , k = list ( map ( int , input ( ) . split ( ) ) ) k -= 1 if n > 65 : m = n - 65 if k < len ( a ) * m : ans += a [ k % len ( a ) ] continue k -= len ( a ) * m n = n - m ans += solve ( n , k ) print ( ans ) NEW_LINE",
"s0 = ' What ▁ are ▁ you ▁ doing ▁ at ▁ the ▁ end ▁ of ▁ the ▁ world ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ save ▁ us ? ' s1 = ' What ▁ are ▁ you ▁ doing ▁ while ▁ sending ▁ \" ' s2 = ' \" ? ▁ Are ▁ you ▁ busy ? ▁ Will ▁ you ▁ send ▁ \" ' l0 = len ( s0 ) l1 = len ( s1 ) l2 = len ( s2 ) def get ( h ) : if h > 55 : return int ( 1e20 ) return ( l0 + l1 + l2 + 2 << h ) - l1 - l2 - 2 def solve ( n , k ) : if get ( n ) <= k : return ' . ' while True : if n == 0 : return s0 [ k ] if k < l1 : return s1 [ k ] k -= l1 if k < get ( n - 1 ) : n -= 1 continue k -= get ( n - 1 ) if k < l2 : return s2 [ k ] k -= l2 if k < get ( n - 1 ) : n -= 1 else : return ' \" ? ' [ k - get ( n - 1 ) ] q = int ( input ( ) ) for i in range ( q ) : n , k = list ( map ( int , input ( ) . split ( ) ) ) print ( solve ( n , k - 1 ) , end = ' ' ) NEW_LINE"
] |
codeforces_687_B | [
"import java . io . * ; import java . util . * ; public class Main2 { static void main ( ) throws Exception { int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; HashSet < Integer > all = new HashSet < Integer > ( ) ; while ( n -- > 0 ) { all . add ( sc . nextInt ( ) ) ; } for ( int i = k ; i <= 1000000 ; i += k ) { if ( all . contains ( i ) ) { pw . println ( \" Yes \" ) ; return ; } } for ( int i = 2 ; i <= k ; i ++ ) { if ( k % i == 0 ) { int cur = 1 ; while ( k % i == 0 ) { k /= i ; cur *= i ; } boolean f = false ; for ( int j = cur ; j <= 1000000 ; j += cur ) { if ( all . contains ( j ) ) { f = true ; break ; } } if ( ! f ) { pw . println ( \" No \" ) ; return ; } } } pw . println ( \" Yes \" ) ; } public static void main ( String [ ] args ) throws Exception { sc = new MScanner ( System . in ) ; pw = new PrintWriter ( System . out ) ; int tc = 1 ;"
] | [
"import sysfrom math import gcd , sqrt , ceil , log2from collections import defaultdict , Counter , dequefrom bisect import bisect_left , bisect_rightimport mathsys . setrecursionlimit ( 2 * 10 ** 5 + 10 ) import heapqfrom itertools import permutations NEW_LINE",
"import math def main ( ) : n , k = map ( int , input ( ) . split ( ) ) C = list ( map ( int , input ( ) . split ( ) ) ) l = C [ 0 ] for c in C : l = l * c // math . gcd ( l , c ) % k if ( l == 0 ) : print ( \" Yes \" ) return print ( \" No \" ) main ( ) NEW_LINE",
"import sys , mathinput = sys . stdin . readline def getInts ( ) : return [ int ( s ) for s in input ( ) . split ( ) ] def getInt ( ) : return int ( input ( ) ) def getStrs ( ) : return [ s for s in input ( ) . split ( ) ] def getStr ( ) : return input ( ) . strip ( ) def listStr ( ) : return list ( input ( ) . strip ( ) ) import collections as colimport math def solve ( ) : NEW_LINE",
"import sys , mathinput = sys . stdin . readline def getInts ( ) : return [ int ( s ) for s in input ( ) . split ( ) ] def getInt ( ) : return int ( input ( ) ) def getStrs ( ) : return [ s for s in input ( ) . split ( ) ] def getStr ( ) : return input ( ) . strip ( ) def listStr ( ) : return list ( input ( ) . strip ( ) ) import collections as colimport math def prime_factors ( n ) : factors = [ ] num = 0 while n % 2 == 0 : num += 1 n //= 2 if num : factors . append ( ( 2 , num ) ) i = 3 while n > 1 and i * i <= n : num = 0 while n % i == 0 : num += 1 n //= i if num : factors . append ( ( i , num ) ) i += 2 if n > 2 : factors . append ( ( n , 1 ) ) return factors def fails ( num , C ) : for c in C : if c % num == 0 : return False return True def solve ( ) : NEW_LINE"
] |
codeforces_558_B | [
"import java . util . * ; import java . io . * ; import java . math . * ; public class Main { static PrintWriter out ; static Reader in ; public static void main ( String [ ] args ) throws IOException {",
"import java . io . * ; import java . util . * ; public class ez { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int size = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int max = 1000000 ; int [ ] a = new int [ max ] ; int [ ] star = new int [ max ] ; int [ ] end = new int [ max ] ; for ( int i = 0 ; i < size ; i ++ ) { int num = Integer . parseInt ( st . nextToken ( ) ) ; a [ num - 1 ] ++ ; if ( star [ num - 1 ] == 0 ) star [ num - 1 ] = i + 1 ; end [ num - 1 ] = i + 1 ; } int mod = 0 ; for ( int i = 0 ; i < max ; i ++ ) { if ( a [ i ] > mod ) mod = a [ i ] ; } int s = 1 ; int e = Integer . MAX_VALUE ; for ( int i = 0 ; i < max ; i ++ ) { if ( a [ i ] == mod && end [ i ] - star [ i ] < e - s ) { s = star [ i ] ; e = end [ i ] ; } } System . out . println ( s + \" ▁ \" + e ) ; } }"
] | [
"n = int ( input ( ) ) arr = tuple ( map ( int , input ( ) . split ( ) ) ) d = { } for i in arr : if i in d : d [ i ] += 1 else : d [ i ] = 1 big = 0 for i in d : if d [ i ] > big : big = d [ i ] s = { i } elif d [ i ] == big : s . add ( i ) small = { } large = { } for i in range ( n ) : if arr [ i ] not in small : small [ arr [ i ] ] = ifor i in range ( n - 1 , - 1 , - 1 ) : if arr [ i ] not in large : large [ arr [ i ] ] = ibest = n + 1 for i in s : j = small [ i ] k = large [ i ] if k - j + 1 < best : best = k - j + 1 ans = ( j + 1 , k + 1 ) print ( * ans ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = { } for i in range ( n ) : if str ( a [ i ] ) not in d : d [ str ( a [ i ] ) ] = [ 1 , i , i ] else : d [ str ( a [ i ] ) ] [ 0 ] += 1 d [ str ( a [ i ] ) ] [ 2 ] = max ( d [ str ( a [ i ] ) ] [ 2 ] , i ) res = sorted ( d , key = lambda x : d [ x ] [ 0 ] , reverse = True ) maxx = d [ res [ 0 ] ] [ 0 ] ans = float ( ' inf ' ) for i in range ( len ( res ) ) : if d [ res [ i ] ] [ 0 ] < maxx : break if ans > d [ res [ i ] ] [ 2 ] - d [ res [ i ] ] [ 1 ] : ans = d [ res [ i ] ] [ 2 ] - d [ res [ i ] ] [ 1 ] ind = [ d [ res [ i ] ] [ 1 ] + 1 , d [ res [ i ] ] [ 2 ] + 1 ] print ( * ind ) NEW_LINE",
"from collections import Countern = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) start = dict ( [ ] ) end = dict ( [ ] ) all = [ ] count = Counter ( a ) maxx = max ( list ( count . values ( ) ) ) for j in count : if count [ j ] == maxx : all . append ( j ) for i in range ( n ) : if a [ i ] not in start : start [ a [ i ] ] = i + 1 end [ a [ i ] ] = i + 1 else : end [ a [ i ] ] = i + 1 minn = 100000000 ele = 0 for k in all : if ( end [ k ] - start [ k ] ) < minn : minn = end [ k ] - start [ k ] ele = kprint ( start [ ele ] , end [ ele ] ) NEW_LINE",
"n = int ( input ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] b = [ [ ] for x in range ( 1 , 10 ** 6 + 10 ) ] for i , j in enumerate ( arr ) : b [ j ] . append ( i ) maxi = 0 for i in b : maxi = max ( maxi , len ( i ) ) best = 10 ** 10 l , r = 1 , 1 for i in b : if len ( i ) == maxi : if i [ - 1 ] - i [ 0 ] < best : best = i [ - 1 ] - i [ 0 ] l , r = i [ 0 ] , i [ - 1 ] print ( l + 1 , r + 1 ) NEW_LINE",
"from collections import Countern = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) start = dict ( [ ] ) end = dict ( [ ] ) all = [ ] count = Counter ( a ) maxx = max ( list ( count . values ( ) ) ) for j in count : if count [ j ] == maxx : all . append ( j ) for i in range ( n ) : if a [ i ] not in start : start [ a [ i ] ] = i + 1 end [ a [ i ] ] = i + 1 else : end [ a [ i ] ] = i + 1 minn = 100000000 ele = 0 for k in all : if ( end [ k ] - start [ k ] ) < minn : minn = end [ k ] - start [ k ] ele = kprint ( start [ ele ] , end [ ele ] ) NEW_LINE"
] |
codeforces_1341_A | [
"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 ) { int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( ( a + b ) * n < c - d || ( a - b ) * n > c + d ) { System . out . println ( \" NO \" ) ; } else { System . out . println ( \" YES \" ) ; } } } }",
"import java . util . * ; import java . io . * ; public class Practice { 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 ( ) {",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int T = s . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int n = s . nextInt ( ) ; int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; if ( Math . abs ( a - b ) * n <= c + d && ( a + b ) * n >= Math . abs ( c - d ) ) { System . out . println ( \" YES \" ) ; } else System . out . println ( \" NO \" ) ; } } } "
] | [
"for t in range ( int ( input ( ) ) ) : n , a , b , c , d = map ( int , input ( ) . split ( ) ) if n * ( a - b ) > ( c + d ) or n * ( a + b ) < ( c - d ) : print ( ' No ' ) else : print ( ' Yes ' ) NEW_LINE",
"for i in range ( int ( input ( ) ) ) : n , a , b , c , d = map ( int , input ( ) . split ( ) ) if c - d <= n * ( a + b ) and c + d >= n * ( a - b ) : print ( \" Yes \" ) else : print ( \" No \" ) NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : n , a , b , c , d = map ( int , input ( ) . split ( ) ) u1 = a + b d1 = abs ( a - b ) u2 = c + d d2 = abs ( c - d ) z = 0 if ( n * u1 < d2 ) : z = 1 elif ( n * d1 > u2 ) : z = 1 if ( z == 1 ) : print ( \" NO \" ) else : print ( \" YES \" ) NEW_LINE",
"from sys import stdin , stdout def main ( ) : for _ in range ( int ( stdin . readline ( ) ) ) : n , a , b , c , d = map ( int , stdin . readline ( ) . split ( ' ▁ ' ) ) min_mass = ( a - b ) * n max_mass = ( a + b ) * n if min_mass > c + d or max_mass < c - d : stdout . write ( ' No \\n ' ) else : stdout . write ( ' Yes \\n ' ) if __name__ == \" _ _ main _ _ \" : main ( ) NEW_LINE"
] |
codeforces_749_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 { public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int a [ ] [ ] = new int [ 3 ] [ 2 ] ; a [ 0 ] [ 0 ] = input . nextInt ( ) ; a [ 0 ] [ 1 ] = input . nextInt ( ) ; a [ 1 ] [ 0 ] = input . nextInt ( ) ; a [ 1 ] [ 1 ] = input . nextInt ( ) ; a [ 2 ] [ 0 ] = input . nextInt ( ) ; a [ 2 ] [ 1 ] = input . nextInt ( ) ; Arrays . sort ( a , new Comparator < int [ ] > ( ) { @ Override public int compare ( int [ ] t , int [ ] t1 ) { if ( t [ 0 ] - t1 [ 0 ] == 0 ) { return t1 [ 1 ] - t [ 1 ] ; } return t [ 0 ] - t1 [ 0 ] ; } } ) ;",
"import java . io . * ; import java . util . * ; public class Solution { public static void main ( String [ ] args ) throws Exception { int [ ] a = in . readA ( ) ; int [ ] b = in . readA ( ) ; int [ ] c = in . readA ( ) ; System . out . println ( 3 ) ; System . out . println ( getCoord ( a , b , c ) ) ; System . out . println ( getCoord ( c , a , b ) ) ; System . out . println ( getCoord ( b , c , a ) ) ; } public static String getCoord ( int [ ] a , int [ ] b , int [ ] c ) {",
"import java . util . * ; import java . io . * ; import java . io . * ; import java . util . * ; public class MainClass { public static void main ( String args [ ] ) throws IOException { Reader in = new Reader ( ) ; long [ ] X = new long [ 3 ] ; long [ ] Y = new long [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { X [ i ] = in . nextLong ( ) ; Y [ i ] = in . nextLong ( ) ; } int ans = 0 ; StringBuilder stringBuilder = new StringBuilder ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = i + 1 ; j < 3 ; j ++ ) { long xx = X [ i ] + X [ j ] - X [ 3 - i - j ] ; long yy = Y [ i ] + Y [ j ] - Y [ 3 - i - j ] ; if ( ! ( ( xx == X [ i ] && yy == Y [ i ] ) || ( yy == Y [ j ] && xx == X [ j ] ) ) ) { ans ++ ; stringBuilder . append ( xx ) . append ( \" ▁ \" ) . append ( yy ) . append ( \" \\n \" ) ; } } } System . out . println ( ans ) ; System . out . println ( stringBuilder ) ; } } class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ; public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ;",
"import java . util . * ; import java . io . * ; public class Asd { static Scanner s = new Scanner ( System . in ) ; static PrintWriter w = new PrintWriter ( System . out ) ; public static void main ( String args [ ] ) { int t = 1 ;"
] | [
"p = [ ] for i in range ( 3 ) : p . append ( list ( map ( int , input ( ) . split ( ) ) ) ) print ( 3 ) print ( p [ 0 ] [ 0 ] + p [ 1 ] [ 0 ] - p [ 2 ] [ 0 ] , p [ 0 ] [ 1 ] + p [ 1 ] [ 1 ] - p [ 2 ] [ 1 ] ) print ( p [ 0 ] [ 0 ] + p [ 2 ] [ 0 ] - p [ 1 ] [ 0 ] , p [ 0 ] [ 1 ] + p [ 2 ] [ 1 ] - p [ 1 ] [ 1 ] ) print ( p [ 1 ] [ 0 ] + p [ 2 ] [ 0 ] - p [ 0 ] [ 0 ] , p [ 1 ] [ 1 ] + p [ 2 ] [ 1 ] - p [ 0 ] [ 1 ] ) NEW_LINE",
"x = [ ] y = [ ] for i in range ( 3 ) : a , b = input ( ) . split ( ) x . append ( int ( a ) ) y . append ( int ( b ) ) print ( 3 ) for i in range ( 3 ) : print ( str ( sum ( x ) - 2 * x [ i ] ) + ' ▁ ' + str ( sum ( y ) - 2 * y [ i ] ) ) NEW_LINE",
"x1 , y1 = map ( int , input ( ) . split ( ) ) x2 , y2 = map ( int , input ( ) . split ( ) ) x3 , y3 = map ( int , input ( ) . split ( ) ) points = [ ] points . append ( [ x1 + x2 - x3 , y1 + y2 - y3 ] ) if [ x2 + x3 - x1 , y2 + y3 - y1 ] not in points : points . append ( [ x2 + x3 - x1 , y2 + y3 - y1 ] ) if [ x3 + x1 - x2 , y3 + y1 - y2 ] not in points : points . append ( [ x3 + x1 - x2 , y3 + y1 - y2 ] ) print ( len ( points ) ) for m in points : print ( m [ 0 ] , m [ 1 ] ) NEW_LINE"
] |
codeforces_1073_B | [
"import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class a { static int [ ] count , count1 , count2 ; static int [ ] arr ; static char [ ] ch , ch1 ; static int [ ] darr , farr ; static Character [ ] [ ] mat , mat1 ; static long x , h ; static long maxl ; static double dec ; static String s ; static long minl ; static int mx = ( int ) 1e6 ; static long mod = 998244353l ;",
"import java . util . HashMap ; import java . util . Scanner ; public class VasyaAndBooks2 { public static void main ( String [ ] args ) { Scanner entrada = new Scanner ( System . in ) ; String n ;",
"import java . util . Scanner ; public class VasyaBooks { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , i , a [ ] = new int [ n + 1 ] , l = - 1 ; StringBuilder sb = new StringBuilder ( ) ; for ( i = 0 ; i < n ; i ++ ) a [ in . nextInt ( ) ] = i ; for ( i = 0 ; i < n ; i ++ ) { int b = in . nextInt ( ) ; if ( a [ b ] <= l ) { sb . append ( \"0 ▁ \" ) ; } else { sb . append ( ( a [ b ] - l ) + \" ▁ \" ) ; l = a [ b ] ; } } in . close ( ) ; System . out . println ( sb . toString ( ) ) ; } }"
] | [
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) backpack = set ( ) pos = 0 for x in b : if x in backpack : print ( 0 , end = ' ▁ ' ) else : cnt = 0 while True : backpack . add ( a [ pos ] ) cnt += 1 if a [ pos ] == x : break pos += 1 pos += 1 print ( cnt , end = ' ▁ ' ) NEW_LINE",
"I = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE",
"I = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) backpack = set ( ) cur = 0 for x in b : if cur >= n or x in backpack : print ( 0 , end = ' ▁ ' ) else : cnt = 0 while a [ cur ] != x : backpack . add ( a [ cur ] ) cnt += 1 cur += 1 backpack . add ( a [ cur ] ) cur += 1 cnt += 1 print ( cnt , end = ' ▁ ' ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) backpack = set ( ) cur = 0 for x in b : if cur >= n or x in backpack : print ( 0 , end = ' ▁ ' ) else : cnt = 0 while a [ cur + cnt ] != x : backpack . add ( a [ cur + cnt ] ) cnt += 1 backpack . add ( a [ cur + cnt ] ) cnt += 1 cur += cnt print ( cnt , end = ' ▁ ' ) NEW_LINE"
] |
codeforces_1351_B | [
"import java . util . * ; public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int a1 = sc . nextInt ( ) ; int b1 = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int b2 = sc . nextInt ( ) ; boolean check = false ; if ( a1 == a2 ) { if ( b1 + b2 == a1 ) { check = true ; } } if ( a1 == b2 ) { if ( b1 + a2 == a1 ) { check = true ; } } if ( b1 == a2 ) { if ( a1 + b2 == b1 ) { check = true ; } } if ( b1 == b2 ) { if ( a1 + a2 == b1 ) { check = true ; } } if ( check ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } } public static boolean strive ( String s ) { Stack < Character > stack = new Stack < > ( ) ; stack . push ( s . charAt ( 0 ) ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { char ch1 = s . charAt ( i ) ; if ( ch1 == ' ) ' ) { if ( ! stack . isEmpty ( ) && stack . peek ( ) == ' ( ' ) { stack . pop ( ) ; } else { return false ; } } else { stack . push ( ' ( ' ) ; } } return stack . size ( ) == 0 ; } public static int getAns ( int [ ] ar , int bigger , int [ ] [ ] dp , int i , int j ) { if ( i < 0 || j < 0 ) { return 0 ; } if ( dp [ i ] [ j ] != - 1 ) { return dp [ i ] [ j ] ; } int ans1 = 0 , ans2 = 0 , ans3 = 0 ; if ( ar [ i ] < bigger ) { ans1 = 1 + getAns ( ar , ar [ i ] , dp , i - 1 , j ) ;",
"import java . util . * ; public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int a1 = sc . nextInt ( ) ; int b1 = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int b2 = sc . nextInt ( ) ; boolean check = false ; if ( a1 == a2 ) { if ( b1 + b2 == a1 ) { check = true ; } } if ( a1 == b2 ) { if ( b1 + a2 == a1 ) { check = true ; } } if ( b1 == a2 ) { if ( a1 + b2 == b1 ) { check = true ; } } if ( b1 == b2 ) { if ( a1 + a2 == b1 ) { check = true ; } } if ( check ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } } public static boolean strive ( String s ) { Stack < Character > stack = new Stack < > ( ) ; stack . push ( s . charAt ( 0 ) ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { char ch1 = s . charAt ( i ) ; if ( ch1 == ' ) ' ) { if ( ! stack . isEmpty ( ) && stack . peek ( ) == ' ( ' ) { stack . pop ( ) ; } else { return false ; } } else { stack . push ( ' ( ' ) ; } } return stack . size ( ) == 0 ; } public static int getAns ( int [ ] ar , int bigger , int [ ] [ ] dp , int i , int j ) { if ( i < 0 || j < 0 ) { return 0 ; } if ( dp [ i ] [ j ] != - 1 ) { return dp [ i ] [ j ] ; } int ans1 = 0 , ans2 = 0 , ans3 = 0 ; if ( ar [ i ] < bigger ) { ans1 = 1 + getAns ( ar , ar [ i ] , dp , i - 1 , j ) ;",
"import java . util . * ; public class Practise { ",
"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 ) { int a1 = sc . nextInt ( ) ; int b1 = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int b2 = sc . nextInt ( ) ; if ( a1 == a2 && ( b1 + b2 ) == a1 ) { System . out . println ( \" YES \" ) ; } else if ( b1 == b2 && ( a1 + a2 ) == b1 ) { System . out . println ( \" YES \" ) ; } else if ( b1 == a2 && ( a1 + b2 ) == b1 ) { System . out . println ( \" YES \" ) ; } else if ( a1 == b2 && ( a2 + b1 ) == a1 ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } } }"
] | [
"cases = int ( input ( ) ) while cases : cases -= 1 a , b = map ( int , input ( ) . split ( ) ) c , d = map ( int , input ( ) . split ( ) ) if max ( a , b ) == max ( c , d ) == min ( a , b ) + min ( c , d ) : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"t = int ( input ( ) ) for test in range ( t ) : a = list ( sorted ( map ( int , input ( ) . split ( ) ) ) ) b = list ( sorted ( map ( int , input ( ) . split ( ) ) ) ) if a [ 0 ] + b [ 0 ] == a [ 1 ] and a [ 0 ] + b [ 0 ] == b [ 1 ] : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : a1 , b1 = map ( int , input ( ) . split ( ) ) a2 , b2 = map ( int , input ( ) . split ( ) ) m1 = max ( a1 , b1 ) m2 = max ( a2 , b2 ) n1 = a1 if b1 == m1 else b1 n2 = a2 if b2 == m2 else b2 if m1 == m2 and m1 == n1 + n2 : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"import sysdef get_list ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) for i in range ( int ( input ( ) ) ) : a = get_list ( ) a1 = get_list ( ) if max ( a ) == max ( a1 ) : if min ( a ) + min ( a1 ) == max ( a ) : print ( ' Yes ' ) else : print ( ' NO ' ) else : print ( ' NO ' ) NEW_LINE"
] |
codeforces_954_B | [
"import static java . lang . Math . max ; import static java . lang . Math . min ; import static java . lang . Math . abs ; import java . util . * ; import java . io . * ; public class x954B { public static void main ( String hi [ ] ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; char [ ] arr = infile . readLine ( ) . toCharArray ( ) ; int best = 1 ; for ( int len = 1 ; len <= N / 2 ; len ++ ) { boolean works = true ; for ( int i = 0 ; i < len ; i ++ ) if ( arr [ i ] != arr [ i + len ] ) works = false ; if ( works ) best = len ; } System . out . println ( N - best + 1 ) ; } public static int [ ] readArr ( int N , BufferedReader infile , StringTokenizer st ) throws Exception { int [ ] arr = new int [ N ] ; st = new StringTokenizer ( infile . readLine ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; return arr ; } }",
"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 . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import javafx . util . Pair ; public class Main { public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; String s = \" ▁ \" + input . next ( ) ; int i = 1 ; int maxcount = 0 ; while ( i * 2 <= n ) { int stop = i ; int k = stop + 1 ; boolean check = true ; for ( int j = 1 ; j <= stop ; j ++ , k ++ ) { if ( s . charAt ( j ) != s . charAt ( k ) ) { check = false ; } } if ( check ) maxcount = Math . max ( maxcount , i ) ; i ++ ; } System . out . println ( maxcount + ( n - maxcount * 2 ) + ( ( maxcount > 0 ) ? 1 : 0 ) ) ; } 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 = int ( input ( ) ) s = input ( ) ans = 1 for i in range ( 1 , n // 2 + 1 ) : if s [ : i ] == s [ i : 2 * i ] : ans = iprint ( n - ans + 1 ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) word = ' ' biggest_repetition = 1 for i in range ( len ( s ) ) : word += s [ i ] if word in s [ i + 1 : i + len ( word ) + 1 ] : biggest_repetition = max ( biggest_repetition , len ( word ) ) print ( len ( s ) - biggest_repetition + 1 ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) best = nfor i in range ( 2 , n // 2 + 1 ) : if s [ : i ] == s [ i : 2 * i ] : cur = i + 1 + n - 2 * i best = min ( best , cur ) print ( best ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) ans = nfor i in range ( n - 1 , - 1 , - 1 ) : if ( s [ : i // 2 + 1 ] * 2 == s [ : i + 1 ] ) : ans = min ( ans , n - ( ( i + 1 ) // 2 ) + 1 ) breakprint ( ans ) NEW_LINE",
" n = int ( input ( ) ) st = input ( ) i = n // 2 - 1 ; j = 0 for j in range ( i , - 1 , - 1 ) : if st [ 0 : j + 1 ] == st [ j + 1 : 2 * j + 2 ] : breakprint ( n - j ) NEW_LINE"
] |
codeforces_1245_A | [
"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 ) { int g = gcd ( s . nextInt ( ) , s . nextInt ( ) ) ; if ( g > 1 ) { System . out . println ( \" Infinite \" ) ; } else { System . out . println ( \" Finite \" ) ; } } } public static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; } }",
"import java . util . Scanner ; public class _0682GoodolNumbersColoring { static int gcd ( int n1 , int n2 ) { while ( n1 != n2 ) { if ( n1 > n2 ) n1 -= n2 ; else n2 -= n1 ; } return n1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int q = sc . nextInt ( ) ; while ( q > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( gcd ( a , b ) == 1 ) { System . out . println ( \" Finite \" ) ; } else { System . out . println ( \" Infinite \" ) ; } q -- ; } } }",
"import java . util . Scanner ; public class GoodNumbersColoring { 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 ( gcd ( a , b ) == 1 ) System . out . println ( \" Finite \" ) ; else System . out . println ( \" Infinite \" ) ; } } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } }"
] | [
"import math t = int ( input ( ) ) for tc in range ( t ) : a , b = map ( int , input ( ) . split ( ) ) if math . gcd ( a , b ) == 1 : print ( \" Finite \" ) else : print ( \" Infinite \" ) NEW_LINE",
"import mathfor i in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) print ( \" Finite \" ) if ( math . gcd ( a , b ) == 1 ) else print ( \" infinite \" ) NEW_LINE",
"import math def solve ( ) : a , b = map ( int , input ( ) . split ( ) ) if math . gcd ( a , b ) > 1 : print ( ' Infinite ' ) else : print ( ' Finite ' ) t = int ( input ( ) ) for _ in range ( t ) : solve ( ) NEW_LINE",
"I = lambda : map ( int , input ( ) . split ( ) ) INT = lambda : int ( input ( ) ) def gcd ( x , y ) : return x if y == 0 else gcd ( y , x % y ) T = INT ( ) NEW_LINE",
"import mathfor _ in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) if math . gcd ( a , b ) != 1 : print ( \" INFINITE \" ) else : print ( \" FINITE \" ) NEW_LINE"
] |
codeforces_508_A | [
"import java . util . * ; public class ICPC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; boolean [ ] [ ] ar = new boolean [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { ar [ i ] [ j ] = false ; } } List < Integer > list = new ArrayList < > ( ) ; List < Integer > list1 = new ArrayList < > ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int n1 = sc . nextInt ( ) - 1 ; int n2 = sc . nextInt ( ) - 1 ; list . add ( n1 ) ; list1 . add ( n2 ) ; } for ( int i = 0 ; i < k ; i ++ ) { int n1 = list . get ( i ) ; int n2 = list1 . get ( i ) ; ar [ n1 ] [ n2 ] = true ; int x1 = n1 ; int y1 = n2 + 1 ; int x2 = n1 + 1 ; int y2 = n2 ; int x3 = n1 + 1 ; int y3 = n2 + 1 ;"
] | [
"def check ( board , n , m , i , j ) : if i < n - 1 and j < m - 1 and board [ i ] [ j ] and board [ i ] [ j + 1 ] and board [ i + 1 ] [ j ] and board [ i + 1 ] [ j + 1 ] : return True if i < n - 1 and j > 0 and board [ i ] [ j ] and board [ i ] [ j - 1 ] and board [ i + 1 ] [ j ] and board [ i + 1 ] [ j - 1 ] : return True if i > 0 and j < m - 1 and board [ i ] [ j ] and board [ i ] [ j + 1 ] and board [ i - 1 ] [ j ] and board [ i - 1 ] [ j + 1 ] : return True if i > 0 and j > 0 and board [ i ] [ j ] and board [ i ] [ j - 1 ] and board [ i - 1 ] [ j ] and board [ i - 1 ] [ j - 1 ] : return True return False n , m , k = [ int ( s ) for s in input ( ) . split ( ) ] board = [ [ False ] * m for _ in range ( n ) ] ans = 0 for r in range ( k ) : i , j = [ int ( s ) - 1 for s in input ( ) . split ( ) ] board [ i ] [ j ] = True if check ( board , n , m , i , j ) : ans = r + 1 breakprint ( ans ) NEW_LINE",
"n , m , k = map ( int , input ( ) . split ( ) ) l = [ [ 0 for i in range ( m + 2 ) ] for j in range ( n + 2 ) ] def check ( r , c ) : return l [ r ] [ c ] and l [ r ] [ c + 1 ] and l [ r + 1 ] [ c ] and l [ r + 1 ] [ c + 1 ] for i in range ( k ) : x , y = map ( int , input ( ) . split ( ) ) l [ x ] [ y ] = 1 ans = check ( x , y ) or check ( x , y - 1 ) or check ( x - 1 , y - 1 ) or check ( x - 1 , y ) if ans : print ( i + 1 ) breakelse : print ( 0 ) NEW_LINE",
"import sysimport mathimport bisect def query ( A , x , y ) : n = len ( A ) m = len ( A [ 0 ] ) if x >= 0 and x + 1 < n and y >= 0 and y + 1 < m : cnt = 0 if A [ x ] [ y ] == 1 : cnt += 1 if A [ x ] [ y + 1 ] == 1 : cnt += 1 if A [ x + 1 ] [ y ] == 1 : cnt += 1 if A [ x + 1 ] [ y + 1 ] == 1 : cnt += 1 if cnt == 4 : return True return False def main ( ) : n , m , q = map ( int , input ( ) . split ( ) ) A = [ ] for i in range ( n ) : A . append ( [ 0 ] * m ) ans = 0 for i in range ( q ) : x , y = map ( int , input ( ) . split ( ) ) x -= 1 y -= 1 if A [ x ] [ y ] == 0 : A [ x ] [ y ] = 1 if query ( A , x - 1 , y - 1 ) : ans = i + 1 break if query ( A , x - 1 , y ) : ans = i + 1 break if query ( A , x , y - 1 ) : ans = i + 1 break if query ( A , x , y ) : ans = i + 1 break ''' ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' x : ▁ % d , ▁ y : ▁ % d ' ▁ % ▁ ( x , ▁ y ) ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( n ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' A [ % d ] : ▁ % s ' ▁ % ▁ ( j , ▁ str ( A [ j ] ) ) ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ''' print ( ans ) if __name__ == \" _ _ main _ _ \" : main ( ) NEW_LINE",
"R = lambda : map ( int , input ( ) . split ( ) ) n , m , k = R ( ) N = 1024 g = [ [ 0 ] * N for _ in range ( N ) ] def T ( r , c ) : return g [ r ] [ c ] and g [ r + 1 ] [ c ] and g [ r ] [ c + 1 ] and g [ r + 1 ] [ c + 1 ] for i in range ( k ) : r , c = R ( ) g [ r ] [ c ] = 1 if T ( r - 1 , c - 1 ) or T ( r - 1 , c ) or T ( r , c - 1 ) or T ( r , c ) : print ( i + 1 ) breakelse : print ( 0 ) NEW_LINE",
"n , m , k = map ( int , input ( ) . split ( ) ) flag = 0 d = set ( ) for i in range ( k ) : x , y = map ( int , input ( ) . split ( ) ) d . add ( ( x , y ) ) for j in [ - 1 , 0 ] : for k in [ - 1 , 0 ] : if all ( ( x + j + a , y + k + b ) in d for a in [ 0 , 1 ] for b in [ 0 , 1 ] ) : if not flag : print ( i + 1 ) flag = 1 if not flag : print ( 0 ) NEW_LINE"
] |
codeforces_343_B | [
"import java . io . * ; import java . util . * ; import java . util . stream . * ; public class ACM { public static void main ( String args [ ] ) throws FileNotFoundException , IOException { Scanner x = new Scanner ( System . in ) ; Stack < Character > s = new Stack < Character > ( ) ; String str = x . next ( ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( s . empty ( ) ) s . push ( str . charAt ( i ) ) ; else if ( s . peek ( ) . equals ( str . charAt ( i ) ) ) s . pop ( ) ; else s . push ( str . charAt ( i ) ) ; }",
"import java . io . * ; import java . util . * ; import java . util . stream . * ; public class ACM { public static void main ( String args [ ] ) throws FileNotFoundException , IOException { Scanner x = new Scanner ( System . in ) ; String s = x . next ( ) ; StackDynamicArray < Character > sd = new StackDynamicArray < Character > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( sd . isEmpty ( ) ) sd . push ( s . charAt ( i ) ) ; else if ( sd . topp ( ) . equals ( s . charAt ( i ) ) ) sd . pop ( ) ; else sd . push ( s . charAt ( i ) ) ; }",
"import java . util . * ; public class BAlternatingCurrent { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int n = s . length ( ) ; if ( n % 2 == 0 ) { int stk = 0 ; for ( int i = 0 ; i < n ; i += 2 ) { if ( s . charAt ( i ) == ' - ' && s . charAt ( i + 1 ) == ' + ' ) stk ++ ; if ( s . charAt ( i ) == ' + ' && s . charAt ( i + 1 ) == ' - ' ) stk -- ; } if ( stk == 0 ) { System . out . println ( \" Yes \" ) ; return ; } } System . out . println ( \" No \" ) ; } }",
"import java . util . Stack ; public class p343B { public static void main ( String [ ] args ) { Stack < Character > st = new Stack < > ( ) ; char pre = ' ▁ ' ; for ( char c : new java . util . Scanner ( System . in ) . next ( ) . toCharArray ( ) ) { if ( c == pre ) st . pop ( ) ; else st . add ( c ) ; if ( ! st . isEmpty ( ) ) pre = st . peek ( ) ; else pre = ' ▁ ' ; } System . out . println ( st . empty ( ) ? \" Yes \" : \" No \" ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . IOException ; import java . util . Stack ; 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 ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , InputReader in , PrintWriter out ) {"
] | [
"import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 ** 9 + 7 NEW_LINE",
"secuencia = input ( ) plus = secuencia . count ( \" + \" ) minus = secuencia . count ( \" - \" ) if len ( secuencia ) % 2 == 0 : if ( secuencia == secuencia [ : : - 1 ] ) : print ( \" Yes \" ) else : if plus % 2 == 0 and minus % 2 == 0 : largo = len ( secuencia ) // 2 if ( \" + + \" in secuencia ) or ( \" - - \" in secuencia ) : for i in range ( 0 , largo ) : NEW_LINE",
"secuencia = input ( ) plus = secuencia . count ( \" + \" ) minus = secuencia . count ( \" - \" ) if len ( secuencia ) % 2 == 0 : if ( secuencia == secuencia [ : : - 1 ] ) : print ( \" Yes \" ) else : if plus % 2 == 0 and minus % 2 == 0 : largo = len ( secuencia ) // 2 if ( \" + + \" in secuencia ) or ( \" - - \" in secuencia ) : for i in range ( 0 , largo ) : try : secuencia = secuencia . replace ( \" + + \" , \" \" ) secuencia = secuencia . replace ( \" - - \" , \" \" ) continue except : continue if secuencia == \" \" : print ( \" Yes \" ) else : print ( \" No \" ) else : print ( \" No \" ) else : print ( \" No \" ) else : print ( \" No \" ) NEW_LINE",
"secuencia = input ( ) plus = secuencia . count ( \" + \" ) minus = secuencia . count ( \" - \" ) if len ( secuencia ) % 2 == 0 : if ( secuencia == secuencia [ : : - 1 ] ) : print ( \" Yes \" ) else : if plus % 2 == 0 and minus % 2 == 0 : largo = len ( secuencia ) // 2 if \" + + \" in secuencia or \" - - \" in secuencia : for i in range ( 0 , largo ) : NEW_LINE"
] |
codeforces_1201_A | [
"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; s . nextLine ( ) ; String a [ ] = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextLine ( ) ; int b [ ] = new int [ m ] ; for ( int j = 0 ; j < m ; j ++ ) b [ j ] = s . nextInt ( ) ; HashMap < Character , Integer > h1 = new HashMap < > ( ) ; h1 . put ( ' A ' , 0 ) ; h1 . put ( ' B ' , 1 ) ; h1 . put ( ' C ' , 2 ) ; h1 . put ( ' D ' , 3 ) ; h1 . put ( ' E ' , 4 ) ; int r [ ] = new int [ 5 ] ; int r1 [ ] = new int [ m ] ; int p = 0 ; for ( int k = 0 ; k < m ; k ++ ) { for ( int k1 = 0 ; k1 < n ; k1 ++ ) { int u = h1 . get ( a [ k1 ] . charAt ( k ) ) ; r [ u ] = r [ u ] + 1 ; } r1 [ k ] = max ( r ) ; for ( int g = 0 ; g < 5 ; g ++ ) r [ g ] = 0 ; } int sum = 0 ; for ( p = 0 ; p < m ; p ++ ) { sum = sum + ( r1 [ p ] * b [ p ] ) ; } System . out . println ( sum ) ; } public static int max ( int r [ ] ) { int max = 0 ; for ( int i = 0 ; i < r . length ; i ++ ) { if ( r [ i ] > max ) max = r [ i ] ; } return max ; } }",
"import java . util . * ; public class M_Round_1 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; String ans [ ] = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) ans [ i ] = sc . next ( ) ; int points [ ] = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) points [ i ] = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int count [ ] = new int [ 5 ] ; for ( int j = 0 ; j < n ; j ++ ) count [ ans [ j ] . charAt ( i ) - ' A ' ] ++ ; int max = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) max = Math . max ( max , count [ j ] ) ; sum += points [ i ] * max ; } System . out . println ( sum ) ; } }",
"import java . util . * ; public class ICPC { public static void main ( String [ ] args ) {",
" import java . util . * ; import java . lang . * ; import java . io . * ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; char mat [ ] [ ] = new char [ n ] [ m ] ; for ( int i = 0 ; i < n ; ++ i ) { String temp = sc . next ( ) ; for ( int j = 0 ; j < m ; ++ j ) { mat [ i ] [ j ] = temp . charAt ( j ) ; } } int arr [ ] = new int [ m ] ; for ( int i = 0 ; i < m ; ++ i ) { arr [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < m ; ++ i ) { int ash [ ] = new int [ 5 ] ; for ( int j = 0 ; j < n ; ++ j ) { if ( mat [ j ] [ i ] == ' A ' ) { ash [ 0 ] = ash [ 0 ] + 1 ; } if ( mat [ j ] [ i ] == ' B ' ) { ash [ 1 ] = ash [ 1 ] + 1 ; } if ( mat [ j ] [ i ] == ' C ' ) { ash [ 2 ] = ash [ 2 ] + 1 ; } if ( mat [ j ] [ i ] == ' D ' ) { ash [ 3 ] = ash [ 3 ] + 1 ; } if ( mat [ j ] [ i ] == ' E ' ) { ash [ 4 ] = ash [ 4 ] + 1 ; } } int maxi = 0 ; for ( int k = 0 ; k < 5 ; ++ k ) { maxi = Math . max ( maxi , ash [ k ] ) ; } ans = ans + maxi * arr [ i ] ; } System . out . println ( ans ) ; } }",
"import java . util . * ; public class important_exam { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int A [ ] = new int [ m ] ; String S [ ] = new String [ n ] ; sc . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { S [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int score = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int frequency = 0 ; int acount = 0 , bcount = 0 , ccount = 0 , dcount = 0 , ecount = 0 ; for ( int j = 0 ; j < n ; j ++ ) { char ch = S [ j ] . charAt ( i ) ; switch ( ch ) { case ' A ' : acount ++ ; break ; case ' B ' : bcount ++ ; break ; case ' C ' : ccount ++ ; break ; case ' D ' : dcount ++ ; break ; case ' E ' : ecount ++ ; break ; default : frequency = 0 ; } } frequency = Math . max ( acount , Math . max ( bcount , Math . max ( ccount , Math . max ( dcount , ecount ) ) ) ) ; score += A [ i ] * frequency ; } System . out . println ( score ) ; } }"
] | [
"import collectionscases , n = map ( int , input ( ) . split ( ) ) marks = [ ] while cases : cases -= 1 s = list ( input ( ) ) marks . append ( s ) arr = list ( map ( int , input ( ) . split ( ) ) ) traverse = [ [ marks [ i ] [ j ] for i in range ( len ( marks ) ) ] for j in range ( len ( marks [ 0 ] ) ) ] ans = 0 for n , m in zip ( arr , traverse ) : count = collections . Counter ( m ) mx = max ( count . values ( ) ) ans += mx * n print ( ans ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) s = [ ] for i in range ( n ) : s . append ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 for i in range ( k ) : b = [ 0 ] * 5 for j in range ( n ) : b [ ord ( s [ j ] [ i ] ) - ord ( ' A ' ) ] += 1 tmp = 0 for j in range ( 5 ) : tmp = max ( tmp , b [ j ] ) ans += tmp * a [ i ] print ( ans ) NEW_LINE",
"students , question = map ( int , input ( ) . split ( ) ) final_list = [ ] for each in range ( 0 , students ) : final_list . append ( input ( ) ) value = list ( map ( int , input ( ) . split ( ) ) ) i = 0 score = 0 for each in range ( 0 , question ) : count_list = [ 0 ] * 5 for ans_student in final_list : count_list [ ord ( ans_student [ i ] ) - 65 ] += value [ i ] score = score + max ( count_list ) i += 1 print ( score ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) s = [ ] ans = 0 for i in range ( n ) : l = input ( ) s . append ( l ) marks = list ( map ( int , input ( ) . split ( ) ) ) t = { ' A ' : 0 , ' B ' : 1 , ' C ' : 2 , ' D ' : 3 , ' E ' : 4 } for i in range ( m ) : d = [ 0 , 0 , 0 , 0 , 0 ] for j in range ( n ) : d [ t . get ( s [ j ] [ i ] ) ] += 1 ans += max ( d ) * marks [ i ] print ( ans ) NEW_LINE"
] |
codeforces_1300_A | [
"import java . util . * ; public class A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tc = sc . nextInt ( ) ; for ( ; tc > 0 ; tc -- ) { int n = sc . nextInt ( ) ; int zero = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int x = sc . nextInt ( ) ; if ( x == 0 ) zero ++ ; sum += x ; } if ( zero == 0 && sum != 0 ) { System . out . println ( 0 ) ; continue ; } if ( zero == 0 && sum == 0 ) { System . out . println ( 1 ) ; continue ; } sum += zero ; if ( sum == 0 ) zero ++ ; System . out . println ( zero ) ; } } }",
"import java . util . * ; public class questionCF { 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 ] ; int sum = 0 , count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] == 0 ) { a [ i ] = 1 ; count ++ ; } } for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; if ( sum == 0 ) System . out . println ( ++ count ) ; else System . out . println ( count ) ; } } }",
"import java . util . * ; import java . io . * ; import java . math . * ; public class A { private static long INF = 2000000000000000000L , M = 1000000007 , MM = 998244353 ; private static int N = 0 ; public static void process ( ) throws IOException { int n = sc . nextInt ( ) ; int arr [ ] = sc . readArray ( n ) ; int zero = 0 ; int sum = 0 ; for ( int e : arr ) { if ( e == 0 ) zero ++ ; sum += e ; } if ( zero > 0 ) { sum += zero ; } if ( sum == 0 ) { System . out . println ( zero + 1 ) ; } else { System . out . println ( zero ) ; } } ",
"import java . math . * ; 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 ( ) ;"
] | [
"I = inputexec ( int ( I ( ) ) * \" I ( ) ; a = [ * map ( int , I ( ) . split ( ) ) ] ; s = a . count ( 0 ) ; print ( s + ( s + sum ( a ) = = 0 ) ) ; \" ) NEW_LINE",
"''' ▁ 1300a ▁ Non ▁ zero ''' for _ in range ( int ( input ( ) ) ) : input ( ) arr = [ int ( x ) for x in input ( ) . split ( ) ] ch = 0 for i , x in enumerate ( arr ) : ch += x == 0 arr [ i ] += x == 0 print ( ch + int ( sum ( arr ) == 0 ) ) NEW_LINE",
"def string_to_list ( s , char ) : collector = \" \" output_list = [ ] for i in range ( len ( s ) ) : if s [ i ] != char : collector += s [ i ] if i == len ( s ) - 1 : output_list . append ( int ( collector ) ) else : output_list . append ( int ( collector ) ) collector = \" \" return output_list NEW_LINE",
"def q1300a ( ) : n = int ( input ( ) ) for _ in range ( n ) : arr_len = int ( input ( ) ) arr = [ int ( num ) for num in input ( ) . split ( ) ] subproblem ( arr_len , arr ) def subproblem ( arr_len , arr ) : zero_count = 0 for i in range ( len ( arr ) ) : if ( arr [ i ] == 0 ) : zero_count += 1 arr [ i ] = 1 if ( sum ( arr ) == 0 ) : zero_count += 1 print ( zero_count ) q1300a ( ) NEW_LINE"
] |
codeforces_323_A | [
"import java . io . * ; public class CF2 { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; Task solver = new Task ( ) ; solver . solve ( br , pw ) ; pw . close ( ) ; } static class Task { public void solve ( BufferedReader br , PrintWriter pw ) throws IOException { int n = Integer . parseInt ( br . readLine ( ) ) ; if ( n % 2 == 1 ) { pw . println ( - 1 ) ; return ; } int rowLen = 2 ; StringBuilder layer = new StringBuilder ( \" bb \\n \" + \" bb \\n \" ) ; int numRows = 2 ; boolean black = false ; int end = ( n - 2 ) / 2 ; for ( int i = 0 ; i < end ; i ++ ) { char c = black ? ' b ' : ' w ' ; int start = 0 ; for ( int j = 0 ; j < numRows ; j ++ ) { layer . insert ( start , c ) ; start += rowLen + 1 ; layer . insert ( start , c ) ; start += 2 ; } rowLen += 2 ; numRows += 2 ; StringBuilder row = new StringBuilder ( ) ; for ( int j = 0 ; j < rowLen ; j ++ ) { row . append ( c ) ; } row . append ( \" \\n \" ) ; layer . insert ( 0 , row ) ; layer . append ( row ) ; black = ! black ; } StringBuilder layer2 = new StringBuilder ( ) ; for ( int i = 0 ; i < layer . length ( ) ; i ++ ) { if ( layer . charAt ( i ) == ' b ' ) { layer2 . append ( ' w ' ) ; } else if ( layer . charAt ( i ) == ' w ' ) { layer2 . append ( ' b ' ) ; } else { layer2 . append ( layer . charAt ( i ) ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { pw . println ( layer ) ; } else { pw . println ( layer2 ) ; } } } } }",
"import java . io . * ; import java . lang . reflect . Array ; import java . math . * ; import java . util . * ; public class icpc { public static void main ( String [ ] args ) throws IOException { Reader in = new Reader ( ) ;"
] | [
"import sys , mathreadline = sys . stdin . readline k = int ( readline ( ) ) if k % 2 : print ( - 1 ) else : for i in range ( k ) : for j in range ( k ) : s = ' ' if ( i // 2 + j ) & 1 : s = ' wwbb ' * ( k // 4 ) if k % 4 != 0 : s += ' ww ' else : s = ' bbww ' * ( k // 4 ) if k % 4 != 0 : s += ' bb ' print ( s ) NEW_LINE",
"class CodeforcesTask323ASolution : def __init__ ( self ) : self . result = ' ' self . k = 0 def read_input ( self ) : self . k = int ( input ( ) ) def process_task ( self ) : if self . k % 2 : self . result = \" - 1\" elif self . k == 2 : self . result = \" bb \\n ww \\n \\n bb \\n ww \" else : level = \" b \" cube = [ [ [ None for y in range ( self . k ) ] for x in range ( self . k ) ] for z in range ( self . k ) ] for z in range ( self . k ) : level = \" w \" if z % 2 else \" b \" for k in range ( self . k // 2 ) : NEW_LINE"
] |
codeforces_77_B | [
"import java . io . * ; import java . util . * ; public class code implements Runnable {",
"# include < iostream > # include < cstdio > # include < cmath > using namespace std ; typedef long long ll ; const int maxn = 300005 ; ",
"for i in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) print ( 0.5 + a / ( b << 4 ) if 4 * b > a else 1 - b / a if a else 1 )",
"import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; public class FallingAnvils { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader sc = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Solver solver = new Solver ( ) ; int t = sc . nextInt ( ) ;"
] | [
"def li ( ) : return list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) NEW_LINE for _ in range ( int ( input ( ) ) ) : a , b = li ( ) NEW_LINE if b != 0 and a != 0 : s = ( max ( 0 , a - 4 * b ) + a ) / 2 NEW_LINE s *= min ( ( a / 4 ) , b ) NEW_LINE ans = 1 / 2 + s / ( 2 * a * b ) NEW_LINE print ( \" { : . 8f } \" . format ( ans ) ) elif b == 0 : print ( 1 ) else : print ( 0.5 ) NEW_LINE",
"from fractions import Fractiont = int ( input ( ) ) NEW_LINE for _ in range ( t ) : a , b = map ( lambda x : Fraction ( x ) , input ( ) . split ( ' ▁ ' ) ) NEW_LINE if b == 0 : print ( 1 ) NEW_LINE continue elif a == 0 : print ( 0.5 ) NEW_LINE continue up = a * ( b + b + a / 4 ) / 2 - max ( 0 , a - 4 * b ) * ( a / 4 - b ) / 2 NEW_LINE down = a * 2 * b NEW_LINE print ( float ( up / down ) ) NEW_LINE",
"for i in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 0.5 + a / ( b << 4 ) if 4 * b > a else 1 - b / a if a else 1 ) NEW_LINE",
"t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : a , b = map ( float , input ( ) . split ( ) ) NEW_LINE if b == 0.0 : NEW_LINE INDENT print ( 1.0 ) elif a == 0.0 : NEW_LINE print ( 0.5 ) elif a / 4.0 <= b : NEW_LINE print ( ( a + 8.0 * b ) / 16.0 / b ) else : NEW_LINE print ( 1.0 - b / a ) NEW_LINE DEDENT"
] |
codeforces_535_B | [
"import java . io . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ;",
"import java . io . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ;",
"import java . util . * ; public class Absolutezero { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int size = 0 ; int cop = n ; while ( cop != 0 ) { cop /= 10 ; size ++ ; } if ( size != 1 ) { long h = ( long ) ( 2 * ( Math . pow ( 2 , size - 1 ) - 1 ) ) ; int c1 = 0 ; long g = 0 ; while ( n != 0 ) { int d = n % 10 ; if ( d == 7 ) { g = ( long ) ( g + Math . pow ( 2 , c1 ) ) ; } n /= 10 ; c1 ++ ; }",
"import javax . print . DocFlavor ; import javax . swing . * ; import java . awt . image . BandedSampleModel ; import java . util . * ; public class Example { static long [ ] [ ] dp ;"
] | [
"try : n = input ( ) length = len ( n ) ans = ( 1 << length ) - 2 count = 0 for i in range ( length - 1 , - 1 , - 1 ) : if n [ i ] == \"7\" : ans += ( 1 << count ) count += 1 print ( ans + 1 ) except EOFError as e : print ( \" ▁ \" ) NEW_LINE",
"def answer ( n ) : l = len ( str ( n ) ) lst = [ ] mask = 0 NEW_LINE",
"s = input ( ) n = len ( s ) base = 0 for i in range ( 0 , n ) : base = base + 2 ** inews = \" \" for c in s : if c == '4' : news = news + '0' else : news = news + '1' news = '0b ' + newsprint ( int ( news , 2 ) + base ) NEW_LINE",
"s = input ( ) ans = 0 n = len ( s ) for i in range ( 1 , n ) : ans += pow ( 2 , i ) for i in range ( 0 , n ) : if ( s [ i ] == '7' ) : ans += pow ( 2 , n - 1 - i ) print ( ans + 1 ) NEW_LINE",
"s = input ( ) ans = 0 n = len ( s ) for i in range ( 1 , n ) : ans += pow ( 2 , i ) for i in range ( 0 , n ) : if ( s [ i ] == '7' ) : ans += pow ( 2 , n - 1 - i ) print ( ans + 1 ) NEW_LINE"
] |
codeforces_1066_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Vova_and_Train { static class RealScanner { 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 ) { RealScanner sc = new RealScanner ( ) ; int n = sc . nextInt ( ) ; while ( n -- > 0 ) { int a , b , c , d ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; d = sc . nextInt ( ) ; int divVal = a / b ; int fast = ( c - 1 ) / b ; int preFast = d / b ; System . out . println ( divVal - ( preFast - fast ) ) ;",
"import java . util . * ; import java . math . * ; public class VovaAndTrain { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { long l1 = sc . nextLong ( ) ; long v = sc . nextLong ( ) ; long l2 = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long first = l1 / v ; long second = ( r / v ) - ( ( l2 - 1 ) / v ) ; System . out . println ( first - second ) ; } } }",
"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 long oo = ( long ) 1e12 ; static int get ( int a , int b , int m ) { if ( a % m == 0 ) return ( b / m ) - ( a / m ) + 1 ; return ( b / m ) - ( a / m ) ; } public static void solve ( ) throws Exception { int l = f . ni ( ) ; int v = f . ni ( ) ; int a = f . ni ( ) ; int b = f . ni ( ) ; int cnt1 = get ( 1 , l , v ) ; int cnt2 = get ( a , b , v ) ; int ans = cnt1 - cnt2 ; pn ( ans ) ; } public static void main ( String [ ] args ) throws Exception { if ( memory ) new Thread ( null , new Runnable ( ) { public void run ( ) { try { new Main ( ) . run ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } } } , \" \" , 1 << 28 ) . start ( ) ; else new Main ( ) . run ( ) ; } void run ( ) throws Exception { if ( System . getProperty ( \" ONLINE _ JUDGE \" ) == null ) { f = new FastScanner ( \" \" ) ; pw = new PrintWriter ( System . out ) ; } else { f = new FastScanner ( ) ; pw = new PrintWriter ( System . out ) ;"
] | [
"t = int ( input ( ) ) for _ in range ( 0 , t ) : L , v , l , r = map ( int , input ( ) . split ( ) ) s = l // v + L // v - r // v if ( l % v == 0 ) : s -= 1 print ( s ) NEW_LINE",
"t = int ( input ( ) ) while t > 0 : t = t - 1 a = list ( map ( int , input ( ) . split ( ) ) ) L = a [ 0 ] v = a [ 1 ] l = a [ 2 ] r = a [ 3 ] ans = int ( 0 ) ans = int ( L / v ) - ( int ( r / v ) - int ( ( l - 1 ) / v ) ) print ( ans ) NEW_LINE",
"t = int ( input ( ) ) while t >= 1 : t = t - 1 a = list ( map ( int , input ( ) . split ( ) ) ) L = a [ 0 ] v = a [ 1 ] l = a [ 2 ] r = a [ 3 ] ans = int ( 0 ) ans = int ( L / v ) - ( int ( r / v ) - int ( ( l - 1 ) / v ) ) print ( ans ) NEW_LINE",
"from math import ceilfor _ in range ( int ( input ( ) ) ) : L , v , l , r = map ( int , input ( ) . split ( ) ) c = ceil ( l / v ) - 1 c += ( L // v ) - ceil ( r // v ) print ( c ) NEW_LINE",
"import sysimport bisectdef gcd ( a , b ) : if ( a == 0 ) : return b return gcd ( b % a , a ) def input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( str , input ( ) . split ( ) ) ) for _ in range ( iinput ( ) ) : L , v , l , r = minput ( ) print ( L // v + ( l - 1 ) // v - r // v ) NEW_LINE"
] |
codeforces_622_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Scanner ; import java . util . StringTokenizer ; import static java . lang . Math . max ; import java . util . HashSet ; public class Test {",
"import java . util . Scanner ; public class Polikarp { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . next ( ) ; int a = input . nextInt ( ) ; char c = s . charAt ( 0 ) ; char t = s . charAt ( 1 ) ; char g = s . charAt ( 3 ) ; char f = s . charAt ( 4 ) ; String h = c + \" \" + t ; String v = g + \" \" + f ; int n = Integer . parseInt ( h ) ; int y = Integer . parseInt ( v ) ; int b = ( ( n * 60 + y + a ) % 1440 ) ; if ( b / 60 < 10 && b % 60 >= 10 ) { System . out . println ( \"0\" + b / 60 + \" : \" + b % 60 ) ; } if ( b / 60 >= 10 && b % 60 < 10 ) { System . out . println ( b / 60 + \" : \" + \"0\" + b % 60 ) ; } if ( b / 60 >= 10 && b % 60 >= 10 ) { System . out . println ( b / 60 + \" : \" + b % 60 ) ; } if ( b / 60 < 10 && b % 60 < 10 ) { System . out . println ( \"0\" + b / 60 + \" : \" + \"0\" + b % 60 ) ; } } }",
" import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String m = sc . next ( ) ; int n = sc . nextInt ( ) ; String input [ ] = m . split ( \" : \" ) ; int hour = Integer . parseInt ( input [ 0 ] ) ; int min = Integer . parseInt ( input [ 1 ] ) ; hour += n / 60 ; min += n % 60 ; if ( min >= 60 ) { hour ++ ; min %= 60 ; } hour %= 24 ; String hour1 = String . valueOf ( hour ) ; String min1 = String . valueOf ( min ) ; if ( hour < 10 ) hour1 = \"0\" + hour1 ; if ( min < 10 ) min1 = \"0\" + min1 ; System . out . println ( hour1 + \" : \" + min1 ) ; } }",
"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 long oo = ( long ) 1e18 ; public static void solve ( ) throws Exception { String inp [ ] = f . next ( ) . split ( \" : \" ) ; int h = Integer . parseInt ( inp [ 0 ] ) ; int m = Integer . parseInt ( inp [ 1 ] ) ; int a = f . ni ( ) ; for ( int i = 0 ; i < a ; ++ i ) { ++ m ; if ( m == 60 ) { m = 0 ; ++ h ; if ( h == 24 ) h = 0 ; } } if ( h < 10 ) p ( \"0\" + h + \" : \" ) ; else p ( h + \" : \" ) ; if ( m < 10 ) p ( \"0\" + m ) ; else p ( m ) ; } public static void main ( String [ ] args ) throws Exception { if ( memory ) new Thread ( null , new Runnable ( ) { public void run ( ) { try { new Main ( ) . run ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } } } , \" \" , 1 << 28 ) . start ( ) ; else new Main ( ) . run ( ) ; } void run ( ) throws Exception { if ( System . getProperty ( \" ONLINE _ JUDGE \" ) == null ) { f = new FastScanner ( \" \" ) ; pw = new PrintWriter ( System . out ) ; } else { f = new FastScanner ( ) ; pw = new PrintWriter ( System . out ) ;",
"import java . util . * ; public class CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int n = sc . nextInt ( ) ; int index = s . indexOf ( \" : \" ) ; int h = Integer . parseInt ( s . substring ( 0 , index ) ) ; int m = Integer . parseInt ( s . substring ( index + 1 ) ) ; int givenmtoh = n / 60 ; h = ( h + givenmtoh ) % 24 ; int minl = n % 60 ; int fm = ( m + minl ) ; h = ( h + fm / 60 ) % 24 ; m = fm % 60 ; String h1 = h + \" \" ; String m1 = m + \" \" ; if ( h >= 0 && h <= 9 ) { h1 = \"0\" + h1 ; } if ( m >= 0 && m <= 9 ) { m1 = \"0\" + m1 ; } System . out . println ( h1 + \" : \" + m1 ) ; } public static void minDfs ( boolean [ ] visited , int num , List < List < Integer > > lists ) { visited [ num ] = true ;"
] | [
"s = input ( ) . split ( ' : ' ) n = int ( input ( ) ) s = int ( s [ 0 ] ) * 60 + int ( s [ 1 ] ) + n if ( s >= 24 * 60 ) : s %= ( 24 * 60 ) hr = str ( s // 60 ) . rjust ( 2 , '0' ) s %= 60 mi = str ( s ) . rjust ( 2 , '0' ) print ( f \" { hr } : { mi } \" ) NEW_LINE",
"h , m = [ int ( x ) for x in input ( ) . split ( ' : ' ) ] a = int ( input ( ) ) hrs = a // 60 h += hrsa = a - ( 60 * hrs ) m += aif m >= 60 : m -= 60 h += 1 t = str ( h % 24 ) . zfill ( 2 ) + ' : ' + str ( m ) . zfill ( 2 ) print ( t ) NEW_LINE"
] |
codeforces_40_A | [
"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 ) ; Task_random_1 solver = new Task_random_1 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task_random_1 { public void solve ( int testNumber , InputReader in , OutputWriter out ) { int x = in . nextInt ( ) , y = in . nextInt ( ) ; ",
"import java . util . * ; import java . lang . * ; import java . math . * ; import java . awt . image . ConvolveOp ; import java . io . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; import java . util . * ; public class Codeforces { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader sc = new FastReader ( ) ; static int pInf = Integer . MAX_VALUE ; static int nInf = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int test = 1 ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class FindColor { public static void main ( String [ ] args ) throws IOException { BufferedReader entrada = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int x , y ; StringTokenizer linea = new StringTokenizer ( entrada . readLine ( ) ) ; x = Integer . parseInt ( linea . nextToken ( ) ) ; y = Integer . parseInt ( linea . nextToken ( ) ) ; calcColor ( x , y ) ; } public static void calcColor ( int x , int y ) { double ratio = calcRatio ( x , y ) , aux = Math . floor ( ratio ) ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class FindColor { public static void main ( String [ ] args ) throws IOException { BufferedReader entrada = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int x , y ; StringTokenizer linea = new StringTokenizer ( entrada . readLine ( ) ) ; x = Integer . parseInt ( linea . nextToken ( ) ) ; y = Integer . parseInt ( linea . nextToken ( ) ) ; calcColor ( x , y ) ; } public static void calcColor ( int x , int y ) { double ratio = calcRatio ( x , y ) , aux = Math . floor ( ratio ) ;"
] | [
"from math import sqrtx , y = list ( map ( int , input ( ) . split ( ) ) ) l = sqrt ( x ** 2 + y ** 2 ) if x * y > 0 : if l % 2 > 1 : print ( ' white ' ) else : print ( ' black ' ) else : if 1 > l % 2 > 0 : print ( ' white ' ) else : print ( ' black ' ) NEW_LINE",
"def findcolor ( x , p ) : i = 0 while i * i < x * x + p * p : i += 1 l = 0 if ( i * i == x * x + p * p ) or ( x * p >= 0 ) != ( i % 2 == 0 ) : l = 1 print ( \" black \" ) if l else print ( \" white \" ) x , p = map ( int , input ( ) . split ( ) ) findcolor ( x , p ) NEW_LINE",
"from math import sqrt , floorx , y = map ( int , input ( ) . split ( ) ) rmin = floor ( sqrt ( x ** 2 + y ** 2 ) ) if x ** 2 + y ** 2 == rmin ** 2 : print ( \" black \" ) else : if x >= 0 and y >= 0 or x <= 0 and y <= 0 : print ( \" white \" if rmin % 2 else \" black \" ) else : print ( \" white \" if rmin % 2 == 0 else \" black \" ) NEW_LINE",
"import mathimport sys x , y = map ( int , input ( ) . split ( ) ) is_right = ( x * y >= 0 ) r = ( x ** 2 + y ** 2 ) ** 0.5 if r % 1 == 0 : print ( \" black \" ) else : if is_right : if r % 2 > 1 : print ( \" white \" ) else : print ( \" black \" ) else : if r % 2 > 1 : print ( \" black \" ) else : print ( \" white \" ) NEW_LINE"
] |
codeforces_1490_A | [
"import java . util . * ; public class A1490 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int ar [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } int min = 0 , max = 0 , c = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { min = ( int ) Math . min ( ar [ i ] , ar [ i + 1 ] ) ; max = ( int ) Math . max ( ar [ i ] , ar [ i + 1 ] ) ; while ( min * 2 < max ) { c ++ ; if ( max % 2 == 0 ) max = max / 2 ; else max = ( max / 2 ) + 1 ; } } System . out . println ( c ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; int [ ] a = new int [ 55 ] ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int res = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { int max = Math . max ( a [ i ] , a [ i - 1 ] ) ; int min = Math . min ( a [ i ] , a [ i - 1 ] ) ; while ( max / ( min * 1.0 ) > 2 ) { min *= 2 ; res ++ ; } } System . out . println ( res ) ; } } }",
"import java . util . Scanner ; public class Problem1490A { 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 ( ) ; } int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int max = Math . max ( a [ i ] , a [ i + 1 ] ) ; int min = Math . min ( a [ i ] , a [ i + 1 ] ) ; while ( max > min * 2 ) { min = min * 2 ; count ++ ; } } System . out . println ( count ) ; } } }",
"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 ans = 0 ; for ( int j = 1 ; j < n ; j ++ ) { int max = Math . max ( arr [ j ] , arr [ j - 1 ] ) ; int min = Math . min ( arr [ j ] , arr [ j - 1 ] ) ; min = 2 * min ; while ( min < max ) { min = min * 2 ; 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 t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int last = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int nw = sc . nextInt ( ) ; int a = Math . min ( last , nw ) ; int b = Math . max ( last , nw ) ; while ( a * 2 < b ) { ans ++ ; a *= 2 ; } last = nw ; } System . out . println ( ans ) ; } } }"
] | [
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( sum ( len ( bin ( - 1 - y // - x ) ) - 3 for x , y in map ( sorted , zip ( a , a [ 1 : ] ) ) ) ) NEW_LINE",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( sum ( len ( bin ( - 1 - y // - x ) ) - 3 for x , y in map ( sorted , zip ( a , a [ 1 : ] ) ) ) ) NEW_LINE",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( sum ( len ( bin ( - 1 - y // - x ) ) - 3 for x , y in map ( sorted , zip ( a , a [ 1 : ] ) ) ) ) NEW_LINE",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( sum ( len ( bin ( - 1 - y // - x ) ) - 3 for x , y in map ( sorted , zip ( a , a [ 1 : ] ) ) ) ) NEW_LINE",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( sum ( len ( bin ( - 1 - y // - x ) ) - 3 for x , y in map ( sorted , zip ( a , a [ 1 : ] ) ) ) ) NEW_LINE"
] |
codeforces_7_B | [
"import java . io . * ; import java . util . * ; import java . math . * ; public class B { static int cc = 1 ; public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;",
"import java . io . * ; import java . util . * ; public class Ishu { static Scanner scan = new Scanner ( System . in ) ; static int block = 0 ; static int [ ] meme = new int [ 1 ] ; static void alloc ( ) { int m = meme . length ; int n = scan . nextInt ( ) ; int i ; int ctr = 0 ; boolean exist = false ; for ( i = 0 ; i < m ; ++ i ) { if ( meme [ i ] == 0 ) ++ ctr ; else ctr = 0 ; if ( ctr == n ) { exist = true ; break ; } } if ( ! exist ) System . out . println ( \" NULL \" ) ; else { ++ block ; ctr = i - n + 1 ; for ( i = 0 ; i < n ; ++ i ) meme [ ctr + i ] = block ; System . out . println ( block ) ; } } static void erase ( ) { int m = meme . length ; int x = scan . nextInt ( ) ; boolean exist = false ; int i ; for ( i = 0 ; i < m ; ++ i ) if ( meme [ i ] == x && meme [ i ] > 0 ) { exist = true ; meme [ i ] = 0 ; } if ( ! exist ) System . out . println ( \" ILLEGAL _ ERASE _ ARGUMENT \" ) ; } static void defragment ( ) { int m = meme . length ; int i = 0 , j = 0 ; for ( i = 0 ; i < m ; ++ i ) if ( meme [ i ] > 0 ) { int data = meme [ i ] ; meme [ i ] = 0 ; meme [ j ++ ] = data ; } } static void tc ( ) { int t , m ; t = scan . nextInt ( ) ; m = scan . nextInt ( ) ; meme = new int [ m ] ; while ( t -- > 0 ) { String query = scan . next ( ) ; if ( query . equals ( \" alloc \" ) ) alloc ( ) ; else if ( query . equals ( \" erase \" ) ) erase ( ) ; else defragment ( ) ; } } public static void main ( String [ ] args ) { int t = 1 ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . LinkedList ; import java . util . StringTokenizer ; public class CF7B { public static void main ( String [ ] args ) throws IOException { solve ( ) ; } private static void solve ( ) throws IOException { int n = IN . nextInt ( ) , max = IN . nextInt ( ) - 1 ; LinkedList < int [ ] > list = new LinkedList < > ( ) ;",
"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; int m = s . nextInt ( ) ; int [ ] memory = new int [ m ] ; int allocIdx = 0 ; for ( int j = 0 ; j < t ; j ++ ) { switch ( s . next ( ) ) { case \" alloc \" : int n = s . nextInt ( ) ; int len = 0 ; boolean canAlloc = false ; for ( int i = 0 ; i < m ; i ++ ) { if ( memory [ i ] == 0 ) len ++ ; else len = 0 ; if ( len == n ) { canAlloc = true ; len = i - n + 1 ; break ; } } if ( canAlloc ) { allocIdx ++ ; for ( int i = len ; i < len + n ; i ++ ) memory [ i ] = allocIdx ; System . out . println ( allocIdx ) ; } else System . out . println ( \" NULL \" ) ; break ; case \" erase \" : int x = s . nextInt ( ) ; if ( x <= 0 ) { System . out . println ( \" ILLEGAL _ ERASE _ ARGUMENT \" ) ; break ; } boolean hasErased = false ; for ( int i = 0 ; i < m ; i ++ ) { if ( memory [ i ] == x ) { memory [ i ] = 0 ; hasErased = true ; } } if ( ! hasErased ) System . out . println ( \" ILLEGAL _ ERASE _ ARGUMENT \" ) ; break ; case \" defragment \" : int d = 0 ;"
] | [
"''' Jana ▁ Goodman6 7B ▁ Memory ▁ Manager ''' import re SPACE = ' ▁ ' ALLOC = ' alloc ' ERASE = ' erase ' DEFRAG = ' defragment ' ALLOC_ERR = ' NULL ' ERASE_ERR = ' ILLEGAL _ ERASE _ ARGUMENT ' FREE = 0 class Memory : def __init__ ( self , size ) : self . size = size self . next_id = 0 self . bytes = [ FREE ] * size def is_free ( self , block ) : return all ( byte == FREE for byte in block ) def is_allocated ( self , id ) : return id in self . bytes def free_block ( self , n ) : block_len , start = None , None for i , byte in enumerate ( self . bytes ) : if byte == FREE : if block_len is None : start = i block_len = 1 else : block_len += 1 if block_len == n : return start else : block_len = None return None def fill ( self , start , n , x ) : if start == 78 and start + n == 90 : debug = 1 for i in range ( start , start + n ) : self . bytes [ i ] = x def alloc ( self , n ) : start = self . free_block ( n ) if start is None : print ( ALLOC_ERR ) else : self . next_id += 1 self . fill ( start , n , self . next_id ) print ( self . next_id ) def erase ( self , x ) : if x == 0 : print ( ERASE_ERR ) elif self . is_allocated ( x ) : self . fill ( self . bytes . index ( x ) , self . bytes . count ( x ) , FREE ) else : print ( ERASE_ERR ) def defragment ( self ) : new_bytes = list ( ) if FREE in self . bytes : n = 0 for byte in self . bytes : if byte > FREE : new_bytes . append ( byte ) n += 1 new_bytes += [ FREE ] * ( self . size - len ( new_bytes ) ) self . bytes = [ _ for _ in new_bytes ] NEW_LINE",
"commands , bytes = map ( int , input ( ) . split ( ) ) s = [ 0 ] * bytesc = 0 for i in range ( commands ) : op = input ( ) . split ( ) if op [ 0 ] == ' alloc ' : NEW_LINE",
"import reclass Memory : def __init__ ( self , bytes ) : self . memory = [ 0 for x in range ( bytes ) ] self . identifier = 1 def out ( self ) : print ( self . memory ) def alloc ( self , bytes ) : avail = False for i in range ( len ( self . memory ) - ( bytes - 1 ) ) : if max ( self . memory [ i : i + bytes ] ) == 0 : print ( self . identifier ) for j in range ( i , i + bytes ) : self . memory [ j ] = self . identifier self . identifier += 1 avail = True if avail : break if not avail : print ( \" NULL \" ) def erase ( self , x ) : if x in self . memory and x != 0 : for i in range ( self . memory . count ( x ) ) : self . memory [ self . memory . index ( x ) ] = 0 else : print ( \" ILLEGAL _ ERASE _ ARGUMENT \" ) def defrag ( self ) : zeroCount = self . memory . count ( 0 ) for i in range ( zeroCount ) : self . memory . remove ( 0 ) self . memory . append ( 0 ) t , m = map ( int , input ( ) . split ( ) ) memory = Memory ( m ) for i in range ( t ) : operation = input ( ) if operation . startswith ( \" alloc \" ) : aN = re . findall ( r ' \\b\\d + \\b ' , operation ) memory . alloc ( int ( aN [ 0 ] ) ) elif operation . startswith ( \" erase \" ) : aE = re . findall ( r ' \\b\\d + \\b ' , operation ) memory . erase ( int ( aE [ 0 ] ) ) else : memory . defrag ( ) NEW_LINE"
] |
codeforces_1495_B | [
" import java . util . * ; import java . io . * ; import java . text . DecimalFormat ; public class hiking { static DecimalFormat df1 = new DecimalFormat ( \" # .000000\" ) ; static DecimalFormat df = new DecimalFormat ( \" # . # # # # # # \" ) ; static boolean printing = false ; static int N ; static long total = 0L ; static int ret = 0 ; public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ;"
] | [
"n = int ( input ( ) ) NEW_LINE array = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE leftToRight = [ 0 for i in range ( n ) ] NEW_LINE rightToLeft = [ 0 for i in range ( n ) ] for i in range ( 1 , n ) : if NEW_LINE array [ i - 1 ] < array [ i ] : leftToRight [ i ] = leftToRight [ i - 1 ] + 1 for i in range ( n - 2 , - 1 , - 1 ) : if NEW_LINE array [ i + 1 ] < array [ i ] : rightToLeft [ i ] = rightToLeft [ i + 1 ] + 1 maxVal = max ( max ( leftToRight ) , max ( rightToLeft ) ) NEW_LINE maxCount = 0 NEW_LINE maxOnSameIdx = 0 NEW_LINE for i in range ( n ) : if NEW_LINE leftToRight [ i ] == maxVal : maxCount += 1 NEW_LINE if rightToLeft [ i ] == maxVal : maxCount += 1 NEW_LINE if leftToRight [ i ] == maxVal and rightToLeft [ i ] == maxVal : maxOnSameIdx += 1 if maxCount == 2 and maxOnSameIdx == 1 and maxVal % 2 == 0 : NEW_LINE INDENT print ( 1 ) else : NEW_LINE print ( 0 ) NEW_LINE DEDENT",
"import arrayimport NEW_LINE collectionsfrom NEW_LINE collections NEW_LINE import defaultdictimport NEW_LINE math mxN = 2e5 + 10 NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Rs = [ 0 ] * ( n + 10 ) NEW_LINE Ls = [ 0 ] * ( n + 10 ) NEW_LINE for i in range ( 1 , n ) : if NEW_LINE a [ i ] > a [ i - 1 ] : Ls [ i ] = Ls [ i - 1 ] + 1 NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : if NEW_LINE a [ i + 1 ] < a [ i ] : Rs [ i ] = Rs [ i + 1 ] + 1 NEW_LINE mx = max ( * Rs , * Ls ) NEW_LINE c = 0 NEW_LINE for i in range ( 0 , n ) : if NEW_LINE mx == Rs [ i ] : c += 1 NEW_LINE if mx == Ls [ i ] : c += 1 NEW_LINE",
"import arrayimport NEW_LINE collectionsfrom NEW_LINE collections NEW_LINE import defaultdictimport NEW_LINE math mxN = 2e5 + 10 NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Rs = [ 0 ] * ( n + 10 ) NEW_LINE Ls = [ 0 ] * ( n + 10 ) NEW_LINE for i in range ( 1 , n ) : if NEW_LINE a [ i ] > a [ i - 1 ] : Ls [ i ] = Ls [ i - 1 ] + 1 NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : if NEW_LINE a [ i + 1 ] < a [ i ] : Rs [ i ] = Rs [ i + 1 ] + 1 NEW_LINE mx = max ( * Rs , * Ls ) NEW_LINE c = 0 NEW_LINE for i in range ( 0 , n ) : if NEW_LINE mx == Rs [ i ] : c += 1 NEW_LINE if mx == Ls [ i ] : c += 1 NEW_LINE",
"import sysimport NEW_LINE mathfrom NEW_LINE math NEW_LINE import factorial , inf , gcdfrom NEW_LINE heapq NEW_LINE import * from functools NEW_LINE import * from itertools NEW_LINE import * from collections NEW_LINE import * from typing NEW_LINE import NEW_LINE * sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE"
] |
codeforces_321_B | [
"import java . util . * ; import javax . swing . RowFilter . Entry ; import javax . swing . text . AbstractDocument . BranchElement ; import javax . swing . text . html . parser . Entity ; import java . io . * ; public class C { static PrintWriter pw ; static BufferedReader br ; static int inf = ( int ) 1e9 ; static long mod = ( long ) 1e9 + 7 ; static int [ ] [ ] memo ; static boolean [ ] vis ; static boolean [ ] [ ] ok ; static int [ ] a ; static int n , m ; static ArrayList < Integer > [ ] adj ; static ArrayList < Integer > primes ; static int [ ] isComposite ; static void sieve ( int N )",
"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 ) { greedy ( in , out ) ; } int N ; int M ; void greedy ( FastScanner in , PrintWriter out ) {"
] | [
"n , m = map ( int , input ( ) . split ( ) ) a , d = [ 1e9 ] , [ 1e9 ] for x in range ( n ) : p , s = input ( ) . split ( ) [ d , a ] [ p < ' B ' ] . append ( int ( s ) ) v = [ int ( input ( ) ) for y in range ( m ) ] for q in [ a , d , v ] : q . sort ( ) s = sum ( v ) i = j = 0 for t in v : if t > d [ i ] : s , i = s - t , i + 1 elif t >= a [ j ] : s , j = s - a [ j ] , j + 1 if i + j - n : s = 0 print ( max ( s , sum ( max ( 0 , y - x ) for x , y in zip ( a , v [ : : - 1 ] ) ) ) ) NEW_LINE"
] |
codeforces_1365_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int t = sc . nextInt ( ) ; t -- > 0 ; ) { int n = sc . nextInt ( ) , a [ ] = new int [ n ] ; boolean x = true , y = false , z = y ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( i > 0 && a [ i - 1 ] > a [ i ] ) x = false ; } for ( int i = 0 ; i < n ; i ++ ) if ( sc . nextInt ( ) > 0 ) y = true ; else z = true ; System . out . println ( ( x || ( y && z ) ) ? \" Yes \" : \" No \" ) ; } } }",
"import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ;",
"import java . awt . Desktop ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; 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 ; } } 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 boolean IsSorted ( int [ ] a , int n ) { if ( n == 0 || n == 1 ) return true ; else if ( a [ n - 1 ] < a [ n - 2 ] ) return false ; else return IsSorted ( a , n - 1 ) ; } public static boolean IsQ ( int [ ] b , int n ) { for ( int i = n - 1 ; i > 0 ; i -- ) if ( b [ 0 ] != b [ i ] ) return false ; return true ; } public static Scanner ayat = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int t = ayat . nextInt ( ) ; int [ ] a = new int [ 1000000 ] ; int [ ] b = new int [ 1000000 ] ; while ( t > 0 ) { int n = ayat . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = ayat . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) b [ i ] = ayat . nextInt ( ) ; if ( IsSorted ( a , n ) ) System . out . println ( \" YES \" ) ; else if ( IsQ ( b , n ) ) System . out . println ( \" NO \" ) ; else System . out . println ( \" YES \" ) ; t -- ; } } }"
] | [
"from copy import deepcopyfor _ in range ( int ( input ( ) ) ) : a = int ( input ( ) ) l3 = [ ] l1 = list ( map ( int , input ( ) . split ( ) ) ) l2 = list ( map ( int , input ( ) . split ( ) ) ) l = deepcopy ( l1 ) l . sort ( ) if l1 == l : print ( ' Yes ' ) elif l2 . count ( 0 ) == a or l2 . count ( 1 ) == a : print ( ' No ' ) else : print ( ' Yes ' ) NEW_LINE",
"from collections import * from itertools import * from string import * from bisect import * from queue import * from heapq import * from math import * from sys import * from re import * def fast ( ) : return stdin . readline ( ) . strip ( ) def zzz ( ) : return [ int ( i ) for i in fast ( ) . split ( ) ] z , zz = input , lambda : list ( map ( int , z ( ) . split ( ) ) ) szz , graph , mod , szzz = lambda : sorted ( zz ( ) ) , { } , 10 ** 9 + 7 , lambda : sorted ( zzz ( ) ) def lcd ( xnum1 , xnum2 ) : return ( xnum1 * xnum2 // gcd ( xnum1 , xnum2 ) ) def output ( answer ) : stdout . write ( str ( answer ) ) dx = [ - 1 , 1 , 0 , 0 , 1 , - 1 , 1 , - 1 ] dy = [ 0 , 0 , 1 , - 1 , 1 , - 1 , - 1 , 1 ] NEW_LINE",
"t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) li = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) indexes = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) if 0 in indexes and 1 in indexes : print ( \" YES \" ) else : if list ( sorted ( li ) ) == li : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) if a == sorted ( a ) : print ( \" YES \" ) continue if b . count ( 1 ) > 0 and b . count ( 0 ) > 0 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE",
"def answer ( n , a , b ) : if b . count ( 0 ) >= 1 and b . count ( 1 ) >= 1 : return ' Yes ' a_s = sorted ( a ) if a_s == a : return ' Yes ' return ' No ' def main ( ) : t = int ( input ( ) ) while t : n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] b = [ int ( i ) for i in input ( ) . split ( ) ] print ( answer ( n , a , b ) ) t -= 1 returnmain ( ) NEW_LINE"
] |
codeforces_1487_A | [
"import java . util . * ; public class Arena { public static void main ( String args [ ] ) { Scanner e = new Scanner ( System . in ) ; int t = e . nextInt ( ) ; while ( t > 0 ) { int n = e . nextInt ( ) ; int a [ ] = new int [ n ] ; int x = 100 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = e . nextInt ( ) ; if ( a [ i ] < x ) x = a [ i ] ; } int b = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > x ) b ++ ; } System . out . println ( b ) ; t -- ; } } }",
"import java . util . * ; import java . io . * ; public class code { 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 ( ) ; int min = a [ 0 ] , c = 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( min > a [ i ] ) min = a [ i ] ; for ( int i = 0 ; i < n ; i ++ ) if ( min == a [ i ] ) c ++ ; System . out . println ( n - c ) ; } } }",
"import java . util . * ; public class A1487 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int ar [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } Arrays . sort ( ar ) ; int k = ar [ 0 ] ; int c = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( ar [ i ] == k ) c ++ ; else break ; } System . out . println ( n - c ) ; } } }",
"import java . util . * ; public class Solution { 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 ( ) ; int min = Arrays . stream ( A ) . min ( ) . getAsInt ( ) ; int cnt = 0 ; for ( int x : A ) { if ( x > min ) cnt ++ ; } System . out . println ( cnt ) ; } sc . close ( ) ; } }",
"import java . util . * ; public class Arena { public static void main ( String args [ ] ) { Scanner e = new Scanner ( System . in ) ; int t = e . nextInt ( ) ; while ( t > 0 ) { int n = e . nextInt ( ) ; int a [ ] = new int [ n ] ; int x = 100 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = e . nextInt ( ) ; if ( a [ i ] < x ) x = a [ i ] ; } int b = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > x ) b ++ ; } System . out . println ( b ) ; t -- ; } } }"
] | [
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( len ( a ) - a . count ( min ( a ) ) ) NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) ; a = [ int ( i ) for i in input ( ) . split ( ) ] ; print ( n - a . count ( min ( a ) ) ) NEW_LINE",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( len ( a ) - a . count ( min ( a ) ) ) NEW_LINE",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( len ( a ) - a . count ( min ( a ) ) ) NEW_LINE",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = * map ( int , s . split ( ) ) , ; print ( len ( a ) - a . count ( min ( a ) ) ) NEW_LINE"
] |
codeforces_1375_B | [
"import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ; public class absolute { static int [ ] I = new int [ ] { 0 , - 1 , 0 , 1 } ; static int [ ] J = new int [ ] { - 1 , 0 , 1 , 0 } ; static int [ ] [ ] mat ; public static void main ( String [ ] args ) {",
"import java . util . * ; public class NeighborGrid { public static void main ( String [ ] args ) {"
] | [
"for _ in range ( int ( input ( ) ) ) : n , m = map ( int , input ( ) . split ( ) ) g = [ ] for _ in range ( n ) : g . append ( list ( map ( int , input ( ) . split ( ) ) ) ) f = 0 for i in range ( n ) : for j in range ( m ) : maxx = 4 if j in ( 0 , m - 1 ) : maxx -= 1 if i in ( 0 , n - 1 ) : maxx -= 1 if g [ i ] [ j ] > maxx : print ( \" NO \" ) f = 1 break if f : break if not f : print ( \" YES \" ) for i in range ( n ) : for j in range ( m ) : maxx = 4 if j in ( 0 , m - 1 ) : maxx -= 1 if i in ( 0 , n - 1 ) : maxx -= 1 print ( maxx , end = ' ▁ ' ) print ( ) NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : m , n = map ( int , input ( ) . split ( ) ) l = [ [ int ( i ) for i in input ( ) . split ( ) ] for k in range ( m ) ] f = 0 for i in range ( m ) : for j in range ( n ) : ct = 0 if i - 1 >= 0 : ct += 1 if i + 1 < m : ct += 1 if j - 1 >= 0 : ct += 1 if j + 1 < n : ct += 1 if l [ i ] [ j ] > ct : f = 1 break else : l [ i ] [ j ] = ct if f == 1 : break if f == 1 : print ( ' NO ' ) else : print ( ' YES ' ) for i in l : print ( * i ) NEW_LINE",
"from collections import dequeimport sysinf = float ( ' inf ' ) input = sys . stdin . readline \"\"\" n ▁ = ▁ int ( input ( ) ) n , k ▁ = ▁ map ( int , input ( ) . split ( ) ) arr ▁ = ▁ list ( map ( int , input ( ) . split ( ) ) ) \"\"\" for _ in range ( int ( input ( ) ) ) : Row , Col = map ( int , input ( ) . split ( ) ) matt = [ ] for i in range ( Row ) : matt . append ( list ( map ( int , input ( ) . split ( ) ) ) ) flag = True for row in range ( Row ) : for col in range ( Col ) : if ( row == 0 or row == Row - 1 ) and ( col == 0 or col == Col - 1 ) : if matt [ row ] [ col ] > 2 : flag = False elif ( row == 0 or row == Row - 1 ) or ( col == 0 or col == Col - 1 ) : if matt [ row ] [ col ] > 3 : flag = False else : if matt [ row ] [ col ] > 4 : flag = False if not flag : print ( ' NO ' ) else : print ( ' YES ' ) for row in range ( Row ) : for col in range ( Col ) : if ( row == 0 or row == Row - 1 ) and ( col == 0 or col == Col - 1 ) : matt [ row ] [ col ] = 2 elif ( row == 0 or row == Row - 1 ) or ( col == 0 or col == Col - 1 ) : matt [ row ] [ col ] = 3 else : matt [ row ] [ col ] = 4 for i in matt : print ( * i ) NEW_LINE",
"import sysimport mathfrom math import factorial , inf , gcdfrom heapq import * from functools import * from itertools import * from collections import * from typing import * sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE",
"import sys def answer ( n , m , a ) : NEW_LINE"
] |
codeforces_13_A | [
"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 long GCD ( long n1 , long n2 ) { if ( n1 == 0 ) { return n2 ; } return GCD ( n2 % n1 , n1 ) ; } public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; long sum = 0 ; for ( int i = 2 ; i < n ; i ++ ) { int temp = n ; while ( temp != 0 ) { sum += temp % i ; temp /= i ; } } long gc = GCD ( sum , n - 2 ) ; System . out . println ( ( sum / gc ) + \" / \" + ( ( n - 2 ) / gc ) ) ; } 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 ( ) ) ; } } }",
"import java . util . * ; import java . lang . Math . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; long sum = 0 ; int d = 0 ; int b = a ; for ( int i = 2 ; i < b ; i ++ ) { int x = 0 ; while ( a != 0 ) { x = x + a % i ; a = a / i ; } sum = sum + x ; a = b ; d ++ ; } for ( int j = 2 ; j < d ; j ++ ) { if ( ( sum % j == 0 ) && ( d % j == 0 ) ) { sum = sum / j ; d = d / j ; j -- ; } } System . out . println ( sum + \" / \" + d ) ; } }",
"import java . util . Scanner ; public class Main { public static int getGcd ( int num1 , int num2 ) { if ( num2 == 0 ) { return num1 ; } else { return getGcd ( num2 , num1 % num2 ) ; } } public static int sumsOfDigits ( int num ) { int result = 0 ; for ( int i = 2 ; i < num ; i ++ ) { int tmp = num ; while ( tmp != 0 ) { result += tmp % i ; tmp = tmp / i ; } } return result ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int num = in . nextInt ( ) ; int result = sumsOfDigits ( num ) ; int divisor = num - 2 ; int gcd = getGcd ( result , divisor ) ; System . out . println ( ( result / gcd ) + \" / \" + ( divisor / gcd ) ) ; in . close ( ) ; } }"
] | [
"from math import gcd def base ( n , b ) : c = 0 while n : c += n % b n //= b return c n = int ( input ( ) ) x = 0 for i in range ( 2 , int ( n ) ) : x += base ( int ( n ) , i ) n -= 2 hcf = gcd ( x , n ) x //= hcfn //= hcfprint ( f \" { x } / { n } \" ) NEW_LINE",
"from math import gcdn , s = int ( input ( ) ) , 0 for i in range ( 2 , n ) : k = n while k != 0 : s += k % i k //= ip = gcd ( s , n - 2 ) print ( f ' { s / / p } / { ( n - 2 ) / / p } ' ) NEW_LINE",
"from math import gcd n = int ( input ( ) ) s = 0 for i in range ( 2 , n ) : copy = n while copy > 0 : s += copy % i copy //= i a = sb = n - 2 g = gcd ( a , b ) print ( f \" { a ▁ / / ▁ g } / { b ▁ / / ▁ g } \" ) NEW_LINE",
"a = int ( input ( ) ) s = 0 for i in range ( 2 , a ) : x = a while x : s += x % i x //= ib = a - 2 for i in range ( 2 , 1001 ) : while s % i == 0 and b % i == 0 : s //= i b //= iprint ( s , ' / ' , b , sep = ' ' ) NEW_LINE"
] |
codeforces_414_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 . * ; public class _240_A_Mashmokh_and_numbers { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int pairs = n / 2 ; if ( n == 1 ) { if ( k == 0 ) System . out . println ( 1 ) ; else System . out . println ( - 1 ) ; System . exit ( 0 ) ; } if ( k < pairs ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; } HashSet < Integer > hset = new HashSet < > ( ) ; int t = k - pairs + 1 ; System . out . print ( t + \" ▁ \" + ( 2 * t ) + \" ▁ \" ) ; hset . add ( t ) ; hset . add ( t * 2 ) ; int j = 1 ; if ( hset . contains ( j ) || hset . contains ( 1 + j ) ) j = j + 2 ; for ( int i = 1 ; i < pairs ; i ++ ) { while ( hset . contains ( j ) || hset . contains ( j + 1 ) ) j ++ ; System . out . print ( j + \" ▁ \" + ( 1 + j ) + \" ▁ \" ) ; hset . add ( j ) ; hset . add ( j + 1 ) ; } if ( pairs * 2 != n ) { while ( hset . contains ( j ) ) j ++ ; System . out . print ( j ) ; } } }"
] | [
"arr = [ int ( x ) for x in input ( ) . split ( ) ] n , k = arr [ 0 ] , arr [ 1 ] if ( k < n // 2 ) : print ( - 1 ) elif ( n == 1 ) : if ( k > 0 ) : print ( - 1 ) else : print ( 1 ) else : ans = [ ] if ( n % 2 == 0 ) : temp = n // 2 temp -= 1 k -= temp i = 1 print ( k , 2 * k , end = \" ▁ \" ) while ( temp > 0 ) : if ( i != k and i != 2 * k and i + 1 != k and i + 1 != 2 * k ) : print ( i , i + 1 , end = \" ▁ \" ) temp -= 1 i += 2 else : temp = n // 2 temp -= 1 k -= temp i = 1 print ( k , 2 * k , end = \" ▁ \" ) while ( temp > 0 ) : if ( i != k and i != 2 * k and i + 1 != k and i + 1 != 2 * k ) : print ( i , i + 1 , end = \" ▁ \" ) temp -= 1 i += 2 print ( i + 17 ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = n // 2 z = k - a + 1 ans = [ 10 ** 9 - i for i in range ( 1 , n + 1 ) ] if z == 1 : print ( * ans ) elif z < 1 or n == 1 : print ( - 1 ) else : if n == 1 : print ( 99 ) else : ans [ 0 ] , ans [ 1 ] = z , z * 2 print ( * ans ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) if m < n // 2 and n != 1 or ( n == 1 and m >= n ) : print ( - 1 ) else : if m : k = ( n - 2 ) // 2 print ( ( m - k ) , end = \" ▁ \" ) print ( ( m - k ) * 2 , end = \" ▁ \" ) n -= 2 c = ( m - k ) * 2 + 1 if n != 1 : for i in range ( c , c + n ) : print ( i , end = \" ▁ \" ) else : print ( 1 ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) q = n // 2 if q > k or ( q == 0 and k != 0 ) : print ( - 1 ) elif q == 0 and k == 0 : print ( 1 ) else : w = [ ] r = k // q l = { 0 } y = { } t = [ r + 1 , 0 ] * ( k % q ) + [ r , 0 ] * ( q - k % q ) for i in range ( 0 , 2 * q , 2 ) : y [ t [ i ] ] = 1 for i in range ( 0 , 2 * q , 2 ) : w += [ t [ i ] , t [ i ] * 2 ] for i in range ( 0 , len ( w ) , 2 ) : while w [ i ] in l : y [ t [ i ] ] += 2 ; w [ i ] = y [ t [ i ] ] * t [ i ] l . add ( w [ i ] ) while w [ i + 1 ] in l : y [ t [ i ] ] += 2 ; w [ i + 1 ] = y [ t [ i ] ] * t [ i ] l . add ( w [ i + 1 ] ) if n % 2 : w += [ 10 ** 9 ] print ( * w ) NEW_LINE"
] |
codeforces_426_B | [
" import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . math . RoundingMode ; import java . util . * ; import java . util . concurrent . LinkedBlockingDeque ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . LinkedList ; ",
"import java . io . * ; import java . util . * ; public class CodeForce { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringBuilder sb = new StringBuilder ( ) ; public static int checkreverse ( int [ ] [ ] arr , int n ) { if ( n % 2 == 1 ) return n ; for ( int i = n / 2 - 1 ; i >= 0 ; i -- ) { for ( int j = 0 ; j < arr [ 0 ] . length ; j ++ ) { if ( arr [ i ] [ j ] != arr [ n - i - 1 ] [ j ] ) return n ; } } return checkreverse ( arr , n / 2 ) ; } static boolean flag = false ; static int next ( String [ ] sr , int ind ) { return Integer . parseInt ( sr [ ind ] ) ; } public static void main ( String [ ] args ) throws IOException { String [ ] sr = br . readLine ( ) . split ( \" ▁ \" ) ; int n = next ( sr , 0 ) ; int m = next ( sr , 1 ) ; int [ ] [ ] arr = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { sr = br . readLine ( ) . split ( \" ▁ \" ) ; for ( int j = 0 ; j < m ; j ++ ) arr [ i ] [ j ] = next ( sr , j ) ; } System . out . println ( checkreverse ( arr , n ) ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws InterruptedException { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; solve ( in , out ) ; out . close ( ) ; } static void solve ( MyScanner in , PrintWriter out ) { int n , m ; n = in . nextInt ( ) ; m = in . nextInt ( ) ; int [ ] [ ] mt = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { mt [ i ] [ j ] = in . nextInt ( ) ; } } int ans = n ; while ( ans % 2 == 0 && isSym ( mt , ans ) ) { ans /= 2 ; } out . println ( ans ) ; } static boolean isSym ( int [ ] [ ] mt , int len ) { int up = len / 2 - 1 ; int down = len / 2 ; int m = mt [ 0 ] . length ; while ( up >= 0 ) { for ( int i = 0 ; i < m ; i ++ ) { if ( mt [ up ] [ i ] != mt [ down ] [ i ] ) { return false ; } } up -- ; down ++ ; } return true ; } static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( InputStream io ) { br = new BufferedReader ( new InputStreamReader ( io ) ) ; } 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 ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }"
] | [
"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 , m = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( n ) : l . append ( \" \" . join ( list ( map ( str , input ( ) . split ( ) ) ) ) ) while not n % 2 : if l [ : n // 2 ] != l [ n // 2 : n ] [ : : - 1 ] : break n //= 2 print ( n ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( n ) : l . append ( \" \" . join ( list ( map ( str , input ( ) . split ( ) ) ) ) ) while not n % 2 and l [ : n // 2 ] == l [ n // 2 : n ] [ : : - 1 ] : n //= 2 print ( n ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( n ) : l . append ( list ( map ( str , input ( ) . split ( ) ) ) ) while not n % 2 and l [ : n // 2 ] == l [ n // 2 : n ] [ : : - 1 ] : n //= 2 print ( n ) NEW_LINE",
"from math import log row , col = map ( int , input ( ) . split ( \" ▁ \" ) ) if row % 2 == 1 : print ( row ) else : matrix = [ ] for _ in range ( row ) : matrix . append ( input ( ) . split ( \" ▁ \" ) ) minimum = row for _ in range ( int ( log ( row , 2 ) ) ) : if matrix [ 0 : minimum // 2 ] == matrix [ minimum - 1 : minimum // 2 - 1 : - 1 ] : minimum //= 2 else : break print ( minimum ) NEW_LINE"
] |
codeforces_734_A | [
"import java . util . * ; public class chess { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int c = 0 , d = 0 ; for ( int i = 0 ; i < n ; i ++ ) { char x = s . charAt ( i ) ; if ( x == ' D ' ) d ++ ; else c ++ ; } if ( c > d ) System . out . println ( \" Anton \" ) ; else if ( c < d ) System . out . println ( \" Danik \" ) ; else System . out . println ( \" Friendship \" ) ; } }",
"import java . util . * ; public class test { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String test = scanner . nextLine ( ) ; String str = scanner . nextLine ( ) ; int test1 = Integer . parseInt ( test ) ; int a = 0 ; int d = 0 ; for ( int i = 0 ; i < test1 ; i ++ ) { char ch = str . charAt ( i ) ; if ( ch == ' A ' ) { a ++ ; } else d ++ ; } if ( a > d ) { System . out . println ( \" Anton \" ) ; } else if ( d > a ) { System . out . println ( \" Danik \" ) ; } else System . out . println ( \" Friendship \" ) ; } }",
"import java . util . Scanner ; public class AntonAndDanik { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; String b = scanner . next ( ) ; int anton = 0 ; int danik = 0 ; for ( int i = 0 ; i < b . length ( ) ; i ++ ) { if ( b . charAt ( i ) == ' A ' ) { anton ++ ; } else { danik ++ ; } } if ( anton > danik ) { System . out . println ( \" Anton \" ) ; } else if ( danik > anton ) { System . out . println ( \" Danik \" ) ; } else System . out . println ( \" Friendship \" ) ; } }",
"import java . util . Scanner ; public class AntonAndDanik { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String num = scanner . nextLine ( ) ; String str = scanner . nextLine ( ) ; System . out . println ( solve ( str ) ) ; } public static String solve ( String str ) { int anton = 0 ; int danik = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' A ' ) { anton ++ ; } else if ( str . charAt ( i ) == ' D ' ) { danik ++ ; } } if ( anton > danik ) { return \" Anton \" ; } else if ( danik > anton ) { return \" Danik \" ; } return \" Friendship \" ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int l = in . nextInt ( ) ; int d = 0 , a = 0 ; String s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == ' A ' ) { a ++ ; } else { d ++ ; } } if ( a > d ) { System . out . println ( \" Anton \" ) ; } else if ( a < d ) { System . out . println ( \" Danik \" ) ; } else { System . out . println ( \" Friendship \" ) ; } } } "
] | [
"n = input ( ' ' ) x = input ( ' ' ) a = x . count ( ' A ' ) d = x . count ( ' D ' ) if a > d : print ( ' Anton ' ) elif d > a : print ( ' Danik ' ) else : print ( ' Friendship ' ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) if s . count ( ' A ' ) > s . count ( ' D ' ) : print ( \" Anton \" ) elif s . count ( ' D ' ) > s . count ( ' A ' ) : print ( \" Danik \" ) else : print ( \" Friendship \" ) NEW_LINE",
"n = input ( ) l = list ( input ( ) ) an = l . count ( ' A ' ) dn = l . count ( ' D ' ) if ( an > dn ) : print ( \" Anton \" ) elif ( dn > an ) : print ( \" Danik \" ) else : print ( \" Friendship \" ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) a = len ( s ) c = 0 d = 0 for i in range ( a ) : if ( s [ i ] == ' A ' ) : c = c + 1 elif ( s [ i ] == ' D ' ) : d = d + 1 if ( c > d ) : print ( \" Anton \" ) elif ( d > c ) : print ( \" Danik \" ) elif ( c == d ) : print ( \" Friendship \" ) NEW_LINE"
] |
codeforces_849_B | [
"import java . util . * ; public class Tell_Your_World { static final double E = 0.0000001 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; boolean thereIsAnswer = false ; outer : for ( int i = 1 ; i < 4 ; i ++ ) { for ( int j = i ; j < 4 ; j ++ ) { if ( j == i ) continue ; line src = new line ( i , arr [ i ] , j , arr [ j ] ) ; for ( int k = 1 ; k <= n ; k ++ ) { line other = src . getParallel ( k , arr [ k ] ) ; for ( int l = 1 ; l <= n && ! other . identical ( src ) ; l ++ ) { if ( ( src . passThroughPoint ( l , arr [ l ] ) || other . passThroughPoint ( l , arr [ l ] ) ) ) { thereIsAnswer = true ; } else { thereIsAnswer = false ; break ; } } if ( thereIsAnswer && ! other . identical ( src ) ) break outer ; } } } System . out . println ( thereIsAnswer ? \" YES \" : \" NO \" ) ; } public static int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static class line implements Comparable < line > { int a ; int b ;"
] | [
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) flag = 0 for i in range ( 1 , n ) : k = set ( ) xdif = i ydif = a [ i ] - a [ 0 ] k . add ( a [ 0 ] * xdif ) for j in range ( n ) : k . add ( a [ j ] * xdif - ( ydif * j ) ) if len ( k ) == 2 : flag = 1 breakxdif = 1 ydif = a [ 2 ] - a [ 1 ] k = set ( ) k . add ( a [ 1 ] * xdif - ydif ) for j in range ( n ) : k . add ( a [ j ] * xdif - ( ydif * j ) ) if len ( k ) == 2 : flag = 1 if flag : print ( ' Yes ' ) else : print ( ' No ' ) NEW_LINE",
"n = int ( input ( ) ) y = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 1 , n ) : a = [ ] for j in range ( n ) : NEW_LINE",
"from decimal import * getcontext ( ) . prec = 16 from math import sqrt n = int ( input ( ) ) liste = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) perm = [ ( 0 , 1 , 2 ) , ( 0 , 2 , 1 ) , ( 1 , 2 , 0 ) ] bool = Falsefor element in perm : i0 , i1 , i2 = element count = 2 slope = ( liste [ i1 ] - liste [ i0 ] ) / ( i1 - i0 ) rest = [ ] for i in range ( 3 , n ) : if slope == ( liste [ i1 ] - liste [ i ] ) / ( i1 - i ) : count += 1 else : rest . append ( i ) if slope == ( liste [ i2 ] - liste [ i1 ] ) / ( i2 - i1 ) : count += 1 else : rest . append ( i2 ) if rest != [ ] : count += 1 for i in range ( 1 , len ( rest ) ) : if slope == ( liste [ rest [ 0 ] ] - liste [ rest [ i ] ] ) / ( rest [ 0 ] - rest [ i ] ) : count += 1 if count == n and rest != [ ] : print ( \" YES \" ) break else : print ( \" NO \" ) NEW_LINE"
] |
codeforces_523_B | [
"import java . io . File ; import java . io . IOException ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . lang . reflect . Array ; import java . math . BigInteger ; import java . util . * ; import java . io . DataInputStream ; import java . io . InputStream ; import java . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] argv ) { Task t = new Task ( ) ;",
"import java . io . File ; import java . io . IOException ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . lang . reflect . Array ; import java . math . BigInteger ; import java . util . * ; import java . io . DataInputStream ; import java . io . InputStream ; import java . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] argv ) { Task t = new Task ( ) ;",
"import java . io . File ; import java . io . IOException ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . lang . reflect . Array ; import java . math . BigInteger ; import java . util . * ; import java . io . DataInputStream ; import java . io . InputStream ; import java . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] argv ) { Task t = new Task ( ) ;"
] | [
"n , T , c = input ( ) . split ( ) n = int ( n ) T = int ( T ) c = float ( c ) a = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) q = list ( map ( int , input ( ) . split ( ) ) ) res_a = 0 real = 0 maxi_q = max ( q ) q_n = 0 for i in range ( q [ - 1 ] ) : res_a = ( res_a + a [ i ] / T ) / c real += a [ i ] if i >= T : real -= a [ i - T ] if q [ q_n ] == i + 1 : q_n += 1 r = real / T print ( r , res_a , abs ( r - res_a ) / r ) NEW_LINE",
"def main ( ) : s = input ( ) . split ( ) n , T , c = int ( s [ 0 ] ) , int ( s [ 1 ] ) , float ( s [ 2 ] ) a = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) q = list ( map ( int , input ( ) . split ( ) ) ) sumA , approx , mean = [ 0 ] , [ ] , 0. for i in range ( 1 , n + 1 ) : mean = ( mean + a [ i - 1 ] / T ) / c approx . append ( mean ) sumA . append ( a [ i - 1 ] + sumA [ i - 1 ] ) ans = [ ( sumA [ q [ i ] ] - sumA [ q [ i ] - T ] ) / T for i in range ( m ) ] for i in range ( m ) : print ( ' % .6f ' % ans [ i ] , ' % .6f ' % approx [ q [ i ] - 1 ] , ' % .6f ' % ( abs ( approx [ q [ i ] - 1 ] - ans [ i ] ) / ans [ i ] ) ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE",
"a = list ( input ( ) . split ( ) ) n , T , c = int ( a [ 0 ] ) , int ( a [ 1 ] ) , float ( a [ 2 ] ) a = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) sum_a = sum ( a [ : T - 1 ] ) mean = 0 for t in range ( T - 1 ) : mean = ( mean + a [ t ] / T ) / c i = 0 for t in range ( T - 1 , p [ - 1 ] ) : sum_a += a [ t ] mean = ( mean + a [ t ] / T ) / c if t == p [ i ] - 1 : real = sum_a / T print ( ' % 0.6f ▁ % 0.6f ▁ % 0.6f ' % ( real , mean , abs ( real - mean ) / real ) ) i += 1 if i == len ( p ) : break sum_a -= a [ t - T + 1 ] NEW_LINE",
"__author__ = ' ruckus ' n , T , c = input ( ) . split ( ) n = int ( n ) T = int ( T ) c = float ( c ) a = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) q = list ( map ( int , input ( ) . split ( ) ) ) res_a = 0 real = 0 maxi_q = max ( q ) q_n = 0 for i in range ( q [ - 1 ] ) : res_a = ( res_a + a [ i ] / T ) / c real += a [ i ] if i >= T : real -= a [ i - T ] if q [ q_n ] == i + 1 : q_n += 1 r = real / T print ( r , res_a , abs ( r - res_a ) / r ) NEW_LINE"
] |
codeforces_666_A | [
"import java . io . * ; import java . util . * ; public class main { public static void solucion ( String strPalabra ) { List < String > ans = new ArrayList < > ( ) ;",
"import java . util . Scanner ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; TreeSet < String > suffixes = new TreeSet < > ( ) ; String word = sc . nextLine ( ) ; sc . close ( ) ; String tempSubstring ; boolean doubleStepIsPossible [ ] = new boolean [ word . length ( ) ] ; boolean tripleStepIsPossible [ ] = new boolean [ word . length ( ) ] ; if ( word . length ( ) <= 6 ) { System . out . println ( \"0\" ) ; return ; } int wordLength = word . length ( ) ; doubleStepIsPossible [ wordLength - 2 ] = true ; suffixes . add ( word . substring ( wordLength - 2 , wordLength ) ) ; if ( wordLength > 7 ) { tripleStepIsPossible [ wordLength - 3 ] = true ; suffixes . add ( word . substring ( wordLength - 3 , wordLength ) ) ; } for ( int i = wordLength - 4 ; i >= 5 ; i -- ) { tempSubstring = word . substring ( i , i + 2 ) ; if ( tripleStepIsPossible [ i + 2 ] || ( doubleStepIsPossible [ i + 2 ] && ( ! tempSubstring . equals ( word . substring ( i + 2 , i + 4 ) ) ) ) ) { doubleStepIsPossible [ i ] = true ; suffixes . add ( tempSubstring ) ; } tempSubstring = word . substring ( i , i + 3 ) ; if ( doubleStepIsPossible [ i + 3 ] || ( tripleStepIsPossible [ i + 3 ] && ( ! tempSubstring . equals ( word . substring ( i + 3 , i + 6 ) ) ) ) ) { tripleStepIsPossible [ i ] = true ; suffixes . add ( tempSubstring ) ; } } System . out . println ( suffixes . size ( ) ) ; suffixes . forEach ( System . out :: println ) ; } }",
"import java . util . * ; public class linguistics { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String in = sc . nextLine ( ) ; char [ ] ch = in . toCharArray ( ) ; int n = ch . length ; TreeSet < String > ans = new TreeSet < > ( ) ; boolean [ ] dp2 = new boolean [ n + 1 ] ; boolean [ ] dp3 = new boolean [ n + 1 ] ; dp2 [ n ] = true ; dp3 [ n ] = true ; dp3 [ n - 3 ] = true ; dp2 [ n - 2 ] = true ; boolean s2 , s3 ; for ( int i = n - 1 ; i >= 5 ; i -- ) {"
] | [
"string = input ( ) s = set ( ) finded = { } import syssys . setrecursionlimit ( 900000000 ) def get_substr ( string , start , parent ) : NEW_LINE",
"if __name__ == ' _ _ main _ _ ' : word = input ( ) suffixes = set ( ) possible = set ( ) my_set = set ( ) not_poss = set ( ) possible . add ( ( len ( word ) , 2 ) ) while possible : tam , x = possible . pop ( ) a = tam + x for i in [ x , 5 - x ] : root = tam - i new_pos = ( root , i ) if root < 5 or new_pos in my_set or ( word [ root : tam ] == word [ tam : a ] ) : not_poss . add ( word [ root : tam ] ) else : suffixes . add ( word [ root : tam ] ) possible . add ( new_pos ) my_set . add ( new_pos ) suffixes_alph = sorted ( suffixes ) print ( len ( suffixes ) ) for i in suffixes_alph : print ( i ) NEW_LINE",
"import syssys . setrecursionlimit ( 10000 ) s = input ( ) s = s [ 5 : ] + \" ▁ \" res = set ( ) aux = set ( ) def getWords ( x , y ) : if ( x , y ) in aux : return aux . add ( ( x , y ) ) if x > 1 and s [ x : y ] != s [ x - 2 : x ] : res . add ( s [ x - 2 : x ] ) getWords ( x - 2 , x ) if x > 2 and s [ x : y ] != s [ x - 3 : x ] : res . add ( s [ x - 3 : x ] ) getWords ( x - 3 , x ) getWords ( len ( s ) - 1 , len ( s ) ) print ( len ( res ) ) for word in sorted ( list ( res ) ) : print ( word ) NEW_LINE",
"lectura = input ( ) sufix = set ( ) comb = { ( len ( lectura ) , 2 ) } setPrueba = set ( ) while comb : x , y = comb . pop ( ) pos3 = x + y for i in [ y , 5 - y ] : posIni = x - i stringActual = ( posIni , i ) if ( stringActual in setPrueba or ( posIni < 5 ) or ( lectura [ posIni : x ] == lectura [ x : pos3 ] ) ) : NEW_LINE",
"import sys value = input ( ) if ( len ( value ) < 7 ) : print ( 0 ) sys . exit ( 0 ) res = set ( ) possible = { } possible [ len ( value ) ] = set ( [ 2 ] ) if ( len ( value ) > 7 ) : possible [ len ( value ) ] . add ( 3 ) possibleLen = [ 2 , 3 ] for i in reversed ( range ( 7 , len ( value ) + 1 ) ) : possibleVal = possible . get ( i , set ( ) ) for length in possibleVal : nextI = i - length val = value [ nextI : i ] res . add ( val ) for posLen in possibleLen : if ( nextI >= 5 + posLen and value [ nextI - posLen : nextI ] != val ) : setNextI = possible . setdefault ( nextI , set ( ) ) setNextI . add ( posLen ) print ( len ( res ) ) for val in sorted ( res ) : print ( val ) NEW_LINE"
] |
codeforces_722_A | [
"import java . util . Scanner ; public class A722 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int type = in . nextInt ( ) ; String input = in . next ( ) ; int hStart ; int hEnd ; if ( type == 12 ) { hStart = 1 ; hEnd = 12 ; } else { hStart = 0 ; hEnd = 23 ; } int minDiff = 5 ; String answer = null ; for ( int h = hStart ; h <= hEnd ; h ++ ) { for ( int m = 0 ; m <= 59 ; m ++ ) { String S = String . format ( \" % 02d : %02d \" , h , m ) ; int diff = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { if ( input . charAt ( i ) != S . charAt ( i ) ) { diff ++ ; } } if ( diff < minDiff ) { minDiff = diff ; answer = S ; } } } System . out . println ( answer ) ; } }",
"import java . util . * ; import java . lang . * ; public class Main { public static void main ( String args [ ] ) { Scanner scanner = new Scanner ( System . in ) ; int format = scanner . nextInt ( ) ; String s = scanner . next ( ) ; int a = s . charAt ( 0 ) - '0' ; int b = s . charAt ( 1 ) - '0' ; int c = s . charAt ( 3 ) - '0' ; int d = s . charAt ( 4 ) - '0' ; if ( c > 5 ) c = 0 ; if ( format == 24 && a > 2 ) a = 0 ; if ( format == 24 && a == 2 && b >= 4 ) a = 0 ; if ( format == 12 && a == 0 && b == 0 ) b = 1 ; else if ( format == 12 && a == 1 && b > 2 ) b = 1 ; else if ( format == 12 && a > 1 && b > 2 ) a = 0 ; else if ( format == 12 && a > 1 ) a = 1 ; System . out . println ( a + \" \" + b + \" : \" + c + \" \" + d ) ; } }",
"import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int format = sc . nextInt ( ) ; String time = sc . next ( ) ; System . out . println ( solve ( format , time ) ) ; sc . close ( ) ; } static String solve ( int format , String time ) { int minHour ; int maxHour ; if ( format == 12 ) { minHour = 1 ; maxHour = 12 ; } else { minHour = 0 ; maxHour = 23 ; } int minDiffNum = Integer . MAX_VALUE ; String result = null ; for ( int hour = minHour ; hour <= maxHour ; hour ++ ) { for ( int minute = 0 ; minute <= 59 ; minute ++ ) { String t = String . format ( \" % 02d : %02d \" , hour , minute ) ; int diffNum = ( int ) IntStream . range ( 0 , time . length ( ) ) . filter ( i -> time . charAt ( i ) != t . charAt ( i ) ) . count ( ) ; if ( diffNum < minDiffNum ) { minDiffNum = diffNum ; result = t ; } } } return result ; } }"
] | [
"f = input ( ) h , m = input ( ) . split ( ' : ' ) if f == '12' : if h == '00' : h = '01' elif int ( h ) > 12 : if h [ 1 ] == '0' : h = '10' else : h = '0' + h [ 1 ] if f == '24' and int ( h ) > 23 : h = '1' + h [ 1 ] if int ( m ) > 59 : m = '3' + m [ 1 ] print ( h + ' : ' + m ) NEW_LINE",
"c = input ( ) h , m = list ( map ( int , input ( ) . split ( ' : ' ) ) ) if m >= 60 : m %= 10 if c == '12' and h == 0 : h = 1 elif c == '12' and h > 12 : if h % 10 : h %= 10 else : h = 10 elif c == '24' and h > 23 : h %= 10 print ( ' % 02d : %02d ' % ( h , m ) ) NEW_LINE",
"def solve ( ) : t = int ( input ( ) ) time = list ( input ( ) ) h , m = map ( int , \" \" . join ( time ) . split ( ' : ' ) ) if t == 12 : NEW_LINE",
"n = input ( ) [ 0 ] h , m = map ( int , input ( ) . split ( ' : ' ) ) if 23 < h or '2' > n and not 0 < h < 13 : h = 1 + ( 9 + h ) % 10 if 59 < m : m -= 40 print ( ' { :02 } : { : 02 } ' . format ( h , m ) ) NEW_LINE"
] |
codeforces_487_A | [
" import java . util . * ; import java . io . * ; import java . math . * ; public class Main { static FastReader sc = new FastReader ( ) ; static int dp [ ] [ ] ;",
"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 { 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 hy = fs . nextInt ( ) , ay = fs . nextInt ( ) , dy = fs . nextInt ( ) ; int hm = fs . nextInt ( ) , am = fs . nextInt ( ) , dm = fs . nextInt ( ) ; int H = fs . nextInt ( ) , A = fs . nextInt ( ) , D = fs . nextInt ( ) ; int min = ( int ) 1e9 ; for ( int atk = ay ; atk <= 200 ; atk ++ ) { for ( int def = dy ; def <= 100 ; def ++ ) { if ( atk <= dm ) continue ; int t = ( hm + atk - dm - 1 ) / ( atk - dm ) ; int reqhp = t * Math . max ( 0 , am - def ) + 1 ; int coins = ( atk - ay ) * A + ( def - dy ) * D + Math . max ( 0 , reqhp - hy ) * H ; if ( coins < min ) { min = coins ; } } } out . println ( min ) ; } out . close ( ) ; } static final Random random = new Random ( ) ; static void ruffleSort ( int [ ] a ) { int n = a . length ;"
] | [
"N = 1000 hy , ay , dy = map ( int , input ( ) . split ( ) ) hm , am , dm = map ( int , input ( ) . split ( ) ) h , a , d = map ( int , input ( ) . split ( ) ) res , c = 2e9 , 0 if ay <= dm : c = ( dm - ay + 1 ) * a ay = dm + 1 for i in range ( N ) : for j in range ( N ) : for k in range ( N ) : if am <= dy + k : res = min ( res , h * i + a * j + d * k ) break x = hy + i - am + dy + k - 1 y = am - dy - k z = hm - ay - j + dm - 1 w = ay + j - dm if x // y > z / w : res = min ( res , h * i + a * j + d * k ) breakprint ( res + c ) NEW_LINE"
] |
codeforces_638_B | [
"import java . io . * ; import java . util . * ; public class Template implements Runnable { BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer ( \" \" ) ; void init ( ) throws FileNotFoundException { try { in = new BufferedReader ( new FileReader ( \" input . txt \" ) ) ; out = new PrintWriter ( \" output . txt \" ) ; } catch ( Exception e ) { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; } } String readString ( ) throws IOException { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) ) ; } catch ( Exception e ) { return null ; } } return tok . nextToken ( ) ; } int readInt ( ) throws IOException { return Integer . parseInt ( readString ( ) ) ; } int [ ] readIntArray ( int size ) throws IOException { int [ ] res = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { res [ i ] = readInt ( ) ; } return res ; } long readLong ( ) throws IOException { return Long . parseLong ( readString ( ) ) ; } double readDouble ( ) throws IOException { return Double . parseDouble ( readString ( ) ) ; } < T > List < T > [ ] createGraphList ( int size ) { List < T > [ ] list = new List [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { list [ i ] = new ArrayList < > ( ) ; } return list ; } public static void main ( String [ ] args ) { new Template ( ) . run ( ) ;"
] | [
"n = int ( input ( ) ) m = [ ] sc = [ ] for i in range ( n ) : m . append ( input ( ) ) sc . append ( set ( m [ i ] ) ) i = 0 while i < len ( m ) : j = i + 1 p = False while j < len ( m ) : z = len ( sc [ i ] . intersection ( sc [ j ] ) ) a = len ( sc [ i ] ) b = len ( sc [ j ] ) if z == a : sc . pop ( i ) m . pop ( i ) i -= 1 break elif z == b : sc . pop ( j ) m . pop ( j ) j -= 1 elif z > 0 : if m [ i ] [ - z : ] == m [ j ] [ : z ] : m [ i ] += m [ j ] [ z : ] else : m [ i ] = m [ j ] + m [ i ] [ z : ] sc [ i ] = set ( m [ i ] ) m . pop ( j ) sc . pop ( j ) j -= 1 p = True j += 1 if not p : i += 1 i = 0 print ( ' ' . join ( m ) ) NEW_LINE",
"n = int ( input ( ) ) d = { } p = { } ans = ' ' for x in [ input ( ) for i in range ( n ) ] : for i in range ( len ( x ) - 1 ) : d [ x [ i ] ] = x [ i + 1 ] for i in range ( 1 , len ( x ) ) : p [ x [ i ] ] = 1 d . setdefault ( x [ - 1 ] , ' ' ) for x in range ( 9 , 123 ) : x = chr ( x ) if p . get ( x , 0 ) > 0 or d . get ( x , ' Q ' ) == ' Q ' : continue while x != ' ' : ans += x t = d [ x ] del d [ x ] x = tprint ( ans ) NEW_LINE",
"n = int ( input ( ) ) d = { } p = { } ans = ' ' for x in [ input ( ) for i in range ( n ) ] : for i in range ( len ( x ) - 1 ) : d [ x [ i ] ] = x [ i + 1 ] for i in range ( 1 , len ( x ) ) : p [ x [ i ] ] = 1 d . setdefault ( x [ - 1 ] , ' ' ) for x in range ( 9 , 123 ) : x = chr ( x ) if p . get ( x , 0 ) > 0 or d . get ( x , ' Q ' ) == ' Q ' : continue while x != ' ' : ans += x t = d [ x ] del d [ x ] x = tprint ( ans ) NEW_LINE",
"from typing import Listfrom string import ascii_lowercase def to_idx ( char : str ) -> int : return ord ( char ) - ord ( ' a ' ) def solve ( n : int , genomes : List [ str ] ) -> str : goto = [ - 1 ] * 26 for g in genomes : for curr , nxt in zip ( g , g [ 1 : ] ) : goto [ to_idx ( curr ) ] = to_idx ( nxt ) sources = set ( [ to_idx ( g [ 0 ] ) for g in genomes if to_idx ( g [ 0 ] ) not in goto ] ) ans = [ ] for source in sources : ptr = source ans . append ( ascii_lowercase [ ptr ] ) while goto [ ptr ] != - 1 : ptr = goto [ ptr ] ans . append ( ascii_lowercase [ ptr ] ) return ' ' . join ( ans ) n = int ( input ( ) ) genomes = [ input ( ) for _ in range ( n ) ] print ( solve ( n , genomes ) ) NEW_LINE",
"def main ( ) : ab , tails , res = { } , set ( ) , [ ] for _ in range ( int ( input ( ) ) ) : a , * s = input ( ) for b in s : ab [ a ] = a = b tails . add ( b ) ab . setdefault ( a , ' ' ) for a in ab . keys ( ) : if a not in tails : while a : res . append ( a ) a = ab [ a ] print ( ' ' . join ( res ) ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE"
] |
codeforces_750_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Main { private static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { int [ ] firstLineInput = Arrays . stream ( br . readLine ( ) . split ( \" ▁ \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int n = firstLineInput [ 0 ] ; int k = firstLineInput [ 1 ] ; int timeRemaining = 240 - k ; int sum = 0 ; int i = 0 ; for ( i = 1 ; i <= n ; i ++ ) { sum += 5 * i ; if ( sum > timeRemaining ) { break ; } } System . out . println ( i - 1 ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class NewYearHurry { 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 k = Integer . parseInt ( st . nextToken ( ) ) ; int totalTime = 240 - k ; for ( int i = n ; i >= 0 ; i -- ) { int time = i * ( 1 + i ) / 2 * 5 ; if ( time <= totalTime ) { System . out . println ( i ) ; break ; } } } }",
" import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int time_remaining = ( 4 * 60 ) - k ; int sum = 0 ; int i = 0 ; while ( sum <= time_remaining && ( i ) <= n ) { i ++ ; sum += i * 5 ; } System . out . println ( i - 1 ) ; }",
"import java . util . Arrays ; import java . util . Random ; import java . io . File ; import java . io . FileNotFoundException ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int decided = 0 ; int min = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( min + k > 240 ) { System . out . println ( decided - 1 ) ; return ; } else { decided ++ ; min += ( i + 1 ) * 5 ; } } if ( min + k > 240 ) { System . out . println ( decided - 1 ) ; } else { System . out . println ( decided ) ; } } }"
] | [
"n , k = map ( int , input ( ) . split ( ) ) t = 240 - ki = 1 count = 0 while t >= i * 5 and count < n : count += 1 t = t - i * 5 i += 1 print ( count ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = 240 b = 240 - ks = 0 c = 0 for i in range ( 1 , n + 1 ) : s += 5 * i if ( s <= b ) : c += 1 print ( c ) NEW_LINE",
"a , b = [ int ( x ) for x in input ( ) . split ( ) ] b = 240 - bc = Trued = 0 for i in range ( a ) : if ( ( i + 1 ) * 5 + d > b ) : print ( i ) c = False break d += ( i + 1 ) * 5 if c : print ( a ) NEW_LINE",
"info = [ int ( x ) for x in input ( ) . split ( ) ] problem_times = [ int ( x ) * 5 for x in range ( 1 , info [ 0 ] + 1 ) ] time_to_do = 240 - info [ 1 ] problems_done = 0 for index , i in enumerate ( problem_times ) : if time_to_do >= problem_times [ index ] : time_to_do -= i problems_done += 1 else : breakprint ( problems_done ) NEW_LINE",
"n , k = [ int ( i ) for i in input ( ) . split ( ) ] totalTime = 240 - k for i in range ( n , - 1 , - 1 ) : time = i * ( i + 1 ) / 2 * 5 if ( time <= totalTime ) : print ( i ) break NEW_LINE"
] |
codeforces_1399_A | [
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; while ( t > 0 ) { t -- ; int n = in . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; } Arrays . sort ( a ) ; boolean x = true ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i + 1 ] - a [ i ] > 1 ) { x = false ; break ; } } if ( x || n == 1 ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } } }",
"import java . util . * ; public class a { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) ; for ( int tt = 0 ; tt < t ; tt ++ ) { int x = scan . nextInt ( ) ; ArrayList < Integer > nums = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < x ; i ++ ) { int temp = scan . nextInt ( ) ; nums . add ( temp ) ; } if ( nums . size ( ) == 1 ) { System . out . println ( \" YES \" ) ; continue ; } Collections . sort ( nums ) ; for ( int i = 0 ; i < nums . size ( ) - 1 ; i ++ ) { if ( nums . get ( i + 1 ) - nums . get ( i ) <= 1 ) { nums . remove ( i ) ; i -- ; } } System . out . println ( nums . size ( ) == 1 ? \" YES \" : \" NO \" ) ; } } }",
"import java . util . Scanner ; import java . lang . Math ; import java . util . Arrays ; public class pa { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String args [ ] ) { int t = sc . nextInt ( ) ; for ( int j = 0 ; j < t ; j ++ ) { int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . sort ( arr ) ; boolean flag = true ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] + 1 ) { System . out . println ( \" NO \" ) ; flag = false ; break ; } } if ( flag == true ) System . out . println ( \" YES \" ) ; } } }",
"import java . lang . * ; import java . util . * ; public final class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( t > 0 ) { int n = s . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextInt ( ) ; Arrays . sort ( a ) ; List < Integer > l = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) l . add ( a [ i ] ) ; for ( int i = 0 ; i < l . size ( ) - 1 ; i ++ ) { if ( l . get ( i + 1 ) - l . get ( i ) <= 1 ) { l . remove ( i ) ; i = - 1 ; } } if ( l . size ( ) == 1 ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; t -- ; } } }",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int k = 0 ; k < n ; k ++ ) { a [ k ] = sc . nextInt ( ) ; } int f = 1 ; Arrays . sort ( a ) ; for ( int j = 1 ; j < n ; j ++ ) { if ( Math . abs ( a [ j ] - a [ j - 1 ] ) > 1 ) { f = 0 ; break ; } } if ( f == 1 ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } } }"
] | [
"n = int ( input ( ) ) NEW_LINE for t in range ( n ) : NEW_LINE INDENT q = int ( input ( ) ) NEW_LINE a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE g = 0 NEW_LINE for i in range ( 0 , q - 1 ) : NEW_LINE INDENT if abs ( a [ i ] - a [ i + 1 ] ) > 1 : NEW_LINE INDENT g = 1 NEW_LINE DEDENT DEDENT if g != 1 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT DEDENT",
"for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE l = sorted ( [ int ( x ) for x in input ( ) . split ( ) ] ) NEW_LINE res = ' YES ' NEW_LINE for i in range ( len ( l ) - 1 ) : NEW_LINE INDENT if l [ i + 1 ] - l [ i ] > 1 : NEW_LINE INDENT res = ' NO ' NEW_LINE break NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE DEDENT",
"import random NEW_LINE def quick_sort ( array ) : NEW_LINE INDENT if len ( array ) < 2 : NEW_LINE INDENT return array NEW_LINE DEDENT index = random . randint ( 1 , len ( array ) ) - 1 NEW_LINE pivot = array [ index ] NEW_LINE smaller = [ i for i in array [ : index ] + array [ index + 1 : ] if i <= pivot ] NEW_LINE bigger = [ i for i in array [ : index ] + array [ index + 1 : ] if i > pivot ] NEW_LINE return quick_sort ( smaller ) + [ pivot ] + quick_sort ( bigger ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE for _ in range ( n ) : NEW_LINE INDENT inp = int ( input ( ) ) NEW_LINE numbers = [ int ( i ) for i in input ( ) . split ( ' ▁ ' ) ] NEW_LINE numbers = quick_sort ( numbers ) NEW_LINE i = 0 NEW_LINE while True : NEW_LINE INDENT if i >= len ( numbers ) - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if abs ( numbers [ i ] - numbers [ i + 1 ] ) <= 1 : NEW_LINE INDENT if numbers [ i ] <= numbers [ i + 1 ] : NEW_LINE INDENT numbers . pop ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT numbers . pop ( i + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT i += 1 NEW_LINE DEDENT DEDENT if len ( numbers ) <= 1 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT DEDENT DEDENT",
"for s in [ * open ( 0 ) ] [ 2 : : 2 ] : a = { * map ( int , s . split ( ) ) } ; print ( ' YNEOS ' [ len ( a ) <= max ( a ) - min ( a ) : : 2 ] ) NEW_LINE",
"t = int ( input ( ) ) NEW_LINE for x in range ( t ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE list_a = sorted ( [ int ( k ) for k in input ( ) . split ( ) ] ) NEW_LINE f = 1 NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT if abs ( list_a [ i ] - list_a [ i + 1 ] ) > 1 : NEW_LINE INDENT f = 0 NEW_LINE DEDENT DEDENT if f == 1 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT DEDENT"
] |
codeforces_514_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int x0 = in . nextInt ( ) ; int y0 = in . nextInt ( ) ; boolean x0Line = false ; boolean y0Line = false ; Set < Double > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) - x0 ; int y = in . nextInt ( ) - y0 ; if ( x == 0 ) x0Line = true ; else if ( y == 0 ) y0Line = true ; else set . add ( ( double ) y / ( double ) x ) ; } System . out . println ( ( x0Line ? 1 : 0 ) + ( y0Line ? 1 : 0 ) + set . size ( ) ) ; } }",
"import java . util . * ; public class HanSoloAndLazerGun { static class Key { double m ; double c ; Key ( double m , double c ) { this . m = m ; this . c = c ; } public double hashcode ( ) { double hash = 7 ; hash = ( 17 * this . m ) + ( hash * this . c ) ; return hash ; } @ Override public boolean equals ( Object v ) { boolean ans = false ; if ( v instanceof Key ) { Key k = ( Key ) v ; return ( this . c == k . c && this . m == k . m ) ; } return ans ; } } public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; double x0 = sc . nextDouble ( ) ; double y0 = sc . nextDouble ( ) ; int a [ ] [ ] = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] [ 0 ] = sc . nextInt ( ) ; a [ i ] [ 1 ] = sc . nextInt ( ) ; } ArrayList < Key > al = new ArrayList < > ( ) ; double slope , cut ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] [ 0 ] - x0 == 0 ) { slope = Double . MAX_VALUE ; cut = Double . MAX_VALUE ; } else { slope = ( a [ i ] [ 1 ] - y0 ) / ( a [ i ] [ 0 ] - x0 ) ; cut = y0 - ( x0 * slope ) ; }",
"import java . util . Scanner ; public class StormTroopers { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 1 ) ; return ; } long Gx = scanner . nextLong ( ) ; long Gy = scanner . nextLong ( ) ; boolean [ ] dead = new boolean [ n ] ; Long [ ] [ ] location = new Long [ n ] [ 2 ] ; location [ 0 ] [ 0 ] = scanner . nextLong ( ) ; location [ 0 ] [ 1 ] = scanner . nextLong ( ) ; dead [ 0 ] = true ; int count = 1 ; for ( int i = 1 ; i < n ; i ++ ) { location [ i ] [ 0 ] = scanner . nextLong ( ) ; location [ i ] [ 1 ] = scanner . nextLong ( ) ; boolean check = ( location [ i ] [ 1 ] - Gy ) * ( location [ 0 ] [ 0 ] - Gx ) == ( location [ 0 ] [ 1 ] - Gy ) * ( location [ i ] [ 0 ] - Gx ) ; if ( check ) dead [ i ] = true ; } for ( int i = 1 ; i < n ; i ++ ) { if ( ! dead [ i ] ) { count ++ ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( ! dead [ j ] ) { boolean check = ( location [ j ] [ 1 ] - Gy ) * ( location [ i ] [ 0 ] - Gx ) == ( location [ i ] [ 1 ] - Gy ) * ( location [ j ] [ 0 ] - Gx ) ; if ( check ) { dead [ j ] = true ; } } } } } System . out . println ( count ) ; } }"
] | [
"n , x0 , y0 = map ( int , input ( ) . split ( ) ) s = set ( ) for _ in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) if x == x0 : s . add ( float ( ' inf ' ) ) else : s . add ( ( y - y0 ) / ( x - x0 ) ) print ( len ( s ) ) NEW_LINE",
"n , gx , gy = map ( int , input ( ) . split ( ) ) cx = 0 cy = 0 umap = { } for i in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) if ( x == gx ) : cx += 1 elif y == gy : cy += 1 else : d = ( y - gy ) / ( x - gx ) if ( d in umap ) : umap [ d ] += 1 else : umap [ d ] = 1 c = 0 NEW_LINE",
"n , x_0 , y_0 = map ( int , input ( ) . split ( ) ) arr = [ ] for i in range ( n ) : a = list ( map ( int , input ( ) . split ( ) ) ) [ : 2 ] arr . append ( a ) def tangent ( x_0 , y_0 , p1 , p2 ) : return float ( ( y_0 - p2 ) / ( x_0 - p1 ) ) arr1 = [ ] for i in range ( n ) : if arr [ i ] [ 0 ] == x_0 : arr1 . append ( - 0.0000001 ) continue for j in range ( 2 ) : a = tangent ( x_0 , y_0 , arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) arr1 . append ( a ) NEW_LINE"
] |
codeforces_1420_A | [
"import java . util . * ; public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { ar [ j ] = sc . nextInt ( ) ; } boolean check = true ; for ( int j = 0 ; j < n - 1 ; j ++ ) { if ( ar [ j ] <= ar [ j + 1 ] ) { check = false ; break ; } } if ( check ) { System . out . println ( \" NO \" ) ; } else { System . out . println ( \" YES \" ) ; } } } public static long getAns ( int n ) { if ( n == 0 ) { return n ; } int ans1 = n / 2 ; int ans2 = n / 3 ; int ans3 = n / 4 ;",
"import java . util . * ; public class HelloWorld { public static void main ( String [ ] args ) {",
"import java . io . File ; import java . io . FileNotFoundException ; import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . FileReader ; import java . io . FileWriter ; 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 . Calendar ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . Set ; import java . util . StringTokenizer ; public class B { static int mx = 1000005 ; static MScanner in = new MScanner ( System . in ) ; static void solve ( ) throws Exception { MScanner sc = new MScanner ( System . in ) ; int n = s . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextInt ( ) ; boolean can = false ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i - 1 ] <= a [ i ] ) { can = true ; break ; } } System . out . println ( can ? \" YES \" : \" NO \" ) ; } static Integer [ ] sort ( Integer [ ] arr , int n ) { Arrays . sort ( arr , new Comparator < Integer > ( ) { @ Override public int compare ( Integer arg0 , Integer arg1 ) {",
" import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . math . * ; public class ada_obstacles {",
"import java . util . * ; public class Example { static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;"
] | [
"for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) d = dict ( ) NEW_LINE for i in range ( len ( a ) ) : if NEW_LINE a [ i ] not in d : d [ a [ i ] ] = True if len ( d . keys ( ) ) == len ( a ) : k = [ ] NEW_LINE for el in a : k . append ( el ) k . sort ( reverse = True ) NEW_LINE rev = True NEW_LINE for i in range ( len ( a ) ) : if NEW_LINE a [ i ] != k [ i ] : rev = False NEW_LINE break if rev : NEW_LINE INDENT print ( \" NO \" ) else : NEW_LINE print ( \" YES \" ) else : print ( \" YES \" ) NEW_LINE DEDENT",
"import NEW_LINE INDENT sysinput = sys . stdin . readline NEW_LINE DEDENT",
"import NEW_LINE INDENT sysinput = sys . stdin . readline NEW_LINE DEDENT",
"for u in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE x = [ int ( w ) for w in input ( ) . split ( ) ] NEW_LINE f = False NEW_LINE for i in range ( n - 1 ) : if NEW_LINE INDENT ( x [ i ] <= x [ i + 1 ] ) : f = True NEW_LINE DEDENT break NEW_LINE if ( f ) : NEW_LINE INDENT print ( \" YES \" ) else : NEW_LINE print ( \" NO \" ) NEW_LINE DEDENT",
"from sys import stdin , stdoutfrom NEW_LINE math NEW_LINE import floor , gcd , fabs , factorial , fmod , sqrt , inf , logfrom NEW_LINE collections NEW_LINE import defaultdict as dd , dequefrom NEW_LINE heapq NEW_LINE import merge , heapify , heappop , heappush , nsmallestfrom NEW_LINE bisect NEW_LINE import bisect_left as bl , bisect_right as br , bisect NEW_LINE mod = pow ( 10 , 9 ) + 7 NEW_LINE mod2 = 998244353 NEW_LINE def inp ( ) : return stdin . readline ( ) . strip ( ) NEW_LINE def iinp ( ) : return int ( inp ( ) ) NEW_LINE def out ( var , end = \" \\n \" ) : stdout . write ( str ( var ) + \" \\n \" ) NEW_LINE def outa ( * var , end = \" \\n \" ) : stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) NEW_LINE def lmp ( ) : return list ( mp ( ) ) NEW_LINE def mp ( ) : return map ( int , inp ( ) . split ( ) ) NEW_LINE def smp ( ) : return map ( str , inp ( ) . split ( ) ) NEW_LINE def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] NEW_LINE def l2d ( n , m , val = 0 ) : return [ l1d ( m , val ) for j in range ( n ) ] NEW_LINE def remadd ( x , y ) : return 1 if x % y else 0 NEW_LINE def ceil ( a , b ) : return ( a + b - 1 ) // b NEW_LINE def isprime ( x ) : if NEW_LINE x <= 1 : NEW_LINE return False NEW_LINE if x in ( 2 , 3 ) : return True NEW_LINE if x % 2 == 0 : return False NEW_LINE for i in range ( 3 , int ( sqrt ( x ) ) + 1 , 2 ) : if NEW_LINE x % i == 0 : NEW_LINE return False NEW_LINE return True NEW_LINE for _ in range ( int ( inp ( ) ) ) : n = iinp ( ) NEW_LINE arr = lmp ( ) NEW_LINE print ( \" NO \" if arr == sorted ( arr , reverse = True ) and len ( set ( arr ) ) == n else \" YES \" ) NEW_LINE"
] |
codeforces_789_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . Collections ; public class Main { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int T = 1 ;",
"import java . util . Scanner ; public class AnastasiaPebbles { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double n = in . nextDouble ( ) , k = in . nextDouble ( ) , s = 0 ; for ( int i = 0 ; i < n ; i ++ ) s += Math . ceil ( in . nextDouble ( ) / k ) ; in . close ( ) ; System . out . println ( ( int ) Math . ceil ( s / 2 ) ) ; } }",
"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 k = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; while ( a != 0 ) { if ( a < k ) { count ++ ; a = 0 ; } else { a = a - k ; count ++ ; } } } if ( count % 2 == 0 ) { System . out . println ( count / 2 ) ; } else { System . out . println ( ( count / 2 ) + 1 ) ; } } }"
] | [
"import mathn , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) count1 = 0 count2 = 0 for i in range ( 0 , n ) : count2 += int ( l [ i ] / ( 2 * k ) ) if l [ i ] % ( 2 * k ) > 0 : if l [ i ] % ( 2 * k ) <= k : count1 += 1 else : count2 += 1 print ( math . ceil ( count1 / 2 ) + count2 ) NEW_LINE",
"import mathn , k = map ( int , input ( ) . split ( ) ) li = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) [ : n ] total = 0 for i in li : temp = math . ceil ( i / k ) total += tempans = math . ceil ( total / 2 ) print ( ans ) 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 , k = map ( int , input ( ) . split ( ) ) lst = list ( map ( int , input ( ) . split ( ) ) ) s = 0 for i in range ( n ) : s += math . ceil ( lst [ i ] / k ) print ( math . ceil ( s / 2 ) ) NEW_LINE",
"from math import ceiln , k = map ( int , input ( ) . split ( ) ) w = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) minDay = 0 total = 0 for i in range ( 1 , n + 1 ) : total += ceil ( w [ i ] / k ) minDay = ceil ( total / 2 ) print ( minDay ) NEW_LINE"
] |
codeforces_279_B | [
"import java . util . * ; public class Books { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } int sum = 0 , num = 0 ; for ( int i = 0 , j = 0 ; i < n ; i ++ ) { sum += ar [ i ] ; if ( sum <= m ) { num = num + 1 ; } else { sum = sum - ar [ j ] ; j ++ ; } } System . out . println ( num ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int time = sc . nextInt ( ) ; int [ ] book = new int [ n ] ; int ans = 0 ; int sum = 0 ; int l = 0 ; for ( int i = 0 ; i < n ; i ++ ) { book [ i ] = sc . nextInt ( ) ; sum += book [ i ] ; while ( sum > time ) { sum -= book [ l ++ ] ; } ans = Math . max ( i - l + 1 , ans ) ; } System . out . println ( ans ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . TreeSet ; public class Books { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int t = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] books = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { books [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; } br . close ( ) ; int [ ] booksPrefixSum = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { booksPrefixSum [ i ] = booksPrefixSum [ i - 1 ] + books [ i - 1 ] ; } TreeSet < TimeIndexPair > booksPrefixSet = new TreeSet < TimeIndexPair > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { booksPrefixSet . add ( new TimeIndexPair ( booksPrefixSum [ i ] , i ) ) ; } int [ ] candidates = new int [ n ] ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { int currTime = booksPrefixSum [ i ] ; TimeIndexPair optimal = new TimeIndexPair ( currTime + t , 0 ) ; TimeIndexPair best = booksPrefixSet . floor ( optimal ) ; if ( best != null ) { candidates [ i ] = best . index - i ; } } int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < candidates . length ; i ++ ) { max = Math . max ( candidates [ i ] , max ) ; } System . out . println ( max ) ; } } class TimeIndexPair implements Comparable < TimeIndexPair > { int time ; int index ; TimeIndexPair ( int time , int index ) { this . time = time ; this . index = index ; } @ Override public int compareTo ( TimeIndexPair o ) { return this . time - o . time ; } }"
] | [
"n , t = map ( int , input ( ) . split ( ) ) best = 0 a = list ( map ( int , input ( ) . split ( ) ) ) j = 0 s = 0 for i in range ( n ) : s += a [ i ] while s > t : s -= a [ j ] j += 1 best = max ( best , i - j + 1 ) print ( best ) NEW_LINE",
"n , t = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = 0 h = { } s = 0 l = 0 for i in range ( n ) : s += a [ i ] if s <= t : c = max ( c , i - l + 1 ) else : s -= a [ l ] l += 1 print ( c ) NEW_LINE",
"a , b = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) p1 = 0 p2 = 0 best = 0 while p2 < a : if p1 == p2 : if l [ p1 ] <= b : top = l [ p1 ] p2 += 1 else : p1 += 1 p2 += 1 top = 0 elif p1 < p2 : if top + l [ p2 ] <= b : top += l [ p2 ] p2 += 1 else : best = max ( best , p2 - p1 ) top -= l [ p1 ] p1 += 1 best = max ( best , p2 - p1 ) print ( best ) NEW_LINE",
"a , b = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) e = s = best = 0 while e < a : if s == e : if l [ s ] <= b : top = l [ s ] e += 1 else : s = e = s + 1 elif s < e : if top + l [ e ] <= b : top += l [ e ] e += 1 else : best = max ( best , e - s ) top -= l [ s ] s += 1 best = max ( best , e - s ) print ( best ) NEW_LINE",
" n , t = [ int ( _ ) for _ in input ( ) . split ( ) ] b = [ int ( _ ) for _ in input ( ) . split ( ) ] bc = 0j = 0 tr = t for i in range ( n ) : while j < n and tr >= b [ j ] : tr -= b [ j ] j += 1 bc = max ( bc , j - i ) tr += b [ i ] print ( bc ) NEW_LINE"
] |
codeforces_66_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; try { long x = in . nextLong ( ) ; if ( x <= 127 ) System . out . println ( \" byte \" ) ; else if ( x <= 32767 ) System . out . println ( \" short \" ) ; else if ( x <= 2147483647 ) System . out . println ( \" int \" ) ; else System . out . println ( \" long \" ) ; } catch ( Exception e ) { System . out . println ( \" BigInteger \" ) ; } } }",
"import java . util . * ; public class Solution { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String args [ ] ) { String s = sc . next ( ) ; long num = 0 ; String sarr [ ] = { \" byte \" , \" short \" , \" int \" , \" long \" , \" BigInteger \" } ; long upperlimit [ ] = { 127 , ( long ) Math . pow ( 2 , 15 ) - 1 , ( long ) Math . pow ( 2 , 31 ) - 1 , ( long ) ( 2 * ( Math . pow ( 2 , 62 ) - 0.5 ) ) } ; long lowerlimit [ ] = { - 128 , ( long ) - Math . pow ( 2 , 16 ) , ( long ) - Math . pow ( 2 , 32 ) , ( long ) - Math . pow ( 2 , 64 ) } ; int limitptr = 0 ;",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; long n ; try { n = stdin . nextLong ( ) ; } catch ( Exception e ) { System . out . println ( \" BigInteger \" ) ; return ; } if ( n >= - 128 && n <= 127 ) System . out . println ( \" byte \" ) ; else if ( n >= - 32768 && n <= 32767 ) System . out . println ( \" short \" ) ; else if ( n >= - 2147483648 && n <= 2147483647 ) System . out . println ( \" int \" ) ; else System . out . println ( \" long \" ) ; } }",
"import java . util . * ; import java . math . BigInteger ; import java . io . * ; public class Main { public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String param [ ] = br . readLine ( ) . trim ( ) . split ( \" \\\\ s + \" ) ; BigInteger m = new BigInteger ( param [ 0 ] ) ; BigInteger A = new BigInteger ( \"127\" ) ; BigInteger B = new BigInteger ( \"32767\" ) ; BigInteger C = new BigInteger ( \"2147483647\" ) ; BigInteger D = new BigInteger ( \"9223372036854775807\" ) ; if ( m . compareTo ( A ) <= 0 ) System . out . println ( \" byte \" ) ; else if ( m . compareTo ( B ) <= 0 ) System . out . println ( \" short \" ) ; else if ( m . compareTo ( C ) <= 0 ) System . out . println ( \" int \" ) ; else if ( m . compareTo ( D ) <= 0 ) System . out . println ( \" long \" ) ; else System . out . println ( \" BigInteger \" ) ; } }",
"import java . util . Scanner ; public class p66A { public static void main ( String [ ] args ) { Scanner x = new Scanner ( new Scanner ( System . in ) . next ( ) ) ; String s ; if ( x . hasNextByte ( ) ) s = \" byte \" ; else if ( x . hasNextShort ( ) ) s = \" short \" ; else if ( x . hasNextInt ( ) ) s = \" int \" ; else if ( x . hasNextLong ( ) ) s = \" long \" ; else s = \" BigInteger \" ; System . out . println ( s ) ; } }"
] | [
"n = int ( input ( ) ) if n >= - 128 and n <= 127 : NEW_LINE INDENT print ( ' byte ' ) elif n >= - 32768 and n <= 32767 : NEW_LINE print ( ' short ' ) elif n >= - 2147483648 and n <= 2147483647 : NEW_LINE print ( ' int ' ) elif n >= - 9223372036854775808 and n <= 9223372036854775807 : NEW_LINE print ( ' long ' ) else : NEW_LINE print ( ' BigInteger ' ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE if n >= - 128 and n <= 127 : NEW_LINE INDENT print ( \" byte \" ) elif n >= - 32768 and n <= 32767 : NEW_LINE print ( \" short \" ) elif n >= - 2147483648 and n <= 2147483647 : NEW_LINE print ( \" int \" ) elif n >= - 9223372036854775808 and n <= 9223372036854775807 : NEW_LINE print ( \" long \" ) else : NEW_LINE print ( \" BigInteger \" ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE if - ( 2 ** 7 ) <= n <= 2 ** 7 - 1 : NEW_LINE INDENT print ( \" byte \" ) else : NEW_LINE if NEW_LINE DEDENT - ( 2 ** 15 ) <= n <= 2 ** 15 - 1 : print ( \" short \" ) else : if - ( 2 ** 31 ) <= n <= 2 ** 31 - 1 : NEW_LINE INDENT print ( \" int \" ) else : NEW_LINE if NEW_LINE DEDENT - ( 2 ** 63 ) <= n <= 2 ** 63 - 1 : print ( \" long \" ) else : print ( \" BigInteger \" ) NEW_LINE",
"import sysimport NEW_LINE mathimport NEW_LINE collectionsimport NEW_LINE bisectdef NEW_LINE get_ints ( ) : NEW_LINE return map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) NEW_LINE def get_list ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) NEW_LINE def get_string ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE for t in range ( 1 ) : n = int ( input ( ) ) NEW_LINE if n >= - 128 and n <= 127 : NEW_LINE INDENT print ( \" byte \" ) elif n >= - 32768 and n <= 32767 : NEW_LINE print ( \" short \" ) elif n >= - 2147483648 and n <= 2147483647 : NEW_LINE print ( \" int \" ) elif n >= - 9223372036854775808 and n <= 9223372036854775807 : NEW_LINE print ( \" long \" ) else : NEW_LINE print ( \" BigInteger \" ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE if n >= - 128 and n <= 127 : NEW_LINE INDENT print ( ' byte ' ) elif n >= - 32768 and n <= 32767 : NEW_LINE print ( ' short ' ) elif n >= - 2147483648 and n <= 2147483647 : NEW_LINE print ( ' int ' ) elif n >= - 9223372036854775808 and n <= 9223372036854775807 : NEW_LINE print ( ' long ' ) else : NEW_LINE print ( ' BigInteger ' ) NEW_LINE DEDENT"
] |
codeforces_108_A | [
"import java . io . * ; public class Main { static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { String s = input . nextLine ( ) ; String [ ] str = s . split ( \" : \" ) ; int n = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; while ( true ) { m ++ ; n += m / 60 ; m = m % 60 ; n = n % 24 ; if ( n / 10 == m % 10 && n % 10 == m / 10 ) { break ; } } pr . printf ( \" % d % d : % d % d \" , n / 10 , n % 10 , m / 10 , m % 10 ) ; pr . flush ( ) ; } static class input { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StreamTokenizer in = new StreamTokenizer ( br ) ; static String nextLine ( ) throws IOException { return br . readLine ( ) ; } static int nextInt ( ) throws IOException { in . nextToken ( ) ; return ( int ) in . nval ; } static long nextLong ( ) throws IOException { in . nextToken ( ) ; return ( long ) in . nval ; } static double nextDouble ( ) throws IOException { in . nextToken ( ) ; return in . nval ; } } } ",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; String [ ] split = s . split ( \" : \" ) ; int a = Integer . valueOf ( split [ 0 ] ) ; int b = Integer . valueOf ( split [ 1 ] ) ; while ( true ) { b ++ ; a += ( b / 60 ) ; b %= 60 ; a %= 24 ; if ( b / 10 == a % 10 && b % 10 == a / 10 ) { break ; } } System . out . println ( a / 10 + \" \" + a % 10 + \" : \" + b / 10 + b % 10 ) ; } } ",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int h = Integer . valueOf ( s . substring ( 0 , 2 ) ) ; int m = Integer . valueOf ( s . substring ( 3 , 5 ) ) ; int rev = 0 ; int temp = h ; if ( h >= 16 && h <= 19 ) { h = 20 ; System . out . println ( h / 10 + \" \" + h % 10 + \" : \" + h % 10 + \" \" + h / 10 ) ; } else if ( h >= 6 && h <= 9 ) { h = 10 ; System . out . println ( h / 10 + \" \" + h % 10 + \" : \" + h % 10 + \" \" + h / 10 ) ; } else { for ( int i = 0 ; i < 2 ; i ++ , temp = temp / 10 ) rev = rev * 10 + temp % 10 ; if ( m < rev ) { h = ( h >= 16 && h <= 19 ) ? 20 : h ; System . out . println ( h / 10 + \" \" + h % 10 + \" : \" + h % 10 + \" \" + h / 10 ) ; } else { h = ( h + 1 != 24 ) ? h + 1 : 0 ; h = ( h >= 16 && h <= 19 ) ? 20 : h ; System . out . println ( h / 10 + \" \" + h % 10 + \" : \" + h % 10 + \" \" + h / 10 ) ; } } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; while ( scanner . hasNext ( ) ) { String [ ] s = scanner . next ( ) . split ( \" : \" ) ; int h = Integer . parseInt ( s [ 0 ] ) ; int m = Integer . parseInt ( s [ 1 ] ) ; while ( true ) { m ++ ; h += m / 60 ; m %= 60 ; h %= 24 ; if ( h / 10 == m % 10 && h % 10 == m / 10 ) break ; } System . out . print ( h / 10 ) ; System . out . print ( h % 10 ) ; System . out . print ( \" : \" ) ; System . out . print ( m / 10 ) ; System . out . println ( m % 10 ) ; } } }"
] | [
"h , m = [ y for y in input ( ) . split ( \" : \" ) ] h1 = int ( h [ 0 ] ) h2 = int ( h [ 1 ] ) m1 = int ( m [ 0 ] ) m2 = int ( m [ 1 ] ) cond = Truewhile cond : m2 += 1 if m2 == 10 : m2 = 0 m1 += 1 if m1 == 6 : m1 = 0 h2 += 1 if h2 == 4 and h1 == 2 : h1 = 0 h2 = 0 elif h2 == 10 : h2 = 0 h1 += 1 if m2 == h1 and h2 == m1 : print ( h1 , h2 , end = \" \" , sep = \" \" ) print ( \" : \" , end = \" \" ) print ( m1 , m2 , sep = \" \" ) break NEW_LINE",
"def pal ( h , m ) : return ( h % 10 == m // 10 ) and ( h // 10 == m % 10 ) s = input ( ) h = int ( s [ 0 ] ) * 10 + int ( s [ 1 ] ) m = int ( s [ 3 ] ) * 10 + int ( s [ 4 ] ) + 1 if ( m == 60 ) : m = 0 h = h + 1 if ( h == 24 ) : h = 0 while ( pal ( h , m ) is False ) : m = m + 1 if ( m == 60 ) : m = 0 h = h + 1 if ( h == 24 ) : h = 0 if ( h < 10 ) : print ( \"0\" , end = \" \" ) print ( h , end = \" \" ) print ( \" : \" , end = \" \" ) if ( m < 10 ) : print ( \"0\" , end = \" \" ) print ( m , end = \" \" ) NEW_LINE",
"s = input ( ) h = int ( s [ : 2 ] ) m = int ( s [ 3 : ] ) while True : m += 1 h += m // 60 m = m % 60 h = h % 24 if h // 10 == m % 10 and m // 10 == h % 10 : breakprint ( h // 10 , h % 10 , ' : ' , m // 10 , m % 10 , sep = ' ' ) NEW_LINE",
"h , m = map ( int , input ( ) . split ( ' : ' ) ) while 1 : m += 1 if m == 60 : h += 1 ; m = 0 if h == 24 : h = 0 a = str ( h ) ; a = '0' * ( 2 - len ( a ) ) + a b = str ( m ) ; a += ' : ' + '0' * ( 2 - len ( b ) ) + b if ( a == a [ : : - 1 ] ) : print ( a ) ; exit ( ) NEW_LINE"
] |
codeforces_1316_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 . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Second { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; int t ; t = in . nextInt ( ) ;",
"import java . util . * ; import java . io . * ; import java . math . * ; public class Practice { static FastReader sc = new FastReader ( ) ; static int dx [ ] = { - 1 , 0 , 1 , 0 } ; static int dy [ ] = { 0 , 1 , 0 , - 1 } ; static int k ; public static void main ( String [ ] args ) {",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Main { static String original ; static int n ; static String smallest ; public static int Smaller ( String s ) { int value = smallest . compareTo ( s ) ; return value ; } public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int tc = input . nextInt ( ) ; while ( tc -- > 0 ) { n = input . nextInt ( ) ; original = input . next ( ) ; smallest = original ; int ans = 1 ; int min = original . compareTo ( smallest ) ; int score = 2 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( ( n % 2 == 0 && score % 2 == 0 ) || ( n % 2 != 0 && score % 2 != 0 ) ) {"
] | [
"for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) s = input ( ) k = 1 z = ' ' a = [ s ] b = [ ] while k < n : z = s [ k : n ] if n % 2 == k % 2 : z += s [ 0 : k ] else : z += s [ 0 : k ] [ : : - 1 ] a . append ( z ) b . append ( k ) k += 1 print ( min ( a ) ) try : print ( b [ a . index ( min ( a ) ) ] ) except IndexError : print ( n ) NEW_LINE",
"def solve ( s , n , k ) : s = [ w for w in s ] i = k - 1 if ( n - k + 1 ) % 2 == 0 : ans = s [ i : ] + s [ 0 : i ] else : p = s [ : i ] p . reverse ( ) ans = s [ i : ] + p return ' ' . join ( ans ) for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) s = input ( ) NEW_LINE",
"import sysinput = sys . stdin . readlinet = int ( input ( ) ) for you in range ( t ) : n = int ( input ( ) ) s = input ( ) s = s [ : - 1 ] ans = 0 mina = s for i in range ( n ) : pref = s [ : i ] suff = s [ i : ] swaps = ( n - i ) if ( swaps % 2 ) : z = suff + pref [ : : - 1 ] else : z = suff + pref if ( z < mina ) : mina = z ans = i print ( mina ) print ( ans + 1 ) 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 ) : x // d if ( x % d == 0 ) else x // d + 1 def LCM ( a , b ) : return ( a * b ) // gcd ( a , b ) def solve ( ) : n = iin ( ) a = sin ( ) z = [ ] for k in range ( n - 1 ) : if n % 2 == k % 2 : z . append ( [ a [ k : ] + a [ : k ] , k + 1 ] ) continue z . append ( [ a [ k : ] + a [ : k ] [ : : - 1 ] , k + 1 ] ) z . append ( [ a [ : : - 1 ] , n ] ) NEW_LINE"
] |
codeforces_362_A | [
"import java . io . * ; import java . util . * ; import static java . lang . Math . max ; import static java . lang . Math . min ; import static java . lang . StrictMath . abs ; public class Solution implements Runnable { public static void main ( String [ ] args ) throws IOException , InterruptedException {"
] | [
"n = int ( input ( ) ) for t in range ( n ) : if t : input ( ) board = [ [ c for c in input ( ) ] for i in range ( 8 ) ] k1 , k2 = ( ( i , j ) for i in range ( 8 ) for j in range ( 8 ) if board [ i ] [ j ] == ' K ' ) if ( k1 [ 0 ] - k2 [ 0 ] ) % 4 == 0 and ( k1 [ 1 ] - k2 [ 1 ] ) % 4 == 0 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE",
"t = int ( input ( ) ) for _ in range ( t ) : s = [ input ( ) for i in range ( 8 ) ] oh = True flag = True for i in range ( 8 ) : for j in range ( 8 ) : if ( s [ i ] [ j ] == ' K ' ) : if ( flag ) : pos1x = i pos1y = j flag = False else : pos2x = i pos2y = j if ( pos1x % 4 == pos2x % 4 ) and ( pos1y % 4 == pos2y % 4 ) : print ( ' YES ' ) else : print ( ' NO ' ) if ( _ < t - 1 ) : k = input ( ) NEW_LINE",
"t = int ( input ( ) ) while t : t += - 1 l = [ ] mp = [ ] for i in range ( 8 ) : tmp = list ( input ( ) ) l . append ( tmp ) mp . append ( [ 0 ] * 8 ) i1 , j1 , i2 , j2 = - 1 , - 1 , - 1 , - 1 for i in range ( 8 ) : for j in range ( 8 ) : if l [ i ] [ j ] == ' K ' and i1 == - 1 : i1 , j1 = i , j if l [ i ] [ j ] == ' K ' : i2 , j2 = i , j if abs ( i2 - i1 ) % 4 == 0 and abs ( j2 - j1 ) % 4 == 0 : print ( ' YES ' ) else : print ( ' NO ' ) if t != 0 : input ( ) NEW_LINE",
"t = int ( input ( ) ) while t : t += - 1 l = [ ] mp = [ ] for i in range ( 8 ) : tmp = list ( input ( ) ) l . append ( tmp ) mp . append ( [ 0 ] * 8 ) i1 , j1 , i2 , j2 = - 1 , - 1 , - 1 , - 1 for i in range ( 8 ) : for j in range ( 8 ) : if l [ i ] [ j ] == ' K ' and i1 == - 1 : i1 , j1 = i , j if l [ i ] [ j ] == ' K ' : i2 , j2 = i , j if abs ( i2 - i1 ) % 4 == 0 and abs ( j2 - j1 ) % 4 == 0 : print ( ' YES ' ) else : print ( ' NO ' ) if t != 0 : input ( ) NEW_LINE"
] |
codeforces_383_A | [
"import java . util . Scanner ; public class C { public static void main ( String [ ] args ) {",
"import java . util . * ; public class practice { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int index = 0 ; index < n ; index ++ ) { a [ index ] = scan . nextInt ( ) ; } long b [ ] = new long [ n ] , cnt = 0 ; for ( int index = 0 ; index < n ; index ++ ) { if ( a [ index ] == 0 ) cnt ++ ; b [ index ] = cnt ; } long sum = 0 ; for ( int index = n - 1 ; index >= 0 ; index -- ) { if ( a [ index ] != 0 ) sum += b [ n - 1 ] - b [ index ] ; } System . out . println ( sum ) ; return ; } }",
"import java . lang . * ; import java . text . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { arr [ i ] = scanner . nextInt ( ) ; } int cnt = 0 ; int [ ] tool = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; -- i ) { if ( arr [ i ] == 0 ) cnt ++ ; tool [ i ] = cnt ; } long lost = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( arr [ i ] == 1 ) lost += tool [ i ] ; } System . out . println ( lost ) ; scanner . close ( ) ; }"
] | [
"n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) x = l . count ( 0 ) y = l . count ( 1 ) if x >= y : a = [ ] k = 0 for i in range ( n - 1 , - 1 , - 1 ) : if l [ i ] == 1 : a . append ( k ) else : k += 1 else : a = [ ] k = 0 for i in range ( n ) : if l [ i ] == 0 : a . append ( k ) else : k += 1 print ( sum ( a ) ) NEW_LINE",
"n = int ( input ( ) ) lst = list ( map ( int , input ( ) . split ( ) ) ) dp_0 = [ 0 for i in range ( n ) ] dp_1 = [ 0 for i in range ( n ) ] count_1 = 0 for i in range ( n ) : dp_1 [ i ] = count_1 count_1 += lst [ i ] count_0 = 0 for i in range ( n - 1 , - 1 , - 1 ) : dp_0 [ i ] = count_0 if ( lst [ i ] == 0 ) : count_0 += 1 num_0 = 0 num_1 = 0 total_0 = 0 total_1 = 0 for i in range ( n ) : if ( lst [ i ] == 1 ) : total_1 = total_1 + dp_0 [ i ] + dp_1 [ i ] total_1 = total_1 - ( n - i - 1 - dp_0 [ i ] ) else : total_0 = total_0 + dp_0 [ i ] + dp_1 [ i ] total_0 = total_0 - ( i - dp_1 [ i ] ) NEW_LINE",
"n = int ( input ( ) ) a = input ( ) a = [ int ( x ) for x in a . split ( ) ] sum = 0 ans = 0 for i in range ( n ) : if a [ i ] == 1 : sum += 1 else : ans += sumprint ( ans ) NEW_LINE",
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) dif = [ 0 ] * nl = 0 for i in range ( n - 1 , - 1 , - 1 ) : if arr [ i ] == 0 : l += 1 dif [ i ] = lnuksan = 0 for i in range ( n - 1 ) : if arr [ i ] == 1 : nuksan += dif [ i + 1 ] print ( nuksan ) NEW_LINE"
] |
codeforces_478_B | [
"import java . util . * ; public class RandomTeams { public static void main ( String [ ] args ) {",
" import java . io . * ; import java . util . * ; public class B_478 { public static void main ( String args [ ] ) { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; long n = in . nextLong ( ) ; long m = in . nextLong ( ) ; long max = ( ( n - m + 1 ) * ( n - m ) ) / 2 ; int i = 0 ; if ( m == 1 ) { System . out . println ( max + \" ▁ \" + max ) ; } else if ( n == m ) { System . out . println ( 0 + \" ▁ \" + 0 ) ; } else { long p = n / m ; long q = n % m ; long min = ( q * ( ( p + 1 ) * p ) / 2 ) + ( ( m - q ) * ( p * ( p - 1 ) ) / 2 ) ;",
"import java . util . * ; import java . math . * ; public class RandomTeams { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; long max = n - ( m - 1 ) ; max = max * ( max - 1 ) / 2 ; long x = n / m , y = n % m ; long min = 0 ; min += ( m - y ) * x * ( x - 1 ) / 2 ; x ++ ; min += y * x * ( x - 1 ) / 2 ; System . out . println ( min + \" ▁ \" + max ) ; } }",
"import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {"
] | [
"n , m = map ( int , input ( ) . split ( ) ) f = n // mq = n % m mini = ( f * ( f - 1 ) ) // ( 1 + 1 ) mini *= mmini += f * q ma = n - mma = ( ma * ( ma + 1 ) ) // ( 1 + 1 ) print ( mini , ma ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) kmin = n // mkmax = n - m pairMin = m * kmin * ( kmin - 1 ) // 2 + kmin * ( n % m ) pairMax = ( kmax + 1 ) * kmax // 2 print ( pairMin , pairMax ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) kmin = n // mkmax = n - mpairMin = m * kmin * ( kmin - 1 ) // 2 + kmin * ( n % m ) pairMax = ( kmax + 1 ) * kmax // 2 print ( pairMin , pairMax ) NEW_LINE",
"n , m = map ( int , input ( ) . split ( ) ) f = n // mt = n % m mini = ( f * ( f - 1 ) ) // ( 1 + 1 ) mini *= mmini += f * t ma = n - mma = ( ma * ( ma + 1 ) ) // ( 1 + 1 ) print ( mini , ma ) NEW_LINE"
] |
codeforces_1095_A | [
"import java . util . * ; public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int j = 0 , a = 0 ; while ( j < s . length ( ) ) { System . out . print ( s . charAt ( j ) ) ; a ++ ; j += a ; } } }",
"import java . util . * ; import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; public class Trin { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int c = 1 ; int i = 0 ; String result = \" \" ; while ( i < s . length ( ) ) { result = result + s . charAt ( i ) ; i = i + c ; c ++ ; } System . out . println ( result ) ; pw . flush ( ) ; pw . close ( ) ; } public static int findMaxSumSubarray ( int [ ] arr , int k ) { int maxValue = Integer . MIN_VALUE ; int currentRunningSum = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { currentRunningSum += arr [ i ] ; if ( i >= k - 1 ) { maxValue = Math . max ( maxValue , currentRunningSum ) ; currentRunningSum -= arr [ i - ( k - 1 ) ] ;",
"import java . util . * ; import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; public class Trin { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int c = 1 ; int i = 0 ; String result = \" \" ; while ( i < s . length ( ) ) { result = result + s . charAt ( i ) ; i = i + c ; c ++ ; } System . out . println ( result ) ; pw . flush ( ) ; pw . close ( ) ; } public static int findMaxSumSubarray ( int [ ] arr , int k ) { int maxValue = Integer . MIN_VALUE ; int currentRunningSum = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { currentRunningSum += arr [ i ] ; if ( i >= k - 1 ) { maxValue = Math . max ( maxValue , currentRunningSum ) ; currentRunningSum -= arr [ i - ( k - 1 ) ] ;",
"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 FileWriter fw ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static int oo = Integer . MAX_VALUE ;"
] | [
"n = int ( input ( ) ) m = input ( ) s = [ ] s [ : 0 ] = mc = 0 a = [ ] if n == 1 : print ( m ) else : for i in range ( 1 , n , 1 ) : if ( c < len ( s ) ) : a . append ( s [ c ] ) else : break c += i print ( ' ' . join ( map ( str , a ) ) ) NEW_LINE",
"size = int ( input ( ) ) string = input ( ) t = 0 for i in range ( len ( string ) ) : try : print ( string [ i + t ] , end = ' ' ) except IndexError : break t += i + 1 NEW_LINE",
"n = int ( input ( ) ) s = input ( ) res = ' ' counter = 0 k = 1 while counter <= n : res += s [ counter ] k += 1 counter += kprint ( res ) NEW_LINE",
"n = int ( input ( ) ) s = input ( ) . strip ( ) c = 1 i = 0 an = [ ] while ( i < n ) : an . append ( s [ i ] ) i += c c += 1 print ( ' ' . join ( an ) ) NEW_LINE",
"n = int ( input ( ) ) t = input ( ) s = ' ' i = j = 0 while i < n : s += t [ i ] ; j += 1 ; i += jprint ( s ) NEW_LINE"
] |
codeforces_650_B | [
"import java . io . * ; import java . util . * ; import java . math . * ; public class Main { public int cost ( char c ) { if ( c == ' w ' ) { return 1 + b ; } else { return 1 ; } } int n , a , b , t ; public void solve ( ) throws IOException { n = in . nextInt ( ) ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; t = in . nextInt ( ) ; char [ ] str = in . next ( ) . toCharArray ( ) ; int cum = cost ( str [ 0 ] ) ; if ( cum > t ) { out . println ( 0 ) ; return ; } int res = 1 ; int l = n - 1 ; int r = 0 ; "
] | [
"from sys import stdin , stdoutnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) for _ in range ( 1 ) : NEW_LINE",
"read = lambda : map ( int , input ( ) . split ( ) ) per = lambda L , R : R - L - 1 + min ( R - n - 1 , n - L ) n , a , b , T = read ( ) f = [ 1 + ( i == ' w ' ) * b for i in input ( ) ] * 2 L , R = 0 , nans = 0 cur = sum ( f ) // 2 while L <= n and R < n * 2 : cur += f [ R ] ; R += 1 while R - L > n or cur + per ( L , R ) * a > T : cur -= f [ L ] ; L += 1 ans = max ( ans , R - L ) print ( ans ) NEW_LINE",
"def main ( ) : n , a , b , t = map ( int , input ( ) . split ( ) ) b += 1 l = [ b if char == \" w \" else 1 for char in input ( ) ] t -= sum ( l ) - a * ( n + 2 ) hi , n2 = n , n * 2 n3 = n2 + 1 lo = res = 0 l *= 2 while lo <= n and hi < n2 : t -= l [ hi ] hi += 1 while ( hi - lo + ( hi if hi < n3 else n3 ) ) * a > t or lo < hi - n : t += l [ lo ] lo += 1 n3 -= 1 if res < hi - lo : res = hi - lo if res == n : break print ( res ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE"
] |
codeforces_248_B | [
"import java . util . * ; import java . io . * ; public class R152D2B { public static void main ( String [ ] args ) throws Exception {"
] | [
"INDENT def main ( ) : n = int ( input ( ) ) if ( n < 3 ) : print ( - 1 ) else : n -= 1 p = n b = 10 res = 1 while p : if p & 0x1 : res *= b b *= b p >>= 1 for i in range ( 0 , 1000 ) : if ( res + i ) % 210 == 0 : print ( 10 ** n + i ) exit ( ) main ( ) NEW_LINE DEDENT",
"import mathn = int ( input ( ) ) if n <= 2 : print ( - 1 ) else : print ( 210 * ( ( 10 ** ( n - 1 ) + 209 ) // 210 ) ) NEW_LINE",
"n = int ( input ( ) ) if ( n <= 2 ) : print ( - 1 ) else : print ( ( ( pow ( 10 , n - 1 ) // 210 ) + 1 ) * 210 ) NEW_LINE",
"def mypow ( a , b ) : base = a res = 1 while b : if b & 1 : res *= base base *= base b >>= 1 return resdef sol ( n ) : sum = mypow ( 10 , n - 1 ) for i in range ( sum , sum + 210 + 1 , 1 ) : if i % 210 == 0 : return in = int ( input ( ) ) if n < 3 : print ( - 1 ) else : print ( sol ( n ) ) NEW_LINE",
" def main ( ) : n = int ( input ( ) ) if ( n < 3 ) : print ( - 1 ) else : n -= 1 p = n b = 10 res = 1 while p : if p & 0x1 : res *= b b *= b p >>= 1 for i in range ( 0 , 211 ) : if ( res + i ) % 210 == 0 : print ( 10 ** n + i ) exit ( ) main ( ) NEW_LINE"
] |
codeforces_408_B | [
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class BooBs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str1 = sc . nextLine ( ) ; String str2 = sc . nextLine ( ) ; char [ ] arr1 = str1 . toCharArray ( ) ; char [ ] arr2 = str2 . toCharArray ( ) ; int [ ] map1 = new int [ 26 ] ; Arrays . fill ( map1 , 0 ) ; int [ ] map2 = new int [ 26 ] ; Arrays . fill ( map2 , 0 ) ; int count = 0 ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { map1 [ arr1 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < str2 . length ( ) ; i ++ ) { map2 [ arr2 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( map2 [ i ] > 0 ) { if ( map1 [ i ] == 0 ) { count = - 1 ; break ; } else if ( map1 [ i ] >= map2 [ i ] ) { count += map2 [ i ] ; } else { count += map1 [ i ] ; } } } if ( count == 0 ) { count = - 1 ; } System . out . println ( count ) ; } }",
"import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {",
"import java . util . * ; public class Garland { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String ava = sc . next ( ) ; String gar = sc . next ( ) ; HashMap < Character , Integer > mapava = new HashMap < > ( ) ; HashMap < Character , Integer > mapgar = new HashMap < > ( ) ; for ( int i = 0 ; i < ava . length ( ) ; i ++ ) { if ( ! mapava . containsKey ( ava . charAt ( i ) ) ) mapava . put ( ava . charAt ( i ) , 1 ) ; else mapava . put ( ava . charAt ( i ) , mapava . get ( ava . charAt ( i ) ) + 1 ) ; } for ( int i = 0 ; i < gar . length ( ) ; i ++ ) { if ( ! mapgar . containsKey ( gar . charAt ( i ) ) ) mapgar . put ( gar . charAt ( i ) , 1 ) ; else mapgar . put ( gar . charAt ( i ) , mapgar . get ( gar . charAt ( i ) ) + 1 ) ; } int ans = 0 ; for ( Map . Entry < Character , Integer > mape : mapgar . entrySet ( ) ) { if ( mapava . containsKey ( mape . getKey ( ) ) ) ans += Math . min ( mape . getValue ( ) , mapava . get ( mape . getKey ( ) ) ) ; else { ans = 0 ; break ; } } if ( ans == 0 ) System . out . println ( - 1 ) ; else System . out . println ( ans ) ; } } "
] | [
"import sysfrom collections import Counterdef fmax ( n , m ) : cn = Counter ( n ) cm = Counter ( m ) for i in cm : if cn [ i ] == 0 : return - 1 ta = 0 if len ( n ) <= len ( m ) : for i in cm : ta = ta + min ( cn [ i ] , cm [ i ] ) if len ( n ) > len ( m ) : for i in cm : ta = ta + min ( cn [ i ] , cm [ i ] ) return ta if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( str , input . split ( ) ) ) n = data [ 0 ] m = data [ 1 ] print ( fmax ( n , m ) ) NEW_LINE",
"from collections import Countera = list ( input ( ) ) b = list ( input ( ) ) d1 = Counter ( a ) c = 0 d2 = Counter ( b ) for i in d2 : if i in d1 : if d1 [ i ] < d2 [ i ] : c += d1 [ i ] else : c += d2 [ i ] else : c = 0 breakif c == 0 : print ( - 1 ) else : print ( c ) NEW_LINE",
"import sysimport mathdef fn ( n , m ) : cnt = [ 0 ] * 123 cnt1 = [ 0 ] * 123 n = list ( n ) m = list ( m ) m1 = list ( set ( m ) ) for i in range ( len ( n ) ) : cnt [ ord ( n [ i ] ) ] = cnt [ ord ( n [ i ] ) ] + 1 for i in range ( len ( m ) ) : cnt1 [ ord ( m [ i ] ) ] = cnt1 [ ord ( m [ i ] ) ] + 1 for i in range ( len ( m ) ) : if cnt [ ord ( m [ i ] ) ] == 0 : return - 1 a = 0 for i in range ( len ( m1 ) ) : if cnt1 [ ord ( m1 [ i ] ) ] <= cnt [ ord ( m1 [ i ] ) ] : a = a + cnt1 [ ord ( m1 [ i ] ) ] elif cnt1 [ ord ( m1 [ i ] ) ] > cnt [ ord ( m1 [ i ] ) ] : a = a + cnt [ ord ( m1 [ i ] ) ] return aif __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( str , input . split ( ) ) ) n = data [ 0 ] m = data [ 1 ] print ( fn ( n , m ) ) NEW_LINE"
] |
codeforces_1359_B | [
"import java . io . * ; import java . util . * ; import java . text . DecimalFormat ; public class Main { static long mod = ( long ) 1e9 + 7 ; static long mod1 = 998244353 ; public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; char [ ] [ ] arr = new char [ n ] [ m ] ; int horizontal_pair = 0 ; int single_dots = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String st = in . next ( ) ; String temp = st ; horizontal_pair += ( m - temp . replace ( \" . . \" , \" \" ) . length ( ) ) / 2 ; for ( int j = 0 ; j < m ; j ++ ) { arr [ i ] [ j ] = st . charAt ( j ) ; if ( arr [ i ] [ j ] == ' . ' ) single_dots ++ ; } } int val1 = single_dots * x ; int val2 = horizontal_pair * y + ( single_dots - horizontal_pair * 2 ) * x ; out . println ( Math . min ( val1 , val2 ) ) ; } out . close ( ) ; } static final Random random = new Random ( ) ; static void ruffleSort ( int [ ] a ) { int n = a . length ;",
"import java . util . Scanner ; public class Solution { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int t = sc . nextInt ( ) ; int [ ] answers = new int [ t ] ; for ( int i = 0 ; i < t ; i ++ ) { int n , m , x , y , totalCost = 0 ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int j = 0 ; j < n ; j ++ ) { String input = sc . nextLine ( ) ; for ( int k = 0 , whites = 0 ; k <= m ; k ++ ) if ( k == m || input . charAt ( k ) == ' * ' ) { if ( ( y / 2.0f ) < x ) totalCost += ( ( whites / 2 ) * y + ( whites % 2 ) * x ) ; else totalCost += ( whites * x ) ; whites = 0 ; } else whites ++ ; } answers [ i ] = totalCost ; } for ( int answer : answers ) System . out . println ( answer ) ; } }",
"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 ) { int n = sc . nextInt ( ) , m = sc . nextInt ( ) , x = sc . nextInt ( ) , y = sc . nextInt ( ) ; int best = Math . min ( 2 * x , y ) , ans = 0 ; char [ ] [ ] ar = new char [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) ar [ i ] [ j ] = s . charAt ( j ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( ar [ i ] [ j ] == ' . ' ) { if ( j == m - 1 ) { ans += x ; ar [ i ] [ j ] = ' * ' ; } else { if ( ar [ i ] [ j + 1 ] == ' . ' ) { ans += best ; ar [ i ] [ j ] = ' * ' ; ar [ i ] [ j + 1 ] = ' * ' ; } else { ans += x ; ar [ i ] [ j ] = ' * ' ; } } } } } System . out . println ( ans ) ; } } }",
"import java . util . * ; import java . io . * ; import java . math . * ; public class First { public static void process ( ) throws IOException { int n = ni ( ) ; int m = ni ( ) ; int x = ni ( ) ; int y = ni ( ) ; char a [ ] [ ] = new char [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String s [ ] = nln ( ) . trim ( ) . split ( \" \" ) ; for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = s [ j ] . charAt ( 0 ) ; } } long cost = 0l ; for ( int i = 0 ; i < n ; i ++ ) { int j = 0 ; while ( j < m ) { if ( a [ i ] [ j ] == ' . ' ) { if ( ( 2 * x ) > y ) { if ( j + 1 < m ) { if ( a [ i ] [ j + 1 ] == ' . ' ) { cost += y ; j += 2 ; } else { cost += x ; j ++ ; } } else { cost += x ; j ++ ; } } else { cost += x ; j ++ ; } } else { j ++ ; } } } pn ( cost ) ; } 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 ; "
] | [
"testcases = int ( input ( ) ) for testcase in range ( testcases ) : v , h , p1 , p2 = [ int ( i ) for i in input ( ) . split ( ) ] r = 0 for v in range ( v ) : tiles = input ( ) double_dot = tiles . count ( ' . . ' ) single_dot = tiles . count ( ' . ' ) r += min ( single_dot * p1 , double_dot * p2 + ( single_dot - double_dot * 2 ) * p1 ) print ( r ) NEW_LINE",
"if __name__ == \" _ _ main _ _ \" : t = int ( input ( ) ) for case in range ( t ) : n , m , x , y = map ( int , input ( ) . split ( ) ) grid = [ ] for _ in range ( n ) : grid . append ( list ( input ( ) ) ) candidate , single_tile = 0 , 0 for i in range ( n ) : j = 0 while j < m : if grid [ i ] [ j ] == ' . ' and j + 1 < m and grid [ i ] [ j + 1 ] == ' . ' : candidate += 2 j += 2 elif grid [ i ] [ j ] == ' . ' : single_tile += 1 j += 1 else : j += 1 if candidate & 1 == 1 : candidate -= 1 single_tile += 1 NEW_LINE",
"for t in range ( int ( input ( ) ) ) : n , m , x , y = map ( int , input ( ) . split ( ) ) if y > 2 * x : y = 2 * x ans = 0 for i in range ( n ) : s = input ( ) . split ( ' * ' ) for item in s : r = len ( item ) ans += y * ( r // 2 ) + x * ( r % 2 ) print ( ans ) NEW_LINE",
"T = int ( input ( ) ) while T > 0 : T -= 1 cost , count = 0 , 0 n , m , x , y = map ( int , input ( ) . strip ( ) . split ( ) ) arr = [ ] for i in range ( n ) : arr . append ( [ ] ) arr [ i ] = [ x for x in input ( ) ] i , j = 0 , 0 while i < n : j = 0 while j < m : if arr [ i ] [ j ] == ' . ' : count += 1 if arr [ i ] [ j ] == ' * ' : j += 1 continue if j < ( m - 1 ) : if arr [ i ] [ j + 1 ] == ' . ' : count += 1 cost += y j += 2 continue cost += x j += 1 i += 1 print ( min ( cost , count * x ) ) NEW_LINE",
"def solver ( ) : pass T = int ( input ( ) ) for _ in range ( T ) : n , m , x , y = [ int ( x ) for x in input ( ) . split ( ) ] stones = [ ] for _ in range ( n ) : stones . append ( input ( ) ) ans = 0 if 2 * x <= y : ans = 0 for s in stones : n = list ( s ) . count ( \" . \" ) ans += ( n * x ) print ( ans ) else : ans = 0 for s in stones : arr = s . split ( \" * \" ) for v in arr : if len ( v ) == 0 : continue else : n = len ( v ) ans += ( n // 2 ) * y ans += ( n % 2 ) * x print ( ans ) NEW_LINE"
] |
codeforces_364_A | [
"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 ( ) ; } void run ( FastScanner in , PrintWriter out ) { long a = in . nextInt ( ) ; char [ ] ca = in . next ( ) . toCharArray ( ) ; int n = ca . length ; Map < Long , Long > rangeSumCount = new HashMap < > ( ) ; long cnt = 0 ; for ( int l = 0 ; l < n ; l ++ ) { long sum = 0 ; for ( int r = l ; r < n ; r ++ ) { sum += ca [ r ] - '0' ; long prev = rangeSumCount . getOrDefault ( sum , 0L ) ; rangeSumCount . put ( sum , prev + 1 ) ; } } for ( long l : rangeSumCount . keySet ( ) ) { if ( a == 0 ) { cnt += rangeSumCount . getOrDefault ( 0L , 0L ) * rangeSumCount . get ( l ) ; } if ( l != 0 && ( a % l == 0 ) && rangeSumCount . containsKey ( a / l ) ) { cnt += rangeSumCount . get ( l ) * rangeSumCount . get ( a / l ) ; } } out . println ( cnt ) ; } 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 ( ) ) ; } } }",
"import java . util . * ; import java . io . * ; import java . math . * ; public class Main { static PrintWriter out ; static Reader in ; public static void main ( String [ ] args ) throws IOException {",
"import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class Main { public 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 FastReader in = new FastReader ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static final int MOD = ( int ) 1e9 + 7 ; public static void main ( String [ ] args ) {"
] | [
"a = int ( input ( ) ) s = input ( ) sm = { } for i in range ( len ( s ) ) : for j in range ( i , len ( s ) ) : if j == i : t = int ( s [ j ] ) else : t += int ( s [ j ] ) if t in sm : sm [ t ] += 1 else : sm [ t ] = 1 if a == 0 : if 0 in sm : sum_pairs = ( len ( s ) * ( len ( s ) + 1 ) ) // 2 print ( ( sm [ 0 ] * ( sum_pairs ) ) + ( sm [ 0 ] * ( ( sum_pairs ) - sm [ 0 ] ) ) ) else : print ( 0 ) else : c = 0 for f in sm : if f != 0 and a % f == 0 and ( a // f ) in sm : c += sm [ f ] * sm [ a // f ] print ( c ) NEW_LINE",
"a = int ( input ( ) ) s = input ( ) sm = { } for i in range ( len ( s ) ) : for j in range ( i , len ( s ) ) : if j == i : t = int ( s [ j ] ) else : t += int ( s [ j ] ) if t in sm : sm [ t ] += 1 else : sm [ t ] = 1 if a == 0 : if 0 in sm : sum_pairs = ( len ( s ) * ( len ( s ) + 1 ) ) // 2 print ( ( sm [ 0 ] * ( sum_pairs ) ) + ( sm [ 0 ] * ( ( sum_pairs ) - sm [ 0 ] ) ) ) else : print ( 0 ) else : c = 0 for f in sm : if f != 0 and a % f == 0 and ( a // f ) in sm : c += sm [ f ] * sm [ a // f ] print ( c ) NEW_LINE",
"import sysfrom math import gcd , sqrt , ceil , log2from collections import defaultdict , Counter , dequefrom bisect import bisect_left , bisect_rightimport mathsys . setrecursionlimit ( 2 * 10 ** 5 + 10 ) import heapqfrom itertools import permutations NEW_LINE",
"a = int ( input ( ) ) s = input ( ) d = { } for i in range ( len ( s ) ) : for j in range ( i , len ( s ) ) : if j == i : t = int ( s [ j ] ) else : t += int ( s [ j ] ) d [ t ] = d . get ( t , 0 ) + 1 if a == 0 : if 0 in d : cnt_pairs = ( len ( s ) * ( len ( s ) + 1 ) ) // 2 print ( ( d [ 0 ] * cnt_pairs ) + ( d [ 0 ] * ( cnt_pairs - d [ 0 ] ) ) ) else : print ( 0 ) else : c = 0 for f in d : if f != 0 and a % f == 0 and ( a // f ) in d : c += d [ f ] * d [ a // f ] print ( c ) NEW_LINE",
"a = int ( input ( ) ) s = input ( ) sm = { } for i in range ( len ( s ) ) : for j in range ( i , len ( s ) ) : if j == i : t = int ( s [ j ] ) else : t += int ( s [ j ] ) if t in sm : sm [ t ] += 1 else : sm [ t ] = 1 if a == 0 : if 0 in sm : sum_pairs = ( len ( s ) * ( len ( s ) + 1 ) ) // 2 print ( ( sm [ 0 ] * ( sum_pairs ) ) + ( sm [ 0 ] * ( ( sum_pairs ) - sm [ 0 ] ) ) ) else : print ( 0 ) else : c = 0 for f in sm : if f != 0 and a % f == 0 and ( a // f ) in sm : c += sm [ f ] * sm [ a // f ] print ( c ) NEW_LINE"
] |
codeforces_134_B | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class B134 { static int solve ( int x , int y ) { int cnt = 0 ; if ( x == 1 && y == 1 ) return 0 ; while ( true ) { if ( x == 0 || y == 0 ) return Integer . MAX_VALUE ; if ( x == 1 || y == 1 ) return ( cnt + Math . max ( x , y ) - 1 ) ; if ( x > y ) x -= y ; else y -= x ; cnt ++ ; } } public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int ans = Integer . MAX_VALUE ; for ( int i = 1 ; i <= n ; ++ i ) { ans = Math . min ( ans , solve ( n , i ) ) ; } if ( n <= 2 ) ans = n - 1 ; System . out . println ( ans ) ; } }",
"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 ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; if ( n == 1 ) { out . println ( 0 ) ; return ; } int res = n - 1 ; for ( int i = 1 ; i < n ; i ++ ) { res = Math . min ( res , solOne ( i , n ) ) ; } out . println ( res ) ; } int solOne ( int l , int r ) { int res = 0 ; while ( l != 1 || r != 1 ) { int d = Math . abs ( l - r ) ; if ( d == 0 ) return Integer . MAX_VALUE ; l = Math . min ( l , r ) ; r = d ; res ++ ; } return res ; } } static class InputReader { private BufferedReader reader ; private StringTokenizer stt ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { return null ; } } public String next ( ) { while ( stt == null || ! stt . hasMoreTokens ( ) ) { stt = new StringTokenizer ( nextLine ( ) ) ; } return stt . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } ",
"import java . io . * ; import java . util . * ; public class B134 { int x , y ; public B134 ( int xx , int yy ) { this . x = xx ; this . y = yy ; } static int INF = 1000000 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int n ; n = sc . nextInt ( ) ; int min = INF ; for ( int i = 1 ; i <= n ; i ++ ) { min = Math . min ( min , path ( n , i ) ) ; } System . out . println ( min ) ; } public static int path ( int a , int b ) { if ( b == 0 ) return INF ; if ( b == 1 ) return a - 1 ; return path ( b , a % b ) + a / b ; } }",
"import java . util . * ; import java . io . * ; public class Solution { static int t ; static int gcd ( int x , int y ) { if ( y == 0 ) return x ; t += x / y ; return gcd ( y , x % y ) ; } public static class Suffix implements Comparable < Suffix > { int index ; int rank ; int next ; public Suffix ( int ind , int r , int nr ) { index = ind ; rank = r ; next = nr ; }"
] | [
"n , ans = int ( input ( ) ) , 1000000 for i in range ( 1 , n + 1 ) : k , a , b = 0 , n , i while b > 1 : k += a // b a , b = b , a % b if b != 0 : ans = min ( ans , a - 1 + k ) print ( ans ) NEW_LINE",
"TMP = 0 def dfs ( a , b , n ) : global TMP if not b : TMP = n return None if b == 1 : TMP += a - 1 return None TMP += a // b dfs ( b , a % b , n ) class CodeforcesTask134BSolution : def __init__ ( self ) : self . result = ' ' self . n = 0 def read_input ( self ) : self . n = int ( input ( ) ) def process_task ( self ) : ans = self . n - 1 for i in range ( 1 , self . n ) : global TMP TMP = 0 dfs ( self . n , i , self . n ) ans = min ( ans , TMP ) self . result = str ( ans ) def get_result ( self ) : return self . result if __name__ == \" _ _ main _ _ \" : Solution = CodeforcesTask134BSolution ( ) Solution . read_input ( ) Solution . process_task ( ) print ( Solution . get_result ( ) ) NEW_LINE",
"def solve ( n ) : ans = n - 1 for i in range ( 2 , n // 2 + 1 ) : j = n k = 0 while i > 1 and j > 1 : k += 1 if j >= i : j -= i else : i -= j if i < 1 or j < 1 : continue elif i == 1 : ans = min ( ans , k + j - 1 ) elif j == 1 : ans = min ( ans , k + i - 1 ) return ans if __name__ == \" _ _ main _ _ \" : ans = solve ( int ( input ( ) ) ) print ( ans ) NEW_LINE",
"import math as m def hcf ( a , b ) : while ( a != b ) : if ( a > b ) : a = a - b else : b = b - a return a n = int ( input ( ) ) if ( n == 1 or n == 2 ) : print ( n - 1 ) exit ( ) mnm = m . inf for k in range ( m . ceil ( n / 2 ) , n ) : if ( hcf ( n , k ) != 1 ) : continue p = k q = n - k count = 2 while ( p != 2 ) : diff = p - q if ( q > diff ) : p = q q = diff else : p = diff count += 1 if ( count < mnm ) : mnm = count print ( mnm ) NEW_LINE",
"def gc ( a , b , rs ) : if b == 1 : return [ 1 , rs + a - 1 ] if b == 0 : return [ a , rs ] rs += ( a // b ) return gc ( b , a % b , rs ) x = int ( input ( ) ) res = 10 ** 9 for n in range ( 1 , x ) : u = gc ( x , n , 0 ) if u [ 0 ] == 1 : res = min ( res , u [ 1 ] ) if res == 10 ** 9 : res = 0 print ( res ) NEW_LINE"
] |
codeforces_1444_B | [
" 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 er10a {",
"import java . io . * ; import java . util . * ; public class CF1444B { 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 ( ) ) ; } } static int MOD = 998244353 ; static int [ ] rk , p , siz ; public static void main ( String [ ] args ) { FastReader br = new FastReader ( ) ; int N = br . nextInt ( ) ; long [ ] fac = new long [ 2 * N + 1 ] ; fac [ 0 ] = 1 ; for ( int i = 1 ; i <= 2 * N ; i ++ ) { fac [ i ] = ( fac [ i - 1 ] * i ) % MOD ; } int [ ] a = new int [ 2 * N ] ; for ( int i = 0 ; i < 2 * N ; i ++ ) { a [ i ] = br . nextInt ( ) ; } Arrays . sort ( a ) ; long sum = 0 ; for ( int i = N ; i < 2 * N ; i ++ ) { sum += a [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { sum -= a [ i ] ; } sum %= MOD ; sum *= fac [ 2 * N ] ; sum %= MOD ; sum *= inv ( fac [ N ] , MOD ) ; sum %= MOD ; sum *= inv ( fac [ N ] , MOD ) ; sum %= MOD ; System . out . println ( sum ) ; } public static long inv ( long a , long b ) {",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Integer [ ] ar = new Integer [ n + n ] ; for ( int i = 0 ; i < n + n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } Arrays . sort ( ar ) ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ar [ n + n - i - 1 ] - ar [ i ] ; }",
"import java . util . * ; public class Main { private static final Scanner sc = new Scanner ( System . in ) ; private static final long mod = 998244353 ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; long [ ] a = new long [ 2 * n ] ; long ans = 0 ; long fn = pow ( fact ( n ) , mod - 2 ) ; long count = fact ( 2 * n ) ; for ( int i = 0 ; i < 2 * n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < n ; i ++ ) { ans = mod ( ans + a [ 2 * n - i - 1 ] - a [ i ] ) ; } ans = mod ( count * ans ) ; ans = mod ( ans * fn ) ; ans = mod ( ans * fn ) ; System . out . println ( ans ) ; } private static long fact ( long num ) { long ans = 1 ; for ( long i = 2 ; i <= num ; i ++ ) { ans = mod ( ans * i ) ; } return ans ; } private static long mod ( long num ) { return ( num % mod + mod ) % mod ; } private static long pow ( long a , long n ) { if ( n == 0 ) return 1 ; long ans = pow ( a , n / 2 ) ; ans *= ans ; ans %= mod ; if ( n % 2 == 1 ) { ans *= a ; ans %= mod ; } return ans ; } }"
] | [
"n = int ( input ( ) ) NEW_LINE z = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE mod = 998244353 NEW_LINE fact = [ 1 ] * ( 2 * n + 1 ) NEW_LINE for i in range ( 1 , 2 * n + 1 ) : fact [ i ] = fact [ i - 1 ] * i % modinv = [ 0 ] * ( 2 * n + 1 ) NEW_LINE inv [ 2 * n ] = pow ( fact [ i ] , mod - 2 , mod ) NEW_LINE for i in range ( 2 * n - 1 , - 1 , - 1 ) : inv [ i ] = inv [ i + 1 ] * ( i + 1 ) % moddef NEW_LINE ncr ( n , r ) : NEW_LINE return ( fact [ n ] * inv [ n - r ] % mod * inv [ r ] % mod ) % mod a , b = 0 , 0 NEW_LINE for i in range ( n ) : a += z [ i ] NEW_LINE for j in range ( n , 2 * n ) : b += z [ j ] NEW_LINE t = b - aprint ( ( ncr ( 2 * n , n ) * t ) % mod ) NEW_LINE",
"n = int ( input ( ) ) NEW_LINE mod = 998244353 NEW_LINE den = 1 NEW_LINE arr = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE arr . sort ( ) for i in range ( 1 , n + 1 ) : den = den * ( i + n ) * pow ( i , mod - 2 , mod ) % mod print ( ( sum ( arr [ n : 2 * n ] ) - sum ( arr [ 0 : n ] ) ) * den % mod ) NEW_LINE",
"import java . util . * ; public NEW_LINE class Main { private static final Scanner sc = new Scanner ( System . in ) ; private static final long mod = 998244353 ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; long [ ] a = new long [ 2 * n ] ; long ans = 0 ; long fn = pow ( fact ( n ) , mod - 2 ) ; long count = fact ( 2 * n ) ; for ( int i = 0 ; i < 2 * n ; i + + ) { a [ i ] = sc . nextLong ( ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < n ; i + + ) { ans = mod ( ans + a [ 2 * n - i - 1 ] - a [ i ] ) ; } ans = mod ( count * ans ) ; ans = mod ( ans * fn ) ; ans = mod ( ans * fn ) ; System . out . println ( ans ) ; } private static long fact ( long num ) { long ans = 1 ; for ( long i = 2 ; i <= num ; i + + ) { ans = mod ( ans * i ) ; } return ans ; } private static long mod ( long num ) { return ( num % mod + mod ) % mod ; } private static long pow ( long a , long n ) { if ( n == 0 ) return 1 ; long ans = pow ( a , n / 2 ) ; ans *= ans ; ans %= mod ; if ( n % 2 == 1 ) { ans *= a ; ans %= mod ; } return ans ; } } NEW_LINE"
] |
codeforces_455_B | [
"import java . io . * ; import java . util . * ; public class Solution { public static Node root ; public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; Trie tn = new Trie ( ) ; root = tn . root ; for ( int i = 0 ; i < n ; i ++ ) tn . insert ( br . readLine ( ) ) ; boolean [ ] winner = DFS ( tn , tn . root ) ; if ( ! winner [ 0 ] || ( k % 2 == 0 && ! winner [ 1 ] ) ) out . println ( \" Second \" ) ; else out . println ( \" First \" ) ; out . close ( ) ; } public static boolean [ ] DFS ( Trie tn , Node cur ) { boolean [ ] winner = new boolean [ 2 ] ; boolean leaf = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( cur . children [ i ] != null ) { leaf = false ; boolean [ ] win = DFS ( tn , cur . children [ i ] ) ; winner [ 0 ] |= ! win [ 0 ] ; winner [ 1 ] |= ! win [ 1 ] ; } } return ( leaf ) ? new boolean [ ] { false , true } : winner ; } } class Node { Node [ ] children ; public Node ( ) { children = new Node [ 26 ] ; } } class Trie { Node root = new Node ( ) ; public void insert ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( cur . children [ s . charAt ( i ) - ' a ' ] == null ) cur . children [ s . charAt ( i ) - ' a ' ] = new Node ( ) ; cur = cur . children [ s . charAt ( i ) - ' a ' ] ; } } }"
] | [
"from sys import stdin , setrecursionlimit setrecursionlimit ( 200000 ) n , k = [ int ( x ) for x in stdin . readline ( ) . split ( ) ] tree = { } for x in range ( n ) : s = stdin . readline ( ) . strip ( ) cur = tree for x in s : if not x in cur : cur [ x ] = { } cur = cur [ x ] def forced ( tree ) : if not tree : return ( False , True ) else : win = False lose = False for x in tree : a , b = forced ( tree [ x ] ) if not a : win = True if not b : lose = True return ( win , lose ) a , b = forced ( tree ) if a == 0 : print ( ' Second ' ) elif a == 1 and b == 1 : print ( ' First ' ) else : if k % 2 == 0 : print ( ' Second ' ) else : print ( ' First ' ) NEW_LINE"
] |
codeforces_548_B | [
"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 . 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 ) ; } static int n , m ; static int a [ ] [ ] ; static int row [ ] ; public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; n = input . nextInt ( ) ; m = input . nextInt ( ) ; int q = input . nextInt ( ) ; a = new int [ n ] [ m ] ; int max = Integer . MIN_VALUE ; int cur = 0 ; row = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { cur = 0 ; max = 0 ; for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = input . nextInt ( ) ; if ( a [ i ] [ j ] == 0 ) cur = 0 ; else cur ++ ; max = Math . max ( max , cur ) ; } row [ i ] = max ; }"
] | [
"''' Maximum ▁ number ▁ of ▁ consecutive ▁ 1 ' s ''' ml = lambda s : max ( map ( len , \" \" . join ( s ) . split ( '0' ) ) ) n , m , q = map ( int , input ( ) . split ( ) ) arr = [ ] l = [ 0 ] * nfor i in range ( n ) : a = list ( input ( ) . split ( ) ) arr . append ( a ) l [ i ] = ml ( a ) for i in range ( q ) : a , b = map ( int , input ( ) . split ( ) ) a -= 1 b -= 1 arr [ a ] [ b ] = str ( int ( arr [ a ] [ b ] ) ^ 1 ) l [ a ] = ml ( arr [ a ] ) print ( max ( l ) ) NEW_LINE",
"r , c , g = map ( int , input ( ) . split ( ) ) board = [ ] scores = [ ] for i in range ( r ) : board . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) curr = 0 m = 0 for num in board [ - 1 ] : if num == 1 : curr += 1 else : m = max ( m , curr ) curr = 0 m = max ( m , curr ) scores . append ( m ) for i in range ( g ) : x , y = map ( int , input ( ) . split ( ) ) x -= 1 y -= 1 if board [ x ] [ y ] : board [ x ] [ y ] = 0 else : board [ x ] [ y ] = 1 curr = 0 m = 0 for num in board [ x ] : if num == 1 : curr += 1 else : m = max ( m , curr ) curr = 0 m = max ( m , curr ) scores [ x ] = m print ( max ( scores ) ) NEW_LINE",
"r = lambda : input ( ) . split ( ) g = lambda s : max ( map ( len , \" \" . join ( s ) . split ( '0' ) ) ) n , m , q = map ( int , r ( ) ) a = [ r ( ) for nn in range ( n ) ] b = list ( map ( g , a ) ) for qq in range ( q ) : x , y = map ( int , r ( ) ) a [ x - 1 ] [ y - 1 ] = str ( 1 - int ( a [ x - 1 ] [ y - 1 ] ) ) b [ x - 1 ] = g ( a [ x - 1 ] ) print ( max ( b ) ) NEW_LINE"
] |
codeforces_1182_B | [
"import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . time . LocalTime ; import java . util . * ; import java . util . concurrent . * ; import java . util . regex . * ; public class B { public static void main ( String [ ] args ) { FastScanner scan = new FastScanner ( ) ;"
] | [
"h , w = map ( int , input ( ) . split ( ) ) s = [ list ( input ( ) ) for i in range ( h ) ] cnt = 0 p = 0 for i in range ( h ) : cnt += s [ i ] . count ( \" * \" ) for i in range ( 1 , h - 1 ) : for j in range ( 1 , w - 1 ) : if s [ i ] [ j ] == s [ i - 1 ] [ j ] == s [ i + 1 ] [ j ] == s [ i ] [ j - 1 ] == s [ i ] [ j + 1 ] == \" * \" : p += 1 l , r , u , d = j - 1 , j + 1 , i - 1 , i + 1 while 0 <= l and s [ i ] [ l ] == \" * \" : l -= 1 ; p += 1 while r < w and s [ i ] [ r ] == \" * \" : r += 1 ; p += 1 while u >= 0 and s [ u ] [ j ] == \" * \" : u -= 1 ; p += 1 while d < h and s [ d ] [ j ] == \" * \" : d += 1 ; p += 1 if p > 0 : break if p > 0 : breakprint ( \" YES \" if cnt == p != 0 else \" NO \" ) NEW_LINE",
"from collections import * import bisectimport heapqimport sys def ri ( ) : return int ( input ( ) ) def rl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) h , w = rl ( ) grid = [ [ x for x in \" . \" * w ] for _ in range ( h ) ] stars_row = [ 0 ] * hfor i in range ( h ) : grid [ i ] = [ x for x in input ( ) ] C = Counter ( grid [ i ] ) stars_row [ i ] = C [ ' * ' ] Cr = Counter ( stars_row ) if Cr [ 0 ] + Cr [ 1 ] != h - 1 : print ( \" NO \" ) sys . exit ( ) stars_col = [ 0 ] * wfor j in range ( w ) : for i in range ( h ) : if grid [ i ] [ j ] == \" * \" : stars_col [ j ] += 1 Cc = Counter ( stars_col ) if Cc [ 0 ] + Cc [ 1 ] != w - 1 : print ( \" NO \" ) sys . exit ( ) degrees = [ [ - 1 ] * w for _ in range ( h ) ] d0 = 0 d1 = 0 d2 = 0 d4 = 0 d_ = 0 for i in range ( h ) : for j in range ( w ) : if grid [ i ] [ j ] == \" * \" : degrees [ i ] [ j ] = 0 for di , dj in [ ( - 1 , 0 ) , ( 1 , 0 ) , ( 0 , - 1 ) , ( 0 , 1 ) ] : ni = i + di nj = j + dj if ni >= 0 and ni < h and nj >= 0 and nj < w : if grid [ ni ] [ nj ] == \" * \" : degrees [ i ] [ j ] += 1 if degrees [ i ] [ j ] == 1 : d1 += 1 elif degrees [ i ] [ j ] == 2 : d2 += 1 elif degrees [ i ] [ j ] == 4 : d4 += 1 elif degrees [ i ] [ j ] == 0 : d0 += 1 else : d_ += 1 NEW_LINE",
"from collections import * h , w = map ( int , input ( ) . split ( ) ) a = [ input ( ) for _ in [ 0 ] * h ] def f ( a , w ) : c = Counter ( ( x . index ( ' * ' ) , x [ : : - 1 ] . index ( ' * ' ) , x . count ( ' * ' ) ) for x in a if ' * ' in x ) ; z = 2 ; if len ( c ) == 2 : ( x , y , z ) , u = c return z > 1 or x <= u [ 0 ] or y <= u [ 1 ] or sum ( u ) < w print ( ' YNEOS ' [ f ( a , w ) or f ( zip ( * a ) , h ) : : 2 ] ) NEW_LINE"
] |
codeforces_466_A | [
"import java . util . * ; public class HelloWorld { public static void main ( String [ ] args ) {",
"import java . util . * ; import java . io . * ; import java . lang . * ; public class Solution { 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 ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public static void main ( String [ ] args ) { new Solution ( ) . solve ( ) ; } void solve ( ) { int t = 1 ;",
"import java . util . Arrays ; import java . util . Scanner ; public class solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int total = sc . nextInt ( ) ; int ride = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = total * a ; int count = ride ; while ( count <= total ) { ans = Math . min ( ans , count / ride * b + ( total - count ) * a ) ; count += ride ; } System . out . println ( Math . min ( total % ride == 0 ? total / ride * b : ( total / ride + 1 ) * b , ans ) ) ; } }"
] | [
"n , m , a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE",
"n , m , a , b = map ( int , input ( ) . split ( ) ) print ( min ( n * a , - n // m * - b , n // m * b + n % m * a ) ) NEW_LINE",
"n , m , a , b = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( 0 , n * 2 ) : l . append ( i * b + ( ( n - m * i ) * a if n - m * i > 0 else 0 ) ) print ( min ( l ) ) NEW_LINE",
"import mathn , m , a , b = list ( map ( int , input ( ) . split ( ) ) ) res = 100000000 for i in range ( n + 1 ) : res = min ( res , ( a * i + math . ceil ( ( n - i ) / m ) * b ) ) print ( res ) NEW_LINE"
] |
codeforces_264_B | [
"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 ( ) ; } static LinkedList < Integer > primes = new LinkedList < > ( ) ; static { boolean [ ] isPrime = new boolean [ 100_004 ] ; Arrays . fill ( isPrime , true ) ; for ( int i = 2 ; i < isPrime . length ; i ++ ) { if ( isPrime [ i ] ) { primes . offerLast ( i ) ; for ( long p = ( long ) i * i ; p < isPrime . length ; p += i ) isPrime [ ( int ) p ] = false ; } } } void run ( FastScanner in , PrintWriter out ) { int N = in . nextInt ( ) ; HashMap < Integer , Integer > primeToSeqLength = new HashMap < > ( ) ; LinkedList < Integer > myprimes = new LinkedList < > ( ) ; int max = 0 ; while ( N -- > 0 ) { int a = in . nextInt ( ) ; ",
"import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class PracticeProblem { public 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 FastReader in = new FastReader ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static final int N = ( int ) 1e5 ; public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ; int [ ] dp = new int [ n ] ; int answer = - 1 ; Map < Integer , Integer > primeMax = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) {"
] | [
"m = 10 ** 5 + 1 p = [ 0 ] * mt = [ [ ] for i in range ( m ) ] t [ 1 ] = [ 1 ] for i in range ( 2 , m ) : if not t [ i ] : t [ i ] = [ i ] for j in range ( 2 * i , m , i ) : t [ j ] . append ( i ) n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) : x = max ( p [ j ] for j in t [ a [ i ] ] ) + 1 for j in t [ a [ i ] ] : p [ j ] = xprint ( max ( p ) ) NEW_LINE",
"n = 100001 p = [ 0 ] * nt = [ [ ] for i in range ( n ) ] t [ 1 ] = [ 1 ] for i in range ( 2 , n ) : if not t [ i ] : t [ i ] = [ i ] for j in range ( 2 * i , n , i ) : t [ j ] . append ( i ) n = int ( input ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) ] for a in l : x = max ( p [ j ] for j in t [ a ] ) + 1 for j in t [ a ] : p [ j ] = xprint ( max ( p ) ) NEW_LINE"
] |
codeforces_569_B | [
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; TreeSet < Integer > remainNumber = new TreeSet < > ( ) ; TreeSet < Integer > checkingNumber = new TreeSet < > ( ) ; StringBuilder ans = new StringBuilder ( ) ; for ( int i = 1 ; i <= n ; i ++ ) remainNumber . add ( i ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; remainNumber . remove ( a [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { int len = checkingNumber . size ( ) ; if ( a [ i ] <= n ) checkingNumber . add ( a [ i ] ) ; if ( len == checkingNumber . size ( ) ) { ans . append ( remainNumber . pollFirst ( ) + \" ▁ \" ) ; } else { ans . append ( a [ i ] + \" ▁ \" ) ; } } System . out . println ( ans ) ; } }"
] | [
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) dp = [ 0 ] * ( n + 1 ) for i in arr : if i <= n : dp [ i ] += 1 ar = [ ] for i in range ( 1 , n + 1 ) : if dp [ i ] == 0 : ar . append ( i ) cnt = 0 for i in range ( n ) : if arr [ i ] > n : arr [ i ] = ar [ cnt ] ; cnt += 1 elif dp [ arr [ i ] ] >= 2 : dp [ arr [ i ] ] -= 1 ; arr [ i ] = ar [ cnt ] ; cnt += 1 print ( * arr ) NEW_LINE",
"n = int ( input ( ) ) inventory = [ * map ( int , input ( ) . split ( ) ) ] bool = [ False ] * 100001 indices = set ( ) for index , i in enumerate ( inventory ) : if i > n or bool [ i ] : indices . add ( index ) bool [ i ] = True for i in range ( 1 , n + 1 ) : if not bool [ i ] : x = indices . pop ( ) inventory [ x ] = iprint ( \" ▁ \" . join ( [ * map ( str , inventory ) ] ) ) NEW_LINE",
"n = int ( input ( ) ) inventory = [ * map ( int , input ( ) . split ( ) ) ] bool = [ False ] * ( n + 1 ) bads = set ( ) for index , thing in enumerate ( inventory ) : if thing <= n : if bool [ thing ] : bads . add ( index ) else : bool [ thing ] = True else : bads . add ( index ) for num , isin in enumerate ( bool [ 1 : ] ) : if not isin and len ( bads ) : i = bads . pop ( ) inventory [ i ] = num + 1 bool [ num ] = True print ( \" ▁ \" . join ( [ * map ( str , inventory ) ] ) ) NEW_LINE",
"from collections import * n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) lst = [ 0 ] * ncnt = 0 for i in range ( n ) : if a [ i ] <= n : lst [ a [ i ] - 1 ] = 1 miss = [ ] for i in range ( n ) : if lst [ i ] == 0 : miss . append ( i + 1 ) lst = list ( miss ) d = defaultdict ( int ) for i in range ( n ) : if a [ i ] > n : print ( lst [ - 1 ] , end = \" ▁ \" ) lst . pop ( ) elif d [ a [ i ] ] == 0 : d [ a [ i ] ] += 1 print ( a [ i ] , end = \" ▁ \" ) else : print ( lst [ - 1 ] , end = \" ▁ \" ) lst . pop ( ) NEW_LINE",
"n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) x = [ 0 ] * ( 100001 ) z = [ 0 ] * ( 100001 ) y = list ( ) for i in range ( 0 , n ) : x [ a [ i ] ] += 1 for i in range ( 1 , n + 1 ) : if x [ i ] == 0 : y . append ( i ) j = 0 for i in range ( 0 , n ) : if z [ a [ i ] ] == 0 and a [ i ] <= n : print ( a [ i ] , end = \" ▁ \" ) z [ a [ i ] ] = 1 else : print ( y [ j ] , end = \" ▁ \" ) j += 1 NEW_LINE"
] |
codeforces_371_A | [
"import java . io . * ; import java . math . BigInteger ; import java . util . * ; public class Codeforces { public static void main ( String [ ] args ) throws UnsupportedEncodingException , IOException , Exception { StringBuilder out = new StringBuilder ( ) ; StringTokenizer tk ; Reader . init ( System . in ) ; Scanner sc = new Scanner ( System . in ) ;",
"import java . util . * ; public class CodeForces371A { 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 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } if ( n == k ) { System . out . println ( 0 ) ; } else { int ans = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int count_1 = 0 ; int count_2 = 0 ; for ( int j = i ; j < n ; j += k ) { if ( a [ j ] == 1 ) { count_1 ++ ; } else { count_2 ++ ; } } ans += Math . min ( count_2 , count_1 ) ; } System . out . println ( ans ) ; } } }",
"import java . io . * ; import java . math . BigInteger ; import java . util . * ; public class ACM { public static void main ( String args [ ] ) throws FileNotFoundException , IOException { Scanner x = new Scanner ( System . in ) ; int n = x . nextInt ( ) ; int k = x . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = x . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int f = 0 , s = 0 ; for ( int j = i ; j < n ; j += k ) { if ( arr [ j ] == 1 ) { f ++ ; } else { s ++ ; } } sum += Math . min ( f , s ) ; } System . out . println ( sum ) ; } } "
] | [
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) poc = 0 for i in range ( k ) : p1 , p2 = 0 , 0 for j in range ( i , n , k , ) : if a [ j ] == 1 : p1 += 1 else : p2 += 1 poc += min ( p1 , p2 ) print ( poc ) NEW_LINE",
"import math n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 for i in range ( k ) : r = a [ i ] ; m = 0 for j in range ( n // k ) : if a [ i + j * k ] != r : m += 1 ans += min ( m , n // k - m ) print ( ans ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 for i in range ( k ) : s1 , s2 = 0 , 0 for j in range ( i , n , k ) : if A [ j ] == 1 : s1 += 1 else : s2 += 1 ans = ans + min ( s1 , s2 ) print ( ans ) NEW_LINE"
] |
codeforces_557_B | [
"import java . util . Arrays ; import java . util . Scanner ; public class Bai5 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] capacity = new int [ n * 2 ] ; for ( int i = 0 ; i < n * 2 ; i ++ ) { capacity [ i ] = sc . nextInt ( ) ; } Arrays . sort ( capacity ) ; double m = Math . min ( capacity [ 0 ] , ( double ) capacity [ n ] / 2 ) ; double total = 3 * m * n ; System . out . println ( Math . min ( total , w ) ) ; } }",
"import java . io . File ; import java . util . Arrays ; import java . util . Scanner ; import java . util . StringTokenizer ; public class p021 { public static void main ( String args [ ] ) throws Exception {",
"import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ; public class Codechef { static int n ; static double w ; static Double arr [ ] ; static BufferedReader bf ; static StringBuffer str = new StringBuffer ( \" \" ) ; static boolean f ( double mid ) { double girl = mid / ( n * 3 ) ; double boy = 2 * mid / ( n * 3 ) ; return arr [ 0 ] >= girl && arr [ n ] >= boy ; } static void solve ( ) throws Exception { String s [ ] = bf . readLine ( ) . trim ( ) . split ( \" \\\\ s + \" ) ; n = Integer . parseInt ( s [ 0 ] ) ; w = Double . parseDouble ( s [ 1 ] ) ; arr = new Double [ 2 * n ] ; s = bf . readLine ( ) . trim ( ) . split ( \" \\\\ s + \" ) ; for ( int i = 0 ; i < ( 2 * n ) ; i ++ ) arr [ i ] = Double . parseDouble ( s [ i ] ) ; Arrays . sort ( arr ) ; double ans = arr [ 0 ] ; double l = 0 , r = w ; for ( int i = 0 ; i < 100 ; i ++ ) { double mid = l + ( r - l ) / 2 ; if ( f ( mid ) ) { ans = mid ; l = mid ; } else r = mid ; } str . append ( ans + \" \\n \" ) ; } public static void main ( String [ ] args ) throws java . lang . Exception { bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; solve ( ) ; System . out . print ( str ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class PashaAndTea { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long w = sc . nextInt ( ) ; int [ ] a = new int [ n * 2 ] ; for ( int i = 0 ; i < n * 2 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; double unit = Math . min ( a [ 0 ] , ( double ) a [ n ] / 2 ) ; double max = Math . min ( w , unit * n * 3 ) ; System . out . println ( max ) ; } }",
"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 ;"
] | [
"n , w = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) g = a [ 0 ] b = a [ n ] if ( g * 2 ) <= b : b = ( g * 2 ) elif ( g * 2 ) > b : g = b / 2 ans = ( g * n ) + ( b * n ) if ans > w : ans = wprint ( ans ) NEW_LINE",
"n , w = map ( int , input ( ) . split ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] a . sort ( ) print ( min ( a [ 0 ] , a [ n ] / 2 , w / 3 / n ) * 3 * n ) NEW_LINE",
"def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def MAP2 ( ) : return map ( float , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( ) import stringimport sysfrom heapq import heappop , heappushfrom bisect import * from collections import deque , Counterfrom math import * from itertools import permutations , accumulatedx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE",
"n , w = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) g = a [ 0 ] b = a [ n ] if g >= w : print ( w ) else : if g * 2 > b : g = b / 2 t = g * n + g * 2 * n if t <= w : print ( t ) else : print ( w ) NEW_LINE",
"n , w = map ( int , input ( ) . split ( ) ) a = [ float ( x ) for x in input ( ) . split ( ) ] a . sort ( ) tt = min ( a [ 0 ] , ( a [ n ] / 2 ) ) ttt = 3 * n * ttt = wt = min ( w , 3 * n * tt ) print ( t ) NEW_LINE"
] |
codeforces_352_A | [
" import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class experiment { static int M = 1_000_000_007 ; static int INF = Integer . MAX_VALUE ; static final FastScanner fs = new FastScanner ( ) ; ",
"import java . util . ArrayList ; import java . util . Scanner ; public class JeffandDigits { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; System . out . println ( getIndex ( scanner , n ) ) ; } private static String getIndex ( Scanner scanner , int n ) { ArrayList < Integer > arrayList = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { arrayList . add ( scanner . nextInt ( ) ) ; } if ( ! arrayList . contains ( 0 ) ) return \" - 1\" ; int count = 0 ; int count0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arrayList . get ( i ) == 5 ) count ++ ; if ( arrayList . get ( i ) == 0 ) count0 ++ ; }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ar [ ] = new int [ N ] ; boolean isDivisibleByTen = false ; int sum = 0 ; int zeroCount = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int val = sc . nextInt ( ) ; sum += val ; if ( val == 0 ) { isDivisibleByTen = true ; zeroCount ++ ; } } if ( ! isDivisibleByTen ) System . out . println ( - 1 ) ; else { int val = sum / 45 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < 9 * val ; i ++ ) { sb . append ( 5 ) ; } for ( int i = 0 ; i < zeroCount ; i ++ ) { if ( sb . toString ( ) . length ( ) == 0 ) { sb . append ( 0 ) ; break ; } else sb . append ( 0 ) ; } System . out . println ( sb . toString ( ) ) ; } } }",
"import java . util . Scanner ; public class A352 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int five = 0 ; int zero = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = scanner . nextInt ( ) ; if ( x == 5 ) { five ++ ; } else { zero ++ ; } } if ( five < 9 && zero >= 1 ) { System . out . println ( \"0\" ) ; } else if ( five == n ) { System . out . println ( \" - 1\" ) ; } else { int temp = five % 9 ; five -= temp ; for ( int i = 0 ; i < five ; i ++ ) { System . out . print ( \"5\" ) ; } for ( int i = 0 ; i < zero ; i ++ ) { System . out . print ( \"0\" ) ; } } } } ",
"import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int f = 0 , z = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( scan . nextInt ( ) == 5 ) { f ++ ; } else { z ++ ; } } if ( z == 0 ) { System . out . println ( \" - 1\" ) ; } else if ( f < 9 ) { System . out . println ( \"0\" ) ; } else { f = f - f % 9 ; for ( int i = 0 ; i < f ; i ++ ) { System . out . print ( \"5\" ) ; } for ( int j = 0 ; j < z ; j ++ ) { System . out . print ( \"0\" ) ; } } } }"
] | [
"import sysimport itertoolsimport collections def rs ( x = ' ' ) : return sys . stdin . readline ( ) . strip ( ) if len ( x ) == 0 else input ( x ) . strip ( ) def ri ( x = ' ' ) : return int ( rs ( x ) ) def rm ( x = ' ' ) : return map ( str , rs ( x ) . split ( ) ) def rl ( x = ' ' ) : return rs ( x ) . split ( ) def rmi ( x = ' ' ) : return map ( int , rs ( x ) . split ( ) ) def rli ( x = ' ' ) : return [ int ( x ) for x in rs ( x ) . split ( ) ] def println ( val ) : sys . stdout . write ( str ( val ) + ' \\n ' ) def solve ( testCase ) : n , a = ri ( ) , rli ( ) fives = a . count ( 5 ) zeros = n - fives NEW_LINE",
"def solution ( ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) c5 = 0 c0 = 0 for i in arr : if i == 5 : c5 += 1 else : c0 += 1 c5 = ( c5 // 9 ) * 9 if c0 == 0 : print ( - 1 ) return elif c5 == 0 : print ( 0 ) return else : st = '5' * c5 st += '0' * c0 print ( int ( st ) ) \t \t \t if __name__ == ' _ _ main _ _ ' : solution ( ) NEW_LINE",
"n = int ( input ( ) ) bt = list ( map ( int , input ( ) . split ( ) ) ) if 0 in bt : c5 = 0 c0 = 0 for a in bt : if a == 5 : c5 += 1 else : c0 += 1 if c5 < 9 : print ( 0 ) else : print ( ( int ( c5 / 9 ) ) * 9 * \"5\" + c0 * \"0\" ) else : print ( - 1 ) NEW_LINE",
"import mathn = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) c5 = l . count ( 5 ) cc = math . floor ( c5 / 9 ) c0 = l . count ( 0 ) if c0 == 0 : print ( - 1 ) else : if cc == 0 : print ( 0 ) else : a = '5' * ( 9 * cc ) + '0' * c0 print ( a ) NEW_LINE"
] |
codeforces_1055_B | [
"import java . math . BigInteger ; import java . sql . Array ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collection ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . InputMismatchException ; import java . util . Iterator ; import java . util . LinkedHashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . Map . Entry ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; import java . util . Stack ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . TreeMap ; import java . util . TreeSet ; public class Main { static InputReader rd = new InputReader ( System . in ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long m = sc . nextLong ( ) ; long l = sc . nextLong ( ) ; int t = 0 ;"
] | [
"n , m , l = list ( map ( int , input ( ) . split ( ) ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr = [ 0 ] + arr + [ 0 ] count = 0 for i in range ( 1 , n + 1 ) : if arr [ i ] > l and arr [ i - 1 ] <= l : count += 1 for _ in range ( m ) : s = input ( ) . split ( ) if s [ 0 ] == \"0\" : print ( count ) else : p , q = int ( s [ 1 ] ) , int ( s [ 2 ] ) arr [ p ] += q if arr [ p ] <= l or arr [ p ] - q > l : continue if arr [ p - 1 ] <= l and arr [ p + 1 ] <= l : count += 1 elif arr [ p - 1 ] > l and arr [ p + 1 ] > l : count -= 1 NEW_LINE",
"import sys def Find ( parent , x ) : if parent [ x ] != x : parent [ x ] = Find ( parent , parent [ x ] ) return parent [ x ] def Union ( parent , rank , x , y ) : x_root = Find ( parent , x ) y_root = Find ( parent , y ) if x_root == y_root : return if rank [ x_root ] < rank [ y_root ] : parent [ x_root ] = y_root elif rank [ x_root ] > rank [ y_root ] : parent [ y_root ] = x_root else : parent [ x_root ] = y_root rank [ y_root ] += 1 hair_n , request_n , fav = map ( int , sys . stdin . readline ( ) . split ( ) ) hair = [ - 1 ] + list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) parent_list = [ i for i in range ( hair_n + 1 ) ] rank_list = [ 0 for i in range ( hair_n + 1 ) ] ans = 0 for i in range ( 1 , hair_n ) : if hair [ i ] > fav and hair [ i + 1 ] > fav : Union ( parent_list , rank_list , i , i + 1 ) for i in range ( 1 , hair_n + 1 ) : if i == parent_list [ i ] and hair [ i ] > fav : ans += 1 for r in range ( request_n ) : query = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) if query [ 0 ] == 1 : growing_hair = query [ 1 ] change = query [ 2 ] prev_hair = hair [ growing_hair ] hair [ growing_hair ] += change if hair [ growing_hair ] > fav and prev_hair <= fav : ans += 1 if hair [ growing_hair - 1 ] > fav : ans -= 1 if growing_hair < hair_n : if hair [ growing_hair + 1 ] > fav : ans -= 1 else : print ( ans ) NEW_LINE",
"import sys def Find ( parent , x ) : if parent [ x ] != x : parent [ x ] = Find ( parent , parent [ x ] ) return parent [ x ] def Union ( parent , rank , x , y ) : x_root = Find ( parent , x ) y_root = Find ( parent , y ) if x_root == y_root : return if rank [ x_root ] < rank [ y_root ] : parent [ x_root ] = y_root elif rank [ x_root ] > rank [ y_root ] : parent [ y_root ] = x_root else : parent [ x_root ] = y_root rank [ y_root ] += 1 hair_n , request_n , fav = map ( int , sys . stdin . readline ( ) . split ( ) ) hair = [ - 1 ] + list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) parent_list = [ i for i in range ( hair_n + 1 ) ] rank_list = [ 0 for i in range ( hair_n + 1 ) ] ans = 0 for i in range ( 1 , hair_n ) : if hair [ i ] > fav and hair [ i + 1 ] > fav : Union ( parent_list , rank_list , i , i + 1 ) for i in range ( 1 , hair_n + 1 ) : if i == parent_list [ i ] and hair [ i ] > fav : ans += 1 for r in range ( request_n ) : query = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) if query [ 0 ] == 1 : growing_hair = query [ 1 ] change = query [ 2 ] prev_hair = hair [ growing_hair ] hair [ growing_hair ] += change if hair [ growing_hair ] > fav and prev_hair <= fav : ans += 1 if hair [ growing_hair - 1 ] > fav : ans -= 1 if growing_hair < hair_n : if hair [ growing_hair + 1 ] > fav : ans -= 1 else : print ( ans ) NEW_LINE",
"import sys hair_n , request_n , fav = map ( int , input ( ) . split ( ) ) hair = [ - 1 ] + list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) + [ - 1 ] ans = 0 new = Falsefor i in range ( 1 , hair_n + 1 ) : if hair [ i ] > fav and new == False : ans += 1 new = True elif hair [ i ] <= fav : new = False for r in range ( request_n ) : query = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) if query [ 0 ] == 1 : growing_hair = query [ 1 ] change = query [ 2 ] prev_hair = hair [ growing_hair ] hair [ growing_hair ] += change if hair [ growing_hair ] > fav and prev_hair <= fav : ans += 1 if hair [ growing_hair - 1 ] > fav : ans -= 1 if growing_hair < hair_n : if hair [ growing_hair + 1 ] > fav : ans -= 1 else : print ( ans ) NEW_LINE",
"n , m , l = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) subs = [ 0 ] * ( n + 2 ) cnt = 0 flag = Falsefor i in range ( n ) : if a [ i ] > l : if flag == False : cnt += 1 flag = True subs [ i + 1 ] = 1 else : flag = Falsefor i in range ( m ) : q = tuple ( map ( int , input ( ) . split ( ) ) ) op = q [ 0 ] if op == 1 : op , p , d = q before = a [ p - 1 ] a [ p - 1 ] += d if before <= l < a [ p - 1 ] : subs [ p ] = 1 if subs [ p - 1 ] and subs [ p + 1 ] : cnt -= 1 elif not ( subs [ p - 1 ] or subs [ p + 1 ] ) : cnt += 1 else : print ( cnt ) NEW_LINE"
] |
codeforces_359_B | [
"import java . util . * ; import java . lang . * ; import java . io . * ; public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {",
"import java . io . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; PrintWriter out = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) ; out . print ( ( k + 1 ) + \" ▁ \" ) ; for ( int i = 1 ; i <= 2 * n ; i ++ ) if ( i != k + 1 ) out . print ( i + \" ▁ \" ) ; out . flush ( ) ; out . close ( ) ; in . close ( ) ; } }",
" import java . io . * ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main1 { static class pair implements Comparable < pair > { int a ; int b ; public pair ( int a , int b ) { this . a = a ; this . b = b ; } @ Override public int compareTo ( pair o ) {",
"import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import javafx . util . Pair ; public class Main { public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) * 2 ; int a [ ] = new int [ n * 2 ] ; int j = 1 ; for ( int i = 0 ; i < 2 * n ; i += 2 , j ++ ) { a [ i ] = ( j ) * 2 ; a [ i + 1 ] = ( j ) * 2 - 1 ; }"
] | [
"n , k = map ( int , input ( ) . split ( ) ) r = 2 * n - 2 * kfor i in range ( 2 * n , r , - 2 ) : print ( i - 1 , i , end = ' ▁ ' ) for i in range ( r , 1 , - 2 ) : print ( i , i - 1 , end = ' ▁ ' ) NEW_LINE",
"import math ans = [ ] n , m = map ( int , input ( ) . split ( ) ) for i in range ( 1 , n + 1 ) : ans . append ( [ 2 * i - 1 , 2 * i ] ) current = 0 i = 0 while current != 2 * m and i < n : if current < m and i < n : ans [ i ] [ 0 ] , ans [ i ] [ 1 ] = ans [ i ] [ 1 ] , ans [ i ] [ 0 ] current += 1 i += 1 for i in ans : print ( * i , end = \" ▁ \" ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) if ( k == 0 ) : for i in range ( 1 , 2 * n + 1 ) : print ( i , end = \" ▁ \" ) else : l = [ i for i in range ( 1 , 2 * n + 1 ) ] for i in range ( 1 , k + 1 ) : j = 2 * i - 1 m = 2 * i while ( j <= m ) : temp = l [ j - 1 ] l [ j - 1 ] = l [ m - 1 ] l [ m - 1 ] = temp j = j + 1 m = m - 1 for i in range ( 2 * n ) : print ( l [ i ] , end = \" ▁ \" ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) a = [ i + 1 for i in range ( n * 2 ) ] for i in range ( 1 , k + 1 ) : a [ 2 * ( i - 1 ) ] , a [ ( 2 * i ) ] = a [ 2 * i ] , a [ 2 * ( i - 1 ) ] print ( * a ) NEW_LINE"
] |
codeforces_17_A | [
"import java . io . * ; import java . util . ArrayList ; import java . util . StringTokenizer ;",
"import java . io . * ; import java . util . ArrayList ; import java . util . StringTokenizer ;",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int len = 0 ; int len1 = 0 ; for ( int i = 2 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 2 ; j < i ; j ++ ) { if ( ( i % j ) == 0 ) { count ++ ; } } if ( count == 0 ) { len ++ ; } } int [ ] arr = new int [ len ] ; for ( int i = 2 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 2 ; j < i ; j ++ ) { if ( ( i % j ) == 0 ) { count ++ ; } } if ( count == 0 ) { arr [ len1 ] = i ; len1 ++ ; } } int num = 0 ; for ( int i = 0 ; i < arr . length - 1 ; i ++ ) { int ans = arr [ i ] + arr [ i + 1 ] + 1 ;"
] | [
"seive = [ ] def precalc ( n ) : i = 2 while ( i * i <= n ) : if ( seive [ i ] ) : j = i * i while ( j <= n ) : seive [ j ] = False j += i i += 1 def main ( ) : global seive n , k = map ( int , input ( ) . split ( ) ) seive , nums , cnt = [ True ] * ( n + 1 ) , [ ] , 0 precalc ( n ) for i in range ( 2 , n + 1 ) : if ( seive [ i ] ) : nums . append ( i ) limit = len ( nums ) if ( k == 0 ) : print ( ' YES ' ) return if ( n == 1 or n == 2 or n == 3 ) : print ( ' NO ' ) return for num in range ( 4 , n + 1 ) : if ( seive [ num ] ) : num -= 1 for number in range ( 0 , limit ) : if ( number + 1 < limit and nums [ number ] + nums [ number + 1 ] == num ) : cnt += 1 NEW_LINE",
"def is_prime ( num ) : if num == 1 or num % 2 == 0 : return False if num == 2 : return True for i in range ( 3 , 1 + int ( num ** 0.5 ) ) : if num % i == 0 : return False return True n , m = map ( int , input ( ) . split ( ) ) lst = [ ] count = 0 for i in range ( 2 , n + 1 ) : if is_prime ( i ) : lst . append ( i ) for i in range ( 2 , len ( lst ) ) : if count == m : break for j in range ( i ) : if lst [ j ] + lst [ j + 1 ] + 1 == lst [ i ] : count += 1 break print ( ' YES ' if count == m else ' NO ' ) NEW_LINE",
"[ n , k ] = list ( map ( int , input ( ) . split ( ) ) ) pri = [ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 , 101 , 103 , 107 , 109 , 113 , 127 , 131 , 137 , 139 , 149 , 151 , 157 , 163 , 167 , 173 , 179 , 181 , 191 , 193 , 197 , 199 , 211 , 223 , 227 , 229 , 233 , 239 , 241 , 251 , 257 , 263 , 269 , 271 , 277 , 281 , 283 , 293 , 307 , 311 , 313 , 317 , 331 , 337 , 347 , 349 , 353 , 359 , 367 , 373 , 379 , 383 , 389 , 397 , 401 , 409 , 419 , 421 , 431 , 433 , 439 , 443 , 449 , 457 , 461 , 463 , 467 , 479 , 487 , 491 , 499 , 503 , 509 , 521 , 523 , 541 , 547 , 557 , 563 , 569 , 571 , 577 , 587 , 593 , 599 , 601 , 607 , 613 , 617 , 619 , 631 , 641 , 643 , 647 , 653 , 659 , 661 , 673 , 677 , 683 , 691 , 701 , 709 , 719 , 727 , 733 , 739 , 743 , 751 , 757 , 761 , 769 , 773 , 787 , 797 , 809 , 811 , 821 , 823 , 827 , 829 , 839 , 853 , 857 , 859 , 863 , 877 , 881 , 883 , 887 , 907 , 911 , 919 , 929 , 937 , 941 , 947 , 953 , 967 , 971 , 977 , 983 , 991 , 997 , 1050 ] cri = set ( ) for i in range ( 167 ) : cri . add ( pri [ i ] + pri [ i + 1 ] ) emp = 0 for i in range ( n - 1 ) : if pri [ i ] > n : break if pri [ i ] - 1 in cri : NEW_LINE",
"def solve ( n , k ) : primes = set ( [ * range ( 2 , n + 1 ) ] ) for i in range ( 2 , int ( n ** ( 1 / 2 ) ) + 1 ) : if i in primes : j = 2 while i * j < n : if i * j in primes : primes . remove ( i * j ) j += 1 primesL = list ( primes ) total = 0 for i in range ( len ( primesL ) - 2 ) : if ( primesL [ i ] + primesL [ i + 1 ] + 1 ) in primes : total += 1 if total >= k : print ( \" YES \" ) else : print ( \" NO \" ) n , k = map ( int , input ( ) . split ( \" ▁ \" ) ) solve ( n , k ) NEW_LINE"
] |
codeforces_386_A | [
"import java . util . * ; public class secauc { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int max = - 1 ; int index = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max ) { max = arr [ i ] ; index = i ; } } Arrays . sort ( arr ) ; System . out . println ( ( index + 1 ) + \" ▁ \" + arr [ n - 2 ] ) ; } }",
"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; Map < Integer , Integer > prices = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { prices . put ( scan . nextInt ( ) , i + 1 ) ; } List < Integer > pList = new ArrayList < > ( prices . keySet ( ) ) ; Collections . sort ( pList ) ; int participantN = prices . get ( pList . get ( n - 1 ) ) ; int sum = pList . get ( n - 2 ) ; System . out . println ( participantN + \" ▁ \" + sum ) ; } }",
"import java . util . * ; public class SecondPriceAuction { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int temp = 0 ; int pos = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( temp < a [ i ] ) { temp = a [ i ] ; pos = i + 1 ; } } Arrays . sort ( a ) ; System . out . println ( pos + \" ▁ \" + a [ n - 2 ] ) ; } }",
"import java . util . * ; import java . io . * ; public class solution { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int index = 0 ; int max = 0 ; int a [ ] = new int [ n ] ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; if ( a [ i ] > max ) { max = a [ i ] ; index = i + 1 ; } } Arrays . sort ( a ) ; System . out . println ( index + \" ▁ \" + a [ n - 2 ] ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class SecondPriceAuction { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } int max = a [ 0 ] ; int ind = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max ) { max = a [ i ] ; ind = i ; } } Arrays . sort ( a ) ; System . out . println ( ( ind + 1 ) + \" ▁ \" + a [ n - 2 ] ) ; } }"
] | [
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) max = 0 for i in range ( 1 , n ) : if arr [ max ] < arr [ i ] : max = iarr . sort ( ) print ( max + 1 , arr [ - 2 ] ) NEW_LINE",
"n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) i = l . index ( max ( l ) ) + 1 l . remove ( max ( l ) ) print ( i , max ( l ) ) NEW_LINE",
"n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) b = sorted ( p ) a = max ( p ) c = p . index ( a ) + 1 d = b [ - 2 ] print ( c , d ) NEW_LINE",
"n = int ( input ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) c = x . copy ( ) c . sort ( ) print ( x . index ( max ( x ) ) + 1 , c [ - 2 ] ) NEW_LINE"
] |
codeforces_1199_A | [
"import java . util . Scanner ; public class CityDay { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , x = in . nextInt ( ) , y = in . nextInt ( ) , i , a [ ] = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) a [ i ] = in . nextInt ( ) ; in . close ( ) ; for ( i = 0 ; i < n ; i ++ ) { int b = 1 , c = 1 , z = 0 ; while ( i - b >= 0 && b <= x ) { if ( a [ i - b ] <= a [ i ] ) z = 1 ; b ++ ; } while ( c < n - i && c <= y ) { if ( a [ i + c ] <= a [ i ] ) z = 1 ; c ++ ; } if ( z == 0 ) { System . out . println ( i + 1 ) ; break ; } } } }",
"import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . time . LocalTime ; import java . util . * ; import java . util . concurrent . * ; import java . util . regex . * ; public class D { public static void main ( String [ ] args ) { FastScanner scan = new FastScanner ( ) ;",
"import java . io . * ; import java . util . * ; public class NewClassTest42 { static final int LINE_LENGTH = 64 ;",
"import java . util . * ; public class CityDay { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; int res = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int c = 0 , d = 0 , flag = 0 ; for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( c == x ) break ; if ( a [ j ] < a [ i ] ) { flag = 1 ; break ; } c ++ ; } for ( int j = i + 1 ; j < n ; j ++ ) { if ( flag == 1 ) break ; if ( d == y ) break ; if ( a [ j ] < a [ i ] ) { flag = 1 ; break ; } d ++ ; } if ( flag == 0 ) { res = i + 1 ; break ; } } System . out . println ( res ) ; sc . close ( ) ; } }"
] | [
"from sys import stdinn , x , y = map ( int , stdin . readline ( ) . split ( ) ) a = list ( map ( int , stdin . readline ( ) . split ( ) ) ) for i in range ( n ) : if min ( a [ max ( i - x , 0 ) : min ( i + y + 1 , n ) ] ) == a [ i ] : print ( i + 1 ) break NEW_LINE",
"n , x , y = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) i = 0 if n == 1 : print ( 1 ) else : for i in range ( n ) : cnt = 0 j = i - 1 ok = True while j > 0 : if cnt == x : ok = True break if a [ i ] >= a [ j ] : ok = False break else : cnt += 1 j -= 1 if ok : z = 0 j = i + 1 while j <= n - 1 : if z == y : ok = True break if a [ i ] >= a [ j ] : ok = False break else : z += 1 j += 1 if ok : break print ( i + 1 ) NEW_LINE",
"n , a , b = list ( map ( int , input ( ) . split ( ) ) ) days = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) : start = max ( 0 , i - a ) end = min ( i + b + 1 , n ) if days [ i ] == min ( days [ start : end ] ) : print ( i + 1 ) break NEW_LINE"
] |
codeforces_813_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 final long INF = ( long ) Math . pow ( 10 , 16 ) ; 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 = 300005 ; private static final int MAXA = 1000007 ; 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 final long INF = ( long ) Math . pow ( 10 , 16 ) ; 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 = 300005 ; private static final int MAXA = 1000007 ; 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 . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long f = sc . nextLong ( ) ; long l = sc . nextLong ( ) ; long max = 0 ; int j = 0 ; int p = 0 ; ArrayList < Long > res = new ArrayList < > ( ) ; for ( j = 0 ; j < 60 ; j ++ ) { for ( p = 0 ; p < 60 ; p ++ ) { if ( ( Math . pow ( x , j ) + Math . pow ( y , p ) ) <= 1000000000000000000l ) { if ( ( pow ( x , j ) + pow ( y , p ) ) >= f && ( pow ( x , j ) + pow ( y , p ) ) <= l ) { res . add ( ( pow ( x , j ) + pow ( y , p ) ) ) ; } } } } int i = 0 ; Collections . sort ( res ) ; long [ ] arr = new long [ res . size ( ) + 1 ] ; if ( res . size ( ) > 0 ) { arr [ 0 ] = res . get ( 0 ) - f ; for ( i = 1 ; i < arr . length - 1 ; i ++ ) {"
] | [
"import sys , math , itertoolsfrom collections import Counter , deque , defaultdictfrom bisect import bisect_left , bisect_right from heapq import heappop , heappush , heapifymod = 10 ** 9 + 7 INF = float ( ' inf ' ) def inp ( ) : return int ( sys . stdin . readline ( ) ) def inpl ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def inpl_1 ( ) : return list ( map ( lambda x : int ( x ) - 1 , sys . stdin . readline ( ) . split ( ) ) ) def inps ( ) : return sys . stdin . readline ( ) def inpsl ( x ) : tmp = sys . stdin . readline ( ) ; return list ( tmp [ : x ] ) def err ( x ) : print ( x ) ; exit ( ) x , y , l , r = inpl ( ) se = set ( ) for a in range ( 100 ) : if x ** a > r : break for b in range ( 100 ) : now = x ** a + y ** b if now > r : break if now >= l : se . add ( now ) res = 0 NEW_LINE",
"x , y , l , r = map ( int , input ( ) . split ( ' ▁ ' ) ) arr_x = [ 1 ] while True : if arr_x [ - 1 ] * x <= r : arr_x . append ( arr_x [ - 1 ] * x ) else : break arr_y = [ 1 ] while True : if arr_y [ - 1 ] * y <= r : arr_y . append ( arr_y [ - 1 ] * y ) else : break L = [ i + j for i in arr_x for j in arr_y if i + j >= l and i + j <= r ] L = sorted ( list ( set ( L ) ) ) ans = 0 curr = l - 1 for i in L : ans = max ( ans , i - curr - 1 ) curr = i ans = max ( ans , r + 1 - curr - 1 ) print ( ans ) NEW_LINE",
"def solve ( ) : x , y , l , r = [ int ( s ) for s in input ( ) . split ( ' ▁ ' ) ] def pows ( x ) : z = 1 p = set ( ) while z <= 10 ** 18 : p . add ( z ) z *= x return p x_pows = pows ( x ) y_pows = pows ( y ) fails = [ l - 1 ] for a in x_pows : for b in y_pows : if l <= a + b <= r : fails . append ( a + b ) fails . sort ( ) fails . append ( r + 1 ) m = 0 for i in range ( 1 , len ( fails ) ) : m = max ( fails [ i ] - fails [ i - 1 ] - 1 , m ) return m print ( solve ( ) ) NEW_LINE",
"def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def MAP2 ( ) : return map ( float , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( ) import stringimport sysfrom heapq import heappop , heappushfrom bisect import * from collections import deque , Counter , defaultdictfrom math import * from itertools import permutations , accumulatedx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE",
"def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def MAP2 ( ) : return map ( float , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( ) import stringimport sysfrom heapq import heappop , heappushfrom bisect import * from collections import deque , Counter , defaultdictfrom math import * from itertools import permutations , accumulatedx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE"
] |
codeforces_1029_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sampleLength = sc . nextInt ( ) ; int repeats = sc . nextInt ( ) ; String sample = sc . next ( ) ; String result = getString ( sample , sampleLength , repeats ) ; System . out . println ( result ) ; } public static String getString ( String sample , int length , int repeats ) { StringBuilder sb = new StringBuilder ( sample ) ; int mainPos = 0 ; int samplePos = 0 ; for ( int i = 0 ; i < repeats ; i ++ ) { for ( int j = 0 ; j < length ; j ++ ) { if ( ( mainPos + samplePos ) >= sb . length ( ) ) { sb . append ( sample . charAt ( samplePos ) ) ; } if ( sb . charAt ( mainPos + samplePos ) != sample . charAt ( samplePos ) ) { i -- ; break ; } samplePos ++ ; } mainPos ++ ; samplePos = 0 ; } return sb . toString ( ) ; } }",
"import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . util . StringTokenizer ; public class temp4 { 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 class Print { private final BufferedWriter bw ; public Print ( ) { bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; } public void print ( String str ) throws IOException { bw . append ( str ) ; } public void println ( String str ) throws IOException { print ( str ) ; bw . append ( \" \\n \" ) ; } public void close ( ) throws IOException { bw . close ( ) ; } } public static void main ( String [ ] args ) throws IOException { FastReader scn = new FastReader ( ) ; Print pr = new Print ( ) ; int n = scn . nextInt ( ) , k = scn . nextInt ( ) ; String s = scn . next ( ) ; int [ ] lps = new int [ n ] ; computeLPSArray ( s , n , lps ) ; int t = n - lps [ n - 1 ] ; String temp = s . substring ( lps [ n - 1 ] ) ; for ( int i = 1 ; i < k ; i ++ ) { s += temp ; } System . out . println ( s ) ; } public static void computeLPSArray ( String pat , int M , int lps [ ] ) {",
"import java . util . * ; import java . io . * ; public class Main { public static int mod = 1000000007 ; public static void solve ( InputReader in ) { int n = in . readInt ( ) ; int k = in . readInt ( ) ; char s [ ] = in . readString ( ) . toCharArray ( ) ; int lps [ ] = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { int j = lps [ i - 1 ] ; while ( j > 0 && s [ i ] != s [ j ] ) { j = lps [ j - 1 ] ; } if ( s [ i ] == s [ j ] ) { lps [ i ] = ++ j ; } } int sub = n - lps [ n - 1 ] ; for ( int i = 0 ; i < k - 1 ; i ++ ) { for ( int j = 0 ; j < sub ; j ++ ) { System . out . print ( s [ j ] ) ; } } System . out . print ( new String ( s ) ) ; } public static void main ( String [ ] args ) {"
] | [
"def foo ( s ) : if len ( s ) == 1 : return s for i in range ( 1 , len ( s ) ) : if s . startswith ( s [ i : ] ) : return s [ len ( s ) - i : ] return s n , k = [ int ( x ) for x in input ( ) . split ( ) ] t = input ( ) print ( t + ( foo ( t ) * ( k - 1 ) ) ) NEW_LINE",
"n , k = list ( map ( int , input ( ) . split ( ) ) ) s = input ( ) for x in range ( 1 , n ) : if s [ : - x ] == s [ x : ] : print ( s + s [ - x : ] * ( k - 1 ) ) breakelse : print ( s * k ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) s = input ( ) p = len ( s ) - 1 while s [ : p ] != s [ - p : ] : p = p - 1 print ( s + s [ p : ] * ( k - 1 ) ) NEW_LINE",
"v = input ( ) . split ( ) n = int ( v [ 0 ] ) k = int ( v [ 1 ] ) s = input ( ) ap = 0 i = 1 while i < n : if s [ : i ] == s [ - i : ] : ap = i i += 1 print ( s + s [ ap : ] * ( k - 1 ) ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) s = input ( ) f = 0 for i in range ( 1 , n ) : if s [ : n - i ] == s [ i : ] : f = 1 breakif f == 0 : print ( s * k ) else : j = n - i final = s [ j : ] print ( s + final * ( k - 1 ) ) NEW_LINE"
] |
codeforces_961_B | [
"import java . lang . * ; import java . util . * ; import java . io . * ; public class Problem { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; int [ ] wake = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) ar [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) wake [ i ] = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += ( wake [ i ] == 1 ) ? ar [ i ] : 0 ; } int cur = 0 , max = 0 ; int i = 0 , j = 0 ; while ( j <= n ) { if ( j < k ) { cur += ( wake [ j ] == 0 ) ? ar [ j ] : 0 ; } else if ( j >= k && j < n ) { cur += ( ( wake [ j ] == 0 ) ? ar [ j ] : 0 ) - ( ( wake [ i ] == 0 ) ? ar [ i ] : 0 ) ; i ++ ; } max = Math . max ( max , cur ) ; j ++ ; } System . out . println ( ans + max ) ; } }",
"import java . util . * ; public class square { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] a = new int [ n ] , wake = new int [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { wake [ i ] = sc . nextInt ( ) ; if ( wake [ i ] == 1 ) sum += a [ i ] ; } int zeros = 0 , max = 0 ; for ( int i = 0 ; i < k ; i ++ ) if ( wake [ i ] == 0 ) { zeros ++ ; max += a [ i ] ; } int temp = max ; for ( int i = 1 ; i <= n - k ; i ++ ) { if ( wake [ i - 1 ] == 0 ) temp -= a [ i - 1 ] ; if ( wake [ i + k - 1 ] == 0 ) temp += a [ i + k - 1 ] ; max = Math . max ( max , temp ) ; } System . out . println ( sum + max ) ; } }",
"import java . io . * ; import java . util . * ; public class FlippingGame { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String nk [ ] = br . readLine ( ) . trim ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; int a [ ] = new int [ n ] ; int awake [ ] = new int [ n ] ; int p [ ] = new int [ n ] ; int p2 [ ] = new int [ n ] ; String ss [ ] = br . readLine ( ) . trim ( ) . split ( \" ▁ \" ) ; String x [ ] = br . readLine ( ) . trim ( ) . split ( \" ▁ \" ) ; int j = 0 , max = 0 ; while ( j < n ) { a [ j ] = Integer . parseInt ( ss [ j ] ) ; awake [ j ] = Integer . parseInt ( x [ j ] ) ; if ( j == 0 ) { if ( awake [ j ] == 1 ) p [ j ] = a [ j ] ; p2 [ j ] = a [ j ] ; } else if ( awake [ j ] == 0 ) { p [ j ] = p [ j - 1 ] ; p2 [ j ] = p2 [ j - 1 ] + a [ j ] ; } else { p [ j ] = p [ j - 1 ] + a [ j ] ; p2 [ j ] = p2 [ j - 1 ] + a [ j ] ; } j ++ ; } for ( int i = 0 ; i < n - k + 1 ; i ++ ) { if ( i == 0 ) { max = Math . max ( max , p2 [ i + k - 1 ] + ( p [ n - 1 ] - p [ i + k - 1 ] ) ) ; } else {",
"import java . util . * ; import java . io . * ; import java . math . * ; public class First { public static void process ( ) throws IOException { int n = ni ( ) ; int k = ni ( ) ; int a [ ] = new int [ n + 1 ] ; int beh [ ] = new int [ n + 1 ] ; int p [ ] = new int [ n + 1 ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i + 1 ] = ni ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { beh [ i ] = ni ( ) ; } if ( k >= n ) { for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i + 1 ] ; } pn ( sum ) ; } else { for ( int i = 1 ; i <= n ; i ++ ) { if ( beh [ i ] == 1 ) { sum += a [ i ] ; p [ i ] = p [ i - 1 ] ; } else { p [ i ] = p [ i - 1 ] + a [ i ] ; } } int max = Integer . MIN_VALUE ; for ( int i = 1 ; i <= ( n - k + 1 ) ; i ++ ) { int x = p [ i + ( k - 1 ) ] - p [ i - 1 ] ; max = Math . max ( max , x ) ; } sum += max ; pn ( sum ) ; } } 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 ; "
] | [
"n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) t = list ( map ( int , input ( ) . split ( ) ) ) p = 0 for i in range ( n ) : if t [ i ] == 1 : p += a [ i ] a [ i ] = 0 ans = s = sum ( a [ : k ] ) for i in range ( 0 , n - k ) : s = s + a [ i + k ] - a [ i ] ans = max ( ans , s ) print ( ans + p ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( \" ▁ \" ) ) v = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) condition = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) sum = 0 for i in range ( n ) : if condition [ i ] == 1 : sum += v [ i ] v [ i ] = 0 sum2 = 0 for i in range ( k ) : if condition [ i ] == 0 : sum2 += v [ i ] temp = sum2for i in range ( 0 , n - k ) : temp = temp - v [ i ] + v [ i + k ] if temp > sum2 : sum2 = tempprint ( sum2 + sum ) NEW_LINE",
"n , k = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) lst = list ( map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) ) t = list ( map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) ) s = 0 l = [ ] for i in range ( n ) : if t [ i ] == 1 : s += lst [ i ] if t [ i ] == 0 : l . append ( lst [ i ] ) else : l . append ( 0 ) s1 = sum ( l [ : k ] ) m = s1for i in range ( n - k ) : s1 -= l [ i ] s1 += l [ k + i ] if s1 > m : m = s1print ( m + s ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) m = list ( map ( int , input ( ) . split ( ) ) ) d , e , s , f = 0 , 0 , 0 , 0 for i in range ( n ) : if m [ i ] : s = s + l [ i ] l [ i ] = 0 if i > k - 1 : e = max ( e , d ) d = d - l [ f ] f = f + 1 d = d + l [ i ] print ( s + max ( d , e ) ) NEW_LINE"
] |
codeforces_979_A | [
"import java . util . Scanner ; public class SolutionA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; if ( n == 0 ) { System . out . println ( 0 ) ; } else if ( n % 2 == 0 ) { System . out . println ( n + 1 ) ; } else { System . out . println ( ( n + 1 ) / 2 ) ; } } }",
"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 reader = new FastReader ( ) ; long dummy = reader . nextLong ( ) ;",
"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 { long n = Long . parseLong ( buffer . readLine ( ) ) ; n = n + 1 ; if ( n % 2 == 0 ) { logger . write ( n / 2 + \" \" ) ; } else { if ( n == 1 ) { n = 0 ; } logger . write ( n + \" \" ) ; } logger . flush ( ) ; } catch ( IOException exc ) { } } }",
"import java . io . * ; import java . util . * ; import javax . lang . model . util . ElementScanner6 ; public class codeforces { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long n = Long . parseLong ( bf . readLine ( ) . trim ( ) ) ; if ( n == 0 ) System . out . println ( 0 ) ; else { if ( ( n + 1 ) % 2 == 0 ) System . out . println ( ( n + 1 ) / 2 ) ; else System . out . println ( n + 1 ) ; } } }"
] | [
"n = int ( input ( ) ) if n == 0 : print ( 0 ) elif n % 2 == 1 : print ( ( n + 1 ) // 2 ) else : print ( n + 1 ) NEW_LINE",
"n = int ( input ( ) ) n += 1 if ( n == 1 ) : print ( 0 ) elif n % 2 == 0 : print ( n // 2 ) else : print ( n ) NEW_LINE",
"n = int ( input ( ) ) + 1 if n < 2 : print ( 0 ) elif n % 2 == 0 : print ( n // 2 ) else : print ( n ) NEW_LINE",
"n = int ( input ( ) ) + 1 if n == 1 : print ( 0 ) elif n % 2 : print ( n ) else : print ( n // 2 ) NEW_LINE",
"n = int ( input ( ) ) + 1 if n == 1 : print ( 0 ) else : if n % 2 : print ( n ) else : print ( n // 2 ) NEW_LINE"
] |
codeforces_1204_A | [
"import java . math . BigDecimal ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; int counter = 0 ; BigDecimal decimal = bitStringToBigDecimal ( input ) ; if ( ! input . equals ( \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\" ) && ! input . equals ( \"100000000000000000000000000000000000000000000000000000000000000000000000000000001\" ) && ! input . equals ( \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\" ) && ! input . equals ( \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\" ) && ! input . equals ( \"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\" ) ) { while ( BigDecimal . valueOf ( Math . pow ( 4 , counter ) ) . compareTo ( decimal ) == - 1 ) { if ( BigDecimal . valueOf ( Math . pow ( 4 , counter ) ) . compareTo ( decimal ) == - 1 ) { counter ++ ; } } } else if ( input . equals ( \"100000000000000000000000000000000000000000000000000000000000000000000000000000001\" ) ) { counter = 41 ; } else if ( input . equals ( \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\" ) ) { counter = 50 ; } else if ( input . equals ( \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\" ) ) { counter = 49 ; } else if ( input . equals ( \"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\" ) ) { counter = 49 ; } else { counter = 49 ; } System . out . println ( counter ) ; } public static BigDecimal bitStringToBigDecimal ( String bitStr ) { BigDecimal sum = new BigDecimal ( \"0\" ) ; BigDecimal base = new BigDecimal ( 2 ) ; BigDecimal temp ; for ( int i = 0 ; i < bitStr . length ( ) ; i ++ ) { if ( bitStr . charAt ( i ) == '1' ) { int exponent = bitStr . length ( ) - 1 - i ; temp = base . pow ( exponent ) ; sum = sum . add ( temp ) ; } } return sum ; } }",
"import java . nio . file . FileAlreadyExistsException ; import java . sql . SQLOutput ; import java . util . * ; public class Example { static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;",
"import java . nio . file . FileAlreadyExistsException ; import java . sql . SQLOutput ; 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 CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int length = s . length ( ) ; int index = s . lastIndexOf ( '1' ) ; if ( length == 1 ) { System . out . println ( 0 ) ; return ; } if ( index != ( 0 ) ) { long ans = ( length - 1 ) / 2 + 1 ;",
"import java . util . Scanner ; public class BowWowAndTheTimetable { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; solve ( scanner . nextLine ( ) ) ; } public static void solve ( String numbers ) { if ( numbers . lastIndexOf ( \"1\" ) == 0 || numbers . equals ( \"0\" ) ) System . out . println ( numbers . length ( ) / 2 ) ; else System . out . println ( ( numbers . length ( ) + 1 ) / 2 ) ; } }"
] | [
"s = input ( ) print ( ( len ( s ) + ( s . count ( '1' ) > 1 ) ) // 2 ) NEW_LINE",
"s = input ( ) res = len ( s ) // 2 if len ( s ) % 2 == 1 : for c in s [ 1 : ] : if c == '1' : res += 1 breakprint ( res ) NEW_LINE",
"import mathn = input ( ) if n == '0' : print ( 0 ) else : k = int ( n , 2 ) NEW_LINE",
"import math s = input ( ) if len ( s ) == 1 : print ( 0 ) elif len ( s ) == 2 : print ( 1 ) else : ans = math . ceil ( len ( s ) / 2 ) if s [ 1 : ] . count ( '1' ) == 0 and len ( s ) % 2 == 1 : ans -= 1 print ( ans ) NEW_LINE",
"n = input ( ) l = len ( n ) if l % 2 == 0 : print ( int ( l / 2 ) ) else : c = n . count ( '1' ) if c > 1 : print ( int ( l / 2 ) + 1 ) else : print ( int ( l / 2 ) ) NEW_LINE"
] |
codeforces_723_A | [
"import java . util . * ; public class TheNewYearMeetingFriends { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int arr [ ] = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) arr [ i ] = in . nextInt ( ) ; Arrays . sort ( arr ) ; int result = ( arr [ 1 ] - arr [ 0 ] ) + ( arr [ 2 ] - arr [ 1 ] ) ; System . out . println ( result ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int x1 = in . nextInt ( ) ; int x2 = in . nextInt ( ) ; int x3 = in . nextInt ( ) ; int max = Math . max ( x1 , Math . max ( x2 , x3 ) ) ; int min = Math . min ( x1 , Math . min ( x2 , x3 ) ) ; System . out . println ( max - min ) ; } } ",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int x1 = in . nextInt ( ) ; int max = x1 ; int min = x1 ; int x2 = in . nextInt ( ) ; max = Math . max ( max , x2 ) ; min = Math . min ( min , x2 ) ; int x3 = in . nextInt ( ) ; max = Math . max ( max , x3 ) ; min = Math . min ( min , x3 ) ; System . out . println ( max - min ) ; } } ",
"import java . util . Scanner ; public class A723 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int x1 = scanner . nextInt ( ) , x2 = scanner . nextInt ( ) , x3 = scanner . nextInt ( ) , max , min ; max = Math . max ( x1 , Math . max ( x2 , x3 ) ) ; min = Math . min ( x1 , Math . min ( x2 , x3 ) ) ; System . out . println ( max - min ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class MeetingFriends { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n1 = scanner . nextInt ( ) ; int n2 = scanner . nextInt ( ) ; int n3 = scanner . nextInt ( ) ; int min = Math . min ( Math . min ( n1 , n2 ) , n3 ) ; int max = Math . max ( Math . max ( n1 , n2 ) , n3 ) ; int [ ] arr = { n1 , n2 , n3 } ; int mid = Arrays . stream ( arr ) . filter ( e -> e != min && e != max ) . toArray ( ) [ 0 ] ; System . out . println ( ( max - mid ) + ( mid - min ) ) ; } }"
] | [
"a = ( int ( i ) for i in input ( ) . split ( ) ) a = sorted ( a ) print ( ( a [ 1 ] - a [ 0 ] ) + ( a [ 2 ] - a [ 1 ] ) ) NEW_LINE",
"friend_coordinate = list ( map ( int , input ( ) . split ( ) ) ) min_value = min ( friend_coordinate ) max_value = max ( friend_coordinate ) mid = ( min_value + max_value ) // 2 print ( ( max_value - mid ) + ( mid - min_value ) ) NEW_LINE",
"a = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) a . sort ( ) print ( abs ( a [ 1 ] - a [ 0 ] ) + abs ( a [ 1 ] - a [ 2 ] ) ) NEW_LINE",
"x1 , x2 , x3 = input ( ) . split ( ) x11 = int ( x1 ) x22 = int ( x2 ) x33 = int ( x3 ) l = [ x11 , x22 , x33 ] l . sort ( ) x44 = min ( x11 , x22 , x33 ) x55 = max ( x11 , x22 , x33 ) x66 = x55 - l [ 1 ] x77 = l [ 1 ] - x44print ( x66 + x77 ) NEW_LINE",
"l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) mi , mm , md = l [ 0 ] , l [ 1 ] , l [ 2 ] print ( abs ( mi - mm ) + abs ( md - mm ) ) NEW_LINE"
] |
codeforces_675_B | [
" import java . io . * ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main1 { static class pair implements Comparable < pair > { int a ; int b ; public pair ( int a , int b ) { this . a = a ; this . b = b ; } @ Override public int compareTo ( pair o ) {",
"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 ( ) ; long n = input . nextInt ( ) ; long a , b , c , d ; a = input . nextInt ( ) ; b = input . nextInt ( ) ; c = input . nextInt ( ) ; d = input . nextInt ( ) ; long count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { long z1 = b - c + i ; long x2 = i + a - d ; long z2 = i + a + b - c - d ; if ( ( z1 > 0 && z1 <= n ) && ( x2 > 0 && x2 <= n ) && ( z2 > 0 && z2 <= n ) ) { count ++ ; } } System . out . println ( count * n ) ; } 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 . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long x , y , z , w ; long result = 0 ; for ( x = 1 ; x <= n ; x ++ ) { y = b - c + x ; z = a - d + x ; w = a + b - c - d + x ; if ( ( y >= 1 ) && ( y <= n ) && ( z >= 1 ) && ( z <= n ) && ( w >= 1 ) && ( w <= n ) ) { result ++ ; } } result = result * n ;",
"import java . util . Scanner ; public class PaintingCounter { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ; int A = b - c ; int B = a - d ; int C = a + b - c - d ; long sub = Math . max ( Math . max ( A , B ) , C ) ; long diff = Math . min ( Math . min ( A , B ) , C ) ; if ( diff < 0 ) { if ( sub < 0 ) sub = 0 ; sub -= diff ; } long count = n - sub ; if ( count < 0 ) count = 0 ; else count *= n ; System . out . println ( count ) ; } }",
"import java . util . * ; public class b { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long n = in . nextInt ( ) , a = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) , d = in . nextInt ( ) ; if ( Math . abs ( a - d ) + Math . abs ( b - c ) <= n ) System . out . printf ( \" % d \\n \" , n * ( n - Math . abs ( a - d ) - Math . abs ( b - c ) ) ) ; else System . out . printf ( \"0 \\n \" ) ; in . close ( ) ; } }"
] | [
"l = list ( map ( int , input ( ) . split ( ) ) ) n = l [ 0 ] a = l [ 1 ] b = l [ 2 ] c = l [ 3 ] d = l [ 4 ] k = 0 for i in range ( n ) : x = i + 1 c2 = x + b - c c3 = x + a - d c4 = x + a + b - c - d if ( c2 > 0 and c3 > 0 and c4 > 0 ) : if ( c2 < n + 1 and c3 < n + 1 and c4 < n + 1 ) : k += 1 print ( n * k ) NEW_LINE",
"import sysimport mathfrom collections import defaultdictimport itertools MAXNUM = math . infMINNUM = - 1 * math . inf def getInt ( ) : return int ( sys . stdin . readline ( ) . rstrip ( ) ) def getInts ( ) : return map ( int , sys . stdin . readline ( ) . rstrip ( ) . split ( \" ▁ \" ) ) def getString ( ) : return sys . stdin . readline ( ) . rstrip ( ) def printOutput ( ans ) : sys . stdout . write ( str ( ans ) + \" \\n \" ) def solve ( n , a , b , c , d ) : maxCorner = max ( a + b , a + c , c + d , b + d ) minCorner = min ( a + b , a + c , c + d , b + d ) diff = maxCorner - minCorner if n * ( n - diff ) >= 0 : return n * ( n - diff ) return 0 def readinput ( ) : n , a , b , c , d = getInts ( ) printOutput ( solve ( n , a , b , c , d ) ) readinput ( ) NEW_LINE",
"import math , sys , bisect , heapqfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulatefrom functools import lru_cache NEW_LINE",
"import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 ** 9 + 7 NEW_LINE"
] |
codeforces_1202_B | [
"import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . * ; import java . math . * ; public class Main { InputStream is ; PrintWriter out ; String INPUT = \" \" ;"
] | [
"def findMoves ( x , y , p , q ) : res = 21 for i in range ( 11 ) : for j in range ( 11 ) : if i > 0 or j > 0 : if ( x + ( i * p ) + ( j * q ) ) % 10 == y : res = min ( i + j - 1 , res ) if res == 21 : return - 1 return resdef calc ( p , q ) : ans = 0 for i in range ( 10 ) : for j in range ( 10 ) : if count [ i ] [ j ] > 0 : moves = findMoves ( i , j , p , q ) if moves == - 1 : return - 1 else : ans += ( moves * count [ i ] [ j ] ) return anss = str ( input ( ) ) n = len ( s ) count = [ [ 0 ] * 10 for i in range ( 10 ) ] for i in range ( n - 1 ) : j = int ( s [ i ] ) k = int ( s [ i + 1 ] ) count [ j ] [ k ] += 1 answer = [ [ 0 ] * 10 for i in range ( 10 ) ] for i in range ( 10 ) : for j in range ( 10 ) : answer [ i ] [ j ] = calc ( i , j ) print ( \" ▁ \" . join ( str ( x ) for x in answer [ i ] ) ) NEW_LINE",
"from collections import * s = input ( ) c = Counter ( ( ord ( y ) - ord ( x ) ) % 10 for x , y in zip ( s , s [ 1 : ] ) ) for i in range ( 100 ) : a = [ - 1 ] * 10 for j in range ( 1 , 11 ) : for k in range ( j + 1 ) : x = ( ( j - k ) * ( i // 10 ) + k * ( i % 10 ) ) % 10 if a [ x ] == - 1 : a [ x ] = j - 1 z = 0 for x in c : if a [ x ] == - 1 : z = - 1 break else : z += a [ x ] * c [ x ] print ( z ) NEW_LINE",
"from collections import * s = input ( ) c = Counter ( ( ord ( y ) - ord ( x ) ) % 10 for x , y in zip ( s , s [ 1 : ] ) ) for i in range ( 100 ) : a = [ - 1 ] * 10 for j in range ( 1 , 11 ) : for k in range ( j + 1 ) : x = ( ( j - k ) * ( i // 10 ) + k * ( i % 10 ) ) % 10 if a [ x ] == - 1 : a [ x ] = j - 1 z = 0 for x in c : if a [ x ] == - 1 : z = - 1 break else : z += a [ x ] * c [ x ] print ( z ) NEW_LINE"
] |
codeforces_235_B | [
"import java . io . * ; import java . util . * ; public class Main { static FastReader sc = new FastReader ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) throws IOException {"
] | [
"n = input ( ) lst = list ( map ( float , input ( ) . split ( ) ) ) ds = [ ] ds . append ( 0 ) for i , elem in enumerate ( lst [ 1 : ] ) : ds . append ( ds [ i ] * elem + lst [ i ] * elem ) ans = 2 * sum ( ds ) + sum ( lst ) print ( ans ) NEW_LINE",
"n = int ( input ( ) ) p = list ( map ( float , input ( ) . split ( ) ) ) p . append ( 0 ) s = [ p [ 0 ] ] * 3 s [ 2 ] = 0 ans = ( 2 * s [ 2 ] + s [ 1 ] ) * ( 1 - p [ 1 ] ) for i in range ( 1 , n ) : s [ 0 ] += 1 - p [ i - 1 ] for j in range ( 2 , 0 , - 1 ) : s [ j ] += s [ j - 1 ] for j in range ( 3 ) : s [ j ] *= p [ i ] ans += ( 2 * s [ 2 ] + s [ 1 ] ) * ( 1 - p [ i + 1 ] ) print ( ans ) NEW_LINE",
"n = int ( input ( ) . strip ( ) ) p = [ 0 ] + list ( map ( float , input ( ) . split ( ) ) ) a = [ 0 ] * ( n + 1 ) b = [ 0 ] * ( n + 1 ) for i in range ( 1 , n + 1 ) : b [ i ] = ( b [ i - 1 ] + 1 ) * p [ i ] a [ i ] = ( a [ i - 1 ] + 2 * b [ i - 1 ] + 1 ) * p [ i ] + a [ i - 1 ] * ( 1 - p [ i ] ) print ( a [ - 1 ] ) NEW_LINE",
"t1 = t2 = 0.0 A = [ 0.0 ] * 100005 n = int ( input ( ) ) A = list ( map ( float , input ( ) . split ( ) ) ) for i in range ( n ) : t2 += ( t1 * 2 + 1 ) * A [ i ] t1 = ( t1 + 1 ) * A [ i ] print ( \" { : . 15f } \" . format ( t2 ) ) NEW_LINE"
] |
codeforces_353_B | [
"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 ) { int [ ] cnt = new int [ 100 ] ; int n = 2 * in . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; cnt [ a [ i ] ] ++ ; } ",
"import java . io . * ; import java . util . * ; public class CF353B { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] kk = new int [ 100 ] ; int [ ] pp = new int [ 100 ] ; int [ ] qq = new int [ 100 ] ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] aa = new int [ n + n ] ; for ( int i = 0 ; i < n + n ; i ++ ) { int a = Integer . parseInt ( st . nextToken ( ) ) ; kk [ a ] ++ ; aa [ i ] = a ; } int p = 0 , q = 0 ; for ( int a = 10 ; a <= 99 ; a ++ ) if ( kk [ a ] >= 2 ) { p ++ ; q ++ ; pp [ a ] ++ ; qq [ a ] ++ ; kk [ a ] -= 2 ; } else if ( kk [ a ] >= 1 && p <= q ) { p ++ ; pp [ a ] ++ ; kk [ a ] -- ; } else if ( kk [ a ] >= 1 && p > q ) { q ++ ; qq [ a ] ++ ; kk [ a ] -- ; } int m = p * q ; for ( int a = 10 ; a <= 99 ; a ++ ) while ( kk [ a ] > 0 ) if ( p <= q ) { p ++ ; pp [ a ] ++ ; kk [ a ] -- ; } else { q ++ ; qq [ a ] ++ ; kk [ a ] -- ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n + n ; i ++ ) { int a = aa [ i ] , g ; if ( pp [ a ] > 0 ) { g = 1 ; pp [ a ] -- ; } else { g = 2 ; qq [ a ] -- ; } sb . append ( g + \" ▁ \" ) ; } System . out . println ( m ) ; System . out . println ( sb ) ; } }",
"import java . util . * ; public class Round205B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Map < Integer , List < Integer > > map = new HashMap < > ( ) ; for ( int i = 0 ; i < 2 * n ; i ++ ) { map . computeIfAbsent ( sc . nextInt ( ) , k -> new ArrayList < > ( ) ) . add ( i ) ; } int [ ] b = new int [ 2 * n ] ; int max = 2 * n ; int group = 1 ; for ( List < Integer > list : map . values ( ) ) { if ( list . size ( ) == 1 ) { b [ list . get ( 0 ) ] = group ; group = 3 - group ; } } for ( List < Integer > list : map . values ( ) ) { if ( list . size ( ) > 1 ) { for ( int i = 0 ; i < list . size ( ) ; i ++ ) { b [ list . get ( i ) ] = group ; group = 3 - group ; } max -= list . size ( ) - 2 ; } } if ( max % 2 == 0 ) { max = max * max / 4 ; } else { max = ( max / 2 ) * ( max / 2 + 1 ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i : b ) { sb . append ( i ) . append ( \" ▁ \" ) ; } System . out . println ( max + \" \\n \" + sb ) ; } }"
] | [
"from sys import stdin n = int ( stdin . readline ( ) ) a = [ int ( x ) for x in stdin . readline ( ) . split ( ) ] a = sorted ( [ ( a [ x ] , x ) for x in range ( n * 2 ) ] ) group = { } for x , ind in a : if x in group : group [ x ] . append ( ind ) else : group [ x ] = [ ind ] g2 = [ ] for x in group : g2 . append ( [ len ( group [ x ] ) , group [ x ] ] ) g2 . sort ( ) left = 0 right = 0 board = [ 0 for x in range ( n * 2 ) ] ind = 0 for x , l in g2 : if x == 1 : ind += 1 if left <= right : left += 1 board [ l [ 0 ] ] = '1' else : right += 1 board [ l [ 0 ] ] = '2' else : break if right > left : turn = Trueelse : turn = False for x , l in g2 [ ind : ] : left += 1 right += 1 if x % 2 == 1 : last = l . pop ( ) if turn : board [ last ] = '1' else : board [ last ] = '2' turn = not turn for n in l [ : : 2 ] : board [ n ] = '1' for n in l [ 1 : : 2 ] : board [ n ] = '2' print ( left * right ) print ( ' ▁ ' . join ( board ) ) NEW_LINE",
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) adj = [ [ ] for i in range ( 100 ) ] for i in range ( 2 * n ) : adj [ arr [ i ] ] . append ( i ) res = [ 0 ] * ( 2 * n ) mul , curr = [ ] , 1 x = [ 0 , 0 ] for i in range ( 10 , 100 ) : if len ( adj [ i ] ) == 1 : res [ adj [ i ] [ 0 ] ] = curr x [ curr - 1 ] += 1 curr = 3 - curr if len ( adj [ i ] ) > 1 : res [ adj [ i ] [ 0 ] ] = 1 res [ adj [ i ] [ 1 ] ] = 2 x [ 0 ] += 1 x [ 1 ] += 1 for j in range ( 2 , len ( adj [ i ] ) ) : mul . append ( adj [ i ] [ j ] ) for i in range ( len ( mul ) ) : res [ mul [ i ] ] = curr curr = 3 - currprint ( x [ 0 ] * x [ 1 ] ) print ( * res ) NEW_LINE",
"from collections import * n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = Counter ( a ) for i in range ( 2 * n ) : a [ i ] = [ a [ i ] , i ] a . sort ( ) ans = [ 0 for i in range ( 2 * n ) ] da , db = { } , { } f = 0 for i in range ( 2 * n ) : if ( c [ a [ i ] [ 0 ] ] == 1 ) : continue ans [ a [ i ] [ 1 ] ] = f + 1 if ( f & 1 ) : da [ a [ i ] [ 0 ] ] = 1 else : db [ a [ i ] [ 0 ] ] = 1 f ^= 1 for i in range ( 2 * n ) : if ( ans [ a [ i ] [ 1 ] ] != 0 ) : continue ans [ a [ i ] [ 1 ] ] = f + 1 if ( f & 1 ) : da [ a [ i ] [ 0 ] ] = 1 else : db [ a [ i ] [ 0 ] ] = 1 f ^= 1 print ( len ( da ) * len ( db ) ) print ( * ans ) NEW_LINE",
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) g = [ [ ] for i in range ( 100 ) ] for i in range ( 2 * n ) : g [ arr [ i ] ] . append ( i ) x = 0 y = 0 curr = 1 r = [ ] for i in range ( 10 , 100 ) : if len ( g [ i ] ) == 1 : arr [ g [ i ] [ 0 ] ] = curr if curr == 1 : x += 1 else : y += 1 curr = 3 - curr if len ( g [ i ] ) > 1 : arr [ g [ i ] [ 0 ] ] = 1 arr [ g [ i ] [ 1 ] ] = 2 x += 1 y += 1 for j in range ( 2 , len ( g [ i ] ) ) : r . append ( g [ i ] [ j ] ) for i in range ( len ( r ) ) : arr [ r [ i ] ] = 2 - ( i % 2 ) print ( x * y ) print ( * arr ) NEW_LINE",
"n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) g = [ [ ] for i in range ( 100 ) ] for i in range ( 2 * n ) : g [ arr [ i ] ] . append ( i ) x = 0 y = 0 curr = 1 flip = 2 for i in range ( 10 , 100 ) : if len ( g [ i ] ) == 1 : arr [ g [ i ] [ 0 ] ] = curr if curr == 1 : x += 1 else : y += 1 curr = 3 - curr if len ( g [ i ] ) > 1 : arr [ g [ i ] [ 0 ] ] = 1 arr [ g [ i ] [ 1 ] ] = 2 x += 1 y += 1 for j in range ( 2 , len ( g [ i ] ) ) : arr [ g [ i ] [ j ] ] = flip flip = 3 - flipprint ( x * y ) print ( * arr ) NEW_LINE"
] |
codeforces_1144_A | [
"import java . util . * ; import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; public class divs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { String s = sc . next ( ) ; char [ ] a = s . toCharArray ( ) ; Arrays . sort ( a ) ;",
" import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner puttingvaluesinside = new Scanner ( System . in ) ; int t = puttingvaluesinside . nextInt ( ) ; puttingvaluesinside . nextLine ( ) ; while ( t -- > 0 ) { char c [ ] = puttingvaluesinside . nextLine ( ) . toCharArray ( ) ; boolean flag = true ;",
"import java . util . * ; import java . io . * ; public class A { public static FastReader sc = new FastReader ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static void taskSolver ( ) { char ch [ ] = sc . next ( ) . toCharArray ( ) ; int arr [ ] = new int [ ch . length ] ; for ( int i = 0 ; i < ch . length ; i ++ ) { arr [ i ] = ch [ i ] - ' a ' ; } Arrays . sort ( arr ) ; int flag = 1 ; for ( int i = 1 ; i < arr . length ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] + 1 ) { flag = 0 ; break ; } } if ( flag == 0 ) out . println ( \" No \" ) ; else out . println ( \" Yes \" ) ; } public static void main ( String args [ ] ) throws java . lang . Exception { int t = sc . nextInt ( ) ; while ( t -- > 0 ) taskSolver ( ) ; out . 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 . 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 ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int t = in . nextInt ( ) ; for ( int cas = 1 ; cas <= t ; cas ++ ) { String s = in . next ( ) ;",
"import java . util . * ; public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int l = 0 ; l < t ; l ++ ) { String s = sc . next ( ) ; char arr [ ] = s . toCharArray ( ) ; Arrays . sort ( arr ) ; int count = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i < arr . length - 1 ) { char ch = arr [ i ] ; int x = ch ; if ( arr [ i + 1 ] == ( char ) ( x + 1 ) ) count ++ ; } } if ( count == arr . length - 1 ) System . out . println ( \" Yes \" ) ; else System . out . println ( \" No \" ) ; } } }"
] | [
"n = int ( input ( ) ) for i in range ( n ) : a = sorted ( list ( input ( ) ) ) flag = True for j in range ( len ( a ) - 1 ) : if ord ( a [ j ] ) + 1 != ord ( a [ j + 1 ] ) : flag = False if ( flag ) : print ( \" Yes \" ) else : print ( \" No \" ) NEW_LINE"
] |
codeforces_862_B | [
"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 Zad862B { static int [ ] mark ; static Edge [ ] g ; static ArrayList < Integer > al = new ArrayList < > ( ) ; static ArrayList < Integer > roots = new ArrayList < > ( ) ; public static void main ( String [ ] args ) {",
"import java . io . * ; import java . util . * ; public class BipartiteMahmoud { static ArrayList < Node > map ; static boolean [ ] vis ; static int n ; static long l , r ; public static void main ( String [ ] args ) throws IOException { FastReader fr = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; n = fr . nextInt ( ) ; map = new ArrayList < > ( ) ; vis = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { map . add ( new Node ( i ) ) ; } ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; public class Bipratite_862B { static final int RED = 0 ; static final int BLUE = 1 ; public static void main ( String [ ] args ) throws IOException { BufferedReader sc = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( sc . readLine ( ) ) ; List < Integer > [ ] graph = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { graph [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { String [ ] s = sc . readLine ( ) . split ( \" \\\\ s \" ) ; int a = Integer . parseInt ( s [ 0 ] ) ; int b = Integer . parseInt ( s [ 1 ] ) ; graph [ a ] . add ( b ) ; graph [ b ] . add ( a ) ; } BigInteger [ ] colorCount = new BigInteger [ 2 ] ; colorCount [ RED ] = BigInteger . ZERO ; colorCount [ BLUE ] = BigInteger . ZERO ; colorGraph ( graph , new boolean [ n + 1 ] , 1 , RED , colorCount ) ; System . out . println ( colorCount [ BLUE ] . multiply ( colorCount [ RED ] ) . subtract ( ( BigInteger . valueOf ( n - 1 ) ) ) ) ; } static void colorGraph ( List < Integer > [ ] graph , boolean [ ] vis , int vertex , int currColor , BigInteger [ ] colorCount ) { if ( vis [ vertex ] ) return ; List < Integer > edges = graph [ vertex ] ; if ( edges == null ) return ; int next = ( currColor == RED ) ? BLUE : RED ; vis [ vertex ] = true ; colorCount [ currColor ] = colorCount [ currColor ] . add ( BigInteger . ONE ) ; for ( Integer i : edges ) { colorGraph ( graph , vis , i , next , colorCount ) ; } } }",
"import java . util . * ; public class tcf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < ArrayList < Integer > > graph = new ArrayList < > ( ) ; for ( int i = 0 ; i <= n ; i ++ ) { graph . add ( new ArrayList < Integer > ( ) ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; graph . get ( a ) . add ( b ) ; graph . get ( b ) . add ( a ) ; } Queue < Integer > q = new LinkedList < Integer > ( ) ; q . add ( 1 ) ; int level = 0 ; boolean [ ] vis = new boolean [ n + 1 ] ; vis [ 1 ] = true ; long even = 0 ; long odd = 0 ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; while ( ! q . isEmpty ( ) ) { int size = q . size ( ) ;",
"import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static int count1 ; public static int count2 ; public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] u = new int [ n - 1 ] ; int [ ] v = new int [ n - 1 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { u [ i ] = sc . nextInt ( ) ; v [ i ] = sc . nextInt ( ) ; } System . out . println ( solve ( u , v ) ) ; sc . close ( ) ; } public static long solve ( int [ ] u , int [ ] v ) { int n = u . length + 1 ; List < Integer > [ ] adjLists = new List [ n ] ; for ( int i = 0 ; i < adjLists . length ; i ++ ) { adjLists [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < u . length ; i ++ ) { adjLists [ u [ i ] - 1 ] . add ( v [ i ] - 1 ) ; adjLists [ v [ i ] - 1 ] . add ( u [ i ] - 1 ) ; } count1 = 0 ; count2 = 0 ; search ( adjLists , new boolean [ n ] , 0 , true ) ; return ( long ) count1 * count2 - ( n - 1 ) ; } public static void search ( List < Integer > [ ] adjLists , boolean [ ] visited , int node , boolean condTree ) { visited [ node ] = true ; if ( condTree ) { count1 ++ ; } else { count2 ++ ; } for ( int adj : adjLists [ node ] ) { if ( ! visited [ adj ] ) { search ( adjLists , visited , adj , ! condTree ) ; } } } }"
] | [
"import sys def solve ( ) : n = int ( sys . stdin . readline ( ) ) g = [ set ( ) for _ in range ( n + 1 ) ] count = 0 for _ in range ( n - 1 ) : a , b = map ( int , sys . stdin . readline ( ) . split ( ' ▁ ' ) ) g [ a ] . add ( b ) g [ b ] . add ( a ) red , blue = set ( ) , set ( ) nodes = [ 1 ] NEW_LINE",
"def solve ( vertices , edge ) : table = { i : [ ] for i in range ( 1 , vertices + 1 ) } visited = [ False ] * ( vertices + 1 ) setA = 0 setB = 0 putSetA = True for i , j in edge : table [ i ] . append ( j ) table [ j ] . append ( i ) queue = [ edge [ 0 ] [ 0 ] ] while len ( queue ) > 0 : index = 0 length = len ( queue ) while index < length : if visited [ queue [ index ] ] : index += 1 continue if putSetA : setA += 1 else : setB += 1 queue . extend ( table [ queue [ index ] ] ) visited [ queue [ index ] ] = True index += 1 queue = queue [ index : ] if putSetA : putSetA = False else : putSetA = True return ( setA * setB ) - ( vertices - 1 ) v = int ( input ( ) ) ed = [ ] for _ in range ( v - 1 ) : ed . append ( list ( map ( int , input ( ) . split ( ) ) ) ) print ( solve ( v , ed ) ) NEW_LINE",
"from collections import defaultdictfrom collections import dequen = int ( input ( ) ) d = defaultdict ( list ) for i in range ( n - 1 ) : u , v = map ( int , input ( ) . split ( ) ) d [ u ] . append ( v ) d [ v ] . append ( u ) visited = [ 0 ] * ( n + 1 ) c = { } nr , nb = 0 , 0 q = deque ( ) q . append ( 1 ) visited [ 1 ] = 1 c [ 1 ] = ' R ' nr = nr + 1 while q : i = q . popleft ( ) co = ' R ' if c [ i ] == ' B ' else ' B ' for j in d [ i ] : if visited [ j ] == 0 : visited [ j ] = 1 c [ j ] = co if co == ' R ' : nr = nr + 1 else : nb = nb + 1 q . append ( j ) ans = 0 for i in d : if c [ i ] == ' R ' : ans = ans + nb - len ( d [ i ] ) else : ans = ans + nr - len ( d [ i ] ) print ( ans // 2 ) NEW_LINE"
] |
codeforces_433_B | [
"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 B433M2 { 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 java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . PriorityQueue ; import java . util . StringTokenizer ; public class B433_Kuriyama_Mirais_Stones { public static void main ( String [ ] args ) throws NumberFormatException , IOException {",
" import java . util . * ; import java . io . * ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Solution { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] sorted = new long [ n + 1 ] ; long [ ] dp = new long [ n + 1 ] ; long c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; sorted [ i ] = a ; c += a ; dp [ 1 + i ] = c ; } Arrays . sort ( sorted ) ; for ( int i = 0 ; i < n ; i ++ ) sorted [ i + 1 ] += sorted [ i ] ; int q = sc . nextInt ( ) ; while ( q -- > 0 ) { int t = sc . nextInt ( ) , l = sc . nextInt ( ) , r = sc . nextInt ( ) ; System . out . println ( t == 1 ? dp [ r ] - dp [ l - 1 ] : sorted [ r ] - sorted [ l - 1 ] ) ; } } }",
"import javax . swing . plaf . IconUIResource ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class codeforces { static int M = 1_000_000_007 ; static int INF = Integer . MAX_VALUE ; static final FastScanner fs = new FastScanner ( ) ; "
] | [
"n = int ( input ( ) ) v_arr = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) u_arr = v_arr . copy ( ) u_arr . sort ( ) m = int ( input ( ) ) def sum_calc ( arr ) : sum_ = 0 sum_arr = [ 0 ] for item in arr : sum_ += item sum_arr . append ( sum_ ) return sum_arr sum_v = sum_calc ( v_arr ) sum_u = sum_calc ( u_arr ) for i in range ( m ) : inp = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) _type = inp [ 0 ] l = inp [ 1 ] r = inp [ 2 ] if _type == 1 : print ( sum_v [ r ] - sum_v [ l - 1 ] ) else : print ( sum_u [ r ] - sum_u [ l - 1 ] ) NEW_LINE",
"n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) v = [ ] s = 0 for i in l : s += i v . append ( s ) u = [ ] s = 0 l . sort ( ) for i in l : s += i u . append ( s ) m = int ( input ( ) ) for i in range ( m ) : t , L , r = map ( int , input ( ) . split ( ) ) if t == 1 : if L == 1 : print ( v [ r - 1 ] ) else : print ( v [ r - 1 ] - v [ L - 2 ] ) else : if L == 1 : print ( u [ r - 1 ] ) else : print ( u [ r - 1 ] - u [ L - 2 ] ) NEW_LINE",
"n = int ( input ( ) ) v = list ( map ( int , input ( ) . split ( ) ) ) v . insert ( 0 , 0 ) n += 1 a = v . copy ( ) a . sort ( ) for i in range ( n ) : a [ i ] += 0 if i == 0 else a [ i - 1 ] v [ i ] += 0 if i == 0 else v [ i - 1 ] m = int ( input ( ) ) for _ in range ( m ) : t , l , r = map ( int , input ( ) . split ( ) ) if t == 1 : print ( v [ r ] - v [ l - 1 ] ) else : print ( a [ r ] - a [ l - 1 ] ) NEW_LINE",
"def accumulate_sum ( costs ) : result = [ ] result . append ( 0 ) result . append ( costs [ 0 ] ) for i in range ( 1 , len ( costs ) ) : result . append ( result [ i ] + costs [ i ] ) return result n = int ( input ( ) ) costs = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) sorted_costs = sorted ( costs ) vs = accumulate_sum ( costs ) us = accumulate_sum ( sorted_costs ) for i in range ( m ) : q , l , r = map ( int , input ( ) . split ( ) ) if q == 1 : cs = vs else : cs = us if l == r : print ( cs [ r ] - cs [ l - 1 ] ) else : print ( cs [ r ] - cs [ l - 1 ] ) NEW_LINE"
] |
codeforces_99_A | [
"import java . util . * ; public class P2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; boolean bad = false ; int k = 0 ; int p = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' . ' ) { if ( s . charAt ( i - 1 ) == '9' ) { System . out . println ( \" GOTO ▁ Vasilisa . \" ) ; } else if ( s . charAt ( i + 1 ) >= '5' ) { bad = true ; p = Character . getNumericValue ( ( s . charAt ( i - 1 ) ) ) ; p ++ ; System . out . print ( s . substring ( 0 , i - 1 ) ) ; System . out . print ( p ) ; } else { k = i ; System . out . println ( s . substring ( 0 , k ) ) ; } } } } }",
"import java . util . * ; public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int j = 0 ; while ( s . charAt ( j ) != ' . ' ) { j ++ ; } if ( s . charAt ( j - 1 ) == '9' ) System . out . println ( \" GOTO ▁ Vasilisa . \" ) ; else if ( s . charAt ( j + 1 ) < '5' ) { System . out . println ( s . substring ( 0 , j ) ) ; } else if ( s . charAt ( j + 1 ) >= '5' && s . charAt ( j - 1 ) == '9' ) { System . out . println ( \" GOTO ▁ Vasilisa . \" ) ; } else if ( s . charAt ( j + 1 ) >= '5' ) { System . out . print ( s . substring ( 0 , j - 1 ) ) ; int val = Character . getNumericValue ( s . charAt ( j - 1 ) ) ; System . out . print ( val + 1 ) ; } } }",
"import java . math . BigInteger ; import java . util . Scanner ; public class prob2 { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String ch = input . nextLine ( ) ; if ( ch . contains ( \" . \" ) ) { String ch1 = \" \" ; int l = ch . indexOf ( \" . \" ) ; char sign = ch . charAt ( l + 1 ) ; char sign1 = ch . charAt ( l - 1 ) ; for ( int i = 0 ; i < l ; ++ i ) { ch1 += ch . charAt ( i ) + \" \" ; } if ( sign == '5' || sign == '6' || sign == '7' || sign == '8' || sign == '9' || sign1 == '9' ) { if ( sign1 == '9' ) { System . out . println ( \" GOTO ▁ Vasilisa . \" ) ; } else { BigInteger num = new BigInteger ( ch1 ) ; num = num . add ( BigInteger . ONE ) ; System . out . println ( num ) ; } } else { System . out . println ( ch1 ) ; } } else { System . out . println ( ch ) ; } } }"
] | [
"n = input ( ) NEW_LINE r = n . index ( ' . ' ) NEW_LINE if n [ r - 1 ] == '9' : NEW_LINE INDENT print ( ' GOTO ▁ Vasilisa . ' ) NEW_LINE DEDENT else : NEW_LINE INDENT if n [ r + 1 ] >= '5' : NEW_LINE INDENT print ( int ( n [ : r ] ) + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n [ : r ] ) NEW_LINE DEDENT DEDENT",
"a , b = input ( ) . split ( \" . \" ) NEW_LINE if a [ - 1 ] == \"9\" : NEW_LINE INDENT print ( \" GOTO ▁ Vasilisa . \" ) NEW_LINE DEDENT else : NEW_LINE INDENT if int ( b [ 0 ] ) < 5 : NEW_LINE INDENT print ( int ( a ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( a ) + 1 ) NEW_LINE DEDENT DEDENT",
"numero = input ( ) NEW_LINE indice_punto = - 1 NEW_LINE i = 0 NEW_LINE while indice_punto == - 1 and i < len ( numero ) : NEW_LINE INDENT if numero [ i ] == ' . ' : NEW_LINE INDENT indice_punto = i NEW_LINE DEDENT i = i + 1 NEW_LINE DEDENT unidades = int ( numero [ indice_punto - 1 ] ) NEW_LINE decimas = int ( numero [ indice_punto + 1 ] ) NEW_LINE if unidades < 9 and decimas < 5 : NEW_LINE INDENT print ( numero [ : indice_punto ] ) NEW_LINE DEDENT elif unidades < 9 and decimas >= 5 : NEW_LINE INDENT print ( numero [ : indice_punto - 1 ] + str ( int ( numero [ indice_punto - 1 ] ) + 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' GOTO ▁ Vasilisa . ' ) NEW_LINE DEDENT",
"n = input ( ) NEW_LINE ans = \" \" NEW_LINE capture_next = False NEW_LINE for char in n : NEW_LINE INDENT if char == \" . \" : NEW_LINE INDENT capture_next = True NEW_LINE DEDENT elif capture_next : NEW_LINE INDENT last_digit = char NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT ans += char NEW_LINE DEDENT DEDENT if ans [ - 1 ] == \"9\" : NEW_LINE INDENT print ( \" GOTO ▁ Vasilisa . \" ) NEW_LINE DEDENT else : NEW_LINE INDENT if int ( last_digit ) < 5 : NEW_LINE INDENT print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT s = ans [ : - 1 ] + str ( int ( ans [ - 1 ] ) + 1 ) NEW_LINE print ( s ) NEW_LINE DEDENT DEDENT",
"n = input ( ) NEW_LINE idx = n . index ( ' . ' ) NEW_LINE if n [ idx - 1 ] == '9' : NEW_LINE INDENT print ( \" GOTO ▁ Vasilisa . \" ) NEW_LINE DEDENT else : NEW_LINE INDENT if n [ idx + 1 ] < '5' : NEW_LINE INDENT print ( n [ : idx ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( n [ : idx ] ) + 1 ) NEW_LINE DEDENT DEDENT"
] |
codeforces_108_B | [
"import java . util . * ; import java . io . * ; public class A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < Integer > map = new ArrayList < Integer > ( ) ; HashMap < Integer , Integer > hm = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int j = sc . nextInt ( ) ; if ( ! hm . containsKey ( j ) ) { map . add ( j ) ; hm . put ( j , j ) ; } } Collections . sort ( map ) ; boolean found = false ; outer : for ( int i = 0 ; i < map . size ( ) ; i ++ ) { int first = map . get ( i ) * 2 ; for ( int j = i + 1 ; j < map . size ( ) ; j ++ ) { int second = map . get ( j ) ; if ( first > second ) { System . out . println ( \" YES \" ) ; found = true ; break outer ; } } } if ( ! found ) System . out . println ( \" NO \" ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . sort ( arr ) ; boolean flag = false ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] * 2 > arr [ i + 1 ] && arr [ i ] != arr [ i + 1 ] ) flag = true ; System . out . println ( flag ? \" YES \" : \" NO \" ) ; } }"
] | [
"def datatypes ( x , answer ) : for i in range ( 1 , n ) : if x [ i ] < 2 * x [ i - 1 ] and x [ i ] != x [ i - 1 ] : answer = \" YES \" break print ( answer ) n = int ( input ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) x . sort ( ) answer = \" NO \" datatypes ( x , answer ) NEW_LINE",
"n = int ( input ( ) ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( n - 1 ) : if a [ i ] < a [ i + 1 ] and a [ i ] * 2 > a [ i + 1 ] : print ( \" YES \" ) exit ( ) print ( \" NO \" ) NEW_LINE",
"def nik ( rud , ans ) : for i in range ( 1 , n ) : if rud [ i ] < 2 * rud [ i - 1 ] and rud [ i ] != rud [ i - 1 ] : ans = \" YES \" break print ( ans ) n = int ( input ( ) ) rud = list ( map ( int , input ( ) . split ( ) ) ) rud . sort ( ) ans = \" NO \" nik ( rud , ans ) NEW_LINE"
] |
codeforces_1255_B | [
"import java . util . Scanner ; import java . util . * ; public class fridgeLockers { static Scanner input = new Scanner ( System . in ) ; static int t ; static int n , m ; public static void main ( String [ ] args ) { t = input . nextInt ( ) ;",
"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 ( ) ;"
] | [
"t = int ( input ( ) ) import heapq for _ in range ( t ) : n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) if m < n or n <= 2 : print ( - 1 ) continue s = sum ( a ) smallest = heapq . nsmallest ( 2 , range ( len ( a ) ) , a . __getitem__ ) smallest_values = [ a [ i ] for i in smallest ] print ( 2 * s + sum ( smallest_values ) * ( m - n ) ) for i in range ( 1 , n ) : print ( i , i + 1 ) print ( n , 1 ) for i in range ( m - n ) : print ( * smallest ) NEW_LINE",
"def main ( ) : t = int ( input ( ) ) allans = [ ] for _ in range ( t ) : n , m = readIntArr ( ) a = readIntArr ( ) if n > 2 and m >= n : weights = [ ] for i , w in enumerate ( a ) : weights . append ( [ w , i ] ) weights . sort ( key = lambda x : x [ 0 ] ) lo1 = weights [ 0 ] [ 1 ] + 1 NEW_LINE",
"for _ in range ( int ( input ( ) ) ) : n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) if m < n or n == 2 : print ( - 1 ) else : print ( 2 * sum ( a ) ) for i in range ( n ) : print ( i + 1 , max ( 1 , ( i + 2 ) % ( n + 1 ) ) ) 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 ( ) ) ) for _ in range ( iinput ( ) ) : n , m = minput ( ) if n > m or n < 3 : _ = listinput ( ) print ( - 1 ) else : print ( 2 * sum ( listinput ( ) ) ) for i in range ( n ) : print ( i + 1 , ( i + 1 ) % n + 1 ) ''' p = input ( ) q = input ( ) r = input ( ) answer = [ ] for ▁ _ ▁ in ▁ range ( 2 ) : ▁ ▁ ▁ ▁ if ▁ p . find ( q ) ! = - 1 ▁ and ▁ p . find ( q ) + len ( q ) < = p . rfind ( r ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ answer . append ( 1 ) ▁ ▁ ▁ ▁ else : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ answer . append ( 0 ) ▁ ▁ ▁ ▁ p = p [ : : -1 ] if ▁ answer [ 0 ] = = 1 ▁ and ▁ answer [ 1 ] = = 1 : ▁ ▁ ▁ ▁ print ( \" both \" ) elif ▁ answer [ 1 ] = = 1 : ▁ ▁ ▁ ▁ print ( \" backward \" ) elif ▁ answer [ 0 ] = = 1 : ▁ ▁ ▁ ▁ print ( \" forward \" ) else : ▁ ▁ ▁ ▁ print ( \" fantasy \" ) ''' NEW_LINE",
"if __name__ == ' _ _ main _ _ ' : for _ in range ( int ( input ( ) ) ) : n , m = [ int ( s ) for s in input ( ) . split ( ) ] aa = [ int ( s ) for s in input ( ) . split ( ) ] if n < 3 or m < n : print ( - 1 ) else : print ( f ' {2 ▁ * ▁ sum ( aa ) } ' ) for i in range ( n ) : print ( f ' { i + 1 } ▁ { ( i + 1 ) % n ▁ + ▁ 1 } ' ) NEW_LINE"
] |
codeforces_855_A | [
"import java . util . * ; import java . lang . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; String ar [ ] = new String [ t ] ; ArrayList < String > l = new ArrayList < > ( ) ; for ( int p = 0 ; p < t ; p ++ ) { ar [ p ] = sc . next ( ) ; if ( l . contains ( ar [ p ] ) == false ) { l . add ( ar [ p ] ) ; System . out . println ( \" NO \" ) ; } else { l . add ( ar [ p ] ) ; System . out . println ( \" YES \" ) ; } } } }",
"import java . io . * ; import java . util . * ; public class Diary {",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Stack ; 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 boolean check ( String st ) { Stack < Character > stck = new Stack < Character > ( ) ; for ( char c : st . toCharArray ( ) ) { if ( c == ' ( ' ) { stck . push ( ' ) ' ) ; } else if ( c == ' [ ' ) { stck . push ( ' ] ' ) ; } else if ( stck . isEmpty ( ) || c != stck . pop ( ) ) { return false ; } } return stck . isEmpty ( ) ; } public static void main ( String [ ] args ) { PrintWriter pw = new PrintWriter ( System . out ) ; FastReader sc = new FastReader ( ) ; int t = sc . nextInt ( ) ; HashSet < String > hs = new HashSet < String > ( ) ; while ( t -- > 0 ) { String str = sc . nextLine ( ) ; if ( hs . contains ( str ) ) { System . out . println ( \" YES \" ) ; } else { hs . add ( str ) ; System . out . println ( \" NO \" ) ; } } } }",
"import java . io . * ; import java . util . * ; import java . math . * ; import java . awt . Point ; public class CFTemplate { static final long MOD = 1000000007L ;"
] | [
"def main_function ( ) : n = int ( input ( ) ) names = [ ] output_list = [ ] dict = { } for i in range ( n ) : names . append ( input ( ) ) for name in names : if not name in dict : output_list . append ( \" NO \" ) dict [ name ] = 1 else : output_list . append ( \" YES \" ) return \" \\n \" . join ( output_list ) print ( main_function ( ) ) NEW_LINE",
"import sys def main ( ) : _ , * l = sys . stdin . read ( ) . strip ( ) . split ( ) out , s = [ ] , set ( ) for i in l : if i in s : out . append ( ' YES ' ) else : s . add ( i ) ; out . append ( ' NO ' ) return out print ( * main ( ) , sep = ' \\n ' ) NEW_LINE",
"n = int ( input ( ) ) l = [ ] for i in range ( 0 , n ) : y = input ( ) if ( y in l ) : print ( \" YES \" ) else : print ( \" NO \" ) l . append ( y ) NEW_LINE",
"n = int ( input ( ) ) names = { } for i in range ( n ) : name = input ( ) if name in names : print ( ' YES ' ) else : print ( ' NO ' ) names [ name ] = 1 NEW_LINE",
"i = int ( input ( ) ) l = [ ] res = [ ] while i > 0 : a = input ( ) i -= 1 if a in l : res . append ( ' YES ' ) else : l . append ( a ) res . append ( ' NO ' ) for e in res : print ( e ) NEW_LINE"
] |
codeforces_1200_B | [
"import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . math . RoundingMode ; import java . util . * ; import java . util . concurrent . LinkedBlockingDeque ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . LinkedList ; ",
"import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ; public class absolute { public static void main ( String [ ] args ) {"
] | [
"t = int ( input ( ) ) for i in range ( t ) : NEW_LINE",
"from sys import stdininput = lambda : stdin . readline ( ) from math import ceil , sqrt , gcdfor _ in range ( int ( input ( ) ) ) : n , m , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) flag = ' YES ' for i in range ( n - 1 ) : if l [ i + 1 ] > l [ i ] : if l [ i + 1 ] - l [ i ] > k : if m < l [ i + 1 ] - l [ i ] - k : flag = ' NO ' break else : m -= ( l [ i + 1 ] - l [ i ] - k ) NEW_LINE",
"t = int ( input ( ) ) for i in range ( t ) : n , m , k = [ int ( i ) for i in input ( ) . split ( ) ] h = [ int ( i ) for i in input ( ) . split ( ) ] flag = 1 for i in range ( n - 1 ) : m += h [ i ] - max ( 0 , h [ i + 1 ] - k ) if m < 0 : flag = 0 break if flag : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"test = int ( input ( ) ) for t in range ( 0 , test ) : n , m , k = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) p = int ( 0 ) for i in range ( n - 1 ) : m = m + arr [ i ] - max ( p , arr [ i + 1 ] - k ) if m < 0 : p = 1 break if p == 0 : print ( \" YES \" ) else : print ( \" NO \" ) NEW_LINE",
"t = int ( input ( ) ) for zzz in range ( t ) : n , m , k = map ( int , input ( ) . split ( ) ) hs = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n - 1 ) : m += max ( min ( hs [ i ] + k - hs [ i + 1 ] , hs [ i ] ) , 0 ) hs [ i ] -= max ( hs [ i ] + k - hs [ i + 1 ] , 0 ) if ( hs [ i ] + k < hs [ i + 1 ] ) : if ( m >= hs [ i + 1 ] - hs [ i ] - k ) : m -= hs [ i + 1 ] - hs [ i ] - k else : print ( ' NO ' ) break else : print ( ' YES ' ) NEW_LINE"
] |
codeforces_472_B | [
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] f = new int [ n ] ; for ( int i = 0 ; i < f . length ; i ++ ) { f [ i ] = sc . nextInt ( ) ; } System . out . println ( solve ( f , k ) ) ; sc . close ( ) ; } static int solve ( int [ ] f , int k ) { int [ ] sorted = Arrays . stream ( f ) . boxed ( ) . sorted ( ) . mapToInt ( x -> x ) . toArray ( ) ; int result = 0 ; for ( int i = f . length - 1 ; i >= 0 ; i -= k ) { result += ( sorted [ i ] - 1 ) * 2 ; } return result ; } }",
"import java . util . * ; import static java . lang . Math . * ; import java . io . * ; public class SolutionB { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int ans = 0 ; int cnt = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( cnt % k == 0 ) { ans += ( ( a [ i ] - 1 ) * 2 ) ; } cnt ++ ; } System . out . println ( ans ) ; } }",
"import java . util . * ; public class life { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) ; ArrayList < Integer > f = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) f . add ( in . nextInt ( ) ) ; Collections . sort ( f , Collections . reverseOrder ( ) ) ; int c = 0 ; for ( int i = 0 ; i < n ; i += k ) c += f . get ( i ) - 1 ; System . out . println ( 2 * c ) ; } }"
] | [
"a , b = map ( int , input ( ) . split ( ) ) z = list ( map ( int , input ( ) . split ( ) ) ) ; s = 0 for i in set ( z ) : r = z . count ( i ) ; s += 2 * ( i - 1 ) * ( r // b ) for j in range ( b * ( r // b ) ) : z . remove ( i ) z . sort ( reverse = True ) print ( s + sum ( 2 * ( i - 1 ) for i in z [ : : b ] ) ) NEW_LINE",
"n , k = map ( int , input ( ) . split ( ) ) NEW_LINE",
"import mathn , k = map ( int , input ( ) . split ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) p . sort ( ) p . reverse ( ) ans = 0 for i in range ( math . ceil ( n / k ) ) : ans += 2 * ( p [ k * i ] - 1 ) print ( ans ) NEW_LINE",
"from sys import stdinfrom collections import defaultdictinput = stdin . readline NEW_LINE",
"a , b = map ( int , input ( ) . split ( ) ) z = list ( map ( int , input ( ) . split ( ) ) ) ; s = 0 for i in set ( z ) : r = z . count ( i ) ; s += 2 * ( i - 1 ) * ( r // b ) for j in range ( b * ( r // b ) ) : z . remove ( i ) z . sort ( reverse = True ) print ( s + sum ( 2 * ( i - 1 ) for i in z [ : : b ] ) ) NEW_LINE"
] |
codeforces_1036_B | [
"import java . util . * ; public class CodeForces1036B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int q = input . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { long n = input . nextLong ( ) ; long m = input . nextLong ( ) ; long k = input . nextLong ( ) ; long max = Math . max ( n , m ) ; long ans = 0 ; if ( max > k ) { ans = - 1 ; } else if ( n % 2 != m % 2 ) { ans = k - 1 ; } else if ( k % 2 == max % 2 ) { ans = k ; } else { ans = k - 2 ; } System . out . println ( ans ) ; } } }",
"import java . io . * ; import java . util . * ; import java . lang . * ; import java . math . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; public class B { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ;",
"import java . util . Scanner ; public class test48 { private static long testCase48 ( long n , long m , long k ) { long max = Math . max ( n , m ) ; long x = 0 ; long min = Math . min ( n , m ) ; long dif = k - max ; if ( dif == 1 || dif % 2 != 0 ) { x = dif - 1 ; k += ( 1 - dif ) ; dif = x ; } else k -= dif ; if ( ( k % 2 != 0 && min % 2 == 0 ) || ( ( min == 1 || min % 2 != 0 ) && k % 2 == 0 ) ) max -= 1 ; return max + dif ; } public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; long t = input . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { long n = input . nextLong ( ) ; long m = input . nextLong ( ) ; long k = input . nextLong ( ) ; if ( n > k || m > k ) System . out . println ( \" - 1\" ) ; else if ( k == n && k == m ) System . out . println ( k ) ; else System . out . println ( testCase48 ( n , m , k ) ) ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . Random ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Collections ; public class A { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; StringBuffer ans = new StringBuffer ( ) ; int test = sc . nextInt ( ) ; while ( test -- > 0 ) { long n = sc . nextLong ( ) , m = sc . nextLong ( ) , k = sc . nextLong ( ) ; long curx = 0 ; long cury = 0 ; long steps = 0 ; boolean flag = true ;"
] | [
"q = int ( input ( ) ) for _ in range ( q ) : n , m , k = map ( int , input ( ) . split ( ) ) if n > k or m > k : print ( - 1 ) continue ans = k if k % 2 == 0 : NEW_LINE",
"import sys , os , iodef rs ( ) : return sys . stdin . readline ( ) . rstrip ( ) def ri ( ) : return int ( sys . stdin . readline ( ) ) def ria ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def ws ( s ) : sys . stdout . write ( s + ' \\n ' ) def wi ( n ) : sys . stdout . write ( str ( n ) + ' \\n ' ) def wia ( a ) : sys . stdout . write ( ' ▁ ' . join ( [ str ( x ) for x in a ] ) + ' \\n ' ) import math , datetime , functools , itertools , operator , bisect , fractions , statisticsfrom collections import deque , defaultdict , OrderedDict , Counterfrom fractions import Fractionfrom decimal import Decimalfrom sys import stdoutfrom heapq import heappush , heappop , heapify , _heapify_max , _heappop_max , nsmallest , nlargest def main ( ) : NEW_LINE",
"def solve ( n , m , k ) : n , m = max ( abs ( n ) , abs ( m ) ) , min ( abs ( n ) , abs ( m ) ) if ( n - m ) % 2 != 0 : k -= 1 n -= 1 elif ( n - k ) % 2 != 0 : n -= 1 m -= 1 k -= 2 if k < n : return - 1 else : return k q = int ( input ( ) ) for case in range ( q ) : print ( solve ( * [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] ) ) NEW_LINE",
"def solve ( n , m , k ) : if n < m : n , m = m , n if k < n : return - 1 if ( k - n ) % 2 == 1 : m -= 1 k -= 1 return k - ( n - m ) % 2 for _ in range ( int ( input ( ) ) ) : n , m , k = map ( int , input ( ) . split ( ) ) print ( solve ( n , m , k ) ) NEW_LINE",
"q = int ( input ( ) ) for i in range ( q ) : n , m , k = map ( int , input ( ) . split ( ) ) if ( n < m ) : n , m = m , n if ( n % 2 != m % 2 ) : k -= 1 n -= 1 elif ( n % 2 != k % 2 ) : k -= 2 n -= 1 m -= 1 print ( - 1 if k < n else k ) NEW_LINE"
] |
codeforces_61_B | [
"import java . util . * ; public class Main { static void preProcess ( ArrayList < String > str ) { for ( int i = 0 ; i < str . size ( ) ; i ++ ) { String s = str . get ( i ) ; s = s . indexOf ( ' _ ' ) != - 1 ? s . replace ( \" _ \" , \" \" ) : s ; s = s . indexOf ( ' ; ' ) != - 1 ? s . replace ( \" ; \" , \" \" ) : s ; s = s . indexOf ( ' - ' ) != - 1 ? s . replace ( \" - \" , \" \" ) : s ; str . set ( i , s . toLowerCase ( ) ) ; }",
"import java . util . * ; import java . util . regex . * ; import java . io . * ; public class shapur_corrections { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s1 = ( scan . next ( ) ) . replaceAll ( \" [ ; \\\\ - _ ] * \" , \" \" ) . toLowerCase ( ) ; String s2 = ( scan . next ( ) ) . replaceAll ( \" [ ; \\\\ - _ ] * \" , \" \" ) . toLowerCase ( ) ; String s3 = ( scan . next ( ) ) . replaceAll ( \" [ ; \\\\ - _ ] * \" , \" \" ) . toLowerCase ( ) ; Pattern pat1 = Pattern . compile ( s1 ) ; Pattern pat2 = Pattern . compile ( s2 ) ; Pattern pat3 = Pattern . compile ( s3 ) ; String s4 = s1 + s2 + s3 ;",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s1 = br . readLine ( ) ; String s2 = br . readLine ( ) ; String s3 = br . readLine ( ) ; s1 = s1 . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; s2 = s2 . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; s3 = s3 . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; String [ ] ss = new String [ 7 ] ; ss [ 0 ] = s1 + s2 + s3 ; ss [ 1 ] = s1 + s3 + s2 ; ss [ 2 ] = s2 + s1 + s3 ; ss [ 3 ] = s2 + s3 + s1 ; ss [ 4 ] = s3 + s1 + s2 ; ss [ 5 ] = s3 + s2 + s1 ; int n = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String str = br . readLine ( ) ; str = str . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; int j ; for ( j = 0 ; j < 6 ; j ++ ) { if ( str . equals ( ss [ j ] ) ) { System . out . println ( \" ACC \" ) ; break ; } } if ( j < 6 ) { continue ; } System . out . println ( \" WA \" ) ; } } } ",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s1 = br . readLine ( ) ; String s2 = br . readLine ( ) ; String s3 = br . readLine ( ) ; s1 = s1 . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; s2 = s2 . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; s3 = s3 . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; String [ ] ss = new String [ 6 ] ; ss [ 0 ] = s1 + s2 + s3 ; ss [ 1 ] = s1 + s3 + s2 ; ss [ 2 ] = s2 + s1 + s3 ; ss [ 3 ] = s2 + s3 + s1 ; ss [ 4 ] = s3 + s1 + s2 ; ss [ 5 ] = s3 + s2 + s1 ; int n = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String str = br . readLine ( ) ; str = str . replaceAll ( \" - | ; | _ \" , \" \" ) . toLowerCase ( ) ; int j ; for ( j = 0 ; j < 6 ; j ++ ) { if ( str . equals ( ss [ j ] ) ) { System . out . println ( \" ACC \" ) ; break ; } } if ( j < 6 ) { continue ; } System . out . println ( \" WA \" ) ; } } }"
] | [
"from collections import Counter NEW_LINE def SomRas ( s ) : return \" \" . join ( [ item . lower ( ) for item in s if item . isalpha ( ) ] ) NEW_LINE naradmuni = SomRas ( input ( ) ) NEW_LINE vedvyas = SomRas ( input ( ) ) NEW_LINE RishiMuni = SomRas ( input ( ) ) n = int ( input ( ) ) NEW_LINE for test in range ( n ) : koi_dikkat = SomRas ( input ( ) ) was_a_thing = Counter ( koi_dikkat ) NEW_LINE maybe_a_thing = Counter ( naradmuni + vedvyas + RishiMuni ) if was_a_thing != maybe_a_thing : print ( \" WA \" ) NEW_LINE continue sort_kiya_hua_cheez = sorted ( [ naradmuni , vedvyas , RishiMuni ] , key = len ) if sort_kiya_hua_cheez [ 2 ] in koi_dikkat : NEW_LINE INDENT koi_dikkat = koi_dikkat . split ( sort_kiya_hua_cheez [ 2 ] ) else : NEW_LINE print ( \" WA \" ) NEW_LINE DEDENT continue if sort_kiya_hua_cheez [ 1 ] in koi_dikkat [ 0 ] : koi_dikkat += koi_dikkat [ 0 ] . split ( sort_kiya_hua_cheez [ 1 ] ) NEW_LINE koi_dikkat = koi_dikkat [ 1 : ] elif sort_kiya_hua_cheez [ 1 ] in koi_dikkat [ 1 ] : last = koi_dikkat . pop ( ) NEW_LINE koi_dikkat += last . split ( sort_kiya_hua_cheez [ 1 ] ) else : print ( \" WA \" ) NEW_LINE continue if sort_kiya_hua_cheez [ 0 ] in koi_dikkat : NEW_LINE INDENT print ( \" ACC \" ) else : NEW_LINE print ( \" WA \" ) NEW_LINE DEDENT",
"import sysinput = sys . stdin . readline NEW_LINE def insr ( ) : s = input ( ) NEW_LINE return list ( s [ : len ( s ) - 1 ] ) NEW_LINE def fixStr ( s ) : s = list ( s ) NEW_LINE signs = [ ' - ' , ' ; ' , ' _ ' ] NEW_LINE i = 0 NEW_LINE while i < len ( s ) : if NEW_LINE s [ i ] in signs : s . pop ( i ) else : s [ i ] = s [ i ] . lower ( ) NEW_LINE i += 1 NEW_LINE return ' ' . join ( s ) words = [ fixStr ( insr ( ) ) , fixStr ( insr ( ) ) , fixStr ( insr ( ) ) ] NEW_LINE for i in range ( int ( input ( ) ) ) : sts = fixStr ( insr ( ) ) if sts == words [ 0 ] + words [ 1 ] + words [ 2 ] or sts == words [ 0 ] + NEW_LINE INDENT words [ 2 ] + words [ 1 ] or sts == words [ 1 ] + words [ 0 ] + words [ 2 ] or \\ sts == words [ 1 ] + words [ 2 ] + words [ 0 ] or sts == words [ 2 ] + words [ 0 ] + words [ 1 ] or \\ sts == words [ 2 ] + words [ 1 ] + words [ 0 ] : print ( \" ACC \" ) else : print ( \" WA \" ) NEW_LINE DEDENT",
"from collections import Counter NEW_LINE def cleanup ( s ) : return \" \" . join ( [ item . lower ( ) for item in s if item . isalpha ( ) ] ) NEW_LINE s1 = cleanup ( input ( ) ) NEW_LINE s2 = cleanup ( input ( ) ) NEW_LINE s3 = cleanup ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE for test in range ( n ) : st = cleanup ( input ( ) ) NEW_LINE c1 = Counter ( st ) NEW_LINE c2 = Counter ( s1 + s2 + s3 ) NEW_LINE if c1 != c2 : print ( \" WA \" ) NEW_LINE continue NEW_LINE sorted_strings = sorted ( [ s1 , s2 , s3 ] , key = len ) NEW_LINE if sorted_strings [ 2 ] in st : NEW_LINE INDENT st = st . split ( sorted_strings [ 2 ] ) else : NEW_LINE print ( \" WA \" ) NEW_LINE DEDENT continue NEW_LINE if sorted_strings [ 1 ] in st [ 0 ] : st += st [ 0 ] . split ( sorted_strings [ 1 ] ) NEW_LINE st = st [ 1 : ] elif sorted_strings [ 1 ] in st [ 1 ] : last = st . pop ( ) NEW_LINE st += last . split ( sorted_strings [ 1 ] ) else : print ( \" WA \" ) NEW_LINE continue NEW_LINE if sorted_strings [ 0 ] in st : NEW_LINE INDENT print ( \" ACC \" ) else : NEW_LINE print ( \" WA \" ) NEW_LINE DEDENT",
"def removeSigns ( s ) : news = \" \" NEW_LINE for i in s : if NEW_LINE i in \" _ - ; \" : NEW_LINE continue NEW_LINE if i >= ' A ' and i <= ' Z ' : NEW_LINE INDENT news += chr ( ord ( i ) + 32 ) else : NEW_LINE news += i NEW_LINE DEDENT return news a = removeSigns ( input ( ) ) ; NEW_LINE aa = len ( a ) NEW_LINE b = removeSigns ( input ( ) ) ; NEW_LINE bb = len ( b ) NEW_LINE c = removeSigns ( input ( ) ) ; NEW_LINE cc = len ( c ) NEW_LINE concats = [ a + b + c , a + c + b , b + a + c , b + c + a , c + a + b , c + b + a ] NEW_LINE T = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE for _ in range ( T ) : t = removeSigns ( input ( ) ) NEW_LINE if t in concats : NEW_LINE INDENT ans . append ( \" ACC \" ) else : NEW_LINE ans . append ( \" WA \" ) for i in ans : print ( i ) NEW_LINE DEDENT"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.