id
stringlengths
13
20
java
sequence
python
sequence
atcoder_agc013_B
[ "import java . util . ArrayList ; import java . util . LinkedList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; List < ArrayList < Integer > > connect = new ArrayList < ArrayList < Integer > > ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) { connect . add ( new ArrayList < Integer > ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; connect . get ( a ) . add ( b ) ; connect . get ( b ) . add ( a ) ; } boolean taken [ ] = new boolean [ n + 1 ] ; taken [ 1 ] = true ; LinkedList < Integer > ans = new LinkedList < Integer > ( ) ; ans . add ( 1 ) ; extend ( ans , connect , taken , false ) ; extend ( ans , connect , taken , true ) ; System . out . println ( ans . size ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; for ( Integer i : ans ) { sb . append ( i ) ; sb . append ( ' ▁ ' ) ; } sb . deleteCharAt ( sb . length ( ) - 1 ) ; System . out . println ( sb ) ; } static void extend ( LinkedList < Integer > ans , List < ArrayList < Integer > > connect , boolean [ ] taken , boolean right ) { while ( true ) { Integer tmp = right ? ans . getLast ( ) : ans . getFirst ( ) ; boolean found = false ; for ( Integer i : connect . get ( tmp ) ) { if ( ! taken [ i ] ) { taken [ i ] = true ; if ( right ) { ans . addLast ( i ) ; } else { ans . addFirst ( i ) ; } found = true ; break ; } } if ( ! found ) { break ; } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; ArrayList < Integer > [ ] graph = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { graph [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; graph [ a ] . add ( b ) ; graph [ b ] . add ( a ) ; } HashSet < Integer > set = new HashSet < > ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int idx = 1 ; boolean flag = false ; list . add ( idx ) ; set . add ( idx ) ; while ( ! flag ) { flag = true ; for ( int x : graph [ idx ] ) { if ( ! set . contains ( x ) ) { flag = false ; idx = x ; list . add ( idx ) ; set . add ( idx ) ; break ; } } } flag = false ; idx = 1 ; while ( ! flag ) { flag = true ; for ( int x : graph [ idx ] ) { if ( ! set . contains ( x ) ) { flag = false ; idx = x ; list . add ( 0 , idx ) ; set . add ( idx ) ; break ; } } } StringBuilder sb = new StringBuilder ( ) ; sb . append ( list . size ( ) ) . append ( \" \\n \" ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( i != 0 ) { sb . append ( \" ▁ \" ) ; } sb . append ( list . get ( i ) ) ; } System . out . println ( sb ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { static ArrayList < Integer > [ ] graph ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; graph = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) graph [ i ] = new ArrayList < > ( ) ; for ( int j = 0 ; j < m ; j ++ ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; graph [ a ] . add ( b ) ; graph [ b ] . add ( a ) ; } LinkedList < Integer > ans = helper ( n ) ; PrintWriter out = new PrintWriter ( System . out ) ; out . println ( ans . size ( ) ) ; while ( ans . size ( ) > 0 ) { out . print ( ans . poll ( ) ) ; out . print ( \" ▁ \" ) ; } out . flush ( ) ; } static LinkedList < Integer > helper ( int n ) { boolean [ ] vis = new boolean [ n + 1 ] ; LinkedList < Integer > ans = new LinkedList < > ( ) ; ans . add ( 1 ) ; ans . add ( graph [ 1 ] . get ( 0 ) ) ; vis [ 1 ] = true ; vis [ ans . peekLast ( ) ] = true ; boolean flag = true ; while ( flag ) { flag = false ; for ( int w : graph [ ans . peek ( ) ] ) { if ( ! vis [ w ] ) { ans . addFirst ( w ) ; vis [ w ] = true ; flag = true ; break ; } } } flag = true ; while ( flag ) { flag = false ; for ( int w : graph [ ans . peekLast ( ) ] ) { if ( ! vis [ w ] ) { ans . addLast ( w ) ; vis [ w ] = true ; flag = true ; break ; } } } return ans ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( m ) ] NEW_LINE d = { } NEW_LINE for i , j in a : NEW_LINE INDENT d [ i ] = d . get ( i , set ( ) ) | { j } NEW_LINE d [ j ] = d . get ( j , set ( ) ) | { i } NEW_LINE DEDENT path = a [ 0 ] [ : ] NEW_LINE sp = set ( path ) NEW_LINE while d [ path [ - 1 ] ] - sp : NEW_LINE INDENT t = d [ path [ - 1 ] ] - sp NEW_LINE t = t . pop ( ) NEW_LINE path . append ( t ) NEW_LINE sp . add ( t ) NEW_LINE DEDENT path = path [ : : - 1 ] NEW_LINE while d [ path [ - 1 ] ] - sp : NEW_LINE INDENT t = d [ path [ - 1 ] ] - sp NEW_LINE t = t . pop ( ) NEW_LINE path . append ( t ) NEW_LINE sp . add ( t ) NEW_LINE DEDENT print ( len ( path ) ) NEW_LINE print ( * path ) NEW_LINE", "def dfs ( ) : NEW_LINE INDENT ans = [ ] NEW_LINE vNow = 0 NEW_LINE while True : NEW_LINE INDENT useds [ vNow ] = True NEW_LINE ans . append ( vNow + 1 ) NEW_LINE for v2 in adjL [ vNow ] : NEW_LINE INDENT if not useds [ v2 ] : NEW_LINE INDENT vNow = v2 NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE adjL = [ [ ] for v in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE adjL [ a - 1 ] . append ( b - 1 ) NEW_LINE adjL [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT useds = [ False ] * N NEW_LINE ans1 = dfs ( ) NEW_LINE ans2 = dfs ( ) NEW_LINE print ( len ( ans1 ) + len ( ans2 ) - 1 ) NEW_LINE print ( ' ▁ ' . join ( map ( str , ans1 [ : : - 1 ] + ans2 [ 1 : ] ) ) ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE I = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE n , m = I ( ) NEW_LINE g = [ set ( ) for _ in range ( n + 1 ) ] NEW_LINE v = [ 1 for _ in range ( n + 1 ) ] NEW_LINE v [ 1 ] = 0 NEW_LINE for _ in range ( m ) : NEW_LINE INDENT a , b = I ( ) NEW_LINE g [ a ] . add ( b ) NEW_LINE g [ b ] . add ( a ) NEW_LINE DEDENT def dfs ( x ) : NEW_LINE INDENT for j in g [ x ] : NEW_LINE INDENT if v [ j ] : NEW_LINE INDENT v [ j ] = 0 NEW_LINE l = dfs ( j ) NEW_LINE l . append ( j ) NEW_LINE return l NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return [ ] NEW_LINE DEDENT DEDENT z = dfs ( 1 ) + [ 1 ] + dfs ( 1 ) [ : : - 1 ] NEW_LINE print ( len ( z ) ) NEW_LINE print ( * z ) NEW_LINE", "import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE from collections import deque NEW_LINE n , m = li ( ) NEW_LINE graph = [ [ ] for _ in range ( n ) ] NEW_LINE for _ in range ( m ) : NEW_LINE INDENT a , b = li_ ( ) NEW_LINE graph [ a ] . append ( b ) NEW_LINE graph [ b ] . append ( a ) NEW_LINE path = deque ( [ a , b ] ) NEW_LINE DEDENT path_set = set ( path ) NEW_LINE ed = b NEW_LINE satisfied = False NEW_LINE while not satisfied : NEW_LINE INDENT satisfied = True NEW_LINE for nex in graph [ ed ] : NEW_LINE INDENT if nex in path_set : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT path_set . add ( nex ) NEW_LINE path . append ( nex ) NEW_LINE ed = nex NEW_LINE satisfied = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT ed = a NEW_LINE satisfied = False NEW_LINE while not satisfied : NEW_LINE INDENT satisfied = True NEW_LINE for nex in graph [ ed ] : NEW_LINE INDENT if nex in path_set : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT path_set . add ( nex ) NEW_LINE path . appendleft ( nex ) NEW_LINE ed = nex NEW_LINE satisfied = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT path = [ pi + 1 for pi in path ] NEW_LINE print ( len ( path ) ) NEW_LINE print ( * path ) NEW_LINE", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE Edge = [ [ ] for i in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE Edge [ a - 1 ] . append ( b - 1 ) NEW_LINE Edge [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT Used = [ False for i in range ( N ) ] NEW_LINE Path = [ 1 , Edge [ 0 ] [ 0 ] + 1 ] NEW_LINE Used [ 0 ] , Used [ Edge [ 0 ] [ 0 ] ] = True , True NEW_LINE AFin , BFin = False , False NEW_LINE Anext , Bnext = 0 , Edge [ 0 ] [ 0 ] NEW_LINE for node in Edge [ 0 ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Anext = node NEW_LINE Used [ Anext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : AFin = True NEW_LINE for node in Edge [ Bnext ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Bnext = node NEW_LINE Used [ Bnext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : BFin = True NEW_LINE while not AFin or not BFin : NEW_LINE INDENT if not AFin : NEW_LINE INDENT Path . insert ( 0 , Anext + 1 ) NEW_LINE for node in Edge [ Anext ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Anext = node NEW_LINE Used [ Anext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : AFin = True NEW_LINE DEDENT if not BFin : NEW_LINE INDENT Path . append ( Bnext + 1 ) NEW_LINE for node in Edge [ Bnext ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Bnext = node NEW_LINE Used [ Bnext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : BFin = True NEW_LINE DEDENT DEDENT print ( len ( Path ) ) NEW_LINE print ( \" ▁ \" . join ( map ( str , Path ) ) ) NEW_LINE" ]
atcoder_arc070_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] x = new int [ N ] ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextInt ( ) ; a [ i ] = sc . nextInt ( ) - x [ i ] ; } PriorityQueue < Long > lset = new PriorityQueue < > ( new Comparator < Long > ( ) { public int compare ( Long l1 , Long l2 ) { return - Long . compare ( l1 , l2 ) ; } } ) ; lset . add ( ( long ) x [ 0 ] ) ; long ladd = 0 ; PriorityQueue < Long > rset = new PriorityQueue < > ( ) ; rset . add ( ( long ) x [ 0 ] ) ; long radd = 0 ; long min = 0 ; for ( int i = 1 ; i < N ; i ++ ) { ladd -= a [ i ] ; radd += a [ i - 1 ] ; if ( x [ i ] < lset . peek ( ) + ladd ) { min = min + ( lset . peek ( ) + ladd - x [ i ] ) ; lset . add ( x [ i ] - ladd ) ; lset . add ( x [ i ] - ladd ) ; rset . add ( lset . poll ( ) + ladd - radd ) ; } else if ( rset . peek ( ) + radd < x [ i ] ) { min = min + ( x [ i ] - ( rset . peek ( ) + radd ) ) ; rset . add ( x [ i ] - radd ) ; rset . add ( x [ i ] - radd ) ; lset . add ( rset . poll ( ) + radd - ladd ) ; } else { lset . add ( x [ i ] - ladd ) ; rset . add ( x [ i ] - radd ) ; } } System . out . println ( min ) ; sc . close ( ) ; } }", "import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; long lbase = 0 ; long rbase = 0 ; PriorityQueue < Long > lindex = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; PriorityQueue < Long > rindex = new PriorityQueue < > ( ) ; long [ ] l = new long [ N ] ; long [ ] w = new long [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { l [ i ] = scan . nextLong ( ) ; w [ i ] = scan . nextLong ( ) - l [ i ] ; } lindex . add ( l [ 0 ] ) ; rindex . add ( l [ 0 ] ) ; long ans = 0 ; for ( int i = 1 ; i < N ; ++ i ) { lbase += w [ i ] ; rbase += w [ i - 1 ] ; if ( lindex . peek ( ) >= ( l [ i ] + lbase ) ) { lindex . add ( l [ i ] + lbase ) ; lindex . add ( l [ i ] + lbase ) ; ans += Math . abs ( lindex . peek ( ) - ( l [ i ] + lbase ) ) ; rindex . add ( lindex . poll ( ) - lbase - rbase ) ; } else if ( rindex . peek ( ) <= ( l [ i ] - rbase ) ) { rindex . add ( l [ i ] - rbase ) ; rindex . add ( l [ i ] - rbase ) ; ans += Math . abs ( rindex . peek ( ) - ( l [ i ] - rbase ) ) ; lindex . add ( rindex . poll ( ) + lbase + rbase ) ; } else { lindex . add ( l [ i ] + lbase ) ; rindex . add ( l [ i ] - rbase ) ; } } System . out . println ( ans ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE P = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE from heapq import heappush , heappop NEW_LINE l0 , r0 = P [ 0 ] NEW_LINE L = [ - l0 + 1 ] NEW_LINE R = [ l0 - 1 ] NEW_LINE s = t = 0 NEW_LINE res = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT l0 , r0 = P [ i ] NEW_LINE l1 , r1 = P [ i + 1 ] NEW_LINE s += ( r1 - l1 ) ; t += ( r0 - l0 ) NEW_LINE if - s - L [ 0 ] <= l1 - 1 <= t + R [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE DEDENT elif l1 - 1 < - s - L [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( L , - l1 + 1 - s ) NEW_LINE p = - heappop ( L ) - s NEW_LINE heappush ( R , p - t ) NEW_LINE res += ( p - ( l1 - 1 ) ) NEW_LINE DEDENT elif t + R [ 0 ] < l1 - 1 : NEW_LINE INDENT heappush ( R , l1 - 1 - t ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE p = heappop ( R ) + t NEW_LINE heappush ( L , - p - s ) NEW_LINE res += ( ( l1 - 1 ) - p ) NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE P = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE INF = 10 ** 18 NEW_LINE from heapq import heappush , heappop NEW_LINE l0 , r0 = P [ 0 ] NEW_LINE L = [ - l0 + 1 ] NEW_LINE R = [ l0 - 1 ] NEW_LINE s = t = 0 NEW_LINE res = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT l0 , r0 = P [ i ] NEW_LINE l1 , r1 = P [ i + 1 ] NEW_LINE s += ( r1 - l1 ) ; t += ( r0 - l0 ) NEW_LINE if - s - L [ 0 ] <= l1 - 1 <= t + R [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE DEDENT elif l1 - 1 < - s - L [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( L , - l1 + 1 - s ) NEW_LINE p = - heappop ( L ) - s NEW_LINE heappush ( R , p - t ) NEW_LINE res += ( p - ( l1 - 1 ) ) NEW_LINE DEDENT elif t + R [ 0 ] < l1 - 1 : NEW_LINE INDENT heappush ( R , l1 - 1 - t ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE p = heappop ( R ) + t NEW_LINE heappush ( L , - p - s ) NEW_LINE res += ( l1 - 1 - p ) NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE" ]
atcoder_arc078_C
[ "import java . util . * ; import java . io . * ; public class Main { public static void ask ( String number ) { System . out . println ( \" ? ▁ \" + number ) ; } public static void ask ( long number ) { System . out . println ( \" ? ▁ \" + number ) ; } public static void answer ( String number ) { System . out . println ( \" ! ▁ \" + number ) ; } public static void answer ( long number ) { System . out . println ( \" ! ▁ \" + number ) ; } public static long dec ( int k ) { long a = 1 ; for ( int i = 0 ; i < k ; i ++ ) a *= 10 ; return a ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int digit = - 1 ; for ( int i = 0 ; i <= 10 ; i ++ ) { ask ( dec ( i ) ) ; if ( sc . nextLine ( ) . equals ( \" N \" ) ) { digit = i ; break ; } } if ( digit == - 1 ) { for ( int i = 0 ; i <= 10 ; i ++ ) { ask ( 2 * dec ( i ) ) ; if ( sc . nextLine ( ) . equals ( \" Y \" ) ) { answer ( dec ( i ) ) ; System . exit ( 0 ) ; } } } else { long min = dec ( digit - 1 ) ; long max = dec ( digit ) - 1 ; while ( min < max ) { long next = ( min + max ) / 2 ; ask ( next * 10 ) ; if ( sc . nextLine ( ) . equals ( \" Y \" ) ) { max = next ; } else { min = next + 1 ; } } answer ( min ) ; System . exit ( 0 ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; Main main = new Main ( ) ; int l ; int N = 0 ; for ( l = 1 ; l < 11 ; l ++ ) { main . output ( false , ( int ) Math . pow ( 10 , l ) ) ; if ( main . input ( scan ) == 0 ) { break ; } } if ( l != 11 ) { int nMin = ( int ) Math . pow ( 10 , l - 1 ) ; int nMax = ( int ) Math . pow ( 10 , l ) - 1 ; while ( nMin != nMax ) { int n = ( nMin + nMax ) / 2 ; main . output ( false , ( n * 10L ) ) ; if ( main . input ( scan ) == 0 ) { nMin = n + 1 ; } else { nMax = n ; } } N = nMin ; } else { for ( l = 0 ; l < 10 ; l ++ ) { main . output ( false , ( int ) Math . pow ( 10 , l ) * 2 ) ; if ( main . input ( scan ) == 1 ) { N = ( int ) Math . pow ( 10 , l ) ; break ; } } } main . output ( true , N ) ; } private void output ( boolean answerFlag , long n ) { if ( answerFlag ) { System . out . println ( \" ! ▁ \" + n ) ; } else { System . out . println ( \" ? ▁ \" + n ) ; } System . out . flush ( ) ; } private int input ( Scanner scan ) throws Exception { String input = scan . next ( ) ; if ( \" Y \" . equals ( input ) ) { return 1 ; } else if ( \" N \" . equals ( input ) ) { return 0 ; } else { throw new Exception ( ) ; } } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( \" ? ▁ \" + ( long ) 1e10 ) ; String s = sc . next ( ) ; if ( s . equals ( \" Y \" ) ) { int cnt = 0 ; while ( true ) { System . out . println ( \" ? ▁ \" + ( long ) ( 2 * Math . pow ( 10 , cnt ) ) ) ; s = sc . next ( ) ; if ( s . equals ( \" Y \" ) ) { System . out . println ( \" ! ▁ \" + ( long ) Math . pow ( 10 , cnt ) ) ; return ; } ++ cnt ; } } else { int cnt = 9 ; while ( true ) { System . out . println ( \" ? ▁ \" + ( long ) Math . pow ( 10 , cnt ) ) ; s = sc . next ( ) ; if ( s . equals ( \" Y \" ) ) { break ; } -- cnt ; } long left = ( long ) Math . pow ( 10 , cnt ) ; long right = ( long ) Math . pow ( 10 , cnt + 1 ) - 1 ; while ( right - left > 1 ) { long middle = ( right + left ) / 2 ; System . out . println ( \" ? ▁ \" + middle * 10 ) ; s = sc . next ( ) ; if ( s . equals ( \" Y \" ) ) { right = middle ; } else { left = middle ; } } System . out . println ( \" ! ▁ \" + right ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }" ]
[ "def binsearch ( l , r , pred ) : NEW_LINE INDENT assert l < r NEW_LINE l -= 1 NEW_LINE while r - l > 1 : NEW_LINE INDENT m = ( l + r ) // 2 NEW_LINE if pred ( m ) : NEW_LINE INDENT r = m NEW_LINE DEDENT else : NEW_LINE INDENT l = m NEW_LINE DEDENT DEDENT return r NEW_LINE DEDENT import sys NEW_LINE def pred ( n ) : NEW_LINE INDENT assert 1 <= n and n <= 10 ** 18 NEW_LINE print ( ' ? ' , n ) NEW_LINE sys . stdout . flush ( ) NEW_LINE return input ( ) == ' Y ' NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT s = ' ' NEW_LINE s += str ( binsearch ( 1 , 9 + 1 , lambda c : not pred ( int ( s + str ( c ) ) ) ) - 1 ) NEW_LINE if s == '9' : NEW_LINE INDENT f = lambda k : pred ( int ( '1' + '0' * k ) ) NEW_LINE DEDENT else : NEW_LINE INDENT f = lambda k : not pred ( int ( '9' * k ) ) NEW_LINE DEDENT k = 1 NEW_LINE while f ( k ) : NEW_LINE INDENT k += 1 NEW_LINE if k >= 13 : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT if k == 1 : NEW_LINE INDENT s = ' ' NEW_LINE DEDENT for _ in range ( k - 2 ) : NEW_LINE INDENT s += str ( binsearch ( 0 , 9 + 1 , lambda c : not pred ( int ( s + str ( c ) ) ) ) - 1 ) NEW_LINE DEDENT s += str ( binsearch ( 0 , 9 + 1 , lambda c : pred ( int ( s + str ( c ) + '0' ) ) ) ) NEW_LINE return int ( s ) NEW_LINE DEDENT print ( ' ! ' , solve ( ) ) NEW_LINE", "for k in range ( 1 , 10 ) : NEW_LINE INDENT print ( ' ? ' , 10 ** k , flush = True ) NEW_LINE if input ( ) == ' N ' : NEW_LINE INDENT i = 10 ** ( k - 1 ) + 1 NEW_LINE j = 10 ** k - 1 NEW_LINE while i < j : NEW_LINE INDENT m = ( i + j ) // 2 NEW_LINE print ( ' ? ' , m * 10 , flush = True ) NEW_LINE if input ( ) == ' Y ' : NEW_LINE INDENT j = m NEW_LINE DEDENT else : NEW_LINE INDENT i = m + 1 NEW_LINE DEDENT DEDENT print ( ' ! ' , i , flush = True ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for k in range ( 10 ) : NEW_LINE INDENT print ( ' ? ' , 10 ** ( k + 1 ) - 1 , flush = True ) NEW_LINE if input ( ) == ' Y ' : NEW_LINE INDENT print ( ' ! ' , 10 ** k , flush = True ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT", "def query ( val ) : NEW_LINE INDENT print ( ' ? ' , val ) NEW_LINE ans = input ( ) NEW_LINE if ans == ' Y ' : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT LIMIT = 10 ** 9 NEW_LINE import sys NEW_LINE if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT if ( query ( LIMIT ) ) : NEW_LINE INDENT res = 1 NEW_LINE while ( True ) : NEW_LINE INDENT if ( query ( 2 * res ) ) : NEW_LINE INDENT print ( ' ! ' , res ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT res *= 10 NEW_LINE DEDENT DEDENT digit = 10 NEW_LINE res = LIMIT NEW_LINE while ( True ) : NEW_LINE INDENT if ( query ( res ) ) : NEW_LINE INDENT break NEW_LINE DEDENT res = res // 10 NEW_LINE digit -= 1 NEW_LINE DEDENT query = 10 ** ( digit ) NEW_LINE keta = 0 NEW_LINE while ( keta < digit ) : NEW_LINE INDENT low = query NEW_LINE high = query * 10 NEW_LINE left = - 1 NEW_LINE right = 10 NEW_LINE while ( right - left > 1 ) : NEW_LINE INDENT med = ( right + left ) // 2 NEW_LINE if med < 0 : NEW_LINE INDENT left = med NEW_LINE continue NEW_LINE DEDENT if med > 9 : NEW_LINE INDENT right = med NEW_LINE continue NEW_LINE DEDENT if keta == 0 and med == 0 : NEW_LINE INDENT left = med NEW_LINE continue NEW_LINE DEDENT val1 = list ( str ( low ) ) NEW_LINE val1 [ keta ] = str ( med ) NEW_LINE val1 = int ( \" \" . join ( val1 ) ) NEW_LINE print ( \" ? ▁ % d \" % ( val1 ) ) NEW_LINE ans = input ( ) NEW_LINE if ( ans == \" Y \" ) : NEW_LINE INDENT if ( keta == digit - 1 ) : NEW_LINE INDENT query = val1 NEW_LINE DEDENT right = med NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT if ( keta < digit - 1 ) : NEW_LINE INDENT query = val1 NEW_LINE DEDENT left = med NEW_LINE continue NEW_LINE DEDENT DEDENT keta += 1 NEW_LINE DEDENT query = query // 10 NEW_LINE print ( \" ! ▁ % d \" % ( query ) ) NEW_LINE DEDENT", "import sys NEW_LINE ans = None NEW_LINE for idx in range ( 0 , 11 , 1 ) : NEW_LINE INDENT print ( ' ? ▁ 1' + '0' * idx ) NEW_LINE sys . stdout . flush ( ) NEW_LINE kekka = input ( ) NEW_LINE if kekka == ' N ' : NEW_LINE INDENT digits = idx NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for idx in range ( 1 , 11 , 1 ) : NEW_LINE INDENT print ( ' ? ▁ ' + '9' * idx ) NEW_LINE sys . stdout . flush ( ) NEW_LINE kekka = input ( ) NEW_LINE if kekka == ' Y ' : NEW_LINE INDENT c = idx - 1 NEW_LINE break NEW_LINE DEDENT DEDENT ans = ' ! ▁ 1' + '0' * c NEW_LINE DEDENT if ans == None : NEW_LINE INDENT kagen = 10 ** ( digits - 1 ) NEW_LINE jogen = 10 ** ( digits ) - 1 NEW_LINE while jogen - kagen > 1 : NEW_LINE INDENT miru = ( jogen + kagen ) // 2 NEW_LINE print ( ' ? ▁ ' + str ( miru ) + '0' ) NEW_LINE sys . stdout . flush ( ) NEW_LINE kekka = input ( ) NEW_LINE if kekka == ' Y ' : NEW_LINE INDENT jogen = miru NEW_LINE DEDENT else : NEW_LINE INDENT kagen = miru NEW_LINE DEDENT DEDENT ans = ' ! ▁ ' + str ( jogen ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE def read_int_list ( ) : NEW_LINE INDENT return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT def read_int ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def read_str_list ( ) : NEW_LINE INDENT return input ( ) . split ( ) NEW_LINE DEDENT def read_str ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT debug = False NEW_LINE N = 5600070 NEW_LINE if debug : NEW_LINE INDENT print ( ) NEW_LINE print ( ' N : ' , N ) NEW_LINE print ( ) NEW_LINE DEDENT def ask ( n ) : NEW_LINE INDENT if debug : NEW_LINE INDENT res = ( n <= N and str ( n ) <= str ( N ) ) or ( n >= N and str ( n ) >= str ( N ) ) NEW_LINE print ( ' ? ' , n , ' \\t ' , res ) NEW_LINE return res NEW_LINE DEDENT print ( ' ? ' , n , flush = True ) NEW_LINE return input ( ) in [ ' y ' , ' Y ' ] NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT if ask ( 10 ** 9 ) : NEW_LINE INDENT for k in range ( 10 ) : NEW_LINE INDENT if ask ( 2 * 10 ** k ) : NEW_LINE INDENT return 10 ** k NEW_LINE DEDENT DEDENT DEDENT l = 1 NEW_LINE while ask ( 10 ** l ) : NEW_LINE INDENT l += 1 NEW_LINE DEDENT d = [ 9 ] * l NEW_LINE for p in range ( l ) : NEW_LINE INDENT a = 0 NEW_LINE if p == 0 : NEW_LINE INDENT a = 1 NEW_LINE DEDENT b = 9 NEW_LINE d [ p ] = a NEW_LINE n = int ( ' ' . join ( map ( str , d ) ) ) NEW_LINE if ask ( 10 * n ) : NEW_LINE INDENT continue NEW_LINE DEDENT while b - a > 1 : NEW_LINE INDENT m = ( a + b ) // 2 NEW_LINE d [ p ] = m NEW_LINE n = int ( ' ' . join ( map ( str , d ) ) ) NEW_LINE if ask ( 10 * n ) : NEW_LINE INDENT b = m NEW_LINE DEDENT else : NEW_LINE INDENT a = m NEW_LINE DEDENT DEDENT d [ p ] = b NEW_LINE DEDENT n = int ( ' ' . join ( map ( str , d ) ) ) NEW_LINE return n NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT res = solve ( ) NEW_LINE print ( ' ! ' , res , flush = True ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_arc017_B
[ "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = br . readLine ( ) . split ( \" ▁ \" , 2 ) ; int n = Integer . parseInt ( arr [ 0 ] ) ; int k = Integer . parseInt ( arr [ 1 ] ) ; int prev = 0 ; int count = 0 ; int sum = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = Integer . parseInt ( br . readLine ( ) ) ; if ( i == 0 ) { count = 1 ; } else if ( prev >= a ) { count = 1 ; } else { count ++ ; } if ( count >= k ) { sum ++ ; } prev = a ; } System . out . println ( sum ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] ary = new int [ N ] ; int [ ] dp = new int [ N ] ; Arrays . fill ( dp , 0 ) ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; } dp [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( ary [ i ] > ary [ i - 1 ] ) { dp [ i ] = dp [ i - 1 ] + 1 ; } else { dp [ i ] = 1 ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( dp [ i ] >= K ) { sum ++ ; } } pl ( sum ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }", "import java . util . * ; public class Main { private static int n ; private static int k ; private static int a [ ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; k = scan . nextInt ( ) ; a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = scan . nextInt ( ) ; } public static void main ( String args [ ] ) { input ( ) ; boolean b [ ] = new boolean [ n - 1 ] ; int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) b [ i ] = true ; else b [ i ] = false ; if ( b [ i ] ) { count ++ ; if ( count >= k - 1 ) ans ++ ; } else count = 0 ; } if ( k == 1 ) System . out . println ( n ) ; else System . out . println ( ans ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) , k = s . nextInt ( ) , b = 0 , c = 0 , r = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( b < ( b = s . nextInt ( ) ) ) ++ c ; else { r += c >= k ? c - k + 1 : 0 ; c = 1 ; } } System . out . println ( c >= k ? r + c - k + 1 : r ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { 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 ( ) ; } int up = 1 ; int count = 0 ; for ( int i = 0 ; i <= N - 1 ; i ++ ) { if ( i > 0 && a [ i - 1 ] < a [ i ] ) { up ++ ; } else { up = 1 ; } if ( up >= K ) { count ++ ; } } System . out . println ( count ) ; } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE prev = 0 NEW_LINE l = 0 NEW_LINE r = 0 NEW_LINE seq = 1 NEW_LINE ans = 0 NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE while r < N : NEW_LINE INDENT if A [ r ] > prev : NEW_LINE INDENT prev = A [ r ] NEW_LINE r += 1 NEW_LINE if r - l == K : NEW_LINE INDENT ans += 1 NEW_LINE l += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT prev = 0 NEW_LINE l = r NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "N , K = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE conti = 1 NEW_LINE previous = int ( input ( ) ) NEW_LINE count = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT current = int ( input ( ) ) NEW_LINE if current > previous : NEW_LINE INDENT conti += 1 NEW_LINE DEDENT else : NEW_LINE INDENT conti = 1 NEW_LINE DEDENT if conti >= K : NEW_LINE INDENT count += 1 NEW_LINE DEDENT previous = current NEW_LINE DEDENT if K == 1 : NEW_LINE INDENT print ( N ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( count ) NEW_LINE DEDENT", "n , k , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE l = [ ] NEW_LINE t = 0 NEW_LINE for i , j in zip ( a , a [ 1 : ] ) : NEW_LINE INDENT if j > i : NEW_LINE INDENT t += 1 NEW_LINE DEDENT else : NEW_LINE INDENT l . append ( t ) NEW_LINE t = 0 NEW_LINE DEDENT DEDENT l . append ( t ) NEW_LINE print ( sum ( max ( 0 , t + 2 - k ) for t in l ) ) NEW_LINE", "def b_low_resolution ( N , K , A ) : NEW_LINE INDENT increasing_length = 1 NEW_LINE increasing_interval = [ ] NEW_LINE for j in range ( 1 , N ) : NEW_LINE INDENT if A [ j ] > A [ j - 1 ] : NEW_LINE INDENT increasing_length += 1 NEW_LINE DEDENT else : NEW_LINE INDENT increasing_interval . append ( increasing_length ) NEW_LINE increasing_length = 1 NEW_LINE DEDENT DEDENT if increasing_length != 1 : NEW_LINE INDENT increasing_interval . append ( increasing_length ) NEW_LINE DEDENT ans = sum ( [ max ( i - K + 1 , 0 ) for i in increasing_interval ] ) NEW_LINE return ans NEW_LINE DEDENT N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE A = [ int ( input ( ) ) for _ in [ 0 ] * N ] NEW_LINE print ( b_low_resolution ( N , K , A ) ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def solve ( ) : NEW_LINE INDENT N , K = inpl ( ) NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE if K == 1 : return N NEW_LINE prev = A [ 0 ] NEW_LINE ans , cnt = 0 , 1 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT cnt += 1 NEW_LINE if A [ i ] <= prev : NEW_LINE INDENT cnt = 1 NEW_LINE DEDENT if cnt >= K : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT prev = A [ i ] NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( solve ( ) ) NEW_LINE" ]
atcoder_abc017_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ans = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { ans += sc . nextInt ( ) * sc . nextInt ( ) / 10 ; } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int s1 = in . nextInt ( ) ; double e1 = in . nextInt ( ) ; int s2 = in . nextInt ( ) ; double e2 = in . nextInt ( ) ; int s3 = in . nextInt ( ) ; double e3 = in . nextInt ( ) ; out . println ( ( int ) ( s1 * ( e1 / 10 ) + s2 * ( e2 / 10 ) + s3 * ( e3 / 10 ) ) ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int a1 = sc . nextInt ( ) ; int b2 = sc . nextInt ( ) ; int c3 = sc . nextInt ( ) ; System . out . println ( a * b / 10 + c * a1 / 10 + b2 * c3 / 10 ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int total = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) total += in . nextInt ( ) * in . nextInt ( ) / 10 ; out . println ( total ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( ( int ) ( sc . nextDouble ( ) * sc . nextDouble ( ) * 0.1 + sc . nextDouble ( ) * sc . nextDouble ( ) * 0.1 + sc . nextDouble ( ) * sc . nextDouble ( ) * 0.1 ) ) ; } }" ]
[ "s1 , e1 = map ( int , input ( ) . split ( ) ) NEW_LINE s2 , e2 = map ( int , input ( ) . split ( ) ) NEW_LINE s3 , e3 = map ( int , input ( ) . split ( ) ) NEW_LINE print ( int ( ( s1 * e1 + s2 * e2 + s3 * e3 ) / 10 ) ) NEW_LINE", "p = 0.0 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE p += l [ 0 ] * l [ 1 ] * 0.1 NEW_LINE DEDENT print ( int ( p ) ) NEW_LINE", "print ( int ( sum ( [ eval ( '0.1 * ' + input ( ) . replace ( ' ▁ ' , ' * ' ) ) for _ in range ( 3 ) ] ) ) ) NEW_LINE", "A = input ( ) . split ( ) NEW_LINE B = input ( ) . split ( ) NEW_LINE C = input ( ) . split ( ) NEW_LINE s1 = int ( A [ 0 ] ) NEW_LINE e1 = int ( A [ 1 ] ) NEW_LINE s2 = int ( B [ 0 ] ) NEW_LINE e2 = int ( B [ 1 ] ) NEW_LINE s3 = int ( C [ 0 ] ) NEW_LINE e3 = int ( C [ 1 ] ) NEW_LINE if 10 <= s1 and s2 and s3 <= 990 : NEW_LINE INDENT if 1 <= e1 and e2 and e3 <= 10 : NEW_LINE INDENT if s1 % 10 == 0 and s2 % 10 == 0 and s3 % 10 == 0 : NEW_LINE INDENT print ( int ( s1 / 10 * e1 + s2 / 10 * e2 + s3 / 10 * e3 ) ) NEW_LINE DEDENT DEDENT DEDENT", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE c , d = map ( int , input ( ) . split ( ) ) NEW_LINE e , f = map ( int , input ( ) . split ( ) ) NEW_LINE A = a * b // 10 NEW_LINE B = c * d // 10 NEW_LINE C = e * f // 10 NEW_LINE print ( A + B + C ) NEW_LINE" ]
atcoder_agc008_C
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; long I = sc . nextLong ( ) ; long O = sc . nextLong ( ) ; long T = sc . nextLong ( ) ; long J = sc . nextLong ( ) ; long L = sc . nextLong ( ) ; long S = sc . nextLong ( ) ; long Z = sc . nextLong ( ) ; long ans = 0 ; long tmp = 0 ; if ( I > 0 ) { ans += ( ( I - 1 ) / 2 ) * 2 ; } ans += O ; if ( J > 0 ) { ans += ( ( J - 1 ) / 2 ) * 2 ; } if ( L > 0 ) { ans += ( ( L - 1 ) / 2 ) * 2 ; } if ( I > 0 && J > 0 && L > 0 ) { ans += 3 ; } tmp += I / 2 * 2 ; tmp += O ; tmp += J / 2 * 2 ; tmp += L / 2 * 2 ; pl ( Math . max ( ans , tmp ) ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }", "import java . io . * ; import java . util . * ; public class Main { private static boolean debug = false ; private static boolean elapsed = false ; private static PrintWriter _err = new PrintWriter ( System . err ) ; private void solve ( Scanner sc , PrintWriter out ) { long ai = sc . nextInt ( ) ; long ao = sc . nextInt ( ) ; long at = sc . nextInt ( ) ; long aj = sc . nextInt ( ) ; long al = sc . nextInt ( ) ; long as = sc . nextInt ( ) ; long az = sc . nextInt ( ) ; long size = 0 ; size = ( ai / 2 + aj / 2 + al / 2 ) * 2 + ao ; if ( ai > 0 && aj > 0 && al > 0 ) { size = Math . max ( size , 3 + ( ( ai - 1 ) / 2 + ( aj - 1 ) / 2 + ( al - 1 ) / 2 ) * 2 + ao ) ; } out . println ( size ) ; } private long C ( long n , long r ) { long res = 1 ; for ( long i = n ; i > n - r ; -- i ) { res *= i ; } for ( long i = r ; i > 1 ; -- i ) { res /= i ; } return res ; } private long P ( long n , long r ) { long res = 1 ; for ( long i = n ; i > n - r ; -- i ) { res *= i ; } return res ; } public static void main ( String [ ] args ) { long S = System . currentTimeMillis ( ) ; Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( sc , out ) ; out . flush ( ) ; long G = System . currentTimeMillis ( ) ; if ( elapsed ) { _err . println ( ( G - S ) + \" ms \" ) ; } _err . flush ( ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] a = new long [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) a [ i ] = sc . nextLong ( ) ; long ans = 0 ; ans += a [ 1 ] ; if ( a [ 0 ] == 0 || a [ 3 ] == 0 || a [ 4 ] == 0 ) { System . out . println ( ans + ( a [ 0 ] / 2 + a [ 3 ] / 2 + a [ 4 ] / 2 ) * 2 ) ; System . exit ( 0 ) ; } long res1 = ( a [ 0 ] / 2 + a [ 3 ] / 2 + a [ 4 ] / 2 ) * 2 ; long temp = Math . min ( Math . min ( a [ 0 ] , a [ 3 ] ) , a [ 4 ] ) ; long res2 = temp * 3 + ( ( a [ 0 ] - temp ) / 2 + ( a [ 3 ] - temp ) / 2 + ( a [ 4 ] - temp ) / 2 ) * 2 ; long res3 = a [ 0 ] + a [ 3 ] + a [ 4 ] - 1 ; ans += Math . max ( Math . max ( res1 , res2 ) , res3 ) ; System . out . println ( ans ) ; } }", "import java . io . * ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int i = in . nextInt ( ) ; int o = in . nextInt ( ) ; int t = in . nextInt ( ) ; int j = in . nextInt ( ) ; int l = in . nextInt ( ) ; int s = in . nextInt ( ) ; int z = in . nextInt ( ) ; long res = o ; int modCnt = i % 2 + j % 2 + l % 2 ; if ( modCnt > 1 && i > 0 && j > 0 && l > 0 ) { i -- ; j -- ; l -- ; res += 3 ; } res += ( i / 2 ) * 2 ; res += ( j / 2 ) * 2 ; res += ( l / 2 ) * 2 ; out . println ( res ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { long i = g ( ) , o = g ( ) , t = g ( ) , j = g ( ) , l = g ( ) , r = l / 2 * 2 + j / 2 * 2 + i / 2 * 2 ; if ( l > 0 && j > 0 && i > 0 ) r = Math . max ( r , 3 + ( l - 1 ) / 2 * 2 + ( j - 1 ) / 2 * 2 + ( i - 1 ) / 2 * 2 ) ; System . out . println ( r + o ) ; } static long g ( ) { return s . nextLong ( ) ; } }" ]
[ "i , o , t , j , l , s , z = map ( int , input ( ) . split ( ) ) NEW_LINE a = 0 NEW_LINE b = 0 NEW_LINE if i > 0 and j > 0 and l > 0 : NEW_LINE INDENT a += 3 NEW_LINE for k in [ i - 1 , j - 1 , l - 1 ] : NEW_LINE INDENT if k % 2 == 1 : NEW_LINE INDENT a += k - 1 NEW_LINE DEDENT else : NEW_LINE INDENT a += k NEW_LINE DEDENT DEDENT DEDENT for k in [ i , j , l ] : NEW_LINE INDENT if k % 2 == 1 : NEW_LINE INDENT b += k - 1 NEW_LINE DEDENT else : NEW_LINE INDENT b += k NEW_LINE DEDENT DEDENT print ( o + max ( a , b ) ) NEW_LINE", "from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" YES \" ) NEW_LINE else : print ( \" NO \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a . pop ( 6 ) NEW_LINE a . pop ( 5 ) NEW_LINE a . pop ( 2 ) NEW_LINE s = sum ( a ) NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT if i != 1 and a [ i ] % 2 : s -= 1 NEW_LINE DEDENT if s + 3 == sum ( a ) : s = sum ( a ) NEW_LINE if s + 2 == sum ( a ) and a [ 0 ] and a [ 2 ] and a [ 3 ] > 3 : s = sum ( a ) - 1 NEW_LINE print ( s ) NEW_LINE", "import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT A = LI ( ) NEW_LINE res = 0 NEW_LINE for e in ( 0 , 3 , 4 ) : NEW_LINE INDENT res += A [ e ] // 2 * 2 NEW_LINE DEDENT if all ( [ A [ 0 ] , A [ 3 ] , A [ 4 ] ] ) : NEW_LINE INDENT tmp = 3 NEW_LINE for e in ( 0 , 3 , 4 ) : NEW_LINE INDENT tmp += ( A [ e ] - 1 ) // 2 * 2 NEW_LINE DEDENT if res < tmp : NEW_LINE INDENT res = tmp NEW_LINE DEDENT DEDENT return res + A [ 1 ] NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "a , square , qqq , b , c , qqqq , qqqqq = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a_ = a % 2 NEW_LINE b_ = b % 2 NEW_LINE c_ = c % 2 NEW_LINE b_sub = b - b_ NEW_LINE c_sub = c - c_ NEW_LINE if b_ == 1 and c_ == 1 and a > 0 : NEW_LINE INDENT a = a - 1 NEW_LINE a_ = a % 2 NEW_LINE a_sub = a - a_ NEW_LINE print ( a_sub + b_sub + c_sub + 3 + square ) NEW_LINE DEDENT elif a_ == 1 and c_ == 1 and b > 0 : NEW_LINE INDENT a_sub = a - a_ NEW_LINE b = b - 1 NEW_LINE b_ = b % 2 NEW_LINE b_sub = b - b_ NEW_LINE print ( a_sub + b_sub + c_sub + 3 + square ) NEW_LINE DEDENT elif a_ == 1 and b_ == 1 and c > 0 : NEW_LINE INDENT a_sub = a - a_ NEW_LINE c = c - 1 NEW_LINE c_ = c % 2 NEW_LINE c_sub = c - c_ NEW_LINE print ( a_sub + b_sub + c_sub + 3 + square ) NEW_LINE DEDENT else : NEW_LINE INDENT a_ = a % 2 NEW_LINE a_sub = a - a_ NEW_LINE print ( a_sub + b_sub + c_sub + square ) NEW_LINE DEDENT", "import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE i , o , t , j , l , s , z = map ( int , input ( ) . split ( ) ) NEW_LINE ans = o NEW_LINE odd_num = ( i % 2 ) + ( j % 2 ) + ( l % 2 ) NEW_LINE if odd_num >= 2 and i > 0 and j > 0 and l > 0 : NEW_LINE INDENT ans += 3 NEW_LINE i -= 1 NEW_LINE j -= 1 NEW_LINE l -= 1 NEW_LINE DEDENT ans += ( i // 2 ) * 2 NEW_LINE ans += ( j // 2 ) * 2 NEW_LINE ans += ( l // 2 ) * 2 NEW_LINE print ( ans ) NEW_LINE" ]
atcoder_arc076_A
[ "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . util . InputMismatchException ; 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 ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , InputReader in , PrintWriter out ) { long n = in . nextLong ( ) ; long m = in . nextLong ( ) ; if ( Math . abs ( n - m ) >= 2 ) { out . println ( 0 ) ; return ; } long ans = 1 ; long MOD = 1_000_000_007 ; for ( int i = 1 ; i <= n ; i ++ ) { ans = ( ans * i ) % MOD ; } for ( int i = 1 ; i <= m ; i ++ ) { ans = ( ans * i ) % MOD ; } if ( n == m ) ans = ( ans * 2 ) % MOD ; out . println ( ans ) ; } } static class InputReader { BufferedReader in ; StringTokenizer tok ; public String nextString ( ) { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) , \" ▁ \" ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return tok . nextToken ( ) ; } public long nextLong ( ) { return Long . parseLong ( nextString ( ) ) ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( \" \" ) ; } } }", "import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long ans = 1 ; long mod = ( long ) Math . pow ( 10 , 9 ) + 7 ; if ( n == m ) { for ( int i = n ; i > 0 ; i -- ) { ans = ( ( ans * ( long ) i ) % mod ) * ( long ) i % mod ; } ans = ( ans * 2 ) % mod ; } else if ( ( int ) Math . abs ( n - m ) == 1 ) { for ( int i = ( int ) Math . min ( n , m ) ; i > 0 ; i -- ) { ans = ( ( ans * ( long ) i ) % mod ) * ( long ) i % mod ; } ans = ( ans * ( long ) Math . max ( n , m ) ) % mod ; } else { ans = 0 ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; Long facN = this . calcfac ( N ) ; Long facM = this . calcfac ( M ) ; if ( N == M ) { System . out . println ( 2 * facN * facM % 1000000007 ) ; } else if ( N + 1 == M || N == M + 1 ) { System . out . println ( facN * facM % 1000000007 ) ; } else { System . out . println ( 0 ) ; } } Long calcfac ( int num ) { Long sum = new Long ( 1 ) ; for ( int i = num ; i > 0 ; i -- ) { sum *= i ; sum %= 1000000007 ; } return sum ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . Scanner ; public class Main { public static long frac [ ] = new long [ 100020 ] ; public static final int ZYY = 1000000007 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; scan . close ( ) ; if ( Math . abs ( x - y ) > 1 ) { System . out . println ( '0' ) ; return ; } frac [ 0 ] = 1 ; for ( int i = 1 ; i <= 100000 ; i ++ ) frac [ i ] = frac [ i - 1 ] * i % ZYY ; long ans = frac [ x ] * frac [ y ] % ZYY ; if ( x == y ) ans = ans * 2 % ZYY ; System . out . println ( ans ) ; return ; } }", "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 [ ] str = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; long base = ( long ) 1e9 + 7 ; long ans = 1 ; if ( Math . abs ( n - m ) == 0 ) { ans *= 2 ; ans %= base ; } else if ( Math . abs ( n - m ) > 1 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } for ( int i = 1 ; i <= n ; i ++ ) { ans *= i ; ans %= base ; } for ( int i = 1 ; i <= m ; i ++ ) { ans *= i ; ans %= base ; } System . out . println ( ans ) ; } }" ]
[ "N , M = map ( int , input ( ) . split ( ' ▁ ' ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE if abs ( N - M ) > 1 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT ans = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans = ans * ( i + 1 ) % MOD NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT ans = ans * ( i + 1 ) % MOD NEW_LINE DEDENT if N == M : NEW_LINE INDENT ans = ans * 2 % MOD NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE import collections NEW_LINE import math NEW_LINE from collections import Counter NEW_LINE from collections import deque NEW_LINE N , M = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE D = 10 ** 9 + 7 NEW_LINE if abs ( N - M ) >= 2 : NEW_LINE INDENT print ( 0 ) NEW_LINE sys . exit ( 0 ) NEW_LINE DEDENT ret = math . factorial ( N ) * math . factorial ( M ) NEW_LINE if N == M : NEW_LINE INDENT ret *= 2 NEW_LINE DEDENT print ( ret % D ) NEW_LINE", "import math NEW_LINE INF , MOD = float ( \" inf \" ) , 10 ** 9 + 7 NEW_LINE MAX , MIN = - INF , INF NEW_LINE dx1 , dy1 , dx2 , dy2 = [ - 1 , 0 , 1 , 0 ] , [ 0 , - 1 , 0 , 1 ] , [ - 1 , 0 , 1 , - 1 , 1 , - 1 , 0 , 1 ] , [ - 1 , - 1 , - 1 , 0 , 0 , 1 , 1 , 1 ] NEW_LINE def get_int ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def get_int_list ( ) : NEW_LINE INDENT return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT def mins ( x , y ) : NEW_LINE INDENT x = min ( x , y ) NEW_LINE DEDENT def maxs ( x , y ) : NEW_LINE INDENT x = max ( x , y ) NEW_LINE DEDENT def fact ( n ) : NEW_LINE INDENT tmp = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT tmp = int ( tmp * i % MOD ) NEW_LINE DEDENT return tmp NEW_LINE DEDENT while ( True ) : NEW_LINE INDENT try : NEW_LINE INDENT n , m = get_int_list ( ) NEW_LINE if ( n == m ) : NEW_LINE INDENT print ( int ( fact ( n ) ** 2 * 2 % MOD ) ) NEW_LINE DEDENT elif ( abs ( n - m ) == 1 ) : NEW_LINE INDENT print ( int ( fact ( n ) * fact ( m ) % MOD ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT except EOFError : NEW_LINE INDENT exit ( ) NEW_LINE DEDENT DEDENT", "class FactMod ( ) : NEW_LINE INDENT def __init__ ( self , n , mod ) : NEW_LINE INDENT self . f = [ 1 ] * ( n + 1 ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT self . f [ i ] = self . f [ i - 1 ] * i % mod NEW_LINE DEDENT self . inv = [ pow ( self . f [ - 1 ] , mod - 2 , mod ) ] NEW_LINE for i in range ( 1 , n + 1 ) [ : : - 1 ] : NEW_LINE INDENT self . inv . append ( self . inv [ - 1 ] * i % mod ) NEW_LINE DEDENT self . inv . reverse ( ) NEW_LINE DEDENT def fact ( self , n ) : NEW_LINE INDENT return self . f [ n ] NEW_LINE DEDENT DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE ans = 0 NEW_LINE F = FactMod ( max ( N , M ) , mod ) NEW_LINE if abs ( N - M ) == 1 : NEW_LINE INDENT ans = F . fact ( N ) * F . fact ( M ) % mod NEW_LINE DEDENT elif N == M : NEW_LINE INDENT ans = F . fact ( N ) * F . fact ( N ) * 2 % mod NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import math NEW_LINE def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def dmp ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def probC ( ) : NEW_LINE INDENT N , M = getIntList ( ) NEW_LINE N1097 = 10 ** 9 + 7 NEW_LINE dmp ( ( N , M ) ) NEW_LINE if N == M : NEW_LINE INDENT times = 2 NEW_LINE DEDENT elif abs ( N - M ) == 1 : NEW_LINE INDENT times = 1 NEW_LINE DEDENT else : NEW_LINE INDENT times = 0 NEW_LINE DEDENT dmp ( times ) NEW_LINE count = math . factorial ( N ) * math . factorial ( M ) * times % N1097 NEW_LINE return count NEW_LINE DEDENT debug = False NEW_LINE print ( probC ( ) ) NEW_LINE" ]
atcoder_abc037_B
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { static int c [ ] ; static int n ; static int lowbit ( int x ) { return x & ( - x ) ; } static void add ( int i , int val ) { while ( i <= n ) { c [ i ] += val ; i += lowbit ( i ) ; } } static int sum ( int i ) { int sum = 0 ; while ( i > 0 ) { sum += c [ i ] ; i -= lowbit ( i ) ; } return sum ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; int p = in . nextInt ( ) ; c = new int [ n ] ; while ( p -- > 0 ) { int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; int k = in . nextInt ( ) ; Arrays . fill ( c , l - 1 , r , k ) ; } for ( int i : c ) { System . out . println ( i ) ; } } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] nq = scanner . nextLine ( ) . split ( \" ▁ \" , 2 ) ; int n = Integer . parseInt ( nq [ 0 ] ) ; int q = Integer . parseInt ( nq [ 1 ] ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < q ; i ++ ) { String [ ] lrt = scanner . nextLine ( ) . split ( \" ▁ \" , 3 ) ; int l = Integer . parseInt ( lrt [ 0 ] ) ; int r = Integer . parseInt ( lrt [ 1 ] ) ; int t = Integer . parseInt ( lrt [ 2 ] ) ; for ( int j = l - 1 ; j < r ; j ++ ) { arr [ j ] = t ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( arr [ i ] ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] ary = new int [ sc . nextInt ( ) ] ; int count = sc . nextInt ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int f = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int num = sc . nextInt ( ) ; for ( int e = 0 ; e < ary . length ; e ++ ) { if ( f <= ( e + 1 ) && l > e ) ary [ e ] = num ; } } for ( int i : ary ) { System . out . println ( i ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < > ( ) ; int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) list . add ( 0 ) ; for ( int i = 0 ; i < Q ; i ++ ) { int L = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; L -- ; R -- ; for ( int j = L ; j <= R ; j ++ ) list . set ( j , T ) ; } for ( Iterator it = list . iterator ( ) ; it . hasNext ( ) ; ) { System . out . println ( it . next ( ) ) ; } } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int n = stdIn . nextInt ( ) , q = stdIn . nextInt ( ) , l , r , t , i , j , a [ ] = new int [ 100 ] ; for ( i = 0 ; i < q ; i ++ ) { l = stdIn . nextInt ( ) ; r = stdIn . nextInt ( ) ; t = stdIn . nextInt ( ) ; for ( j = l - 1 ; j < r ; j ++ ) a [ j ] = t ; } for ( i = 0 ; i < n ; i ++ ) System . out . println ( a [ i ] ) ; } }" ]
[ "n , q = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ 0 ] * n NEW_LINE for i in range ( q ) : NEW_LINE INDENT l , r , t = map ( int , input ( ) . split ( ) ) NEW_LINE for x in range ( l - 1 , r ) : NEW_LINE INDENT a [ x ] = t NEW_LINE DEDENT DEDENT print ( * a , sep = \" \\n \" ) NEW_LINE", "N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE row = [ 0 for _ in range ( N ) ] NEW_LINE lines = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( Q ) ] NEW_LINE for line in lines : NEW_LINE INDENT for ind in range ( line [ 0 ] - 1 , line [ 1 ] ) : NEW_LINE INDENT row [ ind ] = line [ 2 ] NEW_LINE DEDENT DEDENT for i in row : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT", "def editorial ( N : int , Q : int , queries : list ) -> list : NEW_LINE INDENT a = [ 0 ] * N NEW_LINE for l , r , t in queries : NEW_LINE INDENT for i in range ( l - 1 , r ) : NEW_LINE INDENT a [ i ] = t NEW_LINE DEDENT DEDENT return a NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT Q = 0 NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( Q ) ] NEW_LINE ans = editorial ( N , Q , queries ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT", "I = lambda : map ( int , input ( ) . split ( ) ) ; n , q = I ( ) ; a = [ 0 ] * n ; exec ( ' l , r , t = I ( ) ; a [ l - 1 : r ] = [ t ] * ( r - l + 1 ) ; ' * q ) ; print ( * a , sep = ' \\n ' ) NEW_LINE", "import numpy as np NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE ans = np . zeros ( N , dtype = np . int64 ) NEW_LINE for i in range ( Q ) : NEW_LINE INDENT L , R , T = map ( int , input ( ) . split ( ) ) NEW_LINE ans [ L - 1 : R ] = T NEW_LINE DEDENT for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT" ]
atcoder_abc034_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( y - x > 0 ) { System . out . println ( \" Better \" ) ; return ; } System . out . println ( \" Worse \" ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . Queue ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; if ( x < y ) { out . println ( \" Better \" ) ; } else { out . println ( \" Worse \" ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( a > b ? \" Worse \" : \" Better \" ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { out . println ( nextInt ( ) > nextInt ( ) ? \" Worse \" : \" Better \" ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; if ( a > b ) { System . out . println ( \" Worse \" ) ; } else { System . out . println ( \" Better \" ) ; } } }" ]
[ "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE print ( \" Better \" if y > x else \" Worse \" ) NEW_LINE", "print ( ' BWeotrtseer ' [ eval ( input ( ) . replace ( ' ▁ ' , ' > = ' ) ) : : 2 ] ) NEW_LINE", "def test ( x : int , y : int ) -> bool : NEW_LINE INDENT return x < y NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE yes = test ( x , y ) NEW_LINE print ( ' Better ' if yes else ' Worse ' ) NEW_LINE DEDENT", "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if x > y : NEW_LINE INDENT print ( \" Worse \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Better \" ) NEW_LINE DEDENT", "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if y - x > 0 : NEW_LINE INDENT print ( \" Better \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Worse \" ) NEW_LINE DEDENT" ]
atcoder_abc121_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int H , W , h , w ; H = s . nextInt ( ) ; W = s . nextInt ( ) ; h = s . nextInt ( ) ; w = s . nextInt ( ) ; System . out . println ( ( W - w ) * ( H - h ) ) ; } }", "import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int h1 = Integer . parseInt ( sc . next ( ) ) ; int w1 = Integer . parseInt ( sc . next ( ) ) ; int h2 = Integer . parseInt ( sc . next ( ) ) ; int w2 = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; if ( h1 == h2 && w1 == w2 ) { count = 0 ; } else { count = h1 * w1 - ( h2 * w2 + ( h2 * ( w1 - w2 ) ) + ( w2 * ( h1 - h2 ) ) ) ; } System . out . println ( count ) ; System . out . flush ( ) ; sc . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( final String [ ] args ) { try ( final Scanner sc = new Scanner ( System . in ) ) { final int H = sc . nextInt ( ) ; final int W = sc . nextInt ( ) ; final int h = sc . nextInt ( ) ; final int w = sc . nextInt ( ) ; final int total = H * W ; System . out . println ( total - ( h * W + ( H - h ) * w ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] [ ] matrix = new int [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) for ( int j = 0 ; j < W ; j ++ ) matrix [ i ] [ j ] = 0 ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) matrix [ i ] [ j ] = 1 ; } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) matrix [ i ] [ j ] = 1 ; } int count = 0 ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( matrix [ i ] [ j ] == 0 ) count ++ ; } } System . out . println ( count ) ; sc . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int H = scanner . nextInt ( ) ; int W = scanner . nextInt ( ) ; scanner . nextLine ( ) ; int h = scanner . nextInt ( ) ; int w = scanner . nextInt ( ) ; scanner . nextLine ( ) ; System . out . println ( ( H - h ) * ( W - w ) ) ; } } }" ]
[ "H , W = map ( int , input ( ) . split ( ) ) NEW_LINE h , w = map ( int , input ( ) . split ( ) ) NEW_LINE print ( int ( ( H * W ) - ( h * W + w * H - h * w ) ) ) NEW_LINE", "import numpy as np NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE h , w = map ( int , input ( ) . split ( ) ) NEW_LINE Orig = np . ones ( ( H , W ) ) NEW_LINE Orig [ 0 : h , : ] = 0 NEW_LINE Orig [ : , 0 : w ] = 0 NEW_LINE total = int ( np . sum ( Orig ) ) NEW_LINE print ( total ) NEW_LINE", "HHH , WWW = map ( int , input ( ) . split ( ) ) NEW_LINE h , w = map ( int , input ( ) . split ( ) ) NEW_LINE full_cells = HHH * WWW NEW_LINE full_cells -= h * WWW NEW_LINE full_cells -= ( ( w * HHH ) - ( h * w ) ) NEW_LINE print ( full_cells ) NEW_LINE", "H , W , h , w = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; print ( ( H - h ) * ( W - w ) ) NEW_LINE", "i = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE s = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = i [ 0 ] * i [ 1 ] + s [ 0 ] * s [ 1 ] - i [ 0 ] * s [ 1 ] - i [ 1 ] * s [ 0 ] NEW_LINE print ( a ) NEW_LINE" ]
atcoder_agc002_B
[ "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] x = new int [ M ] ; int [ ] y = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } boolean [ ] redExists = new boolean [ N + 1 ] ; int [ ] nums = new int [ N + 1 ] ; redExists [ 1 ] = true ; Arrays . fill ( nums , 1 ) ; for ( int i = 0 ; i < M ; i ++ ) { if ( redExists [ x [ i ] ] ) { if ( nums [ x [ i ] ] == 1 ) { redExists [ x [ i ] ] = false ; } redExists [ y [ i ] ] = true ; } nums [ x [ i ] ] -- ; nums [ y [ i ] ] ++ ; } int cnt = 0 ; for ( int n = 1 ; n <= N ; n ++ ) { if ( redExists [ n ] ) { cnt ++ ; } } out . println ( cnt ) ; } }", "import java . io . OutputStream ; import java . io . PrintWriter ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { InputReader cin = new InputReader ( System . in ) ; PrintWriter cout = new PrintWriter ( System . out ) ; Task task = new Task ( ) ; task . run ( cin , cout ) ; cout . close ( ) ; } } class Task { void run ( InputReader cin , PrintWriter cout ) { int n = cin . nextInt ( ) ; int m = cin . nextInt ( ) ; int [ ] n_ball = new int [ n ] ; boolean [ ] may_good = new boolean [ n ] ; Arrays . fill ( n_ball , 1 ) ; Arrays . fill ( may_good , false ) ; may_good [ 0 ] = true ; for ( int i = 0 ; i < m ; ++ i ) { int x = cin . nextInt ( ) - 1 ; int y = cin . nextInt ( ) - 1 ; n_ball [ x ] -= 1 ; n_ball [ y ] += 1 ; if ( may_good [ x ] ) { may_good [ y ] = true ; } if ( n_ball [ x ] == 0 ) { may_good [ x ] = false ; } } int n_good = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( may_good [ i ] ) { n_good += 1 ; } } cout . printf ( \" % d \\n \" , n_good ) ; } } class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( this . next ( ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int boxes = sc . nextInt ( ) ; int operations = sc . nextInt ( ) ; boolean [ ] redPossible = new boolean [ boxes + 1 ] ; redPossible [ 1 ] = true ; int [ ] boxBalls = new int [ boxes + 1 ] ; int possibility = 0 ; for ( int i = 1 ; i < boxBalls . length ; i ++ ) { boxBalls [ i ] = 1 ; } for ( int i = 0 ; i < operations ; i ++ ) { int pick = sc . nextInt ( ) ; int put = sc . nextInt ( ) ; if ( redPossible [ pick ] == true ) { redPossible [ put ] = true ; } boxBalls [ pick ] = boxBalls [ pick ] - 1 ; boxBalls [ put ] = boxBalls [ put ] + 1 ; if ( boxBalls [ pick ] == 0 ) { redPossible [ pick ] = false ; } } for ( int i = 0 ; i < redPossible . length ; i ++ ) { if ( redPossible [ i ] != false ) { possibility ++ ; } } System . out . println ( possibility ) ; } }", "import java . util . Arrays ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] cnt = new int [ n ] ; Arrays . fill ( cnt , 1 ) ; Set < Integer > s = new HashSet < > ( ) ; s . add ( 0 ) ; for ( int i = 0 ; i < m ; i ++ ) { int x = sc . nextInt ( ) - 1 , y = sc . nextInt ( ) - 1 ; cnt [ x ] -- ; cnt [ y ] ++ ; if ( s . contains ( x ) ) { s . add ( y ) ; } if ( cnt [ x ] == 0 ) { s . remove ( x ) ; } } debug ( s ) ; System . out . println ( s . size ( ) ) ; } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static int count ( boolean [ ] array ) { int ans = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) if ( array [ i ] ) ans ++ ; return ans ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] boll = new int [ N ] ; boolean [ ] red = new boolean [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { boll [ n ] = 1 ; red [ n ] = ( n == 0 ) ; } int M = sc . nextInt ( ) ; for ( int m = 0 ; m < M ; m ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; if ( red [ x ] ) red [ y ] = true ; boll [ y ] ++ ; if ( boll [ x ] <= 1 ) red [ x ] = false ; boll [ x ] -- ; } System . out . println ( count ( red ) ) ; } }" ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE red = [ False for i in range ( N + 1 ) ] NEW_LINE red [ 1 ] = True NEW_LINE box = [ 1 for i in range ( N + 1 ) ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if red [ x ] : NEW_LINE INDENT red [ y ] = True NEW_LINE DEDENT box [ x ] -= 1 NEW_LINE box [ y ] += 1 NEW_LINE if box [ x ] == 0 : NEW_LINE INDENT red [ x ] = False NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if red [ i ] and box [ i ] > 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from collections import Counter NEW_LINE def main ( ) : NEW_LINE INDENT N , M = LI ( ) NEW_LINE XY = [ ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT XY . append ( LI_ ( ) ) NEW_LINE DEDENT balls = [ 1 ] * N NEW_LINE exp = set ( [ 0 ] ) NEW_LINE for x , y in XY : NEW_LINE INDENT balls [ x ] -= 1 NEW_LINE balls [ y ] += 1 NEW_LINE if x in exp : NEW_LINE INDENT exp . add ( y ) NEW_LINE if balls [ x ] == 0 : NEW_LINE INDENT exp . remove ( x ) NEW_LINE DEDENT DEDENT DEDENT ans = len ( exp ) NEW_LINE return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "N , M = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE W = [ list ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) for _ in range ( M ) ] NEW_LINE BOX = [ [ 1 , 1 ] ] NEW_LINE BOX . extend ( [ [ 1 , 0 ] for _ in range ( N ) ] ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT BOX [ W [ i ] [ 0 ] ] [ 0 ] = BOX [ W [ i ] [ 0 ] ] [ 0 ] - 1 NEW_LINE BOX [ W [ i ] [ 1 ] ] [ 0 ] = BOX [ W [ i ] [ 1 ] ] [ 0 ] + 1 NEW_LINE if ( BOX [ W [ i ] [ 0 ] ] [ 1 ] == 1 ) : NEW_LINE INDENT BOX [ W [ i ] [ 1 ] ] [ 1 ] = 1 NEW_LINE if ( BOX [ W [ i ] [ 0 ] ] [ 0 ] == 0 ) : NEW_LINE INDENT BOX [ W [ i ] [ 0 ] ] [ 1 ] = 0 NEW_LINE DEDENT DEDENT DEDENT print ( sum ( list ( map ( lambda x : x [ : ] [ 1 ] , BOX ) ) ) ) NEW_LINE", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE n = [ 1 ] * a NEW_LINE r = [ 0 ] * a NEW_LINE r [ 0 ] = 1 NEW_LINE for i in range ( b ) : NEW_LINE INDENT ta , tb = map ( int , input ( ) . split ( ) ) NEW_LINE ta -= 1 NEW_LINE tb -= 1 NEW_LINE if r [ ta ] == 1 : NEW_LINE INDENT r [ tb ] = 1 NEW_LINE DEDENT n [ ta ] -= 1 NEW_LINE n [ tb ] += 1 NEW_LINE if n [ ta ] == 0 : NEW_LINE INDENT r [ ta ] = 0 NEW_LINE DEDENT DEDENT print ( sum ( r ) ) NEW_LINE", "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE l = [ [ 0 ] * 2 for i in range ( n ) ] NEW_LINE l [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT l [ i + 1 ] [ 1 ] = 1 NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE a = a - 1 NEW_LINE b = b - 1 NEW_LINE if l [ a ] [ 0 ] > 0 : NEW_LINE INDENT l [ a ] [ 0 ] -= 1 NEW_LINE l [ b ] [ 0 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT l [ a ] [ 1 ] -= 1 NEW_LINE l [ b ] [ 1 ] += 1 NEW_LINE DEDENT if l [ b ] [ 0 ] > 0 : NEW_LINE INDENT l [ b ] [ 0 ] += l [ b ] [ 1 ] NEW_LINE l [ b ] [ 1 ] = 0 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if l [ i ] [ 0 ] > 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc082_A
[ "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyReader in = new MyReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , MyReader in , PrintWriter out ) { int M = 100005 ; int [ ] cnt = new int [ 100005 ] ; int N = in . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int a = in . nextInt ( ) ; cnt [ a ] ++ ; } int ma = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int tot = cnt [ i ] ; if ( i > 0 ) tot += cnt [ i - 1 ] ; if ( i + 1 < M ) tot += cnt [ i + 1 ] ; ma = Math . max ( ma , tot ) ; } out . println ( ma ) ; } } static class MyReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public MyReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . HashMap ; import java . util . Scanner ; import java . util . StringJoiner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; StringJoiner sj = new StringJoiner ( \" \\n \" ) ; for ( int i = 0 ; i < 2 ; i ++ ) { sj . add ( scanner . nextLine ( ) ) ; } System . out . println ( solve ( sj . toString ( ) ) ) ; } private static int solve ( String stdinString ) { String [ ] splits = stdinString . split ( \" \\n \" ) ; int N = Integer . parseInt ( splits [ 0 ] ) ; int [ ] nums = new int [ N ] ; splits = splits [ 1 ] . split ( \" ▁ \" ) ; for ( int i = 0 ; i < N ; i ++ ) { nums [ i ] = Integer . parseInt ( splits [ i ] ) ; } int max = Integer . MIN_VALUE ; HashMap < Integer , Integer > xCounts = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { xCounts . put ( nums [ i ] - 1 , xCounts . getOrDefault ( nums [ i ] - 1 , 0 ) + 1 ) ; max = Math . max ( max , xCounts . get ( nums [ i ] - 1 ) ) ; xCounts . put ( nums [ i ] , xCounts . getOrDefault ( nums [ i ] , 0 ) + 1 ) ; max = Math . max ( max , xCounts . get ( nums [ i ] ) ) ; xCounts . put ( nums [ i ] + 1 , xCounts . getOrDefault ( nums [ i ] + 1 , 0 ) + 1 ) ; max = Math . max ( max , xCounts . get ( nums [ i ] + 1 ) ) ; } return max ; } private static String ex1 = \"7 \\n 3 ▁ 1 ▁ 4 ▁ 1 ▁ 5 ▁ 9 ▁ 2\" ; private static String ex2 = \"10 \\n 0 ▁ 1 ▁ 2 ▁ 3 ▁ 4 ▁ 5 ▁ 6 ▁ 7 ▁ 8 ▁ 9\" ; private static String ex3 = \"1 \\n 99999\" ; private static void tests ( ) { System . out . println ( solve ( ex1 ) ) ; System . out . println ( solve ( ex2 ) ) ; System . out . println ( solve ( ex3 ) ) ; } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? \" Yes \" : \" No \" ; } public static void main ( String [ ] args ) { HashMap < Integer , Integer > map = new HashMap < > ( ) ; int n = nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int temp = nextInt ( ) ; map . put ( temp , map . getOrDefault ( temp , 0 ) + 1 ) ; map . put ( temp + 1 , map . getOrDefault ( temp + 1 , 0 ) + 1 ) ; map . put ( temp - 1 , map . getOrDefault ( temp - 1 , 0 ) + 1 ) ; } int max = Integer . MIN_VALUE ; for ( Map . Entry < Integer , Integer > e : map . entrySet ( ) ) { max = Math . max ( max , e . getValue ( ) ) ; } out . println ( max ) ; } }", "import java . util . * ; import java . lang . * ; class Pair implements Comparable < Pair > { int a ; int cnt ; public Pair ( int i , int j ) { this . a = i ; this . cnt = j ; } public int compareTo ( Pair p ) { if ( this . cnt == p . cnt ) return 0 ; if ( this . cnt < p . cnt ) return - 1 ; return 1 ; } } class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; HashMap < Integer , Pair > map = new HashMap < > ( ) ; ArrayList < Pair > l = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int c = Integer . parseInt ( sc . next ( ) ) ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( j == 1 ) c -- ; else if ( j == 2 ) c += 2 ; if ( ! map . containsKey ( c ) ) { Pair p = new Pair ( c , 1 ) ; map . put ( c , p ) ; l . add ( p ) ; } else { Pair p = map . get ( c ) ; p . cnt ++ ; } } } Collections . sort ( l ) ; Pair res = l . get ( l . size ( ) - 1 ) ; System . out . println ( res . cnt ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashMap ; import java . util . Map ; public class Main { public static Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; public static int max = 0 ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { int in1 = Integer . parseInt ( br . readLine ( ) ) ; String [ ] in2 = br . readLine ( ) . split ( \" ▁ \" ) ; for ( String str : in2 ) { int key = Integer . parseInt ( str ) ; setMap ( key , 0 ) ; setMap ( key , + 1 ) ; setMap ( key , - 1 ) ; } System . out . println ( max ) ; } catch ( Exception e ) { System . exit ( 0 ) ; } } public static void setMap ( int key , int num ) { int key2 = key + num ; int val = 0 ; if ( map . containsKey ( key2 ) ) { val = map . get ( key2 ) ; } val += 1 ; map . put ( key2 , val ) ; if ( val > max ) { max = val ; } } }" ]
[ "from collections import defaultdict NEW_LINE N = int ( input ( ) ) NEW_LINE As = map ( int , input ( ) . split ( ) ) NEW_LINE counts = defaultdict ( int ) NEW_LINE for a in As : NEW_LINE INDENT counts [ a - 1 ] += 1 NEW_LINE counts [ a ] += 1 NEW_LINE counts [ a + 1 ] += 1 NEW_LINE DEDENT print ( max ( counts . values ( ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE ctr = [ 0 for _ in range ( 10 ** 5 + 2 ) ] NEW_LINE a = inpl ( ) NEW_LINE for i in a : NEW_LINE INDENT ctr [ i ] += 1 NEW_LINE DEDENT subsum = ctr [ 0 ] + ctr [ 1 ] + ctr [ 2 ] NEW_LINE ans = subsum NEW_LINE for i in range ( 2 , 10 ** 5 + 1 ) : NEW_LINE INDENT subsum = subsum - ctr [ i - 2 ] + ctr [ i + 1 ] NEW_LINE ans = max ( ans , subsum ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "input ( ) ; a = [ 0 ] * 100000 NEW_LINE for i in map ( int , input ( ) . split ( ) ) : a [ i ] += 1 NEW_LINE print ( max ( map ( sum , zip ( a , a [ 1 : ] , a [ 2 : ] ) ) ) ) NEW_LINE", "def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a . sort ( ) NEW_LINE r = 0 NEW_LINE i , j = 0 , 0 NEW_LINE while i < N : NEW_LINE INDENT while j < N : NEW_LINE INDENT if a [ j ] - a [ i ] <= 2 : NEW_LINE INDENT j += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT r = max ( r , j - i ) NEW_LINE if j == N : NEW_LINE INDENT break NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print ( r ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import collections NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE counter = collections . Counter ( A ) NEW_LINE Y = sorted ( list ( counter . keys ( ) ) ) NEW_LINE ans = - 1 NEW_LINE if max ( Y ) - min ( Y ) <= 2 : NEW_LINE INDENT ans = N NEW_LINE DEDENT else : NEW_LINE INDENT Y_all = [ counter [ i ] for i in range ( min ( Y ) , max ( Y ) + 1 ) ] NEW_LINE for i in range ( len ( Y_all ) - 2 ) : NEW_LINE INDENT ans = max ( sum ( Y_all [ i : i + 3 ] ) , ans ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc020_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; if ( a == 1 ) { System . out . println ( \" ABC \" ) ; } else { System . out . println ( \" chokudai \" ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( in . nextInt ( ) == 1 ? \" ABC \" : \" chokudai \" ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; System . out . println ( a == 1 ? \" ABC \" : \" chokudai \" ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int Q = in . nextInt ( ) ; out . println ( ( Q == 1 ) ? \" ABC \" : \" chokudai \" ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { out . println ( nextInt ( ) == 1 ? \" ABC \" : \" chokudai \" ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( ' ABC ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' chokudai ' ) NEW_LINE DEDENT", "print ( [ ' ABC ' , ' chokudai ' ] [ int ( input ( ) ) - 1 ] ) NEW_LINE", "q = int ( input ( ) ) NEW_LINE print ( \" ABC \" if q == 1 else \" chokudai \" ) NEW_LINE", "hoge = \" ABC \" if int ( input ( ) ) == 1 else \" chokudai \" NEW_LINE print ( hoge ) NEW_LINE", "q = int ( input ( ) ) NEW_LINE ans = \" \" NEW_LINE if q == 1 : NEW_LINE INDENT ans = \" ABC \" NEW_LINE DEDENT else : NEW_LINE INDENT ans = \" chokudai \" NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc085_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; System . out . println ( S . replaceFirst ( \"2017\" , \"2018\" ) ) ; } }", "import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { out . println ( in . next ( ) . replace ( \"2017\" , \"2018\" ) ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( \" End ▁ of ▁ Input \" ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; import java . util . TreeSet ; import org . omg . Messaging . SyncScopeHelper ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_100 ( ) . doIt ( ) ; } class Test_100 { void doIt ( ) { String str [ ] = sc . next ( ) . split ( \" / \" ) ; System . out . println ( \"2018 / \" + str [ 1 ] + \" / \" + str [ 2 ] ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) . replace ( \"2017\" , \"2018\" ) ; System . out . println ( S ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s ; s = sc . next ( ) ; char str [ ] = s . toCharArray ( ) ; str [ 3 ] = '8' ; System . out . println ( str ) ; sc . close ( ) ; } }" ]
[ "S = input ( ) NEW_LINE print ( S . replace ( '7' , '8' , 1 ) ) NEW_LINE", "print ( input ( 2018 ) [ 4 : ] ) NEW_LINE", "S = input ( ) NEW_LINE S = list ( S ) NEW_LINE S [ 3 ] = \"8\" NEW_LINE S = \" \" . join ( S ) NEW_LINE print ( S ) NEW_LINE", "a = input ( ) NEW_LINE list = a . split ( ' / ' ) NEW_LINE print ( '2018 / ' + list [ 1 ] + ' / ' + list [ 2 ] ) NEW_LINE", "print ( '8' . join ( input ( ) . split ( '7' , 1 ) ) ) NEW_LINE" ]
atcoder_arc062_B
[ "import java . util . Arrays ; import java . util . Scanner ; class Main { static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long gLong ( ) { return Long . parseLong ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { char [ ] c = s . next ( ) . toCharArray ( ) ; int n = c . length ; int [ ] rem = new int [ n ] ; int res = 0 , rem_ = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( c [ i ] == ' g ' ) { ++ rem_ ; } else { if ( rem_ > 0 ) { -- rem_ ; } else { ++ res ; } } rem [ i ] = rem_ ; } System . out . println ( res + rem [ n - 1 ] / 2 ) ; } }", "import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String top = r . readLine ( ) ; boolean cpp = false ; int score = 0 ; for ( int j = 0 ; j < top . length ( ) ; j ++ ) { if ( cpp ) { if ( top . charAt ( j ) == ' g ' ) score ++ ; cpp = false ; } else { if ( top . charAt ( j ) == ' p ' ) score -- ; cpp = true ; } } System . out . println ( score ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { char [ ] s = sc . next ( ) . toCharArray ( ) ; int p = 0 ; for ( char c : s ) { if ( c == ' p ' ) { p ++ ; } } System . out . println ( s . length / 2 - p ) ; } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? \" Yes \" : \" No \" ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; int n = s . length ( ) ; int enemyP = 0 , enemyG = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' p ' ) enemyP ++ ; else enemyG ++ ; } System . out . println ( n / 2 - enemyP ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s = r . readLine ( ) ; int n = s . length ( ) ; int [ ] [ ] a = { { 0 , - 1 } , { 1 , 0 } } ; int p = 0 ; for ( int i = 0 ; i < n ; i ++ ) { p += a [ i % 2 ] [ s . charAt ( i ) == ' g ' ? 0 : 1 ] ; } System . out . println ( p ) ; } }" ]
[ "s = input ( ) NEW_LINE print ( len ( s ) // 2 - s . count ( ' p ' ) ) NEW_LINE", "def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE def getIntLines ( n ) : return [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE def getIntMat ( n ) : NEW_LINE INDENT mat = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT mat . append ( getIntList ( ) ) NEW_LINE DEDENT return mat NEW_LINE DEDENT def zeros2 ( n , m ) : return [ zeros ( m ) ] * n NEW_LINE ALPHABET = [ chr ( i + ord ( ' a ' ) ) for i in range ( 26 ) ] NEW_LINE DIGIT = [ chr ( i + ord ( '0' ) ) for i in range ( 10 ) ] NEW_LINE def dmp ( x , cmt = ' ' ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT print ( cmt , ' : ▁ ▁ ' , end = ' ' ) NEW_LINE DEDENT print ( x ) NEW_LINE DEDENT return x NEW_LINE DEDENT def probC ( ) : NEW_LINE INDENT S = input ( ) NEW_LINE dmp ( S ) NEW_LINE GU = ' g ' NEW_LINE PA = ' p ' NEW_LINE guCount = 0 NEW_LINE paCount = 0 NEW_LINE point = 0 NEW_LINE allTe = ' ' NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i ] == GU : NEW_LINE INDENT if paCount < guCount : NEW_LINE INDENT te = PA NEW_LINE paCount += 1 NEW_LINE DEDENT else : NEW_LINE INDENT te = GU NEW_LINE guCount += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if paCount < guCount : NEW_LINE INDENT te = PA NEW_LINE paCount += 1 NEW_LINE DEDENT else : NEW_LINE INDENT te = GU NEW_LINE guCount += 1 NEW_LINE DEDENT DEDENT if te == GU and S [ i ] == PA : NEW_LINE INDENT point -= 1 NEW_LINE DEDENT elif te == PA and S [ i ] == GU : NEW_LINE INDENT point += 1 NEW_LINE DEDENT allTe += te NEW_LINE DEDENT dmp ( allTe , ' allTe ' ) NEW_LINE dmp ( point ) NEW_LINE return point NEW_LINE DEDENT debug = False NEW_LINE ans = probC ( ) NEW_LINE print ( ans ) NEW_LINE NEW_LINE", "def inpl ( ) : NEW_LINE INDENT return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT S = input ( ) NEW_LINE ans = 0 NEW_LINE g = 0 NEW_LINE p = 0 NEW_LINE for s in S : NEW_LINE INDENT if g == p : NEW_LINE INDENT g += 1 NEW_LINE if s == \" g \" : NEW_LINE INDENT pass NEW_LINE DEDENT elif s == \" p \" : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT p += 1 NEW_LINE if s == \" g \" : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT elif s == \" p \" : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "S = input ( ) NEW_LINE res = 0 NEW_LINE if S [ 0 ] == ' p ' : NEW_LINE INDENT res -= 1 NEW_LINE DEDENT p = 0 NEW_LINE g = 1 NEW_LINE for i in range ( 1 , len ( S ) ) : NEW_LINE INDENT if S [ i ] == ' p ' and p < g : NEW_LINE INDENT p += 1 NEW_LINE DEDENT elif S [ i ] == ' p ' and p >= g : NEW_LINE INDENT g += 1 NEW_LINE res -= 1 NEW_LINE DEDENT elif S [ i ] == ' g ' and p < g : NEW_LINE INDENT p += 1 NEW_LINE res += 1 NEW_LINE DEDENT else : NEW_LINE INDENT g += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE", "s = input ( ) NEW_LINE ans = 0 NEW_LINE for i , x in enumerate ( s ) : NEW_LINE INDENT if i % 2 == 0 and x == ' p ' : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT elif i % 2 == 1 and x == ' g ' : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc029_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; boolean nodec = true ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] <= a [ i - 1 ] ) nodec = false ; } if ( nodec ) { System . out . println ( 1 ) ; return ; } int m = 500 ; int l = 1 , r = 210000 ; int mid = 2 ; int [ ] dec = new int [ m ] ; out : while ( r - l > 1 ) { mid = ( l + r ) / 2 ; dec = new int [ m ] ; Arrays . fill ( dec , 1 ) ; nout : for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] <= a [ i - 1 ] && a [ i ] - 1 < m ) { if ( dec [ a [ i ] - 1 ] < mid ) { dec [ a [ i ] - 1 ] ++ ; } else { int pos = a [ i ] - 1 ; while ( pos > 0 ) { dec [ pos - 1 ] ++ ; for ( int j = pos ; j < m ; j ++ ) { dec [ j ] = 1 ; } if ( dec [ pos - 1 ] <= mid ) continue nout ; pos -- ; } l = mid ; continue out ; } } else { for ( int j = a [ i ] - 1 ; j < m ; j ++ ) { dec [ j ] = 1 ; } } } r = mid ; } System . out . println ( r ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . util . Arrays ; import java . util . TreeMap ; public class Main { private int n ; private int [ ] a ; private TreeMap < Integer , Integer > s ; public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . solve ( ) ; } private void set ( ) { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { n = Integer . parseInt ( br . readLine ( ) ) ; a = Arrays . stream ( br . readLine ( ) . split ( \" ▁ \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; s = new TreeMap < > ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } private void solve ( ) { set ( ) ; int ng = 0 ; int ok = n ; while ( ok - ng > 1 ) { int k = ( ng + ok ) / 2 ; if ( isPossible ( k ) ) { ok = k ; } else { ng = k ; } } System . out . println ( ok ) ; } private boolean isPossible ( int k ) { s . clear ( ) ; int current = 0 ; for ( int ai : a ) { if ( ai <= current ) { if ( k == 1 ) return false ; while ( ! s . isEmpty ( ) && s . lastKey ( ) >= ai ) s . pollLastEntry ( ) ; int p = ai - 1 ; while ( true ) { if ( p < 0 ) return false ; int sp = s . getOrDefault ( p , 0 ) + 1 ; s . put ( p , sp ) ; if ( sp == k ) { s . remove ( p ) ; p -- ; } else { break ; } } } current = ai ; } return true ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if all ( i < j for i , j in zip ( a , a [ 1 : ] ) ) : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT keta_count = 19 NEW_LINE a = [ 10 ** 10 ] + [ v - 1 for v in a if v <= keta_count ] + [ 10 ** 10 ] NEW_LINE a = [ - 1 ] + [ j for i , j , k in zip ( a , a [ 1 : ] , a [ 2 : ] ) if not i < j > k ] NEW_LINE if len ( a ) == 1 : NEW_LINE INDENT print ( 2 ) NEW_LINE exit ( ) NEW_LINE DEDENT ok , ng = len ( a ) , 1 NEW_LINE while ok - ng > 1 : NEW_LINE INDENT mid = ( ok + ng ) // 2 NEW_LINE keta = [ 0 ] * keta_count NEW_LINE for prev , current in zip ( a , a [ 1 : ] ) : NEW_LINE INDENT if prev < current : NEW_LINE INDENT for i in range ( current , prev , - 1 ) : NEW_LINE INDENT keta [ i ] = 0 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT kuriage = 0 NEW_LINE for num in keta [ prev : current : - 1 ] : NEW_LINE INDENT kuriage = ( kuriage + num ) // mid NEW_LINE DEDENT keta [ current ] += kuriage + 1 NEW_LINE DEDENT DEDENT for i in range ( a [ - 1 ] , 0 , - 1 ) : NEW_LINE INDENT keta [ i - 1 ] += keta [ i ] // mid NEW_LINE DEDENT if keta [ 0 ] >= mid : NEW_LINE INDENT ng = mid NEW_LINE DEDENT else : NEW_LINE INDENT ok = mid NEW_LINE DEDENT DEDENT print ( ok ) NEW_LINE" ]
atcoder_abc019_A
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int [ ] array = { in . nextInt ( ) , in . nextInt ( ) , in . nextInt ( ) } ; Arrays . sort ( array ) ; out . println ( array [ 1 ] ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int a [ ] = new int [ 3 ] , i , j ; for ( i = 0 ; i < 3 ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( i = 0 ; i < 3 ; i ++ ) { for ( j = 0 ; j < 3 ; j ++ ) { if ( a [ i ] < a [ j ] ) { int tmp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = tmp ; } } } System . out . println ( a [ 1 ] ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int x [ ] = new int [ 3 ] ; x [ 0 ] = sc . nextInt ( ) ; x [ 1 ] = sc . nextInt ( ) ; x [ 2 ] = sc . nextInt ( ) ; Arrays . sort ( x ) ; System . out . println ( x [ 1 ] ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int [ ] ar = nextIntArray ( 3 ) ; Arrays . sort ( ar ) ; out . println ( ar [ 1 ] ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( a [ 1 ] ) ; } }" ]
[ "a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE l = [ a , b , c ] NEW_LINE l . sort ( ) NEW_LINE print ( l [ 1 ] ) NEW_LINE", "s = input ( ) . split ( ) NEW_LINE a = int ( s [ 0 ] ) NEW_LINE b = int ( s [ 1 ] ) NEW_LINE c = int ( s [ 2 ] ) NEW_LINE if 1 <= a and b and c <= 100 : NEW_LINE INDENT if a < b < c or c < b < a or a == b == c : NEW_LINE INDENT print ( b ) NEW_LINE DEDENT elif a < c < b or b < c < a : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT elif b < a < c or c < a < b : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT elif a == b : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT elif a == c or b == c : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT DEDENT", "print ( sorted ( map ( int , input ( ) . split ( ) ) ) [ 1 ] ) NEW_LINE", "def solve ( ) : NEW_LINE INDENT a = list ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE a . sort ( ) NEW_LINE print ( a [ 1 ] ) NEW_LINE DEDENT solve ( ) NEW_LINE", "abc = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( sorted ( abc ) [ 1 ] ) NEW_LINE" ]
atcoder_abc096_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( a <= b ? a : a - 1 ) ; sc . close ( ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABC096_A solver = new ABC096_A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC096_A { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int ans = a ; if ( a <= b ) { out . print ( ans ) ; } else { out . print ( ans - 1 ) ; } } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; System . out . println ( a > b ? a - 1 : a ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a > b ) { System . out . println ( a - 1 ) ; } else { System . out . println ( a ) ; } } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( a <= b ? a : a - 1 ) ; } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( a - int ( a > b ) ) NEW_LINE", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( 1 , 13 ) : NEW_LINE INDENT if a > b : NEW_LINE INDENT ans = a - 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = a NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "m , d = map ( int , input ( ) . split ( ) ) NEW_LINE res = 0 NEW_LINE if m <= d : NEW_LINE INDENT res = m NEW_LINE DEDENT else : NEW_LINE INDENT res = m - 1 NEW_LINE DEDENT print ( res ) NEW_LINE", "l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( l [ 0 ] if l [ 0 ] <= l [ 1 ] else l [ 0 ] - 1 ) NEW_LINE", "a , b = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE if a > b : print ( a - 1 ) NEW_LINE else : print ( a ) NEW_LINE" ]
atcoder_abc059_A
[ "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String s1 = scan . next ( ) ; String s2 = scan . next ( ) ; String s3 = scan . next ( ) ; System . out . print ( ( char ) ( s1 . charAt ( 0 ) - ( ' a ' - ' A ' ) ) ) ; System . out . print ( ( char ) ( s2 . charAt ( 0 ) - ( ' a ' - ' A ' ) ) ) ; System . out . print ( ( char ) ( s3 . charAt ( 0 ) - ( ' a ' - ' A ' ) ) + \" \\n \" ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String a = in . next ( ) ; String b = in . next ( ) ; String c = in . next ( ) ; out . printf ( \" % C % C % C \\n \" , a . charAt ( 0 ) , b . charAt ( 0 ) , c . charAt ( 0 ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String a = in . next ( ) ; String b = in . next ( ) ; String c = in . next ( ) ; out . print ( a . toUpperCase ( ) . charAt ( 0 ) ) ; out . print ( b . toUpperCase ( ) . charAt ( 0 ) ) ; out . println ( c . toUpperCase ( ) . charAt ( 0 ) ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String [ ] ar = new String [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) ar [ i ] = sc . next ( ) ; String ans = \" \" ; for ( int i = 0 ; i < 3 ; i ++ ) { ans += ar [ i ] . charAt ( 0 ) ; } System . out . println ( ans . toUpperCase ( ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; for ( int i = 0 ; i < 3 ; i ++ ) { char s = sc . next ( ) . charAt ( 0 ) ; int diff = ' a ' - ' A ' ; System . out . print ( ( char ) ( s - diff ) ) ; } } }" ]
[ "s = input ( ) . split ( ) NEW_LINE print ( ( ' ' . join ( [ s [ 0 ] [ 0 ] , s [ 1 ] [ 0 ] , s [ 2 ] [ 0 ] ] ) ) . upper ( ) ) NEW_LINE", "a = list ( input ( ) . split ( ) ) NEW_LINE b = a [ 0 ] [ 0 ] NEW_LINE b = b . swapcase ( ) NEW_LINE c = a [ 1 ] [ 0 ] NEW_LINE c = c . swapcase ( ) NEW_LINE d = a [ 2 ] [ 0 ] NEW_LINE d = d . swapcase ( ) NEW_LINE print ( b , c , d , sep = \" \" ) NEW_LINE", "s_1 , s_2 , s_3 = input ( ) . split ( ) NEW_LINE s_1 = s_1 . upper ( ) NEW_LINE s_2 = s_2 . upper ( ) NEW_LINE s_3 = s_3 . upper ( ) NEW_LINE print ( s_1 [ 0 ] + s_2 [ 0 ] + s_3 [ 0 ] ) NEW_LINE", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a , b , c = ( _ for _ in input ( ) . split ( ) ) NEW_LINE print ( a [ 0 ] . upper ( ) + b [ 0 ] . upper ( ) + c [ 0 ] . upper ( ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE A = list ( map ( str , input ( ) . split ( ) ) ) NEW_LINE ans = A [ 0 ] [ 0 ] + A [ 1 ] [ 0 ] + A [ 2 ] [ 0 ] NEW_LINE return ans . upper ( ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT" ]
atcoder_abc031_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( Math . max ( ( A + 1 ) * B , A * ( B + 1 ) ) ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . println ( Math . max ( a , b ) * ( Math . min ( a , b ) + 1 ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( a >= b ? a * ( b + 1 ) : ( a + 1 ) * b ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int D = in . nextInt ( ) ; out . println ( Math . max ( ( A + 1 ) * ( D ) , ( A ) * ( D + 1 ) ) ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int a = nextInt ( ) , b = nextInt ( ) ; out . println ( max ( ( a + 1 ) * b , ( b + 1 ) * a ) ) ; } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( min ( [ a , b ] ) + 1 ) * max ( [ a , b ] ) ) NEW_LINE", "def game ( A : int , D : int ) -> int : NEW_LINE INDENT return max ( ( A + 1 ) * D , A * ( D + 1 ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT A , D = map ( int , input ( ) . split ( ) ) NEW_LINE ans = game ( A , D ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "a = list ( map ( int , input ( ) . split ( ) ) ) ; c , d = sorted ( a ) ; print ( - ~ c * d ) NEW_LINE", "A , D = map ( int , input ( ) . split ( ) ) NEW_LINE x = ( A + 1 ) * D NEW_LINE y = A * ( D + 1 ) NEW_LINE if x >= y : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( y ) NEW_LINE DEDENT", "[ a , d ] = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( min ( a , d ) + 1 ) * max ( a , d ) ) NEW_LINE" ]
atcoder_arc070_A
[ "import java . io . IOException ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int x = input . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= x ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { count += 1 ; if ( count == x ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } } } }", "import java . util . * ; import java . io . * ; import static java . lang . Math . * ; import static java . util . Arrays . * ; import static java . util . Collections . * ; public class Main { static final long mod = 1000000007 ; public static void main ( String [ ] args ) throws Exception , IOException { Reader sc = new Reader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; long s = 0 , ans = 0 ; for ( int i = 0 ; true ; i ++ ) { s += i + 1 ; if ( n <= s ) { ans = i + 1 ; break ; } } out . println ( ans ) ; out . flush ( ) ; } static void db ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } } class P implements Comparable < P > { int id , d ; P ( int id , int d ) { this . id = id ; this . d = d ; } public int compareTo ( P p ) { return d - p . d ; } } class Reader { private BufferedReader x ; private StringTokenizer st ; public Reader ( InputStream in ) { x = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; } public String nextString ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( x . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( nextString ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( nextString ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( nextString ( ) ) ; } }", "import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int k = ( int ) Math . sqrt ( 2 * n ) ; while ( true ) { int sum = ( 1 + k ) * k / 2 ; if ( sum < n ) ++ k ; else break ; } System . out . println ( k ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int home = reader . nextInt ( ) ; double interm = - 0.5 + Math . sqrt ( 0.25 + 2 * home ) ; if ( interm % 1.0 > 0 ) { System . out . println ( ( int ) ( interm + 1 ) ) ; } else { System . out . println ( ( int ) interm ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nestValue = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i <= nestValue ; i ++ ) { if ( maxValue ( i ) >= nestValue ) { result = i ; i = nestValue ; } } System . out . println ( result ) ; sc . close ( ) ; } public static int maxValue ( int n ) { int max = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { max += i ; } return max ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE ans = 1 NEW_LINE m = 1 NEW_LINE while m < n : NEW_LINE INDENT ans += 1 NEW_LINE m += ans NEW_LINE DEDENT print ( ans ) NEW_LINE", "def fun ( ) : NEW_LINE INDENT print ( ' ac ' ) NEW_LINE print ( ' ac ' ) NEW_LINE print ( ' ac ' ) NEW_LINE print ( ' ac ' ) NEW_LINE DEDENT from math import * NEW_LINE n = eval ( input ( ) ) NEW_LINE s = ceil ( ( - 1 + sqrt ( 1 + 8 * n ) ) / 2 ) NEW_LINE print ( s ) NEW_LINE", "X = int ( input ( ) ) NEW_LINE print ( [ t for t in range ( 10 ** 5 ) if t * ( t + 1 ) / 2 < X ] [ - 1 ] + 1 ) NEW_LINE", "import math NEW_LINE x = int ( input ( ) ) NEW_LINE k = 0 NEW_LINE t = 0 NEW_LINE if ( math . sqrt ( 8 * x + 1 ) == math . floor ( math . sqrt ( 8 * x + 1 ) ) ) : NEW_LINE INDENT a = ( - 1 + math . sqrt ( 1 + 8 * x ) ) / 2 NEW_LINE print ( int ( a ) ) NEW_LINE DEDENT else : NEW_LINE INDENT x = ( - 1 + math . sqrt ( 1 + 8 * x ) ) // 2 NEW_LINE print ( int ( x ) + 1 ) NEW_LINE DEDENT", "a = int ( input ( ) ) NEW_LINE ar = [ ] NEW_LINE count = 0 NEW_LINE i = 1 NEW_LINE while True : NEW_LINE INDENT count += i NEW_LINE ar . append ( i ) NEW_LINE if count >= a : NEW_LINE INDENT break NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print ( ar [ len ( ar ) - 1 ] ) NEW_LINE" ]
atcoder_agc024_C
[ "import java . io . * ; 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 ( ) ; } if ( arr [ 0 ] != 0 ) { System . out . println ( - 1 ) ; return ; } for ( int i = 1 ; i < n ; i ++ ) { int dif = arr [ i ] - arr [ i - 1 ] ; if ( dif > 1 ) { System . out . println ( - 1 ) ; return ; } } long ans = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { ans += arr [ i ] ; if ( arr [ i ] > 0 ) { while ( i > 0 && arr [ i ] - arr [ i - 1 ] == 1 ) { i -- ; } } } System . out . println ( ans ) ; return ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; boolean ok = a [ 0 ] == 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( a [ i ] - a [ i - 1 ] > 1 ) ok = false ; if ( ! ok ) { System . out . println ( - 1 ) ; return ; } long ans = 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( a [ i ] > a [ i - 1 ] ) ans ++ ; else ans += a [ i ] ; pw . println ( ans ) ; pw . close ( ) ; } static class Scanner { BufferedReader br ; StringTokenizer st ; public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int length = in . nextInt ( ) ; if ( in . nextInt ( ) > 0 ) { System . out . println ( - 1 ) ; return ; } long ans = 0 ; int prev = 0 ; for ( int i = 1 ; i < length ; i ++ ) { int n = in . nextInt ( ) ; if ( n == 0 ) { } else if ( n - prev > 1 ) { System . out . println ( - 1 ) ; return ; } else if ( n - prev == 1 ) { ans ++ ; } else if ( n - prev <= 0 ) { ans += n ; } prev = n ; } System . out . println ( ans ) ; } } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; boolean ch = true ; long ans = 0 ; long A = sc . nextLong ( ) ; if ( A != 0 ) { ch = false ; } long B ; for ( long i = 1 ; i < N ; i ++ ) { B = sc . nextLong ( ) ; if ( B - A > 1 ) { ch = false ; } if ( B - A == 1 ) { ans ++ ; } if ( B <= A ) { ans += B ; } A = B ; } if ( ch ) { System . out . println ( ans ) ; } else { System . out . println ( \" - 1\" ) ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; int n = Integer . parseInt ( r . readLine ( ) ) ; int a [ ] = new int [ 200001 ] ; int x [ ] = new int [ 200001 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( r . readLine ( ) ) ; } if ( a [ 0 ] > 0 ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i + 1 ] - a [ i ] > 1 ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; } } long v = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( a [ i - 1 ] + 1 == a [ i ] ) { v ++ ; } else { v += a [ i ] ; } } System . out . println ( v ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE ans = 0 NEW_LINE if a [ 0 ] != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if a [ i ] - 1 == a [ i - 1 ] : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT if a [ i ] > a [ i - 1 ] + 1 : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += a [ i - 1 ] NEW_LINE DEDENT DEDENT DEDENT ans += a [ n - 1 ] NEW_LINE print ( ans ) NEW_LINE", "import sys NEW_LINE n , = [ int ( x ) for x in input ( ) . strip ( ) . split ( \" ▁ \" ) ] NEW_LINE n = int ( n ) NEW_LINE As = [ ] NEW_LINE for line in sys . stdin : NEW_LINE INDENT a , = line . strip ( ) . split ( \" ▁ \" ) NEW_LINE As . append ( int ( a ) ) NEW_LINE DEDENT if As [ 0 ] != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT result = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT k = n - 1 - i NEW_LINE As [ k ] NEW_LINE if As [ k ] > k : NEW_LINE INDENT print ( - 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT if k == n - 1 : NEW_LINE INDENT result += As [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT if As [ k ] > As [ k + 1 ] : NEW_LINE INDENT result += As [ k ] NEW_LINE DEDENT if As [ k ] == As [ k + 1 ] : NEW_LINE INDENT result += As [ k ] NEW_LINE DEDENT if As [ k ] + 1 < As [ k + 1 ] : NEW_LINE INDENT print ( - 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT DEDENT print ( result ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE prev = 0 NEW_LINE ans = 0 NEW_LINE able = True NEW_LINE for i in range ( N ) : NEW_LINE INDENT now = int ( input ( ) ) NEW_LINE if now - prev > 1 or ( i == 0 and now != 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE able = False NEW_LINE break NEW_LINE DEDENT elif now - prev == 1 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT elif now : NEW_LINE INDENT ans += now NEW_LINE DEDENT prev = now NEW_LINE DEDENT if able : NEW_LINE INDENT print ( ans ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE moves = 0 NEW_LINE previous = 0 NEW_LINE exists = 1 NEW_LINE a = [ 0 for i in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT a [ i ] = int ( input ( ) ) NEW_LINE DEDENT if a [ 0 ] != 0 : NEW_LINE INDENT exists = 0 NEW_LINE DEDENT for i in [ N - j - 1 for j in range ( N ) ] : NEW_LINE INDENT if a [ i ] >= previous : NEW_LINE INDENT moves += a [ i ] NEW_LINE DEDENT elif a [ i ] < previous - 1 : NEW_LINE INDENT exists = 0 NEW_LINE DEDENT previous = a [ i ] NEW_LINE DEDENT if exists == 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( moves ) NEW_LINE DEDENT", "import sys NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ int ( sys . stdin . readline ( ) ) for _ in range ( N ) ] NEW_LINE b = 0 NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if i + b < a : NEW_LINE INDENT print ( - 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT b = a - i NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE pre = - 1 NEW_LINE for a in A [ : : - 1 ] : NEW_LINE INDENT if pre - 1 != a : NEW_LINE INDENT ans += a NEW_LINE DEDENT pre = a NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc014_A
[ "import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( a == b && b == c && a % 2 == 0 ) { System . out . println ( - 1 ) ; } else { int count = 0 ; while ( a % 2 == 0 && b % 2 == 0 && c % 2 == 0 ) { int ta = a ; int tb = b ; int tc = c ; a = ( tb + tc ) / 2 ; b = ( ta + tc ) / 2 ; c = ( ta + tb ) / 2 ; count ++ ; } System . out . println ( count ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ACookieExchanges solver = new ACookieExchanges ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ACookieExchanges { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) ; for ( int i = 0 ; ; i ++ ) { if ( a % 2 == 1 || b % 2 == 1 || c % 2 == 1 ) { out . println ( i ) ; return ; } else if ( a == b && b == c ) { out . println ( - 1 ) ; return ; } int na = b + c , nb = c + a , nc = a + b ; a = na / 2 ; b = nb / 2 ; c = nc / 2 ; } } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] input = br . readLine ( ) . split ( \" ▁ \" ) ; long A = Long . parseLong ( input [ 0 ] ) ; long B = Long . parseLong ( input [ 1 ] ) ; long C = Long . parseLong ( input [ 2 ] ) ; long defineA = A ; long defineB = B ; long defineC = C ; long result = 0 ; while ( true ) { if ( Even ( A ) || Even ( B ) || Even ( C ) ) { break ; } long A2 = A / 2 ; long B2 = B / 2 ; long C2 = C / 2 ; A = B2 + C2 ; B = A2 + C2 ; C = A2 + B2 ; result ++ ; if ( defineA == A && defineB == B && defineC == C ) { result = - 1 ; break ; } } System . out . println ( result ) ; } private static boolean Even ( long A , long B , long C ) { return ( A % 2 != 0 ) && ( B % 2 != 0 ) && ( C % 2 != 0 ) ; } private static boolean Even ( long var ) { return ( var % 2 != 0 ) ; } }", "import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) ; if ( ( a + b + c ) % 2 == 1 ) { out . println ( 0 ) ; } else if ( a == b && b == c && c == a ) { out . println ( - 1 ) ; } else { int ans = 0 ; while ( a % 2 + b % 2 + c % 2 == 0 ) { ans ++ ; int tempA = ( b + c ) / 2 ; int tempB = ( a + c ) / 2 ; int tempC = ( b + a ) / 2 ; a = tempA ; b = tempB ; c = tempC ; } out . println ( ans ) ; } } }", "import java . util . * ; public class Main { long INF = Long . MAX_VALUE ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = sc . nextLong ( ) ; if ( A % 2 == 1 || B % 2 == 1 || C % 2 == 1 ) { System . out . println ( \"0\" ) ; return ; } if ( ( A == B && B == C ) ) { System . out . println ( \" - 1\" ) ; return ; } long count = 1 ; while ( true ) { long a = A / 2 ; long b = B / 2 ; long c = C / 2 ; A = b + c ; B = a + c ; C = a + b ; if ( A % 2 == 1 || B % 2 == 1 || C % 2 == 1 ) { break ; } count ++ ; } System . out . println ( count ) ; } }" ]
[ "def solve ( ) : NEW_LINE INDENT a , b , c = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE queue = [ [ a , b , c ] ] NEW_LINE ct = 0 NEW_LINE while ct < 100000000 : NEW_LINE INDENT if a % 2 == 1 or b % 2 == 1 or c % 2 == 1 : break NEW_LINE tmpa = a // 2 NEW_LINE tmpb = b // 2 NEW_LINE tmpc = c // 2 NEW_LINE a = tmpb + tmpc NEW_LINE b = tmpa + tmpc NEW_LINE c = tmpa + tmpb NEW_LINE if [ a , b , c ] in queue : NEW_LINE INDENT return - 1 NEW_LINE DEDENT else : NEW_LINE INDENT ct += 1 NEW_LINE queue . append ( [ a , b , c ] ) NEW_LINE DEDENT DEDENT return ct NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( ) ) NEW_LINE DEDENT", "import numpy as np NEW_LINE A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE A , B , C = np . sort ( [ A , B , C ] ) NEW_LINE ab = B - A NEW_LINE bc = C - B NEW_LINE if ( A % 2 == 1 ) & ( B % 2 == 1 ) & ( C % 2 == 1 ) : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT elif ( ab == 0 ) & ( bc == 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT for k in range ( 30 ) : NEW_LINE INDENT if ( ( ab % 2 ) == 1 ) | ( ( bc % 2 ) == 1 ) : NEW_LINE INDENT print ( k ) NEW_LINE break NEW_LINE DEDENT ab = int ( ab / 2 ) NEW_LINE bc = int ( bc / 2 ) NEW_LINE DEDENT DEDENT", "cookie = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cookie . sort ( ) NEW_LINE count = 0 NEW_LINE if cookie [ 0 ] == cookie [ 2 ] and cookie [ 0 ] % 2 == 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT while cookie [ 2 ] - cookie [ 0 ] > 0 : NEW_LINE INDENT if cookie [ 0 ] % 2 == 1 or cookie [ 1 ] % 2 == 1 or cookie [ 2 ] % 2 == 1 : NEW_LINE INDENT print ( count ) NEW_LINE exit ( ) NEW_LINE DEDENT if cookie [ 0 ] == cookie [ 2 ] : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT count += 1 NEW_LINE a = ( cookie [ 1 ] + cookie [ 2 ] ) // 2 NEW_LINE b = ( cookie [ 2 ] + cookie [ 0 ] ) // 2 NEW_LINE c = ( cookie [ 0 ] + cookie [ 1 ] ) // 2 NEW_LINE cookie [ 0 ] = a NEW_LINE cookie [ 1 ] = b NEW_LINE cookie [ 2 ] = c NEW_LINE cookie . sort ( ) NEW_LINE DEDENT print ( count ) NEW_LINE", "def solve ( a , b , c , ans ) : NEW_LINE INDENT if ( a , b , c ) in s : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if ( a % 2 ) or ( b % 2 ) or ( c % 2 ) : NEW_LINE INDENT return ans NEW_LINE DEDENT s . add ( ( a , b , c ) ) NEW_LINE a >>= 1 NEW_LINE b >>= 1 NEW_LINE c >>= 1 NEW_LINE return solve ( b + c , c + a , a + b , ans + 1 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE s = set ( ) NEW_LINE print ( solve ( a , b , c , 0 ) ) NEW_LINE DEDENT", "def cookies_divide ( num_of_per , A ) : NEW_LINE INDENT if ( A [ 0 ] == A [ 1 ] == A [ 2 ] and A [ 0 ] % 2 + A [ 1 ] % 2 + A [ 2 ] % 2 == 0 ) : NEW_LINE INDENT return ( - 1 , A ) NEW_LINE DEDENT if ( A [ 0 ] % 2 + A [ 1 ] % 2 + A [ 2 ] % 2 > 0 ) : NEW_LINE INDENT return ( 0 , A ) NEW_LINE DEDENT R = [ 0 for i in range ( num_of_per ) ] NEW_LINE R [ 0 ] = A [ 1 ] // 2 + A [ 2 ] // 2 NEW_LINE R [ 1 ] = A [ 0 ] // 2 + A [ 2 ] // 2 NEW_LINE R [ 2 ] = A [ 0 ] // 2 + A [ 1 ] // 2 NEW_LINE return ( 1 , R ) NEW_LINE DEDENT if ( __name__ == ' _ _ main _ _ ' ) : NEW_LINE INDENT count = 0 NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE while True : NEW_LINE INDENT return_code , A = cookies_divide ( 3 , A ) NEW_LINE if return_code < 0 : NEW_LINE INDENT print ( return_code ) NEW_LINE break ; NEW_LINE DEDENT if return_code == 0 : NEW_LINE INDENT print ( count ) NEW_LINE break ; NEW_LINE DEDENT count += return_code NEW_LINE DEDENT DEDENT" ]
atcoder_arc098_B
[ "import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] xor = new int [ N ] ; int [ ] sum = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { A [ i ] = sc . nextInt ( ) ; xor [ i ] = A [ i ] ^ ( i > 0 ? xor [ i - 1 ] : 0 ) ; sum [ i ] = A [ i ] + ( i > 0 ? sum [ i - 1 ] : 0 ) ; } long ans = 0 ; int t = - 1 ; for ( int i = 0 ; i < N ; ++ i ) { while ( t < i && sum [ i ] - ( t >= 0 ? sum [ t ] : 0 ) != ( xor [ i ] ^ ( t >= 0 ? xor [ t ] : 0 ) ) ) ++ t ; ans += i - t ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . HashMap ; import java . util . HashSet ; import java . util . PriorityQueue ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; String input = br . readLine ( ) ; String [ ] tmpArray = input . split ( \" ▁ \" ) ; long array [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { array [ i ] = Long . parseLong ( tmpArray [ i ] ) ; } long result = 0 ; result = solve ( array ) ; System . out . println ( result ) ; } static long solve ( long [ ] array ) { int n = array . length ; long result = 0 ; long tmpXor = array [ 0 ] ; long tmpSum = array [ 0 ] ; int left = 0 ; int right = 0 ; int count [ ] = new int [ n ] ; while ( left < n ) { if ( right < n - 1 && ( long ) ( tmpXor ^ array [ right + 1 ] ) == tmpSum + array [ right + 1 ] ) { tmpXor ^= array [ right + 1 ] ; tmpSum += array [ right + 1 ] ; right ++ ; } else { count [ left ] = right - left + 1 ; tmpSum -= array [ left ] ; tmpXor = tmpSum ; if ( left < n - 1 && left == right ) { right = left + 1 ; tmpXor = array [ left + 1 ] ; tmpSum = array [ left + 1 ] ; } left ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { result += count [ i ] ; } return result ; } }", "import java . io . PrintStream ; import java . util . Scanner ; public class Main { private static final PrintStream ps = System . out ; private static final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long sum = 0 ; long ans = 0 ; long xsum = 0 ; int r = 0 ; for ( int l = 0 ; l < n ; l ++ ) { if ( l != 0 ) { xsum ^= a [ l - 1 ] ; sum -= a [ l - 1 ] ; } while ( true ) { if ( r >= n ) { ans += r - l ; break ; } xsum ^= a [ r ] ; sum += a [ r ] ; if ( xsum != sum ) { ans += r - l ; xsum ^= a [ r ] ; sum -= a [ r ] ; break ; } r ++ ; } } ps . println ( ans ) ; } }", "import java . math . BigInteger ; import java . util . * ; public class Main { private void doit ( ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int n = sc . nextInt ( ) ; int [ ] data = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { data [ i ] = sc . nextInt ( ) ; } long count = 0 ; int now = 0 ; int left = 0 , right = 0 ; while ( true ) { if ( left >= n ) { break ; } while ( right < n ) { int res = now ^ data [ right ] ; int res2 = now | data [ right ] ; if ( res != res2 ) { break ; } now = now ^ data [ right ] ; right ++ ; } count += right - left ; now = now ^ ( now & data [ left ] ) ; left ++ ; } System . out . println ( count ) ; } } private void debug ( Object ... o ) { System . out . println ( \" debug ▁ = ▁ \" + Arrays . deepToString ( o ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . doit ( ) ; } }", "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 ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int start = 0 ; int end = 0 ; int v = 0 ; long s = 0 ; long ans = 0 ; boolean f = true ; while ( end < n ) { if ( f ) { s += a [ end ] ; v ^= a [ end ] ; } if ( s == v ) { f = true ; end ++ ; } else { f = false ; long len = end - start ; ans += len ; s -= a [ start ] ; v ^= a [ start ] ; start ++ ; } } if ( f ) { long len = ( end - start ) ; ans += ( len ) * ( len - 1 ) / 2 ; ans += len ; } System . out . println ( ans ) ; } static class Scanner { BufferedReader br ; StringTokenizer st ; public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public Scanner ( String s ) throws FileNotFoundException { br = new BufferedReader ( new FileReader ( s ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cnt = 0 NEW_LINE r = 0 NEW_LINE tmp = 0 NEW_LINE for l in range ( N ) : NEW_LINE INDENT while r < N and ( tmp & A [ r ] ) == 0 : NEW_LINE INDENT tmp |= A [ r ] NEW_LINE r += 1 NEW_LINE DEDENT cnt += ( r - l ) NEW_LINE tmp ^= A [ l ] NEW_LINE DEDENT print ( cnt ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n = int ( input ( ) . rstrip ( \" \\b \" ) ) NEW_LINE numbers = [ int ( x ) for x in input ( ) . rstrip ( \" \\b \" ) . split ( \" ▁ \" ) ] NEW_LINE start_number = numbers . pop ( 0 ) NEW_LINE targets = { start_number : 1 } NEW_LINE total = 0 NEW_LINE from collections import defaultdict NEW_LINE for number in numbers : NEW_LINE INDENT next_targets = defaultdict ( int ) NEW_LINE for ( target , count ) in targets . items ( ) : NEW_LINE INDENT total += count NEW_LINE if ( number | target ) >= ( target + number ) : NEW_LINE INDENT next_targets [ target + number ] += count NEW_LINE DEDENT DEDENT next_targets [ number ] += 1 NEW_LINE targets = next_targets NEW_LINE DEDENT for ( target , count ) in targets . items ( ) : NEW_LINE INDENT total += count NEW_LINE DEDENT print ( total ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE A = inpl ( ) NEW_LINE l = r = 0 NEW_LINE ans = 0 NEW_LINE X = Y = A [ 0 ] NEW_LINE while 1 : NEW_LINE INDENT if X == Y : NEW_LINE INDENT ans += r - l + 1 NEW_LINE if r < N - 1 : NEW_LINE INDENT r += 1 NEW_LINE X ^= A [ r ] NEW_LINE Y += A [ r ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT X ^= A [ l ] NEW_LINE Y -= A [ l ] NEW_LINE l += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE n = II ( ) NEW_LINE A = LI ( ) NEW_LINE ans = 0 NEW_LINE right = 0 NEW_LINE num_xor = 0 NEW_LINE num_and = 0 NEW_LINE for left in range ( n ) : NEW_LINE INDENT while right < n and num_xor ^ A [ right ] == num_and + A [ right ] : NEW_LINE INDENT num_xor ^= A [ right ] NEW_LINE num_and += A [ right ] NEW_LINE right += 1 NEW_LINE DEDENT ans += right - left NEW_LINE if left == right : NEW_LINE INDENT right += 1 NEW_LINE DEDENT else : NEW_LINE INDENT num_xor ^= A [ left ] NEW_LINE num_and -= A [ left ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l = 1 ; r = 1 NEW_LINE XOR = A [ 0 ] NEW_LINE SUM = A [ 0 ] NEW_LINE answer = 0 NEW_LINE while True : NEW_LINE INDENT if r < N : NEW_LINE INDENT if XOR ^ A [ r ] == SUM + A [ r ] : NEW_LINE INDENT XOR = XOR ^ A [ r ] NEW_LINE SUM = SUM + A [ r ] NEW_LINE r += 1 NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT if l == r : NEW_LINE INDENT answer += 1 NEW_LINE XOR = A [ r ] NEW_LINE SUM = A [ r ] NEW_LINE l += 1 NEW_LINE r += 1 NEW_LINE DEDENT else : NEW_LINE INDENT answer += r - ( l - 1 ) NEW_LINE XOR = XOR ^ A [ l - 1 ] NEW_LINE SUM = SUM - A [ l - 1 ] NEW_LINE l += 1 NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT answer += ( N - ( l - 1 ) ) * ( N - ( l - 1 ) + 1 ) // 2 NEW_LINE break NEW_LINE DEDENT DEDENT print ( answer ) NEW_LINE" ]
atcoder_arc087_B
[ "import java . util . ArrayList ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . Set ; class Main { static boolean canSet ( int x , List < Integer > list ) { Set < Integer > set = new HashSet < > ( ) ; set . add ( 0 ) ; for ( int i : list ) { Set < Integer > newSet = new HashSet < > ( ) ; for ( int j : set ) { newSet . add ( j + i ) ; newSet . add ( j - i ) ; } set = newSet ; } return set . contains ( x ) ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) + ' T ' ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; List < Integer > hol = new ArrayList < > ( ) ; List < Integer > ver = new ArrayList < > ( ) ; int index = 0 ; while ( s . charAt ( index ) != ' T ' ) ++ index ; x -= index ; int cnt = 0 ; int vec = 0 ; for ( int i = index ; i < s . length ( ) ; ++ i ) { if ( s . charAt ( i ) == ' F ' ) ++ cnt ; else { ++ vec ; if ( cnt > 0 ) { if ( vec % 2 == 1 ) hol . add ( cnt ) ; else ver . add ( cnt ) ; cnt = 0 ; } } } if ( canSet ( x , hol ) && canSet ( y , ver ) ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }", "import java . io . * ; import java . util . * ; import static java . lang . System . in ; class Main { int [ ] [ ] rec = new int [ 1001 ] [ 1001 ] ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; int start = 0 , n = s . length ; while ( start < n && s [ start ] == ' F ' ) start ++ ; ArrayList < Integer > hori = new ArrayList < > ( ) , vert = new ArrayList < > ( ) ; int parity = 0 ; int i = start ; while ( i < n ) { if ( s [ i ] == ' T ' ) { parity = 1 - parity ; i ++ ; } else { int j = i + 1 ; while ( j < n && s [ j ] == ' F ' ) j ++ ; if ( parity == 0 ) hori . add ( j - i ) ; else vert . add ( j - i ) ; i = j ; } } String ans = help ( x - start , hori ) && help ( y , vert ) ? \" Yes \" : \" No \" ; System . out . println ( ans ) ; } static boolean help ( int target , ArrayList < Integer > step ) { int sum = 0 ; for ( int w : step ) sum += w ; if ( sum < Math . abs ( target ) ) return false ; if ( sum == Math . abs ( target ) ) return true ; boolean [ ] cur = new boolean [ 2 * sum + 1 ] , next = new boolean [ 2 * sum + 1 ] ; cur [ sum ] = true ; for ( int w : step ) { for ( int j = 0 ; j <= 2 * sum ; j ++ ) { if ( cur [ j ] ) { next [ j - w ] = true ; next [ j + w ] = true ; } } cur = next ; next = new boolean [ 2 * sum + 1 ] ; } return cur [ target + sum ] ; } }", "import java . util . * ; public class Main { static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { String v = s . next ( ) ; int x = gInt ( ) , y = gInt ( ) ; ArrayList < Integer > dx = new ArrayList < > ( ) , dy = new ArrayList < > ( ) ; boolean dir = true ; int d = 0 ; for ( int i = 0 ; i < v . length ( ) ; i ++ ) { if ( v . charAt ( i ) == ' T ' ) { ( dir ? dx : dy ) . add ( d ) ; d = 0 ; dir ^= true ; } else { d ++ ; } } ( dir ? dx : dy ) . add ( d ) ; x -= dx . remove ( 0 ) ; System . out . println ( dp ( dx , x ) && dp ( dy , y ) ? \" Yes \" : \" No \" ) ; } static boolean dp ( List < Integer > list , int goal ) { Set < Integer > set = new HashSet < > ( ) , buf = new HashSet < > ( ) ; set . add ( 0 ) ; for ( int v : list ) { buf . clear ( ) ; for ( int base : set ) { buf . add ( base + v ) ; buf . add ( base - v ) ; } set . clear ( ) ; set . addAll ( buf ) ; } return set . contains ( goal ) ; } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { static int PLUS = 10000 ; static boolean check ( int start , int x , List < Integer > a ) { boolean [ ] dp = new boolean [ 20002 ] ; dp [ start ] = true ; for ( int i = 0 ; i < a . size ( ) ; i ++ ) { boolean [ ] next_dp = new boolean [ 20002 ] ; for ( int j = 0 ; j < 20002 ; j ++ ) { if ( ! dp [ j ] ) { continue ; } next_dp [ j + a . get ( i ) ] = true ; next_dp [ j - a . get ( i ) ] = true ; } dp = Arrays . copyOf ( next_dp , 20002 ) ; } return dp [ x ] ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { String s = sc . next ( ) ; int x = sc . nextInt ( ) + PLUS ; int y = sc . nextInt ( ) + PLUS ; List < Integer > ax = new ArrayList < > ( ) ; List < Integer > ay = new ArrayList < > ( ) ; boolean isOdd = false ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int cnt = 0 ; while ( i < s . length ( ) && s . charAt ( i ) == ' F ' ) { cnt ++ ; i ++ ; } if ( isOdd ) { ay . add ( cnt ) ; } else { ax . add ( cnt ) ; } isOdd = ! isOdd ; } int nowX = PLUS + ax . get ( 0 ) ; int nowY = PLUS ; if ( check ( nowX , x , ax . subList ( 1 , ax . size ( ) ) ) && check ( nowY , y , ay ) ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } } }" ]
[ "def c ( p , g , lis ) : NEW_LINE INDENT for e in lis : NEW_LINE INDENT if p <= g : NEW_LINE INDENT p += e NEW_LINE DEDENT else : NEW_LINE INDENT p -= e NEW_LINE DEDENT DEDENT return p == g NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = input ( ) NEW_LINE gx , gy = map ( int , input ( ) . split ( ) ) NEW_LINE s = s . split ( \" T \" ) NEW_LINE s = [ len ( _ ) for _ in s ] NEW_LINE x_move = s [ : : 2 ] NEW_LINE y_move = s [ 1 : : 2 ] NEW_LINE x = x_move . pop ( 0 ) NEW_LINE y = 0 NEW_LINE x_move . sort ( reverse = True ) NEW_LINE y_move . sort ( reverse = True ) NEW_LINE if c ( x , gx , x_move ) and c ( y , gy , y_move ) : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT DEDENT", "ai = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ai_ = lambda : [ int ( x ) - 1 for x in input ( ) . split ( ) ] NEW_LINE s = input ( ) . split ( ' T ' ) NEW_LINE x , y = ai ( ) NEW_LINE xx , yy = [ ] , [ ] NEW_LINE c = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if i % 2 : NEW_LINE INDENT yy . append ( len ( s [ i ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT xx . append ( len ( s [ i ] ) ) NEW_LINE DEDENT DEDENT anx = set ( ) NEW_LINE for i in range ( len ( xx ) ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT anx = { xx [ i ] } NEW_LINE DEDENT else : NEW_LINE INDENT aanx = set ( ) NEW_LINE for j in anx : NEW_LINE INDENT aanx . add ( j + xx [ i ] ) NEW_LINE aanx . add ( j - xx [ i ] ) NEW_LINE DEDENT anx = aanx NEW_LINE DEDENT DEDENT any = { 0 } NEW_LINE for i in range ( len ( yy ) ) : NEW_LINE INDENT aany = set ( ) NEW_LINE for j in any : NEW_LINE INDENT aany . add ( j + yy [ i ] ) NEW_LINE aany . add ( j - yy [ i ] ) NEW_LINE DEDENT any = aany NEW_LINE DEDENT if x in anx and y in any : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10000 ) NEW_LINE inp = list ( map ( len , input ( ) . split ( \" T \" ) ) ) NEW_LINE inx , iny = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE memo = { } NEW_LINE def tg ( g , n , t ) : NEW_LINE INDENT g . sort ( ) NEW_LINE g . reverse ( ) NEW_LINE def tn ( g , n , t ) : NEW_LINE INDENT if ( tuple ( g ) , n , t ) in memo : NEW_LINE INDENT return memo [ ( tuple ( g ) , n , t ) ] NEW_LINE DEDENT if g == [ ] : NEW_LINE INDENT if n == t : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if n < t : NEW_LINE INDENT z = tn ( g [ 1 : ] , n + g [ 0 ] , t ) NEW_LINE memo [ ( tuple ( g ) , n , t ) ] = z NEW_LINE return z NEW_LINE DEDENT else : NEW_LINE INDENT z = tn ( g [ 1 : ] , n - g [ 0 ] , t ) NEW_LINE memo [ ( tuple ( g ) , n , t ) ] = z NEW_LINE return z NEW_LINE DEDENT DEDENT return tn ( g , n , t ) NEW_LINE DEDENT if tg ( inp [ 1 : : 2 ] , 0 , iny ) and tg ( inp [ 2 : : 2 ] , inp [ 0 ] , inx ) : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT", "def solve ( s , x , y ) : NEW_LINE INDENT def update ( move ) : NEW_LINE INDENT ncx = set ( ) NEW_LINE cx = cxy [ is_x ] NEW_LINE for x in cx : NEW_LINE INDENT ncx . add ( x + move ) NEW_LINE ncx . add ( x - move ) NEW_LINE DEDENT cxy [ is_x ] = ncx NEW_LINE DEDENT spl = map ( len , s . split ( ' T ' ) ) NEW_LINE is_x = 1 NEW_LINE cxy = [ { next ( spl ) } , { 0 } ] NEW_LINE for l in spl : NEW_LINE INDENT update ( l ) NEW_LINE is_x ^= 1 NEW_LINE DEDENT return x in cxy [ 0 ] and y in cxy [ 1 ] NEW_LINE DEDENT s = input ( ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ' Yes ' if solve ( s , x , y ) else ' No ' ) NEW_LINE", "s = input ( ) + \" T \" NEW_LINE goal_x , goal_y = map ( int , input ( ) . split ( ) ) NEW_LINE length = len ( s ) NEW_LINE dp_x , dp_y = [ 0 ] * ( length * 2 + 1 ) , [ 0 ] * ( length * 2 + 1 ) NEW_LINE start = x_steps = s . index ( \" T \" ) NEW_LINE dp_x [ length + start ] = dp_y [ length ] = 1 NEW_LINE steps = y_steps = 0 NEW_LINE direction = 0 NEW_LINE for i , c in enumerate ( s [ start : ] , start = start ) : NEW_LINE INDENT if c == \" F \" : NEW_LINE INDENT steps += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if steps : NEW_LINE INDENT _dp = [ 0 ] * ( length * 2 + 1 ) NEW_LINE if direction == 0 : NEW_LINE INDENT for x , v in enumerate ( dp_x [ length - x_steps : length + x_steps + 1 ] , start = length - x_steps ) : NEW_LINE INDENT if v : NEW_LINE INDENT _dp [ x - steps ] = _dp [ x + steps ] = 1 NEW_LINE DEDENT DEDENT x_steps += steps NEW_LINE dp_x = _dp NEW_LINE DEDENT else : NEW_LINE INDENT for y , v in enumerate ( dp_y [ length - y_steps : length + y_steps + 1 ] , start = length - y_steps ) : NEW_LINE INDENT if v : NEW_LINE INDENT _dp [ y - steps ] = _dp [ y + steps ] = 1 NEW_LINE DEDENT DEDENT y_steps += steps NEW_LINE dp_y = _dp NEW_LINE DEDENT DEDENT steps = 0 NEW_LINE direction ^= 1 NEW_LINE DEDENT DEDENT print ( \" Yes \" if dp_x [ length + goal_x ] and dp_y [ length + goal_y ] else \" No \" ) NEW_LINE" ]
atcoder_arc014_A
[ "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; if ( N % 2 == 0 ) { System . out . println ( \" Blue \" ) ; } else { System . out . println ( \" Red \" ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( ( in . nextInt ( ) & 1 ) == 1 ? \" Red \" : \" Blue \" ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; if ( N % 2 == 0 ) { pl ( \" Blue \" ) ; } else if ( N % 2 == 1 ) { pl ( \" Red \" ) ; } } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; System . out . println ( ( N % 2 == 0 ) ? \" Blue \" : \" Red \" ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { static int N ; public static void main ( String [ ] args ) { FastScanner fc = new FastScanner ( System . in ) ; N = fc . nextInt ( ) ; System . out . println ( solve ( ) ) ; } static String solve ( ) { return N % 2 == 1 ? \" Red \" : \" Blue \" ; } @ SuppressWarnings ( \" unused \" ) static class FastScanner { private BufferedReader reader ; private StringTokenizer tokenizer ; FastScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; tokenizer = null ; } String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } String nextLine ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( \" \\n \" ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] nextIntArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long [ ] nextLongArray ( int n ) { long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE if n % 2 == 1 : NEW_LINE INDENT print ( \" Red \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Blue \" ) NEW_LINE DEDENT", "print ( ' Red ' if int ( input ( ) ) % 2 else ' Blue ' ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE ans = \" Blue \" NEW_LINE if N % 2 == 1 : NEW_LINE INDENT ans = \" Red \" NEW_LINE DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE if n % 2 == 0 : NEW_LINE INDENT print ( \" Blue \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Red \" ) NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "print ( \" BRleude \" [ int ( input ( ) ) % 2 : : 2 ] ) NEW_LINE" ]
atcoder_abc036_C
[ "public class Main { public static void main ( String [ ] args ) { java . util . Scanner s = new java . util . Scanner ( System . in ) ; int n = s . nextInt ( ) , a [ ] = new int [ n ] ; java . util . List < Integer > list = new java . util . ArrayList < > ( java . util . stream . IntStream . range ( 0 , n ) . map ( i -> a [ i ] = s . nextInt ( ) ) . boxed ( ) . collect ( java . util . stream . Collectors . toCollection ( java . util . TreeSet :: new ) ) ) ; for ( int i : a ) System . out . println ( java . util . Collections . binarySearch ( list , i ) ) ; } }", "import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; long [ ] values = new long [ N ] ; SortedSet < Long > distincts = new TreeSet < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { values [ i ] = sc . nextLong ( ) ; distincts . add ( values [ i ] ) ; } HashMap < Long , Integer > rank = new HashMap < > ( ) ; int index = 0 ; for ( Long v : distincts ) { rank . put ( v , index ) ; index ++ ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . println ( rank . get ( values [ i ] ) ) ; } } }", "import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] a2 = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; a2 [ i ] = a [ i ] ; } Arrays . sort ( a2 ) ; int cnt = 1 ; int tmp = a2 [ 0 ] ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; map . put ( a2 [ 0 ] , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( tmp != a2 [ i ] ) { cnt ++ ; tmp = a2 [ i ] ; map . put ( a2 [ i ] , cnt - 1 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( map . get ( a [ i ] ) ) ; } sc . close ( ) ; } }", "import java . util . * ; public class Main { public static class Pair { int index ; int value ; public Pair ( int index , int value ) { this . index = index ; this . value = value ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; ArrayList < Pair > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int index = i ; int value = sc . nextInt ( ) ; Pair p = new Pair ( index , value ) ; list . add ( p ) ; } Collections . sort ( list , ( a , b ) -> a . value - b . value ) ; int before = Integer . MAX_VALUE ; int nValue = - 1 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { int tmp = list . get ( i ) . value ; if ( tmp != before ) { before = tmp ; nValue ++ ; } list . get ( i ) . value = nValue ; } Collections . sort ( list , ( a , b ) -> a . index - b . index ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { System . out . println ( list . get ( i ) . value ) ; } } }", "import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Zaatu [ ] array = new Zaatu [ n ] ; Zaatu [ ] array2 = new Zaatu [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { Zaatu z = new Zaatu ( ) ; z . a = sc . nextInt ( ) ; array [ i ] = z ; array2 [ i ] = z ; } sc . close ( ) ; Arrays . sort ( array , new Comparator < Zaatu > ( ) { public int compare ( Zaatu o1 , Zaatu o2 ) { return o1 . a - o2 . a ; } } ) ; array [ 0 ] . b = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( array [ i ] . a == array [ i - 1 ] . a ) { array [ i ] . b = array [ i - 1 ] . b ; } else { array [ i ] . b = array [ i - 1 ] . b + 1 ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( array2 [ i ] . b ) ; } } static class Zaatu { int a , b ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE A = list ( int ( input ( ) ) for i in range ( n ) ) NEW_LINE B = sorted ( list ( set ( A ) ) ) NEW_LINE C = { } NEW_LINE for i in range ( len ( B ) ) : NEW_LINE INDENT C [ B [ i ] ] = i NEW_LINE DEDENT for i in range ( len ( A ) ) : NEW_LINE INDENT print ( C [ A [ i ] ] ) NEW_LINE DEDENT", "def seat_pressure ( N : int , A : list ) -> list : NEW_LINE INDENT m = { a : i for i , a in enumerate ( sorted ( set ( A ) ) ) } NEW_LINE return [ m [ a ] for a in A ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE ans = seat_pressure ( N , A ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT", "def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE INF = 10 ** 18 NEW_LINE class Debug ( ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . debug = True NEW_LINE DEDENT def off ( self ) : NEW_LINE INDENT self . debug = False NEW_LINE DEDENT def dmp ( self , x , cmt = ' ' ) : NEW_LINE INDENT if self . debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT w = cmt + ' : ▁ ' + str ( x ) NEW_LINE DEDENT else : NEW_LINE INDENT w = str ( x ) NEW_LINE DEDENT print ( w ) NEW_LINE DEDENT return x NEW_LINE DEDENT DEDENT def prob ( ) : NEW_LINE INDENT d = Debug ( ) NEW_LINE d . off ( ) NEW_LINE N = getInt ( ) NEW_LINE d . dmp ( ( N ) , ' N ' ) NEW_LINE A = zeros ( N ) NEW_LINE adic = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT A [ i ] = getInt ( ) NEW_LINE adic [ A [ i ] ] = 0 NEW_LINE DEDENT ordered = sorted ( list ( adic . keys ( ) ) ) NEW_LINE for i in range ( len ( ordered ) ) : NEW_LINE INDENT adic [ ordered [ i ] ] = i NEW_LINE DEDENT for x in A : NEW_LINE INDENT print ( adic [ x ] ) NEW_LINE DEDENT return NEW_LINE DEDENT ans = prob ( ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE anslist = [ 0 ] * N NEW_LINE for i , j in enumerate ( a ) : NEW_LINE INDENT anslist [ i ] = [ i , j , 0 ] NEW_LINE DEDENT anslist = sorted ( anslist , key = lambda x : x [ 1 ] ) NEW_LINE tmp = anslist [ 0 ] [ 1 ] NEW_LINE cnt = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if anslist [ i ] [ 1 ] == tmp : NEW_LINE INDENT anslist [ i ] [ 2 ] = cnt NEW_LINE DEDENT else : NEW_LINE INDENT tmp = anslist [ i ] [ 1 ] NEW_LINE cnt += 1 NEW_LINE anslist [ i ] [ 2 ] = cnt NEW_LINE DEDENT DEDENT anslist = sorted ( anslist , key = lambda x : x [ 0 ] ) NEW_LINE for i in anslist : NEW_LINE INDENT print ( i [ 2 ] ) NEW_LINE DEDENT", "from collections import * ; n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; b = { v : k for ( k , v ) in enumerate ( sorted ( set ( a ) ) ) } NEW_LINE for i in a : NEW_LINE INDENT print ( b [ i ] ) NEW_LINE DEDENT" ]
atcoder_abc055_B
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long ans = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { ans *= i ; if ( ans > Math . pow ( 10 , 9 ) + 7 ) ans %= Math . pow ( 10 , 9 ) + 7 ; } System . out . println ( ( long ) ans % ( ( long ) Math . pow ( 10 , 9 ) + 7 ) ) ; } }", "import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter out = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; int m = 1000000007 ; long sum = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { sum *= i ; sum %= m ; } out . write ( String . valueOf ( sum ) ) ; out . write ( \" \\n \" ) ; out . close ( ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . MathContext ; import java . math . RoundingMode ; public class Main { private static final long DIVIDER = ( long ) Math . pow ( 10 , 9 ) + 7 ; private static final MathContext MC = new MathContext ( 0 , RoundingMode . HALF_DOWN ) ; public static void main ( String [ ] args ) { int n = 0 ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { n = Integer . parseInt ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } long quotient = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { quotient = ( quotient * i ) % DIVIDER ; } System . out . print ( quotient ) ; } }", "import java . util . * ; import java . util . stream . IntStream ; public class Main { public static boolean found = false ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long ret = 1 ; for ( int i = 0 ; i < n ; i ++ ) { ret = ( ret * ( i + 1 ) ) ; ret = ret % 1000000007 ; } System . out . println ( ret ) ; } }", "import java . math . BigDecimal ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; BigDecimal x = BigDecimal . valueOf ( 1 ) ; for ( int i = 1 ; i <= N ; i ++ ) { x = x . multiply ( BigDecimal . valueOf ( i ) ) . remainder ( BigDecimal . valueOf ( 1000000007 ) ) ; } System . out . println ( x ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE def fact ( n ) : NEW_LINE INDENT val = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT val *= i NEW_LINE val %= 1000000007 NEW_LINE DEDENT return val NEW_LINE DEDENT print ( fact ( N ) ) NEW_LINE", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT N = int ( input ( ) . rstrip ( ) ) NEW_LINE f = math . factorial ( N ) NEW_LINE print ( f % ( 10 ** 9 + 7 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE ans = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT ans *= i NEW_LINE ans = ans % MOD NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "import math NEW_LINE N = int ( input ( ) ) NEW_LINE print ( math . factorial ( N ) % 1000000007 ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE power = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT power = power * ( i + 1 ) % 1000000007 NEW_LINE power %= 1000000007 NEW_LINE DEDENT print ( power ) NEW_LINE" ]
atcoder_abc099_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( sc . nextInt ( ) < 1000 ? \" ABC \" : \" ABD \" ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n >= 1 && n <= 999 ) System . out . println ( \" ABC \" ) ; else if ( n > 999 ) System . out . println ( \" ABD \" ) ; } }", "import java . util . ArrayList ; import java . util . Collections ; import java . util . HashSet ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; System . out . println ( n > 999 ? \" ABD \" : \" ABC \" ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; System . out . println ( N < 1000 ? \" ABC \" : \" ABD \" ) ; } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; System . out . println ( n < 1000 ? \" ABC \" : \" ABD \" ) ; } }" ]
[ "a = int ( input ( ) ) NEW_LINE if a <= 999 : NEW_LINE INDENT print ( \" ABC \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" ABD \" ) NEW_LINE DEDENT", "import sys NEW_LINE import re NEW_LINE from collections import deque , defaultdict , Counter NEW_LINE from math import ceil , sqrt , hypot , factorial , pi , sin , cos , radians NEW_LINE from itertools import permutations , combinations , product NEW_LINE from operator import itemgetter , mul NEW_LINE from copy import deepcopy NEW_LINE from string import ascii_lowercase , ascii_uppercase , digits NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def INT ( ) : return int ( input ( ) ) NEW_LINE def MAP ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE n = INT ( ) NEW_LINE if n < 1000 : NEW_LINE INDENT print ( ' ABC ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' ABD ' ) NEW_LINE DEDENT", "print ( ' ABC ' if int ( input ( ) ) < 1000 else ' ABD ' ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE print ( \" ABC \" if N <= 999 else \" ABD \" ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE if ( N < 1000 ) : NEW_LINE INDENT ans = ' ABC ' NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' ABD ' NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc015_A
[ "import java . util . * ; import static java . lang . System . * ; 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 min = A * ( N - 1 ) + B ; long max = A + ( N - 1 ) * B ; out . println ( Math . max ( 0 , max - min + 1 ) ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; 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 ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AABProblem solver = new AABProblem ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AABProblem { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) , a = in . ints ( ) , b = in . ints ( ) ; long max = ( n - 1L ) * b + a ; long min = ( n - 1L ) * a + b ; out . println ( Math . max ( 0 , max - min + 1 ) ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }", "import java . io . InputStream ; import java . io . IOException ; class MyScanner { InputStream stream ; public MyScanner ( ) { stream = System . in ; } public long nextLong ( ) { long ret = 0 ; try { while ( true ) { char readed = ( char ) stream . read ( ) ; if ( readed < '0' || readed > '9' ) { break ; } ret = ret * 10 + ( readed - '0' ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { return ret ; } } } class Main { public static void main ( String args [ ] ) { MyScanner sc = new MyScanner ( ) ; long n = sc . nextLong ( ) , a = sc . nextLong ( ) , b = sc . nextLong ( ) ; long min = b + a * ( n - 1 ) ; long max = a + b * ( n - 1 ) ; if ( max < min ) { System . out . println ( 0 ) ; } else { System . out . println ( max - min + 1 ) ; } } }", "import java . util . Scanner ; import java . util . Collections ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Queue ; import java . util . ArrayDeque ; import java . util . Deque ; import java . util . PriorityQueue ; import java . util . Set ; import java . util . HashSet ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long n = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; long ans = ( b - a ) * ( n - 2 ) + 1 ; if ( a > b ) { System . out . println ( 0 ) ; } else if ( a == b ) { System . out . println ( 1 ) ; } else if ( a < b ) { if ( n >= 2 ) { System . out . println ( ans ) ; } else if ( n == 1 ) { System . out . println ( 0 ) ; } } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; long a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; if ( a > b ) { System . out . println ( 0 ) ; return ; } if ( n == 1 ) { System . out . println ( a == b ? 1 : 0 ) ; return ; } else { System . out . println ( ( long ) ( ( b - a ) * ( n - 2 ) + 1 ) ) ; } } }" ]
[ "N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if A > B : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT elif N == 1 and A != B : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( B - A ) * ( N - 2 ) + 1 ) NEW_LINE DEDENT", "import sys NEW_LINE import math NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n , a , b = LI ( ) NEW_LINE return max ( 0 , ( n - 2 ) * ( b - a ) + 1 ) NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( max ( ( ( n - 1 ) * b + a ) - ( ( n - 1 ) * a + b ) + 1 , 0 ) ) NEW_LINE", "N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if N == 1 : NEW_LINE INDENT if A == B : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A > B : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT elif A == B or N == 2 : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( B - A ) * ( N - 2 ) + 1 ) NEW_LINE DEDENT DEDENT", "N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if A > B : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT if N == 1 and A != B : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT elif N == 1 and A == B : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( ( B * ( N - 1 ) + A ) - ( A * ( N - 1 ) + B ) + 1 ) NEW_LINE" ]
atcoder_abc116_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int s = sc . nextInt ( ) ; int m = 1 ; for ( int i = 0 ; i < 10000 ; i ++ ) { if ( s == 4 || s == 2 || s == 1 ) { break ; } if ( s % 2 == 0 ) { s = s / 2 ; m = m + 1 ; } else { s = ( s * 3 ) + 1 ; m = m + 1 ; } } m = m + 3 ; System . out . println ( m ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int s = Integer . valueOf ( bf . readLine ( ) ) , m = 1 ; Set < Integer > number = new HashSet < > ( ) ; while ( true ) { if ( ! number . add ( s ) ) { break ; } if ( s % 2 > 0 ) { s = 3 * s + 1 ; } else { s /= 2 ; } m ++ ; } System . out . println ( m ) ; } }", "import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; int f ( int n ) { if ( n % 2 == 0 ) { return n / 2 ; } else { return 3 * n + 1 ; } } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int s = sc . nextInt ( ) ; int [ ] a = new int [ 1000000 ] ; a [ s ] = 1 ; int i , i_1 = s ; int n = 1 ; for ( ; ; ) { i = f ( i_1 ) ; n ++ ; if ( a [ i ] == 1 ) { out . println ( n ) ; break ; } a [ i ] = 1 ; i_1 = i ; } sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }", "import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static int f ( int a ) { if ( a % 2 == 0 ) { return a / 2 ; } else { return 3 * a + 1 ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int s = sc . nextInt ( ) ; int index ; sc . close ( ) ; ArrayList < Integer > data = new ArrayList < Integer > ( ) ; while ( true ) { index = data . indexOf ( s ) ; data . add ( s ) ; if ( index == - 1 ) { s = f ( s ) ; } else { break ; } } System . out . println ( data . size ( ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; Integer s = scan . nextInt ( ) ; List < Integer > numList = new ArrayList ( ) ; OUT : for ( int i = 1 ; ; i ++ ) { if ( i == 1 ) { numList . add ( s ) ; } Integer currentValue = null ; if ( i > 1 ) { Integer prevValue = numList . get ( i - 2 ) ; if ( prevValue % 2 == 0 ) { currentValue = prevValue / 2 ; } else { currentValue = 3 * prevValue + 1 ; } for ( Integer num : numList ) { if ( currentValue == num ) { System . out . println ( i ) ; break OUT ; } } numList . add ( currentValue ) ; } } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "s = int ( input ( ) ) NEW_LINE count = 2 NEW_LINE num = s NEW_LINE collatz_list = [ s ] NEW_LINE while True : NEW_LINE INDENT if num % 2 == 0 : NEW_LINE INDENT num = num // 2 NEW_LINE DEDENT else : NEW_LINE INDENT num = 3 * num + 1 NEW_LINE DEDENT if num in collatz_list : NEW_LINE INDENT print ( count ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT collatz_list . append ( num ) NEW_LINE count += 1 NEW_LINE DEDENT DEDENT", "s = int ( input ( ) ) NEW_LINE a = s NEW_LINE already = set ( ) NEW_LINE already . add ( a ) NEW_LINE for i in range ( 10000000 ) : NEW_LINE INDENT if a % 2 : NEW_LINE INDENT a = 3 * a + 1 NEW_LINE if { a } <= already : NEW_LINE INDENT print ( i + 2 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT already . add ( a ) NEW_LINE DEDENT else : NEW_LINE INDENT a //= 2 NEW_LINE if { a } <= already : NEW_LINE INDENT print ( i + 2 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT already . add ( a ) NEW_LINE DEDENT DEDENT", "s = int ( input ( ) ) NEW_LINE progression = [ s ] NEW_LINE n = s NEW_LINE count = 1 NEW_LINE while True : NEW_LINE INDENT count += 1 NEW_LINE if n % 2 == 0 : NEW_LINE INDENT n = n / 2 NEW_LINE DEDENT else : NEW_LINE INDENT n = 3 * n + 1 NEW_LINE DEDENT if n in progression : NEW_LINE INDENT break NEW_LINE DEDENT else : NEW_LINE INDENT progression . append ( n ) NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE", "def COL ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT return int ( n / 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT return 3 * n + 1 NEW_LINE DEDENT DEDENT s = int ( input ( ) ) NEW_LINE List = [ s ] NEW_LINE s = COL ( s ) NEW_LINE while s not in List : NEW_LINE INDENT List . append ( s ) NEW_LINE s = COL ( s ) NEW_LINE DEDENT print ( len ( List ) + 1 ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE li = [ n ] NEW_LINE x = 0 NEW_LINE i = 0 NEW_LINE while i <= 1000000 and x == 0 : NEW_LINE INDENT if li [ i ] % 2 == 0 : NEW_LINE INDENT li . append ( li [ i ] / 2 ) NEW_LINE for j in range ( i ) : NEW_LINE INDENT if li [ i + 1 ] == li [ j ] : NEW_LINE INDENT x = i + 2 NEW_LINE DEDENT else : pass NEW_LINE DEDENT i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT li . append ( 3 * li [ i ] + 1 ) NEW_LINE for j in range ( i ) : NEW_LINE INDENT if li [ i + 1 ] == li [ j ] : NEW_LINE INDENT x = i + 2 NEW_LINE DEDENT else : pass NEW_LINE DEDENT i += 1 NEW_LINE DEDENT DEDENT print ( x ) NEW_LINE" ]
atcoder_abc016_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] kankeigraph = new int [ N + 1 ] [ N + 1 ] ; int [ ] friend = new int [ 10 ] ; boolean [ ] friend_of_friend = new boolean [ 11 ] ; int friend_cnt = 0 ; for ( int i = 0 ; i <= N ; i ++ ) { for ( int j = 0 ; j <= N ; j ++ ) { kankeigraph [ i ] [ j ] = 0 ; } } for ( int i = 0 ; i < 10 ; i ++ ) { friend [ i ] = 0 ; } for ( int i = 0 ; i < M ; i ++ ) { int from = sc . nextInt ( ) ; int to = sc . nextInt ( ) ; kankeigraph [ from ] [ to ] = 1 ; kankeigraph [ to ] [ from ] = 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { friend [ j ] = 0 ; } for ( int j = 1 ; j <= 10 ; j ++ ) { friend_of_friend [ j ] = false ; } friend_cnt = 0 ; for ( int j = 1 ; j <= N ; j ++ ) { if ( kankeigraph [ i ] [ j ] == 1 ) { friend [ friend_cnt ] = j ; friend_cnt ++ ; } } for ( int j = 0 ; j < friend_cnt ; j ++ ) { for ( int k = 1 ; k <= N ; k ++ ) { if ( kankeigraph [ friend [ j ] ] [ k ] == 1 && kankeigraph [ i ] [ k ] == 0 && i != k ) { friend_of_friend [ k ] = true ; } } } int kazu = 0 ; for ( int j = 1 ; j <= N ; j ++ ) { if ( friend_of_friend [ j ] ) { kazu ++ ; } } System . out . println ( kazu ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . Set ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class C { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; List < Set < Integer > > friends = new ArrayList < > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { friends . add ( new HashSet < > ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { int a = in . nextInt ( ) - 1 , b = in . nextInt ( ) - 1 ; friends . get ( a ) . add ( b ) ; friends . get ( b ) . add ( a ) ; } for ( int i = 0 ; i < n ; i ++ ) { Set < Integer > friend = friends . get ( i ) ; Set < Integer > ff = new HashSet < > ( ) ; for ( int f : friend ) { ff . addAll ( friends . get ( f ) ) ; } ff . removeAll ( friend ) ; ff . remove ( i ) ; out . println ( ff . size ( ) ) ; } } } }", "import java . util . ArrayList ; import java . util . List ; import java . util . Map ; import java . util . function . Function ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , m = scanner . nextInt ( ) ; Map < Integer , List < Integer > > friendMap = IntStream . rangeClosed ( 1 , n ) . boxed ( ) . collect ( Collectors . toMap ( Function . identity ( ) , i -> new ArrayList < > ( ) ) ) ; for ( int i = 0 , l , r ; i < m ; i ++ ) { friendMap . get ( l = scanner . nextInt ( ) ) . add ( r = scanner . nextInt ( ) ) ; friendMap . get ( r ) . add ( l ) ; } IntStream . rangeClosed ( 1 , n ) . mapToLong ( i -> friendMap . get ( i ) . stream ( ) . flatMap ( friend -> friendMap . get ( friend ) . stream ( ) . filter ( f -> ! friendMap . get ( i ) . contains ( f ) && f != i ) ) . distinct ( ) . count ( ) ) . forEach ( System . out :: println ) ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; HashMap < Integer , List < Integer > > relations = new HashMap < Integer , List < Integer > > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; addRelations ( A , B , relations ) ; addRelations ( B , A , relations ) ; } for ( int i = 1 ; i <= N ; i ++ ) { Set < Integer > friendOfFriend = new HashSet < Integer > ( ) ; if ( relations . containsKey ( i ) ) { for ( int f : relations . get ( i ) ) { if ( relations . containsKey ( f ) ) { for ( int ff : relations . get ( f ) ) { if ( i == ff || relations . get ( i ) . contains ( ff ) ) { continue ; } friendOfFriend . add ( ff ) ; } } } } out . println ( friendOfFriend . size ( ) ) ; } } public static void addRelations ( int A , int B , HashMap < Integer , List < Integer > > relations ) { List < Integer > list = new ArrayList < Integer > ( ) ; if ( relations . containsKey ( A ) ) { list = relations . get ( A ) ; } list . add ( B ) ; relations . put ( A , list ) ; } }", "import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] [ ] d = new int [ n + 1 ] [ n + 1 ] ; int inf = 100 ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { d [ i ] [ j ] = inf ; } } for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; d [ a ] [ b ] = d [ b ] [ a ] = 1 ; } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { for ( int k = 1 ; k <= n ; k ++ ) { if ( d [ j ] [ k ] > d [ j ] [ i ] + d [ i ] [ k ] ) { d [ j ] [ k ] = d [ j ] [ i ] + d [ i ] [ k ] ; } } } } for ( int i = 1 ; i <= n ; i ++ ) { int ans = 0 ; for ( int j = 1 ; j <= n ; j ++ ) { if ( j != i && d [ i ] [ j ] == 2 ) { ans ++ ; } } out . println ( ans ) ; } } }" ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE d = [ [ ] for i in range ( n ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE d [ a - 1 ] . append ( b - 1 ) NEW_LINE d [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT c = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT for h in range ( n ) : NEW_LINE INDENT if i != j : NEW_LINE INDENT if j not in d [ i ] : NEW_LINE INDENT if h in d [ i ] : NEW_LINE INDENT if j in d [ h ] : NEW_LINE INDENT c += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( c ) NEW_LINE c = 0 NEW_LINE DEDENT DEDENT", "from collections import defaultdict NEW_LINE class Graph ( object ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . graph = defaultdict ( list ) NEW_LINE DEDENT def __len__ ( self ) : NEW_LINE INDENT return len ( self . graph ) NEW_LINE DEDENT def add_edge ( self , src , dst ) : NEW_LINE INDENT self . graph [ src ] . append ( dst ) NEW_LINE self . graph [ dst ] . append ( src ) NEW_LINE DEDENT DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE friends = Graph ( ) NEW_LINE for m in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE friends . add_edge ( a , b ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT nums = [ ] NEW_LINE for j in friends . graph [ i + 1 ] : NEW_LINE INDENT for k in friends . graph [ j ] : NEW_LINE INDENT if k not in friends . graph [ i + 1 ] : NEW_LINE INDENT nums . append ( k ) NEW_LINE DEDENT DEDENT DEDENT nums = set ( nums ) NEW_LINE if i + 1 in nums : NEW_LINE INDENT nums . remove ( i + 1 ) NEW_LINE DEDENT print ( len ( nums ) ) NEW_LINE DEDENT", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE inf = 10 ** 18 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE AB = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( M ) ] NEW_LINE net = [ [ False ] * N for _ in range ( N ) ] NEW_LINE for Ai , Bi in AB : NEW_LINE INDENT net [ Ai - 1 ] [ Bi - 1 ] = True NEW_LINE net [ Bi - 1 ] [ Ai - 1 ] = True NEW_LINE DEDENT for p in range ( N ) : NEW_LINE INDENT net2 = [ False ] * N NEW_LINE for q in filter ( lambda x : net [ p ] [ x ] , range ( N ) ) : NEW_LINE INDENT if q == p : continue NEW_LINE for r in filter ( lambda x : net [ q ] [ x ] , range ( N ) ) : NEW_LINE INDENT if r == p : continue NEW_LINE if net [ p ] [ r ] : continue NEW_LINE net2 [ r ] = True NEW_LINE DEDENT DEDENT print ( sum ( net2 ) ) NEW_LINE DEDENT", "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE d = [ [ float ( \" inf \" ) ] * n for i in range ( n ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE a -= 1 NEW_LINE b -= 1 NEW_LINE d [ a ] [ b ] = 1 NEW_LINE d [ b ] [ a ] = 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT for k in range ( n ) : NEW_LINE INDENT d [ i ] [ j ] = min ( d [ i ] [ j ] , d [ i ] [ k ] + d [ k ] [ j ] ) NEW_LINE DEDENT DEDENT DEDENT for i in d : NEW_LINE INDENT print ( max ( 0 , i . count ( 2 ) - 1 ) ) NEW_LINE DEDENT", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( M ) ] NEW_LINE dist = [ [ 10 ** 5 for _ in range ( N ) ] for _ in range ( N ) ] NEW_LINE res = [ 0 for _ in range ( N ) ] NEW_LINE def warshall_floyd ( d , V ) : NEW_LINE INDENT for k in range ( V ) : NEW_LINE INDENT for i in range ( V ) : NEW_LINE INDENT for j in range ( V ) : NEW_LINE INDENT d [ i ] [ j ] = min ( d [ i ] [ j ] , d [ i ] [ k ] + d [ k ] [ j ] ) NEW_LINE DEDENT DEDENT DEDENT return d NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT A [ i ] [ 0 ] -= 1 NEW_LINE A [ i ] [ 1 ] -= 1 NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if i == j : NEW_LINE INDENT dist [ i ] [ j ] = 0 NEW_LINE DEDENT DEDENT DEDENT for i in range ( M ) : NEW_LINE INDENT dist [ A [ i ] [ 0 ] ] [ A [ i ] [ 1 ] ] = 1 NEW_LINE dist [ A [ i ] [ 1 ] ] [ A [ i ] [ 0 ] ] = 1 NEW_LINE DEDENT distance = warshall_floyd ( dist , N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if distance [ i ] [ j ] == 2 : NEW_LINE INDENT res [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( N ) : NEW_LINE INDENT print ( res [ i ] ) NEW_LINE DEDENT" ]
atcoder_abc030_A
[ "import java . util . Scanner ; public class Main { 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 ( ) ; if ( a / b > c / d ) { System . out . println ( \" AOKI \" ) ; } else if ( a / b == c / d ) { System . out . println ( \" DRAW \" ) ; } else { System . out . println ( \" TAKAHASHI \" ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { double t = in . nextDouble ( ) / in . nextDouble ( ) ; double a = in . nextDouble ( ) / in . nextDouble ( ) ; if ( a == t ) out . println ( \" DRAW \" ) ; else out . println ( t < a ? \" TAKAHASHI \" : \" AOKI \" ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { double a = sc . nextDouble ( ) , b = sc . nextDouble ( ) , c = sc . nextDouble ( ) , d = sc . nextDouble ( ) ; out . println ( b / a > d / c ? \" TAKAHASHI \" : b / a == d / c ? \" DRAW \" : \" AOKI \" ) ; } }", "import java . util . Scanner ; public class Main { private static final String TEAM_A = \" TAKAHASHI \" ; private static final String TEAM_B = \" AOKI \" ; private static final String DRAW = \" DRAW \" ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double a = sc . nextDouble ( ) ; double b = sc . nextDouble ( ) ; double c = sc . nextDouble ( ) ; double d = sc . nextDouble ( ) ; sc . close ( ) ; double perVicA = b / a ; double perVicB = d / c ; if ( perVicA == perVicB ) { System . out . println ( DRAW ) ; } else if ( perVicA > perVicB ) { System . out . println ( TEAM_A ) ; } else { System . out . println ( TEAM_B ) ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { double A = in . nextInt ( ) ; double B = in . nextInt ( ) ; double C = in . nextInt ( ) ; double D = in . nextInt ( ) ; if ( B / A > D / C ) { out . println ( \" TAKAHASHI \" ) ; } else if ( B / A < D / C ) { out . println ( \" AOKI \" ) ; } else { out . println ( \" DRAW \" ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }" ]
[ "a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE if c * b == a * d : NEW_LINE INDENT print ( ' DRAW ' ) NEW_LINE DEDENT elif c * b > a * d : NEW_LINE INDENT print ( ' TAKAHASHI ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' AOKI ' ) NEW_LINE DEDENT", "def win_rate ( A : int , B : int , C : int , D : int ) -> str : NEW_LINE INDENT if B * C < A * D : NEW_LINE INDENT return ' AOKI ' NEW_LINE DEDENT if B * C > A * D : NEW_LINE INDENT return ' TAKAHASHI ' NEW_LINE DEDENT return ' DRAW ' NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE ans = win_rate ( A , B , C , D ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "ia , ib , ic , id = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if ib / ia == id / ic : NEW_LINE INDENT print ( \" DRAW \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" TAKAHASHI \" if ib / ia > id / ic else \" AOKI \" ) NEW_LINE DEDENT", "x = input ( ) NEW_LINE takahashi = float ( x . split ( ' ▁ ' ) [ 1 ] ) / float ( x . split ( ' ▁ ' ) [ 0 ] ) NEW_LINE aoki = float ( x . split ( ' ▁ ' ) [ 3 ] ) / float ( x . split ( ' ▁ ' ) [ 2 ] ) NEW_LINE if takahashi == aoki : NEW_LINE INDENT print ( ' DRAW ' ) NEW_LINE DEDENT elif takahashi > aoki : NEW_LINE INDENT print ( ' TAKAHASHI ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' AOKI ' ) NEW_LINE DEDENT", "a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE x = b / a NEW_LINE y = d / c NEW_LINE print ( \" TAKAHASHI \" if x > y else \" DRAW \" if x == y else \" AOKI \" ) NEW_LINE" ]
atcoder_abc075_C
[ "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 ( ) ; int m = sc . nextInt ( ) ; ArrayList < DJSet > ds = new ArrayList < DJSet > ( ) ; for ( int i = 0 ; i < m ; i ++ ) ds . add ( new DJSet ( n ) ) ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; for ( int j = 0 ; j < m ; j ++ ) { if ( i != j ) ds . get ( j ) . union ( a , b ) ; } } int ans = 0 ; for ( int i = 0 ; i < m ; i ++ ) { if ( ds . get ( i ) . countSet ( ) != 1 ) ans ++ ; } System . out . println ( ans ) ; sc . close ( ) ; } } class DJSet { public int [ ] upper ; public DJSet ( int n ) { upper = new int [ n ] ; Arrays . fill ( upper , - 1 ) ; } public int root ( int x ) { return upper [ x ] < 0 ? x : ( upper [ x ] = root ( upper [ x ] ) ) ; } public boolean same ( int x , int y ) { return root ( x ) == root ( y ) ; } public boolean union ( int x , int y ) { x = root ( x ) ; y = root ( y ) ; if ( x != y ) { if ( upper [ y ] < upper [ x ] ) { int t = x ; x = y ; y = t ; } upper [ x ] += upper [ y ] ; upper [ y ] = x ; } return x != y ; } public int countSet ( ) { int c = 0 ; for ( int u : upper ) { if ( u < 0 ) c ++ ; } return c ; } public int countElement ( int x ) { return upper [ root ( x ) ] * - 1 ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; boolean [ ] [ ] edges = new boolean [ N ] [ N ] ; for ( int m = 0 ; m < M ; m ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; edges [ a - 1 ] [ b - 1 ] = true ; edges [ b - 1 ] [ a - 1 ] = true ; } solver ( N , edges ) ; } public static void solver ( int N , boolean [ ] [ ] edges ) { Set < Integer > left_nodes = new HashSet < Integer > ( ) ; for ( int n = 0 ; n < N ; n ++ ) { left_nodes . add ( n ) ; } int ans = 0 ; int before_ans = ans + 1 ; while ( ans != before_ans ) { before_ans = ans ; HashMap < Integer , Integer > bridgeable_nodes = new HashMap < Integer , Integer > ( ) ; for ( Integer from : left_nodes ) { ArrayList < Integer > bridge_nodes = new ArrayList < Integer > ( ) ; for ( int to = 0 ; to < N ; to ++ ) { if ( edges [ from ] [ to ] == true ) { bridge_nodes . add ( to ) ; } } if ( bridge_nodes . size ( ) == 1 ) { bridgeable_nodes . put ( from , bridge_nodes . get ( 0 ) ) ; } } for ( Integer from : bridgeable_nodes . keySet ( ) ) { int to = bridgeable_nodes . get ( from ) ; left_nodes . remove ( from ) ; if ( edges [ from ] [ to ] == false ) { continue ; } edges [ from ] [ to ] = false ; edges [ to ] [ from ] = false ; ans ++ ; } } out . println ( ans ) ; } }", "import java . util . * ; public class Main { static ArrayList < Integer > [ ] lists ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; lists = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { lists [ i ] = new ArrayList < Integer > ( ) ; } int [ ] a = new int [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; lists [ a [ i ] ] . add ( b [ i ] ) ; lists [ b [ i ] ] . add ( a [ i ] ) ; } int count = 0 ; for ( int i = 0 ; i < m ; i ++ ) { boolean [ ] test = new boolean [ n + 1 ] ; Arrays . fill ( test , false ) ; search ( 1 , a [ i ] , b [ i ] , test ) ; if ( ! isAllTrue ( test ) ) { count ++ ; } } System . out . print ( count ) ; } static void search ( int idx , int a , int b , boolean [ ] test ) { for ( int i : lists [ idx ] ) { if ( ! test [ i ] && ! ( ( a == i && b == idx ) || ( a == idx && b == i ) ) ) { test [ i ] = true ; search ( i , a , b , test ) ; } } } static boolean isAllTrue ( boolean [ ] bs ) { for ( int i = 1 ; i < bs . length ; i ++ ) { if ( ! bs [ i ] ) { return false ; } } return true ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . Arrays ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; private static int n ; private static boolean [ ] visited ; private static boolean [ ] [ ] graph ; public static void main ( String [ ] args ) { n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; int [ ] a = new int [ m ] , b = new int [ m ] ; graph = new boolean [ n ] [ n ] ; visited = new boolean [ n ] ; for ( int i = 0 ; i < m ; i ++ ) graph [ a [ i ] = scanner . nextInt ( ) - 1 ] [ b [ i ] = scanner . nextInt ( ) - 1 ] = graph [ b [ i ] ] [ a [ i ] ] = true ; int ans = 0 ; for ( int i = 0 ; i < m ; i ++ ) { graph [ a [ i ] ] [ b [ i ] ] = graph [ b [ i ] ] [ a [ i ] ] = false ; Arrays . fill ( visited , false ) ; dfs ( 0 ) ; if ( IntStream . range ( 0 , n ) . anyMatch ( j -> ! visited [ j ] ) ) ans ++ ; graph [ a [ i ] ] [ b [ i ] ] = graph [ b [ i ] ] [ a [ i ] ] = true ; } System . out . println ( ans ) ; } private static void dfs ( int v ) { visited [ v ] = true ; for ( int v2 = 0 ; v2 < n ; v2 ++ ) if ( graph [ v ] [ v2 ] && ! visited [ v2 ] ) dfs ( v2 ) ; } }", "import java . util . * ; import java . lang . * ; public class Main { 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 ] ; int [ ] b = new int [ m ] ; int [ ] count = new int [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; count [ a [ i ] ] ++ ; count [ b [ i ] ] ++ ; } int ans = 0 ; boolean bre = true ; while ( bre ) { bre = false ; out : for ( int i = 0 ; i <= n ; i ++ ) { if ( count [ i ] == 1 ) { count [ i ] -- ; ans ++ ; for ( int j = 0 ; j < m ; j ++ ) { if ( a [ j ] == i ) { count [ b [ j ] ] -- ; a [ j ] = 0 ; b [ j ] = 0 ; bre = true ; break out ; } else if ( b [ j ] == i ) { count [ a [ j ] ] -- ; a [ j ] = 0 ; b [ j ] = 0 ; bre = true ; break out ; } } } } } System . out . println ( ans ) ; } }" ]
[ "n , m = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE edge = [ [ 0 ] * n for _ in range ( n ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE edge [ a - 1 ] [ b - 1 ] = 1 NEW_LINE edge [ b - 1 ] [ a - 1 ] = 1 NEW_LINE DEDENT ans = 0 NEW_LINE order = 0 NEW_LINE pre = [ - 1 ] * n NEW_LINE low = [ - 1 ] * n NEW_LINE def dfs ( node , prev ) : NEW_LINE INDENT global order , ans NEW_LINE pre [ node ] = order NEW_LINE low [ node ] = order NEW_LINE order += 1 NEW_LINE for to in range ( n ) : NEW_LINE INDENT if to == prev or edge [ node ] [ to ] == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if pre [ to ] == - 1 : NEW_LINE INDENT ret = dfs ( to , node ) NEW_LINE low [ node ] = min ( low [ node ] , ret ) NEW_LINE DEDENT else : NEW_LINE INDENT low [ node ] = min ( low [ node ] , pre [ to ] ) NEW_LINE DEDENT if pre [ node ] < low [ to ] : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT return low [ node ] NEW_LINE DEDENT dfs ( 0 , - 1 ) NEW_LINE print ( ans ) NEW_LINE", "class UnionFind ( object ) : NEW_LINE INDENT def __init__ ( self , num ) : NEW_LINE INDENT self . parent = [ - 1 for i in range ( num + 1 ) ] NEW_LINE DEDENT def find ( self , x ) : NEW_LINE INDENT if self . parent [ x ] < 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT self . parent [ x ] = self . find ( self . parent [ x ] ) NEW_LINE return self . parent [ x ] NEW_LINE DEDENT DEDENT def unite ( self , x , y ) : NEW_LINE INDENT x = self . find ( x ) NEW_LINE y = self . find ( y ) NEW_LINE if x == y : NEW_LINE INDENT return NEW_LINE DEDENT if self . size ( x ) > self . size ( y ) : NEW_LINE INDENT self . parent [ x ] += self . parent [ y ] NEW_LINE self . parent [ y ] = x NEW_LINE DEDENT else : NEW_LINE INDENT self . parent [ y ] += self . parent [ x ] NEW_LINE self . parent [ x ] = y NEW_LINE DEDENT DEDENT def size ( self , x ) : NEW_LINE INDENT return - self . parent [ self . find ( x ) ] NEW_LINE DEDENT def same ( self , x , y ) : NEW_LINE INDENT return self . find ( x ) == self . find ( y ) NEW_LINE DEDENT DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE lis = [ ] NEW_LINE count = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT lis . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT u = UnionFind ( n ) NEW_LINE for j in range ( m ) : NEW_LINE INDENT if i == j : NEW_LINE INDENT continue NEW_LINE DEDENT u . unite ( lis [ j ] [ 0 ] , lis [ j ] [ 1 ] ) NEW_LINE DEDENT if not u . same ( lis [ i ] [ 0 ] , lis [ i ] [ 1 ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE", "import numpy as np NEW_LINE import queue NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE V = np . zeros ( ( n + 1 , n + 1 ) , dtype = bool ) NEW_LINE E = [ ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE V [ a ] [ b ] = True NEW_LINE V [ b ] [ a ] = True NEW_LINE E . append ( ( a , b ) ) NEW_LINE DEDENT def BFS ( x , y ) : NEW_LINE INDENT mark = [ False ] * ( n + 1 ) NEW_LINE q = queue . Queue ( ) NEW_LINE q . put ( x ) NEW_LINE while not q . empty ( ) : NEW_LINE INDENT p = q . get ( ) NEW_LINE if p == y : NEW_LINE INDENT return True NEW_LINE DEDENT mark [ p ] = True NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if V [ p ] [ i ] and not mark [ i ] : NEW_LINE INDENT q . put ( i ) NEW_LINE DEDENT DEDENT DEDENT return False NEW_LINE DEDENT res = 0 NEW_LINE for a , b in E : NEW_LINE INDENT V [ a ] [ b ] = False NEW_LINE V [ b ] [ a ] = False NEW_LINE if not BFS ( a , b ) : NEW_LINE INDENT res += 1 NEW_LINE DEDENT V [ a ] [ b ] = True NEW_LINE V [ b ] [ a ] = True NEW_LINE DEDENT print ( res ) NEW_LINE", "n , m = [ int ( val ) for val in input ( ) . split ( ) ] NEW_LINE matrix = [ [ int ( val ) for val in input ( ) . split ( ) ] for val in range ( m ) ] NEW_LINE ee = [ [ val [ 0 ] - 1 , val [ 1 ] - 1 ] for val in matrix ] NEW_LINE cnt = 0 NEW_LINE k = 0 NEW_LINE for L in range ( m ) : NEW_LINE INDENT xx = [ i for i in range ( n ) ] NEW_LINE for j in range ( m ) : NEW_LINE INDENT if j != k : NEW_LINE INDENT val1 = xx [ ee [ j ] [ 1 ] ] NEW_LINE val2 = xx [ ee [ j ] [ 0 ] ] NEW_LINE for i in range ( len ( xx ) ) : NEW_LINE INDENT if xx [ i ] == val1 : NEW_LINE INDENT xx [ i ] = val2 NEW_LINE DEDENT DEDENT DEDENT DEDENT if len ( set ( xx ) ) > 1 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT k += 1 NEW_LINE DEDENT print ( cnt ) NEW_LINE", "import sys NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE vertex = [ [ int ( i ) for i in l . split ( ) ] for l in sys . stdin ] NEW_LINE def find ( x ) : NEW_LINE INDENT if root [ x ] == x : NEW_LINE INDENT return x NEW_LINE DEDENT root [ x ] = find ( root [ x ] ) NEW_LINE return root [ x ] NEW_LINE DEDENT def check ( x , y ) : NEW_LINE INDENT return find ( x ) == find ( y ) NEW_LINE DEDENT def union ( x , y ) : NEW_LINE INDENT x = find ( x ) NEW_LINE y = find ( y ) NEW_LINE if size [ x ] >= size [ y ] : NEW_LINE INDENT root [ y ] = x NEW_LINE DEDENT else : NEW_LINE INDENT root [ x ] = y NEW_LINE DEDENT if size [ x ] == size [ y ] : NEW_LINE INDENT size [ x ] += 1 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT root = [ i for i in range ( n + 1 ) ] NEW_LINE size = [ 0 ] * ( n + 1 ) NEW_LINE for j in range ( m ) : NEW_LINE INDENT if j != i : NEW_LINE INDENT if check ( vertex [ j ] [ 0 ] , vertex [ j ] [ 1 ] ) : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT union ( vertex [ j ] [ 0 ] , vertex [ j ] [ 1 ] ) NEW_LINE DEDENT DEDENT DEDENT for j in range ( 1 , n ) : NEW_LINE INDENT if check ( j , j + 1 ) == True : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc001_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int vv ; int input1 = scanner . nextInt ( ) ; if ( input1 < 100 ) { vv = 0 ; } else if ( input1 >= 100 && input1 <= 5000 ) { vv = input1 * 10 / 1000 ; } else if ( input1 >= 6000 && input1 <= 30000 ) { vv = ( input1 / 1000 ) + 50 ; } else if ( input1 >= 35000 && input1 <= 70000 ) { vv = ( ( ( input1 / 1000 ) - 30 ) / 5 ) + 80 ; } else if ( input1 > 70000 ) { vv = 89 ; } else { throw new RuntimeException ( \" Unnexpected ▁ input : ▁ \" + input1 ) ; } System . out . printf ( \" % 02d \\n \" , vv ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { while ( sc . hasNextInt ( ) ) { int a = Integer . parseInt ( sc . nextLine ( ) ) ; int VV = 0 ; if ( a >= 100 && a <= 5000 ) { VV = a * 10 ; } else if ( a >= 6000 && a <= 30000 ) { VV = a + 50000 ; } else if ( a >= 35000 && a <= 70000 ) { VV = ( a - 30000 ) / 5 + 80000 ; } else if ( a > 70000 ) { VV = 89000 ; } System . out . println ( String . format ( \" % 02d \" , VV / 1000 ) ) ; } } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveB ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numH1 = 0 ; int numH2 = 0 ; try { scanner = new Scanner ( System . in ) ; numH1 = scanner . nextInt ( ) ; numH2 = scanner . nextInt ( ) ; System . out . println ( numH1 - numH2 ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numM = 0 ; try { scanner = new Scanner ( System . in ) ; numM = scanner . nextInt ( ) ; int vv = 0 ; if ( numM < 100 ) { vv = 0 ; } else if ( numM <= 5000 ) { vv = numM / 100 ; } else if ( numM <= 30000 ) { vv = numM / 1000 + 50 ; } else if ( numM <= 70000 ) { vv = ( numM / 1000 - 30 ) / 5 + 80 ; } else { vv = 89 ; } System . out . printf ( \" % 02d % n \" , vv ) ; ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double m = sc . nextDouble ( ) ; double M = m / 1000.0 ; if ( M < 0.1 ) { System . out . println ( \"00\" ) ; } else if ( 0.1 <= M && M <= 5 ) { int ans = ( int ) ( M * 10 ) ; if ( ans <= 9 ) System . out . println ( \"0\" + ans ) ; else System . out . println ( ans ) ; } else if ( 6 <= M && M <= 30 ) { System . out . println ( ( int ) M + 50 ) ; } else if ( 35 <= M && M <= 70 ) { System . out . println ( ( ( int ) M - 30 ) / 5 + 80 ) ; } else if ( 70 < M ) { System . out . println ( 89 ) ; } } }", "import java . util . * ; import java . util . List ; import java . util . ArrayList ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int H1 = scanner . nextInt ( ) ; int H2 = scanner . nextInt ( ) ; System . out . println ( H1 - H2 ) ; } }" ]
[ "m = int ( input ( ) ) NEW_LINE if m < 100 : NEW_LINE INDENT ans = \"00\" NEW_LINE DEDENT elif m <= 5000 : NEW_LINE INDENT if m < 1000 : NEW_LINE INDENT ans = \"0\" + str ( m // 100 ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = int ( m / 100 ) NEW_LINE DEDENT DEDENT elif m <= 30000 : NEW_LINE INDENT ans = int ( m / 1000 ) + 50 NEW_LINE DEDENT elif m <= 70000 : NEW_LINE INDENT ans = ( ( int ( m / 1000 ) - 30 ) // 5 ) + 80 NEW_LINE DEDENT else : NEW_LINE INDENT ans = 89 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import math NEW_LINE m = int ( input ( ) ) / 1000 NEW_LINE if m < 0.1 : NEW_LINE INDENT print ( \"00\" ) NEW_LINE DEDENT elif m >= 0.1 and m <= 5 : NEW_LINE INDENT if m >= 1.0 : NEW_LINE INDENT print ( math . floor ( m * 10 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \"0\" + str ( math . floor ( m * 10 ) ) ) NEW_LINE DEDENT DEDENT elif m >= 6 and m <= 30 : NEW_LINE INDENT print ( math . floor ( m + 50 ) ) NEW_LINE DEDENT elif m >= 35 and m <= 70 : NEW_LINE INDENT print ( math . floor ( ( m - 30 ) / 5 + 80 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 89 ) NEW_LINE DEDENT", "hi = int ( input ( ) ) NEW_LINE if ( hi < 100 ) : NEW_LINE INDENT print ( \" { 0:02d } \" . format ( 0 ) ) NEW_LINE DEDENT elif ( hi >= 100 and hi <= 5000 ) : NEW_LINE INDENT print ( \" { 0:02d } \" . format ( int ( hi / 100 ) ) ) NEW_LINE DEDENT elif ( hi >= 6000 and hi <= 30000 ) : NEW_LINE INDENT print ( \" { 0:02d } \" . format ( int ( hi / 1000 + 50 ) ) ) NEW_LINE DEDENT elif ( hi >= 35000 and hi <= 70000 ) : NEW_LINE INDENT print ( \" { 0:02d } \" . format ( int ( ( hi / 1000 - 30 ) / 5 + 80 ) ) ) NEW_LINE DEDENT elif ( hi > 70000 ) : NEW_LINE INDENT print ( \" { 0:02d } \" . format ( 89 ) ) NEW_LINE DEDENT", "import sys NEW_LINE m = int ( sys . stdin . readline ( ) ) NEW_LINE ans = 0 NEW_LINE if 100 <= m <= 5000 : NEW_LINE INDENT ans = m / 100 NEW_LINE DEDENT elif 6000 <= m <= 30000 : NEW_LINE INDENT ans = m / 1000 + 50 NEW_LINE DEDENT elif 35000 <= m <= 70000 : NEW_LINE INDENT ans = ( m / 1000 - 30 ) / 5 + 80 NEW_LINE DEDENT elif 70000 <= m : NEW_LINE INDENT ans = 89 NEW_LINE DEDENT ans = int ( ans ) NEW_LINE print ( \" { :02 } \" . format ( ans ) ) NEW_LINE", "m = float ( input ( ) ) NEW_LINE km = m / 1000 NEW_LINE VV = 0 NEW_LINE if 0.1 <= km <= 5 : NEW_LINE INDENT VV = str ( int ( km * 10 ) ) NEW_LINE if len ( VV ) == 1 : NEW_LINE INDENT print ( 0 , int ( VV ) , sep = \" \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( km * 10 ) ) NEW_LINE DEDENT DEDENT if 6 <= km <= 30 : NEW_LINE INDENT print ( int ( km + 50 ) ) NEW_LINE DEDENT if 35 <= km <= 70 : NEW_LINE INDENT print ( int ( ( ( km - 30 ) / 5 ) + 80 ) ) NEW_LINE DEDENT if km > 70 : NEW_LINE INDENT print ( 89 ) NEW_LINE DEDENT if km < 0.1 : NEW_LINE INDENT print ( 0 , 0 , sep = \" \" ) NEW_LINE DEDENT" ]
atcoder_arc022_A
[ "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; boolean flag1 = false ; boolean flag2 = false ; boolean flag3 = false ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == ' i ' || S . charAt ( i ) == ' I ' ) { flag1 = true ; } if ( flag1 == true && ( S . charAt ( i ) == ' c ' || S . charAt ( i ) == ' C ' ) ) { flag2 = true ; } if ( flag2 == true && ( S . charAt ( i ) == ' t ' || S . charAt ( i ) == ' T ' ) ) { flag3 = true ; } } if ( flag3 ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; char [ ] ICT = { ' I ' , ' C ' , ' T ' } ; int p = 0 ; for ( int i = 0 ; i < s . length ( ) && p < 3 ; i ++ ) { if ( Character . toUpperCase ( s . charAt ( i ) ) == ICT [ p ] ) p ++ ; } out . println ( p == 3 ? \" YES \" : \" NO \" ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }", "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( s . next ( ) . toLowerCase ( ) . matches ( \" ^ . * i . * c . * t . * $ \" ) ? \" YES \" : \" NO \" ) ; } }", "import java . io . * ; import java . math . * ; import java . text . * ; import java . util . * ; import java . util . regex . * ; public class Main { private static final Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = scan . nextLine ( ) ; List < Character > list = new ArrayList < > ( ) ; list . add ( ' I ' ) ; list . add ( ' C ' ) ; list . add ( ' T ' ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == list . get ( 0 ) || s . charAt ( i ) == list . get ( 0 ) - ' A ' + ' a ' ) { list . remove ( 0 ) ; if ( list . size ( ) == 0 ) { System . out . println ( \" YES \" ) ; return ; } } } System . out . println ( \" NO \" ) ; } }", "import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; String s = sc . next ( ) ; int I = - 1 , C = - 1 , T = - 1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( I == - 1 && ( s . charAt ( i ) == ' I ' || s . charAt ( i ) == ' i ' ) ) I = i ; } for ( int i = s . length ( ) - 1 ; i > - 1 ; i -- ) { if ( T == - 1 && ( s . charAt ( i ) == ' T ' || s . charAt ( i ) == ' t ' ) ) T = i ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' C ' || s . charAt ( i ) == ' c ' ) { if ( I != - 1 && T != - 1 ) { if ( I < i && i < T ) { out . println ( \" YES \" ) ; exit ( 0 ) ; } } } } out . println ( \" NO \" ) ; } }" ]
[ "s = input ( ) NEW_LINE d = \" ICT \" NEW_LINE e = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if e < 3 : NEW_LINE INDENT if d [ e ] == str . upper ( s [ i ] ) : NEW_LINE INDENT e += 1 NEW_LINE DEDENT DEDENT DEDENT print ( \" NO \" if e != 3 else \" YES \" ) NEW_LINE", "S = [ str ( _ ) . upper ( ) for _ in input ( ) ] NEW_LINE N = len ( S ) NEW_LINE flag = False NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] == \" I \" : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT flag = False NEW_LINE for j in range ( i + 1 , N ) : NEW_LINE INDENT if S [ j ] == \" C \" : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if flag : NEW_LINE INDENT flag = False NEW_LINE for k in range ( j + 1 , N ) : NEW_LINE INDENT if S [ k ] == \" T \" : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( \" YES \" if flag else \" NO \" ) NEW_LINE", "s = input ( ) NEW_LINE I = [ ] NEW_LINE C = [ ] NEW_LINE T = [ ] NEW_LINE for j in range ( len ( s ) ) : NEW_LINE INDENT if s [ j ] == ' I ' or s [ j ] == ' i ' : NEW_LINE INDENT I . append ( j ) NEW_LINE DEDENT elif s [ j ] == ' C ' or s [ j ] == ' c ' : NEW_LINE INDENT C . append ( j ) NEW_LINE DEDENT elif s [ j ] == ' T ' or s [ j ] == ' t ' : NEW_LINE INDENT T . append ( j ) NEW_LINE DEDENT else : NEW_LINE INDENT None NEW_LINE DEDENT DEDENT flag = False NEW_LINE I . sort ( ) NEW_LINE C . sort ( ) NEW_LINE T . sort ( ) NEW_LINE if len ( I ) == 0 or len ( C ) == 0 or len ( T ) == 0 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( len ( I ) ) : NEW_LINE INDENT for j in range ( len ( C ) ) : NEW_LINE INDENT if I [ i ] < C [ j ] < T [ len ( T ) - 1 ] : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT None NEW_LINE DEDENT DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT DEDENT", "S = input ( ) NEW_LINE res = ' NO ' NEW_LINE tmp = 0 NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if ( S [ i ] == ' I ' or S [ i ] == ' i ' ) and tmp == 0 : NEW_LINE INDENT tmp += 1 NEW_LINE DEDENT if ( S [ i ] == ' C ' or S [ i ] == ' c ' ) and tmp == 1 : NEW_LINE INDENT tmp += 1 NEW_LINE DEDENT if ( S [ i ] == ' T ' or S [ i ] == ' t ' ) and tmp == 2 : NEW_LINE INDENT res = ' YES ' NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE", "def ans ( ) : NEW_LINE INDENT S = input ( ) . lower ( ) NEW_LINE f = 0 NEW_LINE for s in S : NEW_LINE INDENT if ( s == \" i \" and f == 0 ) : NEW_LINE INDENT f = 1 NEW_LINE DEDENT if ( s == \" c \" and f == 1 ) : NEW_LINE INDENT f = 2 NEW_LINE DEDENT if ( s == \" t \" and f == 2 ) : NEW_LINE INDENT f = 3 NEW_LINE DEDENT DEDENT if ( f == 3 ) : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT DEDENT ans ( ) NEW_LINE" ]
atcoder_abc100_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a = sc . nextInt ( ) ; while ( a % 2 == 0 ) { a /= 2 ; ans ++ ; } } sc . close ( ) ; System . out . println ( ans ) ; } }", "import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; while ( x % 2 == 0 ) { c ++ ; x /= 2 ; } } out . println ( c ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( \" End ▁ of ▁ Input \" ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayDeque ; import java . util . Queue ; public class Main { public static void main ( String args [ ] ) throws Exception { Input input = new Input ( ) ; final Data l = input . readLine ( ) ; Queue < Integer > q = input . getColQueue ( ) ; input . close ( ) ; int ans = 0 ; while ( ! q . isEmpty ( ) ) { int d = q . poll ( ) ; while ( d % 2 == 0 ) { ans ++ ; d /= 2 ; } } System . out . println ( ans ) ; } static class Input { public BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public void close ( ) throws Exception { input . close ( ) ; } public Data readLine ( ) throws Exception { return new Data ( input . readLine ( ) . split ( \" ▁ \" ) ) ; } public Queue < Data > getDataQueue ( int num ) throws Exception { Queue < Data > q ; q = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < num ; i ++ ) { q . offer ( readLine ( ) ) ; } return q ; } public Queue < Integer > getColQueue ( ) throws Exception { Data d = readLine ( ) ; Queue < Integer > q ; q = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < d . col . length ; i ++ ) { q . offer ( d . col [ i ] ) ; } return q ; } } static class Data { public int [ ] col ; public Data ( String [ ] values ) { col = new int [ values . length ] ; for ( int i = 0 ; i < values . length ; i ++ ) { col [ i ] = Integer . parseInt ( values [ i ] ) ; } } } }", "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( java . util . stream . Stream . generate ( ( ) -> null ) . limit ( scanner . nextInt ( ) ) . mapToInt ( n -> ( int ) ( Math . log ( Integer . lowestOneBit ( scanner . nextInt ( ) ) ) / Math . log ( 2 ) ) ) . sum ( ) ) ; } }", "import java . util . Scanner ; import java . util . Collections ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Queue ; import java . util . ArrayDeque ; import java . util . Deque ; import java . util . PriorityQueue ; import java . util . Set ; import java . util . HashMap ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; long [ ] a = new long [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextLong ( ) ; while ( a [ i ] % 2 == 0 ) { a [ i ] /= 2 ; count ++ ; } } System . out . println ( count ) ; } public static int upperBound ( long [ ] a , long val ) { return upperBound ( a , 0 , a . length , val ) ; } public static int upperBound ( long [ ] a , int l , int r , long val ) { if ( r - l == 1 ) { if ( a [ l ] > val ) return l ; return r ; } int mid = ( l + r ) / 2 ; if ( a [ mid ] > val ) { return upperBound ( a , l , mid , val ) ; } else { return upperBound ( a , mid , r , val ) ; } } public static int lowerBound ( long [ ] a , long val ) { return lowerBound ( a , 0 , a . length , val ) ; } public static int lowerBound ( long [ ] a , int l , int r , long val ) { if ( r - l == 1 ) { if ( a [ l ] < val ) return r ; return l ; } int mid = ( l + r ) / 2 ; if ( a [ mid ] < val ) { return lowerBound ( a , mid , r , val ) ; } else { return lowerBound ( a , l , mid , val ) ; } } }" ]
[ "len_list = int ( input ( ) ) NEW_LINE input_list = [ int ( x ) for x in input ( ) . split ( ) ] [ : len_list ] NEW_LINE n = 0 NEW_LINE for x in input_list : NEW_LINE INDENT while ( x % 2 ) == 0 : NEW_LINE INDENT x /= 2 NEW_LINE n += 1 NEW_LINE DEDENT DEDENT print ( n ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE a = map ( int , input ( ) . split ( ) ) NEW_LINE def counter ( x ) : NEW_LINE INDENT num = 0 NEW_LINE while x % 2 == 0 : NEW_LINE INDENT num += 1 NEW_LINE x /= 2 NEW_LINE DEDENT return num NEW_LINE DEDENT s = [ counter ( i ) for i in a ] NEW_LINE print ( sum ( s ) ) NEW_LINE", "import sys NEW_LINE INF = float ( \" inf \" ) NEW_LINE import math NEW_LINE import collections NEW_LINE def solve ( N : int , a : \" List [ int ] \" ) : NEW_LINE INDENT print ( int ( sum ( [ math . log2 ( v & - v ) for v in a ] ) ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE a = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , a ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "_ , a = open ( 0 ) ; print ( sum ( bin ( int ( x ) ) [ : : - 1 ] . index ( '1' ) for x in a . split ( ) ) ) NEW_LINE", "import sys NEW_LINE def countDiv2 ( n : int ) : NEW_LINE INDENT sum = 0 NEW_LINE while n % 2 == 0 : NEW_LINE INDENT sum += 1 NEW_LINE n //= 2 NEW_LINE DEDENT return sum NEW_LINE DEDENT def solve ( N : int , a : \" List [ int ] \" ) : NEW_LINE INDENT sum = 0 NEW_LINE for ia in a : NEW_LINE INDENT sum += countDiv2 ( ia ) NEW_LINE DEDENT print ( sum ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE a = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , a ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_arc001_A
[ "import java . util . * ; import static java . lang . Integer . parseInt ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int question = sc . nextInt ( ) ; ArrayList < String > answers = new ArrayList < String > ( ) ; int scores [ ] = new int [ 4 ] ; answers . add ( sc . next ( ) ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int digit = 0 ; digit < question ; digit ++ ) if ( parseInt ( answers . get ( 0 ) . substring ( digit , digit + 1 ) ) == ( i + 1 ) ) { scores [ i ] = scores [ i ] + 1 ; } } int max = scores [ 0 ] ; int min = scores [ 1 ] ; for ( int i = 0 ; i < scores . length ; i ++ ) { int v = scores [ i ] ; if ( v > max ) { max = v ; } if ( v < min ) { min = v ; } } System . out . println ( max + \" ▁ \" + min ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int [ ] count = new int [ 5 ] ; String str = in . next ( ) ; for ( int i = 0 ; i < N ; i ++ ) { switch ( str . charAt ( i ) ) { case '1' : count [ 1 ] ++ ; break ; case '2' : count [ 2 ] ++ ; break ; case '3' : count [ 3 ] ++ ; break ; case '4' : count [ 4 ] ++ ; break ; } } int max = count [ 1 ] ; int min = count [ 1 ] ; for ( int i = 2 ; i <= 4 ; i ++ ) { max = Math . max ( max , count [ i ] ) ; min = Math . min ( min , count [ i ] ) ; } out . println ( max + \" ▁ \" + min ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int a [ ] = new int [ 4 ] ; for ( int i = 0 ; i < n ; i ++ ) { switch ( s . charAt ( i ) ) { case ( '1' ) : a [ 0 ] ++ ; break ; case ( '2' ) : a [ 1 ] ++ ; break ; case ( '3' ) : a [ 2 ] ++ ; break ; case ( '4' ) : a [ 3 ] ++ ; break ; } } Arrays . sort ( a ) ; System . out . println ( a [ 3 ] + \" ▁ \" + a [ 0 ] ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; String sol = sc . next ( ) ; sc . close ( ) ; String [ ] sols = sol . split ( \" \" ) ; int one = 0 ; int two = 0 ; int three = 0 ; int four = 0 ; for ( int i = 0 ; i < num ; i ++ ) { switch ( sols [ i ] ) { case \"1\" : one ++ ; break ; case \"2\" : two ++ ; break ; case \"3\" : three ++ ; break ; case \"4\" : four ++ ; break ; } } int [ ] arr = { one , two , three , four } ; Arrays . sort ( arr ) ; String result = arr [ 3 ] + \" ▁ \" + arr [ 0 ] ; System . out . println ( result ) ; } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String str = sc . next ( ) ; int [ ] c = new int [ 5 ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = Integer . parseInt ( str . substring ( i , i + 1 ) ) ; if ( tmp == 1 ) { c [ 1 ] ++ ; } else if ( tmp == 2 ) { c [ 2 ] ++ ; } else if ( tmp == 3 ) { c [ 3 ] ++ ; } else if ( tmp == 4 ) { c [ 4 ] ++ ; } } int max = c [ 1 ] ; int min = c [ 1 ] ; for ( int i = 2 ; i < 5 ; i ++ ) { max = Math . max ( max , c [ i ] ) ; min = Math . min ( min , c [ i ] ) ; } pl ( max + \" ▁ \" + min ) ; } private static void pr ( Object o ) { System . out . print ( o ) ; } private static void pl ( Object o ) { System . out . println ( o ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE cs = input ( ) . strip ( ) NEW_LINE cd = { '1' : 0 , '2' : 0 , '3' : 0 , '4' : 0 } NEW_LINE for c in cs : NEW_LINE INDENT cd [ c ] += 1 NEW_LINE DEDENT print ( max ( v for v in cd . values ( ) ) , min ( v for v in cd . values ( ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE c = input ( ) NEW_LINE c1 = c . count ( '1' ) NEW_LINE c2 = c . count ( '2' ) NEW_LINE c3 = c . count ( '3' ) NEW_LINE c4 = c . count ( '4' ) NEW_LINE ans = [ c . count ( '1' ) , c . count ( '2' ) , c . count ( '3' ) , c . count ( '4' ) ] NEW_LINE ans . sort ( ) NEW_LINE print ( ans [ 3 ] , ans [ 0 ] ) NEW_LINE", "import numpy as np NEW_LINE class Calculator : NEW_LINE INDENT def __init__ ( self , arr ) : NEW_LINE INDENT self . arr = arr NEW_LINE DEDENT def calc ( self ) : NEW_LINE INDENT self . min_num = 9999 NEW_LINE self . max_num = 0 NEW_LINE for i in range ( 1 , 5 ) : NEW_LINE INDENT self . sum = np . sum ( self . arr == i ) NEW_LINE self . min_num = min ( self . min_num , self . sum ) NEW_LINE self . max_num = max ( self . max_num , self . sum ) NEW_LINE DEDENT DEDENT def get_max ( self ) : NEW_LINE INDENT return self . max_num NEW_LINE DEDENT def get_min ( self ) : NEW_LINE INDENT return self . min_num NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N , = map ( int , input ( ) . split ( ) ) NEW_LINE c = list ( map ( int , list ( input ( ) ) ) ) NEW_LINE arr = np . array ( c , dtype = int ) NEW_LINE calc = Calculator ( arr ) NEW_LINE calc . calc ( ) NEW_LINE print ( calc . get_max ( ) , calc . get_min ( ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "from sys import stdin NEW_LINE N = stdin . readline ( ) . rstrip ( ) NEW_LINE c = stdin . readline ( ) . rstrip ( ) NEW_LINE count = [ ] NEW_LINE count . append ( c . count ( '1' ) ) NEW_LINE count . append ( c . count ( '2' ) ) NEW_LINE count . append ( c . count ( '3' ) ) NEW_LINE count . append ( c . count ( '4' ) ) NEW_LINE print ( max ( count ) , min ( count ) ) NEW_LINE", "_ , c = open ( 0 ) ; print ( * sorted ( map ( c . count , '1234' ) ) [ : : - 3 ] ) NEW_LINE" ]
atcoder_abc094_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x < a || a + b < x ) { System . out . println ( \" NO \" ) ; } else { System . out . println ( \" YES \" ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numA = 0 ; int numB = 0 ; int numX = 0 ; try { scanner = new Scanner ( System . in ) ; numA = scanner . nextInt ( ) ; numB = scanner . nextInt ( ) ; numX = scanner . nextInt ( ) ; if ( numX - numA <= numB && numA <= numX ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABC094_A solver = new ABC094_A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC094_A { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int x = in . nextInt ( ) ; if ( x < a || a + b < x ) { out . print ( \" NO \" ) ; } else { out . print ( \" YES \" ) ; } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; if ( A <= X && X <= A + B ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }", "import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , x = sc . nextInt ( ) ; if ( x < a ) out . println ( \" NO \" ) ; else { out . println ( x - a <= b ? \" YES \" : \" NO \" ) ; } } }" ]
[ "a , b , x = map ( int , input ( ) . split ( ) ) NEW_LINE print ( \" YES \" if a <= x and x <= a + b else \" NO \" ) NEW_LINE", "from collections import Counter NEW_LINE from functools import reduce NEW_LINE import fractions NEW_LINE import math NEW_LINE import statistics NEW_LINE import sys NEW_LINE import time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def IS ( ) : return input ( ) NEW_LINE def P ( x ) : return print ( x ) NEW_LINE def C ( x ) : return Counter ( x ) NEW_LINE def GCD_LIST ( numbers ) : NEW_LINE INDENT return reduce ( fractions . gcd , numbers ) NEW_LINE DEDENT def LCM_LIST ( numbers ) : NEW_LINE INDENT return reduce ( LCM , numbers ) NEW_LINE DEDENT def LCM ( m , n ) : NEW_LINE INDENT return ( m * n // fractions . gcd ( m , n ) ) NEW_LINE DEDENT a , b , x = MI ( ) NEW_LINE print ( \" YES \" ) if a <= x <= a + b else print ( \" NO \" ) NEW_LINE", "a , b , x = map ( int , input ( ) . split ( ) ) NEW_LINE if a > x : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT elif ( a + b ) < x : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT", "A , B , X = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if A > X : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE exit ( ) NEW_LINE DEDENT if A + B < X : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( \" YES \" ) NEW_LINE", "l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ' YES ' if ( l [ 0 ] + l [ 1 ] >= l [ 2 ] ) & ( l [ 0 ] <= l [ 2 ] ) else ' NO ' ) NEW_LINE" ]
atcoder_abc070_B
[ "import java . util . * ; public class Main { 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 ( ) ; int ans = Math . min ( B , D ) - Math . max ( A , C ) ; System . out . println ( ans >= 0 ? ans : 0 ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int D = in . nextInt ( ) ; int start = A > C ? A : C ; int stop = B < D ? B : D ; out . println ( start < stop ? stop - start : 0 ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . Scanner ; class Main { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( subAbs ( A , B , C , D ) ) ; } public static int subAbs ( int A , int B , int C , int D ) { int sub = Math . min ( B , D ) - Math . max ( A , C ) ; if ( sub > 0 ) { return sub ; } else { return 0 ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) { int a = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; String [ ] tmp = null ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { tmp = br . readLine ( ) . split ( \" \\\\ s \" ) ; a = Integer . parseInt ( tmp [ 0 ] ) ; b = Integer . parseInt ( tmp [ 1 ] ) ; c = Integer . parseInt ( tmp [ 2 ] ) ; d = Integer . parseInt ( tmp [ 3 ] ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } int start = 0 ; int end = 0 ; if ( a < c ) { start = c ; } else { start = a ; } if ( b < d ) { end = b ; } else { end = d ; } int result = end - start ; if ( result < 0 ) { result = 0 ; } System . out . print ( result ) ; } }", "import java . util . * ; import static java . lang . Math . abs ; public class Main { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ ] { sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) } ; int [ ] tl = new int [ 101 ] ; for ( int i = 0 ; i < 101 ; i ++ ) { if ( i >= x [ 0 ] && i < x [ 1 ] ) tl [ i ] ++ ; if ( i >= x [ 2 ] && i < x [ 3 ] ) tl [ i ] ++ ; } int ans = 0 ; for ( int i = 0 ; i < 101 ; i ++ ) { if ( tl [ i ] == 2 ) ans ++ ; } System . out . println ( ans ) ; } }" ]
[ "a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE if a < c : NEW_LINE INDENT x = c NEW_LINE DEDENT else : NEW_LINE INDENT x = a NEW_LINE DEDENT if b < d : NEW_LINE INDENT y = b NEW_LINE DEDENT else : NEW_LINE INDENT y = d NEW_LINE DEDENT print ( max ( 0 , y - x ) ) NEW_LINE", "A , B , C , D = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Alice = set ( range ( A , B ) ) NEW_LINE Bob = set ( range ( C , D ) ) NEW_LINE print ( len ( Alice & Bob ) ) NEW_LINE", "a , b , c , d = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE time = 0 NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT if i >= a and i < b and i >= c and i < d : NEW_LINE INDENT time += 1 NEW_LINE DEDENT DEDENT print ( time ) NEW_LINE", "a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE if b <= c or d <= a : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT elif a <= c : NEW_LINE INDENT if b <= d : NEW_LINE INDENT ans = b - c NEW_LINE DEDENT elif d <= b : NEW_LINE INDENT ans = d - c NEW_LINE DEDENT DEDENT elif c <= a : NEW_LINE INDENT if d <= b : NEW_LINE INDENT ans = d - a NEW_LINE DEDENT elif b <= d : NEW_LINE INDENT ans = b - a NEW_LINE DEDENT DEDENT elif a == c and b == d : NEW_LINE INDENT ans = b - a NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE a , b , c , d = nm ( ) NEW_LINE if b <= c or d <= a : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( min ( b , d ) - max ( a , c ) ) NEW_LINE DEDENT" ]
atcoder_agc031_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int color [ ] = new int [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { color [ i ] = sc . nextInt ( ) ; } int index [ ] = new int [ 2 * ( int ) Math . pow ( 10 , 5 ) + 10 ] ; int same [ ] = new int [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { same [ i ] = index [ color [ i ] ] - 1 ; index [ color [ i ] ] = i + 1 ; } long dp [ ] = new long [ num ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < num ; i ++ ) { if ( color [ i - 1 ] == color [ i ] || same [ i ] < 0 ) { dp [ i ] = dp [ i - 1 ] ; } else { dp [ i ] = mod ( dp [ i - 1 ] + dp [ same [ i ] ] ) ; } } System . out . println ( dp [ num - 1 ] ) ; } static long divisor = ( long ) Math . pow ( 10 , 9 ) + 7 ; public static long mod ( long i ) { return i % divisor + ( ( i % divisor ) < 0 ? divisor : 0 ) ; } }", "import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; final int M = 1_000_000_007 ; int N = scanner . nextInt ( ) ; int [ ] c = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) c [ i ] = scanner . nextInt ( ) ; HashMap < Integer , Integer > lastPos = new HashMap < > ( ) ; long [ ] dp = new long [ N + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { dp [ i ] = dp [ i - 1 ] ; int color = c [ i - 1 ] ; if ( lastPos . containsKey ( color ) && lastPos . get ( color ) < i - 1 ) { dp [ i ] += dp [ lastPos . get ( color ) ] ; if ( dp [ i ] >= M ) dp [ i ] -= M ; } lastPos . put ( color , i ) ; } System . out . println ( dp [ N ] ) ; } }", "import java . util . * ; public class Main { int N ; int [ ] C ; Map < Integer , List < Integer > > indexes ; static final long MOD = 1000000007 ; long result ; long [ ] memo ; long add ( long a , long b ) { return ( a + b ) % MOD ; } Main ( ) { Scanner in = new Scanner ( System . in ) ; N = Integer . parseInt ( in . nextLine ( ) ) ; C = new int [ N ] ; int cMax = - 1 ; for ( int i = 0 ; i < N ; ++ i ) { C [ i ] = Integer . parseInt ( in . nextLine ( ) ) ; cMax = Math . max ( cMax , C [ i ] ) ; } in . close ( ) ; this . memo = new long [ cMax + 1 ] ; Arrays . fill ( this . memo , 0 ) ; this . memo [ C [ 0 ] ] = 1 ; for ( int i = 1 ; i < N ; ++ i ) { if ( C [ i - 1 ] != C [ i ] ) { this . memo [ C [ i ] ] = this . add ( this . memo [ C [ i ] ] , this . memo [ C [ i - 1 ] ] ) ; } } this . result = this . memo [ C [ C . length - 1 ] ] ; } public static void main ( String [ ] args ) { Main ins = new Main ( ) ; System . out . println ( ins . result ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { private static final long DEV_NUM = 1000000000 + 7 ; private static final int MAX_COLOR_NUM = 2 * 100000 ; int [ ] jumpIndex = null ; long [ ] patterns = null ; int N = 0 ; public void solve ( ) { Scanner in = new Scanner ( System . in ) ; N = in . nextInt ( ) ; int [ ] color = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { color [ i ] = in . nextInt ( ) ; } in . close ( ) ; patterns = new long [ N ] ; Arrays . fill ( patterns , - 1 ) ; jumpIndex = new int [ N ] ; Arrays . fill ( jumpIndex , - 1 ) ; int [ ] beforeIndex = new int [ MAX_COLOR_NUM + 1 ] ; Arrays . fill ( beforeIndex , - 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { int c = color [ i ] ; if ( beforeIndex [ c ] == - 1 ) { beforeIndex [ c ] = i ; } else if ( beforeIndex [ c ] == i - 1 ) { beforeIndex [ c ] = i ; } else { jumpIndex [ beforeIndex [ c ] ] = i ; beforeIndex [ c ] = i ; } } for ( int i = N - 1 ; i >= 0 ; i -- ) { patterns [ i ] = getPatterns ( i ) ; } System . out . println ( patterns [ 0 ] ) ; } private long getPatterns ( int index ) { if ( index >= N - 2 ) { return 1 ; } long unjumpPatterns = patterns [ index + 1 ] ; long jumpPatterns = 0 ; if ( jumpIndex [ index ] != - 1 ) { jumpPatterns = patterns [ jumpIndex [ index ] ] ; } return ( unjumpPatterns + jumpPatterns ) % DEV_NUM ; } public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } }", "import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ways = new int [ 200001 ] ; ArrayList < Integer > stones = new ArrayList < > ( ) ; int current = sc . nextInt ( ) ; stones . add ( current ) ; for ( int i = 1 ; i < n ; i ++ ) { current = sc . nextInt ( ) ; if ( current != stones . get ( stones . size ( ) - 1 ) ) { stones . add ( current ) ; } } int [ ] count = new int [ stones . size ( ) ] ; count [ 0 ] = 1 ; ways [ stones . get ( 0 ) ] = 1 ; for ( int i = 1 ; i < stones . size ( ) ; i ++ ) { count [ i ] = ( count [ i - 1 ] + ways [ stones . get ( i ) ] ) % 1_000_000_007 ; ways [ stones . get ( i ) ] = count [ i ] ; } System . out . println ( count [ stones . size ( ) - 1 ] ) ; } }" ]
[ "MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE C = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE dp = [ 0 for i in range ( N ) ] NEW_LINE dp [ 0 ] = 1 NEW_LINE color = { } NEW_LINE for c in C : NEW_LINE INDENT color [ c ] = 0 NEW_LINE DEDENT color [ C [ 0 ] ] = 1 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] NEW_LINE if C [ i - 1 ] != C [ i ] : NEW_LINE INDENT dp [ i ] = ( dp [ i ] + color [ C [ i ] ] ) % MOD NEW_LINE DEDENT color [ C [ i ] ] = dp [ i ] NEW_LINE DEDENT print ( dp [ - 1 ] ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE memo = { } NEW_LINE prev_num = 1 NEW_LINE prev = None NEW_LINE for _ in range ( N ) : NEW_LINE INDENT c = int ( input ( ) ) NEW_LINE if c == prev : NEW_LINE INDENT continue NEW_LINE DEDENT tmp = prev_num NEW_LINE if c in memo : NEW_LINE INDENT tmp += memo [ c ] NEW_LINE DEDENT tmp %= MOD NEW_LINE memo [ c ] = tmp NEW_LINE prev_num = tmp NEW_LINE prev = c NEW_LINE DEDENT print ( prev_num ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE c = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT c . append ( int ( input ( ) ) ) NEW_LINE DEDENT dp = 1 NEW_LINE prev = [ 0 ] * ( max ( c ) + 1 ) NEW_LINE x = 0 NEW_LINE for i in c : NEW_LINE INDENT if x != i : NEW_LINE INDENT dp += prev [ i ] NEW_LINE prev [ i ] = dp NEW_LINE DEDENT x = i NEW_LINE DEDENT print ( dp % ( 10 ** 9 + 7 ) ) NEW_LINE", "import sys NEW_LINE MOD = 1000000007 NEW_LINE MAX_N = 200000 NEW_LINE def solve ( N , C ) : NEW_LINE INDENT last = [ - 1 ] * MAX_N NEW_LINE pairs = [ ] NEW_LINE for i , c in enumerate ( C ) : NEW_LINE INDENT try : NEW_LINE INDENT prev = last [ c - 1 ] NEW_LINE DEDENT except : NEW_LINE INDENT if c >= N : NEW_LINE INDENT return NEW_LINE DEDENT else : NEW_LINE INDENT raise Exception ( ) NEW_LINE DEDENT DEDENT if prev >= 0 and prev < i - 1 : NEW_LINE INDENT pairs . append ( ( prev , i ) ) NEW_LINE DEDENT last [ c - 1 ] = i NEW_LINE DEDENT pairs . sort ( ) NEW_LINE count = [ 0 ] * N NEW_LINE count [ 0 ] = 1 NEW_LINE idx = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if i > 0 : NEW_LINE INDENT count [ i ] += count [ i - 1 ] NEW_LINE count [ i ] %= MOD NEW_LINE DEDENT while idx < len ( pairs ) and pairs [ idx ] [ 0 ] == i : NEW_LINE INDENT count [ pairs [ idx ] [ 1 ] ] += count [ i ] NEW_LINE count [ pairs [ idx ] [ 1 ] ] %= MOD NEW_LINE idx += 1 NEW_LINE DEDENT DEDENT print ( count [ N - 1 ] ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE C = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , C ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE readline = sys . stdin . readline NEW_LINE N = int ( readline ( ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE last = [ - 1 ] * ( 3 * 10 ** 5 ) NEW_LINE dp = [ 0 ] * ( N + 1 ) NEW_LINE dp [ 0 ] = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT c = int ( readline ( ) ) NEW_LINE if last [ c ] != - 1 and last [ c ] + 1 < i : NEW_LINE INDENT dp [ i ] = ( dp [ last [ c ] ] + dp [ i - 1 ] ) % MOD NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] NEW_LINE DEDENT last [ c ] = i NEW_LINE DEDENT print ( dp [ N ] ) NEW_LINE" ]
atcoder_abc032_C
[ "import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long [ ] values = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextLong ( ) ; if ( values [ i ] == 0 ) { System . out . println ( n ) ; return ; } } int l = 0 , r = 0 , res = 0 ; long prod = 1 ; while ( l < n ) { while ( r < n && prod * values [ r ] <= k ) prod *= values [ r ++ ] ; res = Math . max ( res , r - l ) ; if ( l == r ) prod *= values [ r ++ ] ; prod /= values [ l ++ ] ; } System . out . println ( res ) ; } }", "import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long [ ] s = new long [ n ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = sc . nextLong ( ) ; if ( s [ i ] == 0 ) { out . println ( n ) ; exit ( 0 ) ; } else if ( s [ i ] <= k ) { ans = 1 ; } } int r = 0 ; long temp = 1 ; for ( int l = 0 ; l < n ; l ++ ) { while ( r < n && temp * s [ r ] <= k ) { temp *= s [ r ] ; ans = max ( ans , r ++ - l + 1 ) ; } if ( r == l ) r ++ ; else temp /= s [ l ] ; } out . println ( ans ) ; } }", "import java . math . BigInteger ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long [ ] map = new long [ N ] ; long min = Integer . MAX_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { map [ i ] = sc . nextLong ( ) ; if ( map [ i ] == 0 ) { System . out . println ( N ) ; return ; } min = Math . min ( min , map [ i ] ) ; } if ( min > K ) { System . out . println ( 0 ) ; return ; } int ans = 1 ; BigInteger now = BigInteger . valueOf ( map [ 0 ] ) ; int start = 0 ; int end = 0 ; while ( start < map . length ) { while ( true ) { if ( end < map . length - 1 && now . multiply ( BigInteger . valueOf ( map [ end + 1 ] ) ) . compareTo ( BigInteger . valueOf ( K ) ) < 1 ) { end ++ ; now = now . multiply ( BigInteger . valueOf ( map [ end ] ) ) ; ans = Math . max ( ans , end - start + 1 ) ; } else { break ; } } if ( end < map . length - 1 && end == start ) { end ++ ; now = now . multiply ( BigInteger . valueOf ( map [ end ] ) ) ; } now = now . divide ( BigInteger . valueOf ( map [ start ] ) ) ; start ++ ; } System . out . println ( ans ) ; } }", "public class Main { public static void main ( String [ ] $ ) { java . util . Scanner c = new java . util . Scanner ( System . in ) ; int n = c . nextInt ( ) , k = c . nextInt ( ) , r = 0 , i = 0 , l = 0 ; long s [ ] = new long [ n ] , a = 0 , t = 1 ; while ( i < n ) if ( ( s [ i ++ ] = c . nextInt ( ) ) == 0 ) { System . out . println ( n ) ; return ; } for ( ; l < n ; l ++ ) { while ( r < n && t * s [ r ] <= k ) { t *= s [ r ] ; a = Math . max ( a , r ++ - l + 1 ) ; } if ( r == l ) r ++ ; else t /= s [ l ] ; } System . out . println ( a ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nk = sc . nextLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; int [ ] s = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = Integer . parseInt ( sc . nextLine ( ) ) ; if ( s [ i ] == 0 ) { System . out . println ( n ) ; return ; } } int right = 0 ; long product = 1 ; int answer = 0 ; for ( int left = 0 ; left < n ; left ++ ) { while ( right < n && product * s [ right ] <= k ) { product *= s [ right ] ; right ++ ; } if ( right - left > answer ) { answer = right - left ; } if ( left == right ) { right ++ ; } else { product /= s [ left ] ; } } System . out . println ( answer ) ; } }" ]
[ "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE s_list = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE left = 0 NEW_LINE right = 0 NEW_LINE sum_num = 1 NEW_LINE ans = 0 NEW_LINE if 0 in s_list : NEW_LINE INDENT ans = N NEW_LINE DEDENT else : NEW_LINE INDENT while left < N : NEW_LINE INDENT while right < N and sum_num * s_list [ right ] <= K : NEW_LINE INDENT sum_num *= s_list [ right ] NEW_LINE right += 1 NEW_LINE DEDENT ans = max ( ans , right - left ) NEW_LINE if left == right : NEW_LINE INDENT right += 1 NEW_LINE DEDENT else : NEW_LINE INDENT sum_num //= s_list [ left ] NEW_LINE DEDENT left += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT result = sub ( ) NEW_LINE print ( result ) NEW_LINE DEDENT def sub ( ) : NEW_LINE INDENT n , k = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE ss = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE result = 0 NEW_LINE right = 0 NEW_LINE for s in ss : NEW_LINE INDENT if s == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT DEDENT acc = 1 NEW_LINE for left in range ( n ) : NEW_LINE INDENT while ( right < n ) : NEW_LINE INDENT tmp = acc * ss [ right ] NEW_LINE if tmp <= k : NEW_LINE INDENT acc = tmp NEW_LINE right = right + 1 NEW_LINE length = right - left NEW_LINE result = max ( length , result ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if left == right : NEW_LINE INDENT right = right + 1 NEW_LINE continue NEW_LINE DEDENT acc = acc / ss [ left ] NEW_LINE if acc <= k : NEW_LINE INDENT length = right - left NEW_LINE result = max ( length , result ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def sequence ( N : int , K : int , S : list ) -> int : NEW_LINE INDENT S += [ K + 1 ] NEW_LINE if 0 in S : NEW_LINE INDENT return N NEW_LINE DEDENT maxlen = 0 NEW_LINE l , r = 0 , 0 NEW_LINE t = 1 NEW_LINE while r < N : NEW_LINE INDENT while t * S [ r ] <= K : NEW_LINE INDENT t *= S [ r ] NEW_LINE r += 1 NEW_LINE DEDENT maxlen = max ( maxlen , r - l ) NEW_LINE if l < r : NEW_LINE INDENT t //= S [ l ] NEW_LINE l += 1 NEW_LINE DEDENT else : NEW_LINE INDENT l , r = l + 1 , r + 1 NEW_LINE DEDENT DEDENT return maxlen NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = 0 NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE ans = sequence ( N , K , S ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "import sys NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE line = [ int ( i ) for i in sys . stdin ] NEW_LINE flag = False NEW_LINE stack = 1 NEW_LINE start = 0 NEW_LINE ans = 0 NEW_LINE answer = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if line [ i ] == 0 : NEW_LINE INDENT print ( n ) NEW_LINE exit ( ) NEW_LINE DEDENT if stack * line [ i ] <= k : NEW_LINE INDENT stack *= line [ i ] NEW_LINE ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT answer = max ( answer , ans ) NEW_LINE stack *= line [ i ] NEW_LINE ans += 1 NEW_LINE while stack > k and start <= i : NEW_LINE INDENT stack //= line [ start ] NEW_LINE start += 1 NEW_LINE ans -= 1 NEW_LINE DEDENT DEDENT DEDENT answer = max ( ans , answer ) NEW_LINE print ( answer ) NEW_LINE", "import sys NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT s . append ( int ( input ( ) ) ) NEW_LINE DEDENT if 0 in s : NEW_LINE INDENT print ( len ( s ) ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT elif K == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT left = - 1 NEW_LINE right = 0 NEW_LINE mul = s [ 0 ] NEW_LINE ans = 0 NEW_LINE while right < len ( s ) : NEW_LINE INDENT if left == right : NEW_LINE INDENT right += 1 NEW_LINE if right == len ( s ) : NEW_LINE INDENT break NEW_LINE DEDENT else : NEW_LINE INDENT mul = s [ right ] NEW_LINE DEDENT DEDENT if mul <= K : NEW_LINE INDENT ans = max ( ans , right - left ) NEW_LINE right += 1 NEW_LINE if right <= len ( s ) - 1 : NEW_LINE INDENT mul = mul * s [ right ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT elif mul > K : NEW_LINE INDENT left += 1 NEW_LINE if left == right : NEW_LINE INDENT mul = 0 NEW_LINE DEDENT else : NEW_LINE INDENT mul = mul // s [ left ] NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc108_B
[ "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int x1 = scanner . nextInt ( ) ; int y1 = scanner . nextInt ( ) ; int x2 = scanner . nextInt ( ) ; int y2 = scanner . nextInt ( ) ; System . out . printf ( \" % s ▁ % s ▁ % s ▁ % s \" , x2 - y2 + y1 , y2 + x2 - x1 , x1 - y2 + y1 , y1 + x2 - x1 ) ; } }", "import java . awt . Point ; 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 [ ] x1y1x2y2 = br . readLine ( ) . split ( \" ▁ \" ) ; int x1 = Integer . parseInt ( x1y1x2y2 [ 0 ] ) ; int y1 = Integer . parseInt ( x1y1x2y2 [ 1 ] ) ; int x2 = Integer . parseInt ( x1y1x2y2 [ 2 ] ) ; int y2 = Integer . parseInt ( x1y1x2y2 [ 3 ] ) ; Point p1 = new Point ( x1 , y1 ) ; Point p2 = new Point ( x2 , y2 ) ; Square ruinedSquare = new Square ( p1 , p2 ) ; Square recoveredSquare = ruinedSquare . recover ( ) ; System . out . println ( recoveredSquare ) ; } } class Square { private Point p1 , p2 , p3 , p4 ; public Square ( Point p1 , Point p2 ) { this . p1 = p1 ; this . p2 = p2 ; } public Square ( ) { } public Square ( Point p1 , Point p2 , Point p3 , Point p4 ) { this . p1 = p1 ; this . p2 = p2 ; this . p3 = p3 ; this . p4 = p4 ; } private Point nextPointOf ( Point a , Point b ) { int x = b . x - a . x ; int y = b . y - a . y ; return new Point ( b . x - y , b . y + x ) ; } public Square recover ( ) { this . p3 = this . nextPointOf ( this . p1 , this . p2 ) ; this . p4 = this . nextPointOf ( this . p2 , this . p3 ) ; Square recoveredSquare = new Square ( this . p1 , this . p2 , this . p3 , this . p4 ) ; return recoveredSquare ; } @ Override public String toString ( ) { String s = String . format ( \" % d ▁ % d ▁ % d ▁ % d \\n \" , this . p3 . x , this . p3 . y , this . p4 . x , this . p4 . y ) ; return s ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveB ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numK = 0 ; int eqaC = 0 ; int oddC = 0 ; try { scanner = new Scanner ( System . in ) ; numK = scanner . nextInt ( ) ; for ( int i = 1 ; i <= numK ; i ++ ) { if ( i % 2 == 0 ) { eqaC ++ ; } else { oddC ++ ; } } System . out . println ( eqaC * oddC ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int x1 = 0 ; int y1 = 0 ; int x2 = 0 ; int y2 = 0 ; try { scanner = new Scanner ( System . in ) ; x1 = scanner . nextInt ( ) ; y1 = scanner . nextInt ( ) ; x2 = scanner . nextInt ( ) ; y2 = scanner . nextInt ( ) ; int x3 = x2 - ( y2 - y1 ) ; int y3 = y2 + ( x2 - x1 ) ; int x4 = x3 - ( y3 - y2 ) ; int y4 = y3 + ( x3 - x2 ) ; System . out . println ( x3 + \" ▁ \" + y3 + \" ▁ \" + x4 + \" ▁ \" + y4 ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }", "import java . util . * ; import java . lang . Math ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; double x3 = x2 + ( ( x1 - x2 ) * Math . cos ( - Math . PI / 2 ) - ( y1 - y2 ) * Math . sin ( - Math . PI / 2 ) ) ; double y3 = y2 + ( ( x1 - x2 ) * Math . sin ( - Math . PI / 2 ) + ( y1 - y2 ) * Math . cos ( - Math . PI / 2 ) ) ; double x4 = x1 + ( ( x2 - x1 ) * Math . cos ( Math . PI / 2 ) - ( y2 - y1 ) * Math . sin ( Math . PI / 2 ) ) ; double y4 = y1 + ( ( x2 - x1 ) * Math . sin ( Math . PI / 2 ) + ( y2 - y1 ) * Math . cos ( Math . PI / 2 ) ) ; System . out . println ( ( int ) Math . rint ( x3 ) + \" ▁ \" + ( int ) Math . rint ( y3 ) + \" ▁ \" + ( int ) Math . rint ( x4 ) + \" ▁ \" + ( int ) Math . rint ( y4 ) ) ; sc . close ( ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int x1 , y1 , x2 , y2 ; x1 = Integer . parseInt ( sc . next ( ) ) ; y1 = Integer . parseInt ( sc . next ( ) ) ; x2 = Integer . parseInt ( sc . next ( ) ) ; y2 = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( x2 + y1 - y2 ) + \" ▁ \" + ( y2 - x1 + x2 ) + \" ▁ \" + ( x1 + y1 - y2 ) + \" ▁ \" + ( y1 - x1 + x2 ) ) ; } catch ( Exception e ) { System . out . println ( \" out \" ) ; } } }" ]
[ "x_1 , y_1 , x_2 , y_2 = map ( int , input ( ) . split ( ) ) NEW_LINE x_3 = x_2 - y_2 + y_1 NEW_LINE y_3 = y_2 + x_2 - x_1 NEW_LINE x_4 = x_3 - x_2 + x_1 NEW_LINE y_4 = y_3 - y_2 + y_1 NEW_LINE print ( x_3 , y_3 , x_4 , y_4 ) NEW_LINE", "def main ( ) : NEW_LINE INDENT x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) NEW_LINE dx = x2 - x1 NEW_LINE dy = y2 - y1 NEW_LINE x3 = x2 - dy NEW_LINE y3 = y2 + dx NEW_LINE x4 = x3 - dx NEW_LINE y4 = y3 - dy NEW_LINE ans = str ( x3 ) + \" ▁ \" + str ( y3 ) + \" ▁ \" + str ( x4 ) + \" ▁ \" + str ( y4 ) NEW_LINE print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "x = [ 0 ] * 4 NEW_LINE y = [ 0 ] * 4 NEW_LINE x [ 0 ] , y [ 0 ] , x [ 1 ] , y [ 1 ] = map ( int , input ( ) . split ( ) ) NEW_LINE x [ 3 ] = x [ 0 ] - ( y [ 1 ] - y [ 0 ] ) NEW_LINE y [ 3 ] = y [ 0 ] + ( x [ 1 ] - x [ 0 ] ) NEW_LINE x [ 2 ] = x [ 3 ] - ( y [ 0 ] - y [ 3 ] ) NEW_LINE y [ 2 ] = y [ 3 ] + ( x [ 0 ] - x [ 3 ] ) NEW_LINE print ( x [ 2 ] , y [ 2 ] , x [ 3 ] , y [ 3 ] ) NEW_LINE", "x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) NEW_LINE vector = ( x2 - x1 , y2 - y1 ) NEW_LINE x3 , y3 = x2 - vector [ 1 ] , y2 - ( - vector [ 0 ] ) NEW_LINE x4 , y4 = x3 - vector [ 0 ] , y3 - vector [ 1 ] NEW_LINE print ( \" ▁ \" . join ( map ( str , [ x3 , y3 , x4 , y4 ] ) ) ) NEW_LINE", "import heapq NEW_LINE def solve ( ) : NEW_LINE INDENT x1 , y1 , x2 , y2 = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE x = x2 - x1 NEW_LINE y = y2 - y1 NEW_LINE print ( x2 - y , y2 + x , x1 - y , y1 + x ) NEW_LINE DEDENT solve ( ) NEW_LINE" ]
atcoder_agc029_D
[ "import java . util . HashMap ; import java . util . Scanner ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; HashMap < Integer , TreeSet < Integer > > map = new HashMap < > ( ) ; for ( int i = 1 ; i <= h ; i ++ ) { map . put ( i , new TreeSet < > ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; map . get ( x ) . add ( y ) ; } int yMax = 1 ; for ( int i = 2 ; i <= h ; i ++ ) { if ( map . get ( i ) . isEmpty ( ) ) { yMax ++ ; } else if ( map . get ( i ) . first ( ) <= yMax ) { System . out . println ( i - 1 ) ; return ; } else if ( map . get ( i ) . first ( ) > yMax + 1 ) { yMax ++ ; } } System . out . println ( h ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; LinkedList < Integer > [ ] block = new LinkedList [ W ] ; for ( int w = 0 ; w < W ; w ++ ) { block [ w ] = new LinkedList < > ( ) ; block [ w ] . add ( H ) ; } for ( int n = 0 ; n < N ; n ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; block [ y ] . add ( x ) ; } for ( int w = 0 ; w < W ; w ++ ) Collections . sort ( block [ w ] ) ; int ans = 1000000 ; int curX = 0 ; for ( int w = 0 ; w < W ; w ++ ) { curX ++ ; while ( block [ w ] . peek ( ) < curX ) block [ w ] . poll ( ) ; ans = Math . min ( ans , block [ w ] . peek ( ) ) ; while ( w < W - 1 && block [ w + 1 ] . contains ( curX ) ) curX ++ ; if ( curX >= block [ w ] . peek ( ) ) break ; } System . out . println ( ans ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . * ; public class Main { static int H = 200000 + 11 ; static int W = 200000 + 11 ; static List < TreeSet < Integer > > heights = new ArrayList < > ( H ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < w ; i ++ ) { if ( i >= heights . size ( ) ) { heights . add ( new TreeSet < Integer > ( ) ) ; } else { heights . get ( i ) . clear ( ) ; } heights . get ( i ) . add ( h ) ; } for ( int i = 0 ; i < n ; i ++ ) { int h_i = sc . nextInt ( ) ; int w_i = sc . nextInt ( ) ; h_i -= 1 ; w_i -= 1 ; heights . get ( w_i ) . add ( h_i ) ; } int current_h = 0 , current_w = 0 ; int ans = h ; while ( current_h < h && current_w < w ) { int hh = heights . get ( current_w ) . higher ( current_h ) ; ans = Math . min ( ans , hh ) ; current_h += 1 ; if ( heights . get ( current_w ) . contains ( current_h ) ) { break ; } if ( current_w + 1 >= w ) { break ; } if ( ! heights . get ( current_w + 1 ) . contains ( current_h ) ) { current_w += 1 ; } } System . out . println ( ans ) ; } }" ]
[ "import sys NEW_LINE def solve ( obstacles ) : NEW_LINE INDENT offset = 0 NEW_LINE obstacles . sort ( ) NEW_LINE for x , y in obstacles : NEW_LINE INDENT if x > y + offset : NEW_LINE INDENT return x - 1 NEW_LINE DEDENT if x == y + offset : NEW_LINE INDENT offset += 1 NEW_LINE DEDENT DEDENT return h NEW_LINE DEDENT h , w , n = map ( int , input ( ) . split ( ) ) NEW_LINE obstacles = [ tuple ( map ( int , line . split ( ) ) ) for line in sys . stdin . readlines ( ) ] NEW_LINE print ( solve ( obstacles ) ) NEW_LINE", "from collections import defaultdict NEW_LINE import sys NEW_LINE def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE H , W , N = inpl ( ) NEW_LINE if not N : NEW_LINE INDENT print ( H ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT A = [ ] NEW_LINE B = defaultdict ( lambda : [ ] ) NEW_LINE C = defaultdict ( lambda : H + 1 ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT x , y = inpl ( ) NEW_LINE A . append ( ( x , y ) ) NEW_LINE B [ y ] . append ( x ) NEW_LINE DEDENT T = [ 0 ] * ( W + 1 ) NEW_LINE T [ 1 ] = 2 NEW_LINE for i in range ( 1 , W ) : NEW_LINE INDENT if not B [ i + 1 ] : NEW_LINE INDENT T [ i + 1 ] = T [ i ] + 1 NEW_LINE continue NEW_LINE DEDENT ctr = T [ i ] NEW_LINE while True : NEW_LINE INDENT if ctr in B [ i + 1 ] : NEW_LINE INDENT ctr += 1 NEW_LINE continue NEW_LINE DEDENT break NEW_LINE DEDENT T [ i + 1 ] = min ( ctr + 1 , H + 1 ) NEW_LINE DEDENT for x , y in A : NEW_LINE INDENT if x >= T [ y ] : NEW_LINE INDENT C [ y ] = min ( C [ y ] , x ) NEW_LINE DEDENT DEDENT print ( min ( [ i - 1 for i in C . values ( ) ] + [ H ] ) ) NEW_LINE", "import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE eps = 1.0 / 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE dd = [ ( - 1 , 0 ) , ( 0 , 1 ) , ( 1 , 0 ) , ( 0 , - 1 ) ] NEW_LINE ddn = [ ( - 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) , ( 1 , 1 ) , ( 1 , 0 ) , ( 1 , - 1 ) , ( 0 , - 1 ) , ( - 1 , - 1 ) ] NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def pf ( s ) : return print ( s , flush = True ) NEW_LINE def main ( ) : NEW_LINE INDENT h , w , n = LI ( ) NEW_LINE xy = sorted ( [ LI ( ) for _ in range ( n ) ] ) NEW_LINE mx = h + 1 NEW_LINE p = 0 NEW_LINE for x , y in xy : NEW_LINE INDENT if x - p == y : NEW_LINE INDENT p += 1 NEW_LINE continue NEW_LINE DEDENT if x - p <= y : NEW_LINE INDENT continue NEW_LINE DEDENT mx = x NEW_LINE break NEW_LINE DEDENT return mx - 1 NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "isdbg = False NEW_LINE def dprint ( * value , sep = ' ▁ ' , end = ' \\n ' ) : NEW_LINE INDENT if isdbg : NEW_LINE INDENT print ( * value , sep = sep , end = end ) NEW_LINE DEDENT DEDENT H , W , N = map ( int , input ( ) . split ( ) ) NEW_LINE if isdbg : NEW_LINE INDENT XY = [ [ 0 for i in range ( W ) ] for i in range ( H ) ] NEW_LINE DEDENT BL = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT x1 , y1 = map ( int , input ( ) . split ( ) ) NEW_LINE if isdbg : NEW_LINE INDENT XY [ x1 - 1 ] [ y1 - 1 ] = 1 NEW_LINE DEDENT if x1 - 1 in BL : NEW_LINE INDENT BL [ x1 - 1 ] . append ( y1 - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT BL [ x1 - 1 ] = [ y1 - 1 ] NEW_LINE DEDENT DEDENT TL = sorted ( BL . items ( ) , key = lambda x : x [ 0 ] ) NEW_LINE if isdbg : NEW_LINE INDENT for i in range ( W ) : NEW_LINE INDENT for j in range ( H ) : NEW_LINE INDENT dprint ( XY [ i ] [ j ] , end = ' ' ) NEW_LINE DEDENT dprint ( ) NEW_LINE DEDENT DEDENT maxr = 1 NEW_LINE for i in range ( H - 1 ) : NEW_LINE INDENT if i + 1 in BL : NEW_LINE INDENT l = BL [ i + 1 ] NEW_LINE l . sort ( ) NEW_LINE for ll in l : NEW_LINE INDENT if maxr > ll : NEW_LINE INDENT print ( i + 1 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT elif maxr == ll : NEW_LINE INDENT maxr -= 1 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT maxr += 1 NEW_LINE DEDENT print ( H ) NEW_LINE", "x , y , num = map ( int , input ( ) . split ( ) ) NEW_LINE gaiz = [ x ] * x NEW_LINE kaisu = x NEW_LINE for _ in range ( num ) : NEW_LINE INDENT xg , yg = map ( int , input ( ) . split ( ) ) NEW_LINE if xg >= yg : NEW_LINE INDENT sa = xg - yg NEW_LINE if yg < gaiz [ sa ] : NEW_LINE INDENT gaiz [ sa ] = ( yg ) NEW_LINE DEDENT DEDENT DEDENT if len ( gaiz ) == 0 : NEW_LINE INDENT print ( kaisu ) NEW_LINE DEDENT else : NEW_LINE INDENT for num , ( maegai , gai ) in enumerate ( zip ( gaiz [ : - 1 ] , gaiz [ 1 : ] ) ) : NEW_LINE INDENT if maegai > gai and num + gai < kaisu : NEW_LINE INDENT kaisu = num + gai NEW_LINE DEDENT DEDENT print ( kaisu ) NEW_LINE DEDENT" ]
atcoder_abc061_A
[ "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( A <= C && C <= B ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }", "import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; out . println ( c >= a && c <= b ? \" Yes \" : \" No \" ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( \" End ▁ of ▁ Input \" ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; if ( A <= C && C <= B ) { out . println ( \" Yes \" ) ; } else { out . println ( \" No \" ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( C >= A && C <= B ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }", "import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; int O = Integer . parseInt ( sc . next ( ) ) ; if ( O >= N && O <= M ) { out . println ( \" Yes \" ) ; } else { out . println ( \" No \" ) ; } out . flush ( ) ; } }" ]
[ "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ' Yes ' if A <= C <= B else ' No ' ) NEW_LINE", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if A [ 0 ] <= A [ 2 ] <= A [ 1 ] : NEW_LINE INDENT return ' Yes ' NEW_LINE DEDENT else : NEW_LINE INDENT return ' No ' NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a , b , c = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE if c >= a and c <= b : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE print ( \" Yes \" if c >= a and c <= b else \" No \" ) NEW_LINE", "a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if a <= c <= b : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT" ]
atcoder_arc070_D
[ "import java . util . * ; public class Main { static Scanner sc ; static int A , B , N ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; N = A + B ; if ( B >= A ) { System . out . println ( \" Impossible \" ) ; } else { int honest = getHonest ( ) ; char [ ] ans = new char [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { ans [ i ] = ask ( honest , i ) ? '1' : '0' ; } System . out . println ( \" ! ▁ \" + String . valueOf ( ans ) ) ; } sc . close ( ) ; } static int getHonest ( ) { int need = B + 1 ; LinkedList < Integer > list = new LinkedList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( list . isEmpty ( ) ) { list . push ( i ) ; } else { if ( ask ( list . peek ( ) , i ) ) { list . push ( i ) ; } else { list . pop ( ) ; need -- ; } } if ( list . size ( ) >= need ) return list . pop ( ) ; } return - 1 ; } static boolean ask ( int a , int b ) { System . out . println ( \" ? ▁ \" + a + \" ▁ \" + b ) ; return sc . next ( ) . equals ( \" Y \" ) ; } }", "import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner in ; static PrintWriter out ; static String INPUT = \" \" ; static boolean get ( int a , int b ) { out . println ( \" ? ▁ \" + a + \" ▁ \" + b ) ; out . flush ( ) ; return in . next ( ) . charAt ( 0 ) == ' Y ' ; } static void solve ( ) { int A = ni ( ) , B = ni ( ) ; if ( A <= B ) { out . println ( \" Impossible \" ) ; return ; } int n = A + B ; int [ ] stack = new int [ n ] ; int sp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { stack [ sp ++ ] = i ; if ( sp >= 2 ) { if ( ! get ( stack [ sp - 2 ] , stack [ sp - 1 ] ) ) { sp -= 2 ; } } } assert sp - 1 >= 0 ; int honest = stack [ sp - 1 ] ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( get ( honest , i ) ) { sb . append ( 1 ) ; } else { sb . append ( 0 ) ; } } out . print ( \" ! ▁ \" ) ; out . print ( sb ) ; out . println ( ) ; out . flush ( ) ; } public static void main ( String [ ] args ) throws Exception { in = INPUT . isEmpty ( ) ? new Scanner ( System . in ) : new Scanner ( INPUT ) ; out = new PrintWriter ( System . out ) ; solve ( ) ; out . flush ( ) ; } static int ni ( ) { return Integer . parseInt ( in . next ( ) ) ; } static long nl ( ) { return Long . parseLong ( in . next ( ) ) ; } static double nd ( ) { return Double . parseDouble ( in . next ( ) ) ; } static void tr ( Object ... o ) { if ( INPUT . length ( ) != 0 ) System . out . println ( Arrays . deepToString ( o ) ) ; } }", "import java . util . Random ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static Random rnd = new Random ( 42 ) ; static int qc = 0 ; static int A , B , N ; public static void main ( String [ ] args ) { A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; N = A + B ; if ( A <= B ) { System . out . println ( \" Impossible \" ) ; return ; } int start = 0 ; int restA = A ; int honest = - 1 ; OUT : while ( true ) { if ( start == N - 1 ) { honest = start ; break ; } int cur = start ; int next = cur + 1 ; int count = 1 ; while ( true ) { boolean res = query ( cur , next ) ; if ( res ) { ++ count ; if ( count == restA ) { honest = next ; break OUT ; } else { cur = next ; next = cur + 1 ; } } else { if ( next - start + 1 >= count * 2 ) { start = next + 1 ; restA -= count ; break ; } next ++ ; } } } int [ ] result = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { result [ i ] = query ( honest , i ) ? 1 : 0 ; } System . out . print ( \" ! ▁ \" ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( result [ i ] ) ; } System . out . println ( ) ; } static boolean query ( int a , int b ) { ++ qc ; System . out . println ( \" ? ▁ \" + a + \" ▁ \" + b ) ; String ret = sc . next ( ) ; return ret . charAt ( 0 ) == ' Y ' ; } }", "import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; import java . util . concurrent . SynchronousQueue ; class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A <= B ) { System . out . println ( \" Impossible \" ) ; return ; } ArrayDeque < Integer > stack = new ArrayDeque < > ( ) ; stack . add ( 0 ) ; int Asz = A ; int Bsz = B ; for ( int i = 1 ; stack . size ( ) <= Bsz ; ++ i ) { if ( ! stack . isEmpty ( ) ) System . out . println ( \" ? ▁ \" + stack . getFirst ( ) + \" ▁ \" + i ) ; else { stack . addFirst ( i ) ; continue ; } String s = sc . next ( ) ; if ( s . equals ( \" Y \" ) ) { stack . addFirst ( i ) ; } else { -- Bsz ; stack . removeFirst ( ) ; } } int ori = stack . getFirst ( ) ; boolean [ ] beHonest = new boolean [ A + B ] ; beHonest [ ori ] = true ; for ( int i = 0 ; i < A + B ; ++ i ) { if ( i == ori ) continue ; System . out . println ( \" ? ▁ \" + ori + \" ▁ \" + i ) ; String s = sc . next ( ) ; if ( s . equals ( \" Y \" ) ) { beHonest [ i ] = true ; } } StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < A + B ; ++ i ) { if ( beHonest [ i ] ) { ans . append ( \"1\" ) ; } else { ans . append ( \"0\" ) ; } } System . out . println ( \" ! ▁ \" + ans ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }" ]
[ "import collections , sys NEW_LINE p = print NEW_LINE def ask ( x , y ) : NEW_LINE INDENT p ( ' ? ' , x , y ) NEW_LINE return input ( ) == ' Y ' NEW_LINE DEDENT A , B = map ( int , input ( ) . split ( ) ) NEW_LINE r = range ( A + B ) NEW_LINE if A <= B : NEW_LINE INDENT p ( ' Impossible ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT c = collections . deque ( r ) NEW_LINE while len ( c ) > 2 : NEW_LINE INDENT x , y = c . pop ( ) , c . pop ( ) NEW_LINE if ask ( x , y ) : NEW_LINE INDENT c . appendleft ( y ) NEW_LINE DEDENT DEDENT p ( ' ! ' , ' ' . join ( str ( int ( ask ( c [ 0 ] , i ) ) ) for i in r ) ) NEW_LINE", "import bisect NEW_LINE import sys NEW_LINE ( a , b ) = tuple ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE if a <= b : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT n = a + b NEW_LINE def ask ( i , j ) : NEW_LINE INDENT print ( \" ? ▁ \" , i , j ) NEW_LINE ans = input ( ) NEW_LINE if ans == ' Y ' : NEW_LINE INDENT return True NEW_LINE DEDENT elif ans == ' N ' : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT path = [ ] NEW_LINE nlen = b + 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if len ( path ) == 0 : NEW_LINE INDENT path . append ( i ) NEW_LINE if len ( path ) >= nlen : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ask ( path [ - 1 ] , i ) : NEW_LINE INDENT path . append ( i ) NEW_LINE if len ( path ) >= nlen : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT path . pop ( ) NEW_LINE nlen -= 1 NEW_LINE DEDENT DEDENT DEDENT o1 = path [ - 1 ] NEW_LINE result = ' ' NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i != o1 : NEW_LINE INDENT if ask ( o1 , i ) : NEW_LINE INDENT result += '1' NEW_LINE DEDENT else : NEW_LINE INDENT result += '0' NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT result += '1' NEW_LINE DEDENT DEDENT print ( ' ! ' , result ) NEW_LINE", "from collections import * NEW_LINE p , i = print , input NEW_LINE q = lambda * a : ( p ( ' ? ' , * a ) , i ( ) == ' Y ' ) [ 1 ] NEW_LINE A , B = map ( int , i ( ) . split ( ) ) NEW_LINE r = range ( A + B ) NEW_LINE c = deque ( r ) NEW_LINE if A > B : NEW_LINE INDENT while len ( c ) > 2 : c . extendleft ( ( [ ] , [ c [ - 2 ] ] ) [ q ( c . pop ( ) , c . pop ( ) ) ] ) NEW_LINE p ( ' ! ' , ' ' . join ( str ( int ( q ( c [ 0 ] , d ) ) ) for d in r ) ) NEW_LINE DEDENT else : p ( ' Impossible ' ) NEW_LINE", "import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def LF ( ) : return list ( map ( float , input ( ) . split ( ) ) ) NEW_LINE def II ( ) : return int ( input ( ) ) NEW_LINE def LS ( ) : return input ( ) . split ( ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def pf ( s ) : NEW_LINE INDENT print ( s , flush = True ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT a , b = LI ( ) NEW_LINE if a <= b : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT l = [ ] NEW_LINE for i in range ( a + b ) : NEW_LINE INDENT if not l : NEW_LINE INDENT l . append ( i ) NEW_LINE continue NEW_LINE DEDENT pf ( ' ? ▁ { } ▁ { } ' . format ( i , l [ - 1 ] ) ) NEW_LINE if S ( ) == ' Y ' : NEW_LINE INDENT l . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT l = l [ : - 1 ] NEW_LINE DEDENT DEDENT r = [ ] NEW_LINE ai = l [ 0 ] NEW_LINE for i in range ( a + b ) : NEW_LINE INDENT if i == ai : NEW_LINE INDENT r . append ( '1' ) NEW_LINE continue NEW_LINE DEDENT pf ( ' ? ▁ { } ▁ { } ' . format ( ai , i ) ) NEW_LINE if S ( ) == ' Y ' : NEW_LINE INDENT r . append ( '1' ) NEW_LINE DEDENT else : NEW_LINE INDENT r . append ( '0' ) NEW_LINE DEDENT DEDENT return ' ! ▁ { } ' . format ( ' ' . join ( r ) ) NEW_LINE DEDENT print ( main ( ) , flush = True ) NEW_LINE", "import sys NEW_LINE from collections import deque NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ask = lambda x , y : print ( ' ? ' , x , y , flush = True ) NEW_LINE if A <= B : NEW_LINE INDENT print ( ' Impossible ' , flush = True ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT N = A + B NEW_LINE candidates = deque ( range ( N ) , N ) NEW_LINE while len ( candidates ) > 2 : NEW_LINE INDENT x , y = candidates . pop ( ) , candidates . pop ( ) NEW_LINE ask ( x , y ) NEW_LINE if input ( ) == ' Y ' : NEW_LINE INDENT candidates . appendleft ( y ) NEW_LINE DEDENT DEDENT god = candidates [ 0 ] NEW_LINE result = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ask ( god , i ) NEW_LINE result . append ( input ( ) == ' Y ' ) NEW_LINE DEDENT print ( ' ! ' , ' ' . join ( str ( int ( s ) ) for s in result ) , flush = True ) NEW_LINE" ]
atcoder_abc027_B
[ "import java . util . * ; public class Main { static int BridNum ( int n , int [ ] p , int sum ) { if ( sum % n != 0 ) return - 1 ; int pisl = sum / n ; int num = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( p [ i ] != pisl ) { int part = p [ i ] ; for ( int j = 1 ; j < n - i ; j ++ ) { part += p [ i + j ] ; if ( part == pisl * ( j + 1 ) ) { num += j ; i += j ; break ; } } } } return num ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int asum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; asum += a [ i ] ; } System . out . println ( BridNum ( N , a , asum ) ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . io . UncheckedIOException ; import java . util . Arrays ; 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 ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; int [ ] a = in . ints ( n ) ; int total = Arrays . stream ( a ) . sum ( ) ; if ( total % n != 0 ) { out . println ( - 1 ) ; return ; } total /= n ; int pm = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] + pm ) != total ) { ans ++ ; } pm = a [ i ] + pm - total ; } out . println ( ans ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } public int [ ] ints ( int length ) { return IntStream . range ( 0 , length ) . map ( x -> ints ( ) ) . toArray ( ) ; } } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] line = scanner . nextLine ( ) . split ( \" ▁ \" , n ) ; int [ ] arr = new int [ n ] ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Integer . parseInt ( line [ i ] ) ; total += arr [ i ] ; } if ( total % n != 0 ) { System . out . println ( - 1 ) ; return ; } int bridges = 0 ; int avg = total / n ; int currentTotal = 0 ; int currentSize = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( currentTotal + arr [ i ] ) == avg * ( currentSize + 1 ) ) { currentTotal = 0 ; currentSize = 0 ; } else { currentTotal += arr [ i ] ; currentSize ++ ; bridges ++ ; } } System . out . println ( bridges ) ; } }", "import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] pp = new int [ n ] ; int sum = 0 ; int ans = 0 ; int ave = 0 ; for ( int i = 0 ; i < n ; i ++ ) { pp [ i ] = sc . nextInt ( ) ; sum += pp [ i ] ; } if ( sum % n == 0 ) { ave = sum / n ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( pp [ i ] != ave ) { ans ++ ; int tmp = ave - pp [ i ] ; pp [ i + 1 ] = pp [ i + 1 ] - tmp ; pp [ i ] = ave ; } } System . out . println ( ans ) ; } else { System . out . println ( - 1 ) ; } sc . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b [ ] = new int [ a ] ; int count = 0 ; for ( int i = 0 ; i != a ; i ++ ) { b [ i ] = scan . nextInt ( ) ; count += b [ i ] ; } if ( count % a != 0 ) { System . out . println ( - 1 ) ; } else { int ans2 = count / a ; count = 0 ; int ans = 0 ; for ( int i = 0 ; i != a ; i ++ ) { count += b [ i ] ; if ( count != ans2 * ( i + 1 ) ) { ans ++ ; } } System . out . println ( ans ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE if sum ( a ) % n != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE quit ( ) NEW_LINE DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT if sum ( a [ : i + 1 ] ) != ( i + 1 ) * sum ( a ) / n : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE if sum ( a ) % N != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT x = sum ( a ) // N NEW_LINE left_sum = 0 NEW_LINE bridge = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT left_sum += a [ i ] NEW_LINE right_sum = sum ( a ) - left_sum NEW_LINE if left_sum != x * ( i + 1 ) or right_sum != x * ( N - i - 1 ) : NEW_LINE INDENT bridge += 1 NEW_LINE DEDENT DEDENT print ( bridge ) NEW_LINE DEDENT", "def island_and_bridge ( N : int , A : list ) -> int : NEW_LINE INDENT if sum ( A ) % N > 0 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT s = 0 NEW_LINE goal = sum ( A ) // N NEW_LINE bridges = 0 NEW_LINE for a in A : NEW_LINE INDENT s += a - goal NEW_LINE if s != 0 : NEW_LINE INDENT bridges += 1 NEW_LINE DEDENT DEDENT return bridges NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = island_and_bridge ( N , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE hoge = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE kei = sum ( hoge ) NEW_LINE hei = kei / n NEW_LINE nokori = 0 NEW_LINE ans = 0 NEW_LINE if ( kei % n > 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( n - 1 ) : NEW_LINE INDENT nokori += hoge [ i ] NEW_LINE if ( nokori != hei * ( i + 1 ) ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT", "def b_island ( N , A ) : NEW_LINE INDENT s = sum ( A ) NEW_LINE if s % N != 0 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT return sum ( 1 for i in range ( 1 , N ) if sum ( A [ : i ] ) != s // N * i ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( b_island ( N , A ) ) NEW_LINE" ]
atcoder_abc097_A
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; if ( ( Math . abs ( a - b ) <= d && Math . abs ( b - c ) <= d ) || Math . abs ( a - c ) <= d ) { out . println ( \" Yes \" ) ; } else { out . println ( \" No \" ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) , d = sc . nextInt ( ) ; int difAB = ( int ) Math . abs ( a - b ) ; int difBC = ( int ) Math . abs ( b - c ) ; int difAC = ( int ) Math . abs ( a - c ) ; if ( difAB <= d && difBC <= d ) { out . println ( \" Yes \" ) ; } else if ( difAC <= d ) out . println ( \" Yes \" ) ; else out . println ( \" No \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numA = 0 ; int numB = 0 ; int numC = 0 ; int numD = 0 ; try { scanner = new Scanner ( System . in ) ; numA = scanner . nextInt ( ) ; numB = scanner . nextInt ( ) ; numC = scanner . nextInt ( ) ; numD = scanner . nextInt ( ) ; boolean canTalk = false ; canTalk = ( ( Math . abs ( numA - numB ) <= numD && Math . abs ( numB - numC ) <= numD ) || Math . abs ( numA - numC ) <= numD ) ; System . out . println ( canTalk ? \" Yes \" : \" No \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }", "import java . util . * ; class Main { 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 ( ) ; int ab = ( int ) Math . abs ( a - b ) ; int bc = ( int ) Math . abs ( b - c ) ; int ca = ( int ) Math . abs ( c - a ) ; if ( ca <= d ) { System . out . println ( \" Yes \" ) ; return ; } if ( ab <= d && bc <= d ) { System . out . println ( \" Yes \" ) ; return ; } System . out . println ( \" No \" ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABC097_A solver = new ABC097_A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC097_A { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a , b , c , d ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; c = in . nextInt ( ) ; d = in . nextInt ( ) ; if ( Math . abs ( c - a ) <= d ) { out . print ( \" Yes \" ) ; return ; } if ( Math . abs ( c - b ) <= d && Math . abs ( b - a ) <= d ) { out . print ( \" Yes \" ) ; return ; } out . print ( \" No \" ) ; } } }" ]
[ "a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE AB = abs ( a - b ) NEW_LINE AC = abs ( a - c ) NEW_LINE BC = abs ( b - c ) NEW_LINE if AC <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT elif AB <= d and BC <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( \" Yes \" if ( ( abs ( l [ 0 ] - l [ 1 ] ) <= l [ 3 ] ) & ( abs ( l [ 1 ] - l [ 2 ] ) <= l [ 3 ] ) ) or ( abs ( l [ 0 ] - l [ 2 ] ) <= l [ 3 ] ) else \" No \" ) NEW_LINE", "a , b , c , d = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE if abs ( a - c ) <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT elif abs ( a - b ) <= d and abs ( b - c ) <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if ( abs ( A [ 0 ] - A [ 2 ] ) <= A [ 3 ] or ( ( abs ( A [ 0 ] - A [ 1 ] ) <= A [ 3 ] ) and ( abs ( A [ 2 ] - A [ 1 ] ) <= A [ 3 ] ) ) ) : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE print ( [ \" Yes \" , \" No \" ] [ not ( abs ( C - A ) <= D or ( abs ( B - A ) <= D and abs ( C - B ) <= D ) ) ] ) NEW_LINE" ]
atcoder_abc015_B
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; double ans = 0 ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int tmp = in . nextInt ( ) ; if ( 0 < tmp ) { ans += tmp ; count ++ ; } } out . println ( ( int ) Math . ceil ( ans / count ) ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sum = 0 ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; int num = sc . nextInt ( ) ; for ( int n = 0 ; n < num ; n ++ ) { int bu = sc . nextInt ( ) ; if ( bu != 0 ) { list . add ( bu ) ; sum = sum + bu ; } } float a = ( sum + ( list . size ( ) - 1 ) ) / list . size ( ) ; int answer = ( int ) ( Math . ceil ( a ) ) ; System . out . println ( answer ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] a = scanner . nextLine ( ) . split ( \" ▁ \" ) ; scanner . close ( ) ; double haveBug = 0 ; double sumBug = 0 ; for ( String bugNumStr : a ) { int bugNum = Integer . parseInt ( bugNumStr ) ; if ( bugNum != 0 ) { haveBug ++ ; sumBug += bugNum ; } } double avg = sumBug / haveBug ; int avgCeiled = ( int ) Math . ceil ( avg ) ; System . out . println ( avgCeiled ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = scanner . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) A [ i ] = scanner . nextInt ( ) ; int sum = 0 , size = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != 0 ) { sum += A [ i ] ; ++ size ; } } System . out . println ( sum / size + ( sum % size != 0 ? 1 : 0 ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double n = sc . nextInt ( ) ; double tmpN = n ; double a = 0 ; int tmp ; for ( int i = 0 ; i < n ; i ++ ) { tmp = sc . nextInt ( ) ; if ( tmp == 0 ) { tmpN -- ; } else { a += tmp ; } } n = tmpN ; int output = 0 ; while ( true ) { if ( a / n <= output ) { System . out . println ( output ) ; return ; } output ++ ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE soft = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE while ( True ) : NEW_LINE INDENT try : NEW_LINE INDENT soft . remove ( 0 ) NEW_LINE DEDENT except : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( - ( - sum ( soft ) // len ( soft ) ) ) NEW_LINE", "from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE import collections NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" Yay ! \" ) NEW_LINE else : print ( \" : ( \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def printrow ( a ) : NEW_LINE INDENT for i in range ( len ( a ) ) : NEW_LINE INDENT print ( a [ i ] ) NEW_LINE DEDENT DEDENT def combinations ( n , r ) : NEW_LINE INDENT if n < r : return 0 NEW_LINE return math . factorial ( n ) // ( math . factorial ( n - r ) * math . factorial ( r ) ) NEW_LINE DEDENT def permutations ( n , r ) : NEW_LINE INDENT if n < r : return 0 NEW_LINE return math . factorial ( n ) // math . factorial ( n - r ) NEW_LINE DEDENT n = ip ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE num = 0 NEW_LINE s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] : NEW_LINE INDENT num += 1 NEW_LINE s += a [ i ] NEW_LINE DEDENT DEDENT if s / num == s // num : NEW_LINE INDENT print ( s // num ) NEW_LINE DEDENT else : print ( s // num + 1 ) NEW_LINE", "import math NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( math . ceil ( sum ( a ) / ( n - a . count ( 0 ) ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE dnm = N NEW_LINE bugs = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if A [ i ] == 0 : NEW_LINE INDENT dnm -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT bugs += A [ i ] NEW_LINE DEDENT DEDENT import math NEW_LINE print ( math . ceil ( bugs / dnm ) ) NEW_LINE", "import math NEW_LINE import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE n_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count = 0 NEW_LINE total = 0 NEW_LINE for i in n_list : NEW_LINE INDENT if i != 0 : NEW_LINE INDENT count += 1 NEW_LINE total += i NEW_LINE DEDENT DEDENT avrage = total / count NEW_LINE print ( math . ceil ( avrage ) ) NEW_LINE" ]
atcoder_abc109_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) , w = sc . nextInt ( ) ; int froml , fromu = 0 ; List < String > s = new ArrayList < > ( ) ; for ( int i = 0 ; i < h ; i ++ ) { froml = 0 ; for ( int j = 0 ; j < w ; j ++ ) { int a = sc . nextInt ( ) ; a += froml ; if ( j == w - 1 ) { a += fromu ; fromu = a % 2 ; if ( fromu == 1 && i + 2 <= h ) { s . add ( ( i + 1 ) + \" ▁ \" + ( j + 1 ) + \" ▁ \" + ( i + 2 ) + \" ▁ \" + ( j + 1 ) ) ; } break ; } froml = a % 2 ; if ( froml == 1 ) { s . add ( ( i + 1 ) + \" ▁ \" + ( j + 1 ) + \" ▁ \" + ( i + 1 ) + \" ▁ \" + ( j + 2 ) ) ; } } } System . out . println ( s . size ( ) ) ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { System . out . println ( s . get ( i ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] [ ] place = new int [ w ] [ h ] ; for ( int j = 0 ; j < h ; j ++ ) { for ( int i = 0 ; i < w ; i ++ ) { place [ i ] [ j ] = sc . nextInt ( ) ; } } int i = 0 ; int j = 0 ; int ni = 0 ; int nj = 0 ; int count = 0 ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { if ( j % 2 == 0 ) { if ( i == w - 1 ) { ni = i ; nj = j + 1 ; if ( nj == h ) { break ; } } else { ni = i + 1 ; nj = j ; } } else { if ( i == 0 ) { ni = i ; nj = j + 1 ; if ( nj == h ) { break ; } } else { ni = i - 1 ; nj = j ; } } if ( place [ i ] [ j ] % 2 != 0 ) { sb . append ( j + 1 ) . append ( \" ▁ \" ) . append ( i + 1 ) . append ( \" ▁ \" ) . append ( nj + 1 ) . append ( \" ▁ \" ) . append ( ni + 1 ) . append ( \" \\n \" ) ; place [ i ] [ j ] -= 1 ; place [ ni ] [ nj ] += 1 ; count ++ ; } i = ni ; j = nj ; } System . out . println ( count ) ; System . out . print ( sb ) ; } }", "import java . awt . * ; import java . util . * ; import java . util . List ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int [ ] [ ] a = new int [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int cnt = 0 ; List < Point > from = new ArrayList < > ( ) ; List < Point > to = new ArrayList < > ( ) ; for ( int i = 0 ; i < H - 1 ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( a [ i ] [ j ] % 2 != 0 ) { a [ i ] [ j ] -= 1 ; a [ i + 1 ] [ j ] += 1 ; cnt ++ ; from . add ( new Point ( i + 1 , j + 1 ) ) ; to . add ( new Point ( i + 2 , j + 1 ) ) ; } } } for ( int j = 0 ; j < W - 1 ; j ++ ) { if ( a [ H - 1 ] [ j ] % 2 != 0 ) { a [ H - 1 ] [ j ] -= 1 ; a [ H - 1 ] [ j + 1 ] += 1 ; cnt ++ ; from . add ( new Point ( H , j + 1 ) ) ; to . add ( new Point ( H , j + 2 ) ) ; } } out . println ( cnt ) ; for ( int i = 0 ; i < from . size ( ) ; i ++ ) { Point f = from . get ( i ) ; Point t = to . get ( i ) ; out . println ( f . x + \" ▁ \" + f . y + \" ▁ \" + t . x + \" ▁ \" + t . y ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int height = sc . nextInt ( ) ; int width = sc . nextInt ( ) ; boolean oddCoin [ ] [ ] = new boolean [ height ] [ width ] ; for ( int i = 0 ; i < height ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { oddCoin [ i ] [ j ] = sc . nextInt ( ) % 2 == 1 ; } } int count = 0 ; ArrayList < String > output = new ArrayList < String > ( ) ; for ( int i = 0 ; i < height - 1 ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { if ( oddCoin [ i ] [ j ] ) { count ++ ; oddCoin [ i ] [ j ] = ! oddCoin [ i ] [ j ] ; oddCoin [ i + 1 ] [ j ] = ! oddCoin [ i + 1 ] [ j ] ; output . add ( ( i + 1 ) + \" ▁ \" + ( j + 1 ) + \" ▁ \" + ( i + 1 + 1 ) + \" ▁ \" + ( j + 1 ) ) ; } } } for ( int j = 0 ; j < width - 1 ; j ++ ) { if ( oddCoin [ height - 1 ] [ j ] ) { count ++ ; oddCoin [ height - 1 ] [ j ] = ! oddCoin [ height - 1 ] [ j ] ; oddCoin [ height - 1 ] [ j + 1 ] = ! oddCoin [ height - 1 ] [ j + 1 ] ; output . add ( height + \" ▁ \" + ( j + 1 ) + \" ▁ \" + height + \" ▁ \" + ( j + 2 ) ) ; } } System . out . println ( count ) ; for ( int i = 0 ; i < output . size ( ) ; i ++ ) { System . out . println ( output . get ( i ) ) ; } } }", "import java . util . Scanner ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] [ ] map = new int [ h ] [ w ] ; ArrayList < String > list = new ArrayList < > ( ) ; int sum = 0 ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { map [ i ] [ j ] = sc . nextInt ( ) ; } } boolean jud = false ; for ( int i = 0 ; i < h ; i ++ ) { if ( i % 2 == 0 ) { for ( int j = 0 ; j < w ; j ++ ) { if ( jud ) { if ( j == 0 ) { list . add ( i + \" ▁ \" + ( j + 1 ) + \" ▁ \" + ( i + 1 ) + \" ▁ \" + ( j + 1 ) ) ; sum ++ ; } else { list . add ( ( i + 1 ) + \" ▁ \" + j + \" ▁ \" + ( i + 1 ) + \" ▁ \" + ( j + 1 ) ) ; sum ++ ; } } if ( map [ i ] [ j ] % 2 == 1 ) { jud = ! jud ; } } } else { for ( int j = w - 1 ; j >= 0 ; j -- ) { if ( jud ) { if ( j == w - 1 ) { list . add ( i + \" ▁ \" + ( j + 1 ) + \" ▁ \" + ( i + 1 ) + \" ▁ \" + ( j + 1 ) ) ; sum ++ ; } else { list . add ( ( i + 1 ) + \" ▁ \" + ( j + 2 ) + \" ▁ \" + ( i + 1 ) + \" ▁ \" + ( j + 1 ) ) ; sum ++ ; } } if ( map [ i ] [ j ] % 2 == 1 ) { jud = ! jud ; } } } } System . out . println ( sum ) ; for ( String i : list ) { System . out . println ( i ) ; } } }" ]
[ "h , w = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( h ) ] NEW_LINE p = True NEW_LINE q = [ 0 , 0 ] NEW_LINE d = [ ] NEW_LINE for i in range ( h ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT for j in range ( w ) : NEW_LINE INDENT if p : NEW_LINE INDENT if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT q = [ i , j ] NEW_LINE p = False NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT d . append ( [ q [ 0 ] + 1 , q [ 1 ] + 1 , i + 1 , j + 1 ] ) NEW_LINE q = [ i , j ] NEW_LINE if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT p = True NEW_LINE DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT for j in range ( w - 1 , - 1 , - 1 ) : NEW_LINE INDENT if p : NEW_LINE INDENT if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT q = [ i , j ] NEW_LINE p = False NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT d . append ( [ q [ 0 ] + 1 , q [ 1 ] + 1 , i + 1 , j + 1 ] ) NEW_LINE q = [ i , j ] NEW_LINE if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT p = True NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( len ( d ) ) NEW_LINE for i in d : NEW_LINE INDENT print ( i [ 0 ] , i [ 1 ] , i [ 2 ] , i [ 3 ] ) NEW_LINE DEDENT", "H , W = ( int ( x ) for x in input ( ) . split ( ) ) NEW_LINE a_mat = [ ] NEW_LINE for _ in range ( H ) : NEW_LINE INDENT a_mat . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) NEW_LINE DEDENT out_op = [ ] NEW_LINE for h in range ( H ) : NEW_LINE INDENT for w in range ( W ) : NEW_LINE INDENT if h % 2 == 0 : NEW_LINE INDENT wd = w NEW_LINE if w == W - 1 : NEW_LINE INDENT next_pos = ( h + 1 , wd ) NEW_LINE DEDENT else : NEW_LINE INDENT next_pos = ( h , wd + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT wd = W - 1 - w NEW_LINE if w == W - 1 : NEW_LINE INDENT next_pos = ( h + 1 , wd ) NEW_LINE DEDENT else : NEW_LINE INDENT next_pos = ( h , wd - 1 ) NEW_LINE DEDENT DEDENT if h == H - 1 and w == W - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if a_mat [ h ] [ wd ] % 2 == 1 : NEW_LINE INDENT a_mat [ next_pos [ 0 ] ] [ next_pos [ 1 ] ] += 1 NEW_LINE out_op . append ( ( h , wd , next_pos [ 0 ] , next_pos [ 1 ] ) ) NEW_LINE DEDENT DEDENT DEDENT print ( len ( out_op ) ) NEW_LINE for y , x , yn , xn in out_op : NEW_LINE INDENT print ( y + 1 , x + 1 , yn + 1 , xn + 1 ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from itertools import product NEW_LINE def main ( ) : NEW_LINE INDENT H , W = LI ( ) NEW_LINE A = [ ] NEW_LINE for _ in range ( H ) : NEW_LINE INDENT A . append ( LI ( ) ) NEW_LINE DEDENT ans = [ ] NEW_LINE for y , x in product ( range ( 1 , H + 1 ) , range ( 1 , W ) ) : NEW_LINE INDENT j , i = y - 1 , x - 1 NEW_LINE if A [ j ] [ i ] % 2 : NEW_LINE INDENT A [ j ] [ i + 1 ] += 1 NEW_LINE ans . append ( [ y , x , y , x + 1 ] ) NEW_LINE DEDENT DEDENT x = W NEW_LINE i = x - 1 NEW_LINE for y in range ( 1 , H ) : NEW_LINE INDENT j = y - 1 NEW_LINE if A [ j ] [ i ] % 2 : NEW_LINE INDENT A [ j + 1 ] [ i ] += 1 NEW_LINE ans . append ( [ y , x , y + 1 , x ] ) NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for arr in ans : NEW_LINE INDENT print ( * arr ) NEW_LINE DEDENT return 0 NEW_LINE DEDENT main ( ) NEW_LINE", "h , w = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE lists = [ [ 0 ] * w ] * h NEW_LINE for i in range ( h ) : NEW_LINE INDENT lists [ i ] = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE DEDENT count = 0 NEW_LINE operations = \" \" NEW_LINE for i , l in enumerate ( lists ) : NEW_LINE INDENT for j , a in enumerate ( l ) : NEW_LINE INDENT if j == w - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if a % 2 == 1 : NEW_LINE INDENT lists [ i ] [ j ] -= 1 NEW_LINE lists [ i ] [ j + 1 ] += 1 NEW_LINE count += 1 NEW_LINE operations += str ( i + 1 , ) + \" ▁ \" + str ( j + 1 ) + \" ▁ \" + str ( i + 1 ) + \" ▁ \" + str ( j + 2 ) + \" \\n \" NEW_LINE DEDENT DEDENT DEDENT for i in range ( h ) : NEW_LINE INDENT if i == h - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if lists [ i ] [ w - 1 ] % 2 == 1 : NEW_LINE INDENT lists [ i ] [ j ] -= 1 NEW_LINE lists [ i + 1 ] [ j ] += 1 NEW_LINE count += 1 NEW_LINE operations += str ( i + 1 , ) + \" ▁ \" + str ( j + 1 ) + \" ▁ \" + str ( i + 2 ) + \" ▁ \" + str ( j + 1 ) + \" \\n \" NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE print ( operations ) NEW_LINE", "inpl = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE H , W = inpl ( ) NEW_LINE A = [ ] NEW_LINE for _ in range ( H ) : NEW_LINE INDENT A . append ( inpl ( ) ) NEW_LINE DEDENT def pos ( n ) : NEW_LINE INDENT q , m = divmod ( n , W ) NEW_LINE if q % 2 : NEW_LINE INDENT m = ( W - 1 ) - m NEW_LINE DEDENT return q , m NEW_LINE DEDENT ans = [ ] NEW_LINE f = 0 NEW_LINE hn , wn = 0 , 0 NEW_LINE for n in range ( H * W - 1 ) : NEW_LINE INDENT h , w = hn , wn NEW_LINE hn , wn = pos ( n + 1 ) NEW_LINE if ( f + A [ h ] [ w ] ) % 2 : NEW_LINE INDENT ans . append ( [ h + 1 , w + 1 , hn + 1 , wn + 1 ] ) NEW_LINE f = 1 NEW_LINE DEDENT else : NEW_LINE INDENT f = 0 NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for rec in ans : NEW_LINE INDENT print ( rec [ 0 ] , rec [ 1 ] , rec [ 2 ] , rec [ 3 ] ) NEW_LINE DEDENT" ]
atcoder_arc066_A
[ "import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { int n = sc . nextInt ( ) ; int [ ] as = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextInt ( ) ; } Arrays . sort ( as ) ; if ( n % 2 == 0 ) { int tmp = 1 ; for ( int i = 0 ; i < n ; i += 2 ) { if ( as [ i ] != tmp || as [ i + 1 ] != tmp ) { System . out . println ( 0 ) ; return ; } tmp += 2 ; } } else { if ( as [ 0 ] != 0 ) { System . out . println ( 0 ) ; return ; } int tmp = 2 ; for ( int i = 1 ; i < n ; i += 2 ) { if ( as [ i ] != tmp || as [ i + 1 ] != tmp ) { System . out . println ( 0 ) ; return ; } tmp += 2 ; } } int ans = 1 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { ans = ( ans * 2 ) % ( 1_000_000_000 + 7 ) ; } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { private void solve ( ) throws IOException { int n = nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = nextInt ( ) ; } Arrays . sort ( a ) ; long res = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != ( i + n % 2 ) / 2 * 2 + ( 1 - n % 2 ) ) { out . println ( 0 ) ; return ; } if ( i > 0 && a [ i ] == a [ i - 1 ] ) { res = ( res * 2 ) % ( ( long ) ( 1e9 + 7 ) ) ; } } out . println ( res ) ; } BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; PrintWriter out = new PrintWriter ( System . out ) ; String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } return st . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } private void run ( ) throws IOException { solve ( ) ; out . close ( ) ; } }", "import java . util . * ; import java . io . * ; import java . awt . geom . * ; import java . math . * ; public class Main { static final Scanner in = new Scanner ( System . in ) ; static final PrintWriter out = new PrintWriter ( System . out , false ) ; static boolean debug = false ; static final int MOD = 1_000_000_007 ; public static long modPow ( long x , long n , long mod ) { long res = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) res = res * x % mod ; x = x * x % mod ; n >>= 1 ; } return res ; } static void solve ( ) { int n = in . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] x = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; if ( ( n + 1 ) % 2 != a [ i ] % 2 ) { out . println ( 0 ) ; return ; } x [ a [ i ] ] ++ ; if ( x [ a [ i ] ] > 2 ) { out . println ( 0 ) ; return ; } } if ( x [ 0 ] > 1 ) { out . println ( 0 ) ; return ; } out . println ( modPow ( 2 , n / 2 , MOD ) ) ; } public static void main ( String [ ] args ) { debug = args . length > 0 ; long start = System . nanoTime ( ) ; solve ( ) ; out . flush ( ) ; long end = System . nanoTime ( ) ; dump ( ( end - start ) / 1000000 + \" ▁ ms \" ) ; in . close ( ) ; out . close ( ) ; } static void dump ( Object ... o ) { if ( debug ) System . err . println ( Arrays . deepToString ( o ) ) ; } }", "import java . util . * ; public class Main { private static boolean isPossible ( int n , int [ ] counter ) { if ( n % 2 == 0 ) { for ( int i = 1 ; i < n ; i += 2 ) { if ( counter [ i ] != 2 ) { return false ; } } for ( int i = 0 ; i < n ; i += 2 ) { if ( counter [ i ] != 0 ) { return false ; } } return true ; } else { if ( counter [ 0 ] != 1 ) { return false ; } for ( int i = 1 ; i < n ; i += 2 ) { if ( counter [ i ] != 0 ) { return false ; } } for ( int i = 2 ; i < n ; i += 2 ) { if ( counter [ i ] != 2 ) { return false ; } } return true ; } } private static long solve ( int n , int [ ] counter ) { if ( ! isPossible ( n , counter ) ) { return 0 ; } long output = 1 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { output *= 2 ; output %= 1000000007 ; } return output ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = Integer . parseInt ( s . next ( ) ) ; int [ ] counter = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { counter [ Integer . parseInt ( s . next ( ) ) ] ++ ; } System . out . println ( solve ( n , counter ) ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; int [ ] as ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; boolean odd = n % 2 == 1 ; int [ ] check = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( a % 2 == 1 == odd ) { System . out . println ( 0 ) ; return ; } check [ a ] ++ ; if ( check [ a ] > 2 ) { System . out . println ( 0 ) ; return ; } } if ( odd && check [ 0 ] != 1 ) { System . out . println ( 0 ) ; return ; } long ans = pow ( 2 , n / 2 , 1000000007 ) ; System . out . println ( ans ) ; } long pow ( long x , int n , int MOD ) { long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ans * x % MOD ; } x = x * x % MOD ; n >>= 1 ; } return ans ; } 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 ; } } }" ]
[ "def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def solve ( ) : NEW_LINE INDENT A . sort ( ) NEW_LINE db ( A ) NEW_LINE if A [ 0 ] == 0 : NEW_LINE INDENT n = 1 NEW_LINE DEDENT else : NEW_LINE INDENT n = 0 NEW_LINE DEDENT for i in range ( n , len ( A ) , 2 ) : NEW_LINE INDENT db ( i ) NEW_LINE if A [ i ] != A [ i + 1 ] : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT return 2 ** ( len ( A ) // 2 ) % ( 10 ** 9 + 7 ) NEW_LINE DEDENT debug = False NEW_LINE N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE db ( ( N , A ) ) NEW_LINE print ( solve ( ) ) NEW_LINE", "mod = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if N % 2 == 1 : NEW_LINE INDENT l . append ( 0 ) NEW_LINE N -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT l = list ( map ( lambda x : x - 1 , l ) ) NEW_LINE DEDENT l = sorted ( l ) NEW_LINE i = 0 NEW_LINE for f , s in zip ( l [ 0 : : 2 ] , l [ 1 : : 2 ] ) : NEW_LINE INDENT if f == 2 * i and s == 2 * i : NEW_LINE INDENT i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( 2 ** ( N // 2 ) % mod ) NEW_LINE", "import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE c = collections . Counter ( a ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE val = list ( c . values ( ) ) NEW_LINE key = list ( c . keys ( ) ) NEW_LINE check = len ( a ) % 2 NEW_LINE if check == 1 : NEW_LINE INDENT if val . count ( 1 ) != 1 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT if key [ val . index ( 1 ) ] != 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT if val . count ( 2 ) != len ( val ) - 1 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 ** ( val . count ( 2 ) ) % mod ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if val . count ( 2 ) != len ( val ) : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 ** ( len ( val ) ) % mod ) NEW_LINE DEDENT DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE A = LI ( ) NEW_LINE from collections import Counter NEW_LINE cnt = Counter ( A ) NEW_LINE if N % 2 and cnt [ 0 ] < 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT for i in range ( N % 2 + 1 , N , 2 ) : NEW_LINE INDENT if cnt [ i ] != 2 : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT ans = ( 2 ** ( N // 2 ) ) % MOD NEW_LINE return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE ans = None NEW_LINE tmp = 0 NEW_LINE z = 1 NEW_LINE if ( N % 2 == 0 ) : NEW_LINE INDENT tmp = int ( N / 2 ) NEW_LINE ans = [ 2 for i in range ( tmp ) ] NEW_LINE A = map ( int , input ( ) . split ( ) ) NEW_LINE for i in A : NEW_LINE INDENT if ( int ( i / 2 ) <= int ( N / 2 ) ) : NEW_LINE INDENT ans [ int ( i / 2 ) - 1 ] -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT tmp = int ( N / 2 ) NEW_LINE ans = [ 2 for i in range ( tmp ) ] NEW_LINE z = 0 NEW_LINE A = map ( int , input ( ) . split ( ) ) NEW_LINE for i in A : NEW_LINE INDENT if ( i == 0 ) : NEW_LINE INDENT z = 1 NEW_LINE continue NEW_LINE DEDENT if ( int ( i / 2 ) <= int ( N / 2 ) ) : NEW_LINE INDENT ans [ int ( i / 2 ) - 1 ] -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT output = 2 ** ( tmp ) % ( 10 ** 9 + 7 ) NEW_LINE for i in ans : NEW_LINE INDENT if ( i != 0 ) : NEW_LINE INDENT output = 0 NEW_LINE DEDENT DEDENT print ( output * z ) NEW_LINE" ]
atcoder_abc041_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; PriorityQueue < Entry > pq = new PriorityQueue < Entry > ( N , new EntryComparator ( ) ) ; for ( int i = 1 ; i <= N ; i ++ ) { pq . add ( new Entry ( sc . nextInt ( ) , i ) ) ; } while ( ! pq . isEmpty ( ) ) { Entry e = pq . poll ( ) ; System . out . println ( e . index ) ; } } static class EntryComparator implements Comparator < Entry > { @ Override public int compare ( Entry t1 , Entry t2 ) { if ( t1 . height < t2 . height ) { return 1 ; } return - 1 ; } } static class Entry { public int height ; public int index ; public Entry ( int height , int index ) { this . height = height ; this . index = index ; } } }", "import java . util . Collections ; import java . util . TreeMap ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { IntStream . rangeClosed ( 1 , scanner . nextInt ( ) ) . boxed ( ) . collect ( Collectors . toMap ( i -> scanner . nextInt ( ) , i -> i , ( a , b ) -> null , ( ) -> new TreeMap < > ( Collections . reverseOrder ( ) ) ) ) . values ( ) . forEach ( System . out :: println ) ; } }", "import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Seito [ ] array = new Seito [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { Seito seito = new Seito ( ) ; seito . i = i + 1 ; seito . a = sc . nextInt ( ) ; array [ i ] = seito ; } sc . close ( ) ; Arrays . sort ( array , new Comparator < Seito > ( ) { public int compare ( Seito o1 , Seito o2 ) { return o2 . a - o1 . a ; } } ) ; for ( Seito seito : array ) { System . out . println ( seito . i ) ; } } static class Seito { int i , a ; } }", "import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Integer [ ] height = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { height [ i ] = sc . nextInt ( ) ; } abc041cSenojun ( n , height ) ; sc . close ( ) ; } public static void abc041cSenojun ( int n , Integer [ ] height ) { Integer [ ] id = new Integer [ n ] ; Arrays . setAll ( id , i -> i ) ; Arrays . sort ( id , Comparator . comparingInt ( i -> height [ i ] ) ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { System . out . println ( id [ i ] + 1 ) ; } } }", "import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < KeySort > list = new ArrayList < > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( new KeySort ( i + 1 , sc . nextInt ( ) ) ) ; } Collections . sort ( list , new KeySortComparator ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( list . get ( n - 1 - i ) . key ) ; } } } class KeySort { public int key ; public long sort ; public KeySort ( int key , long sort ) { this . key = key ; this . sort = sort ; } } class KeySortComparator implements Comparator < KeySort > { @ Override public int compare ( KeySort sort1 , KeySort sort2 ) { return ( int ) ( sort1 . sort - sort2 . sort ) ; } }" ]
[ "import math NEW_LINE import numpy as np NEW_LINE import copy NEW_LINE from collections import defaultdict , Counter NEW_LINE from itertools import product NEW_LINE from bisect import bisect_left , bisect_right NEW_LINE def s_inpl ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = np . array ( inpl ( ) ) NEW_LINE l = np . argsort ( - a ) NEW_LINE for i in l : NEW_LINE INDENT print ( i + 1 ) NEW_LINE DEDENT", "for v , i in sorted ( [ - int ( v ) , i ] for i , v in enumerate ( open ( 0 ) . read ( ) . split ( ) [ 1 : ] ) ) : print ( i + 1 ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE lst_a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE lst_students = [ ] NEW_LINE for i , h in enumerate ( lst_a ) : NEW_LINE INDENT i += 1 NEW_LINE t_student = ( i , h ) NEW_LINE lst_students . append ( t_student ) NEW_LINE DEDENT lst_height = sorted ( lst_students , reverse = True , key = lambda x : x [ 1 ] ) NEW_LINE for h in lst_height : NEW_LINE INDENT ans = h [ 0 ] NEW_LINE print ( ans ) NEW_LINE DEDENT", "def order_of_height ( N : int , A : list ) -> list : NEW_LINE INDENT return [ i + 1 for _ , i in sorted ( ( - a , i ) for i , a in enumerate ( A ) ) ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = order_of_height ( N , A ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT", "n = int ( input ( ) ) NEW_LINE val = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE key = [ str ( i ) for i in range ( 1 , n + 1 ) ] NEW_LINE d = dict ( zip ( key , val ) ) NEW_LINE d_sorted = sorted ( d . items ( ) , key = lambda x : x [ 1 ] , reverse = True ) NEW_LINE for num , t in d_sorted : NEW_LINE INDENT print ( num ) NEW_LINE DEDENT" ]
atcoder_arc041_A
[ "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int x = s . nextInt ( ) , y = s . nextInt ( ) , k = s . nextInt ( ) ; System . out . println ( x + y - Math . abs ( y - k ) ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( b >= c ) { pl ( a + c ) ; } else { pl ( a + 2 * b - c ) ; } } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; long x = sc . nextLong ( ) , y = sc . nextLong ( ) , k = sc . nextLong ( ) ; long ans = x + k - ( ( y < k ) ? 2 * k - 2 * y : 0 ) ; System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = 0 ; if ( y < k ) { ans = x + y - ( k - y ) ; } else { ans = x + k ; } System . out . println ( ans ) ; } }", "import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int x = sc . nextInt ( ) , y = sc . nextInt ( ) , k = sc . nextInt ( ) ; out . println ( y >= k ? x + k : x + 2 * y - k ) ; } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE if b >= k : NEW_LINE INDENT print ( a + k ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a - ( k - b ) + b ) NEW_LINE DEDENT", "X , Y = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE K = int ( input ( ) ) NEW_LINE print ( X + K if Y >= K else Y + ( X - ( K - Y ) ) ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE if y >= k : NEW_LINE INDENT ans = x + k NEW_LINE DEDENT else : NEW_LINE INDENT ans = x - ( k - y ) + y NEW_LINE DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE if k <= y : NEW_LINE INDENT print ( x + k ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( y + x - ( k - y ) ) NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "ox , uy = map ( int , input ( ) . split ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE if uy >= K : ox += K NEW_LINE else : ox = ox - ( K - uy ) + uy NEW_LINE print ( ox ) NEW_LINE" ]
atcoder_agc016_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int H = scan . nextInt ( ) ; int W = scan . nextInt ( ) ; int h = scan . nextInt ( ) ; int w = scan . nextInt ( ) ; int area = h * w ; int [ ] [ ] box = new int [ H ] [ W ] ; long sum = 0 ; int INF = 1000000000 ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( i % h == h - 1 && j % w == w - 1 ) { box [ i ] [ j ] = INF * - 1 ; } else { if ( i % h == 0 && j % w == 0 ) { box [ i ] [ j ] = INF - area + 1 ; } else { box [ i ] [ j ] = 1 ; } } sum += box [ i ] [ j ] ; } } if ( sum > 0 ) { System . out . println ( \" Yes \" ) ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( box [ i ] [ j ] ) ; if ( j < W - 1 ) { System . out . print ( \" ▁ \" ) ; } } System . out . println ( \" \" ) ; } } else { System . out . println ( \" No \" ) ; } } }", "import java . io . * ; import java . util . * ; 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 ) ; TaskC solver = new TaskC ( ) ; solver . solve ( in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( InputReader in , PrintWriter out ) { int H , W , h , w = 0 ; H = in . nextInt ( ) ; W = in . nextInt ( ) ; h = in . nextInt ( ) ; w = in . nextInt ( ) ; if ( H % h == 0 && W % w == 0 ) { out . println ( \" No \" ) ; } else { out . println ( \" Yes \" ) ; for ( int r = 1 ; r <= H ; r ++ ) { for ( int c = 1 ; c <= W ; c ++ ) { if ( r % h == 0 && c % w == 0 ) { out . print ( \" ▁ \" + ( - 1000 * w * h + 999 ) ) ; } else { out . print ( \" ▁ \" + 1000 ) ; } } out . println ( \" \" ) ; } } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; import java . io . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Integer [ ] HWhw = Arrays . stream ( in . readLine ( ) . split ( \" ▁ \" ) ) . map ( Integer :: parseInt ) . toArray ( Integer [ ] :: new ) ; int H = HWhw [ 0 ] ; int W = HWhw [ 1 ] ; int h = HWhw [ 2 ] ; int w = HWhw [ 3 ] ; long [ ] [ ] rect = new long [ H ] [ W ] ; long large = ( long ) Math . pow ( 10L , 9 ) - 1 ; if ( H % h == 0 && W % w == 0 ) { System . out . println ( \" No \" ) ; } else { System . out . println ( \" Yes \" ) ; for ( int i = 0 ; i < H ; i += h ) { for ( int j = 0 ; j < W ; j += w ) { rect [ i ] [ j ] = large ; } } for ( int i = h - 1 ; i < H ; i += h ) { for ( int j = w - 1 ; j < W ; j += w ) { rect [ i ] [ j ] -= ( large + 1 ) ; } } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( rect [ i ] [ j ] + \" ▁ \" ) ; } System . out . println ( ) ; } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; long h = sc . nextLong ( ) ; long w = sc . nextLong ( ) ; long x = ( - 1000 ) * ( h * w - 1 ) - 1 ; String [ ] ans = new String [ H ] ; for ( int i = 0 ; i < H ; ++ i ) { ans [ i ] = \" \" ; } long sum = 0 ; for ( int i = 1 ; i <= H ; ++ i ) { StringBuilder sb = new StringBuilder ( ) ; for ( int j = 1 ; j <= W ; j ++ ) { if ( i % h == 0 && j % w == 0 ) { sb . append ( x ) ; sb . append ( \" ▁ \" ) ; sum += x ; } else { sb . append ( 1000 ) ; sb . append ( \" ▁ \" ) ; sum += 1000 ; } } sb . deleteCharAt ( sb . length ( ) - 1 ) ; ans [ i - 1 ] = sb . toString ( ) ; } if ( sum <= 0 ) System . out . println ( \" No \" ) ; else { System . out . println ( \" Yes \" ) ; for ( int i = 0 ; i < H ; i ++ ) { System . out . println ( ans [ i ] ) ; } } return ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { DataSet d = new DataSet ( ) ; d . input ( ) ; if ( d . H % d . h == 0 && d . W % d . w == 0 ) System . out . println ( \" No \" ) ; else if ( d . H % d . h != 0 ) { System . out . println ( \" Yes \" ) ; for ( int i = 0 ; i < d . H ; i ++ ) { for ( int j = 0 ; j < d . W ; j ++ ) { System . out . print ( ( i % d . h == 0 ) ? 1000 * d . h - 1001 : - 1000 ) ; if ( j == d . W - 1 ) System . out . println ( ) ; else System . out . print ( \" ▁ \" ) ; } } } else if ( d . W % d . w != 0 ) { System . out . println ( \" Yes \" ) ; for ( int i = 0 ; i < d . H ; i ++ ) { for ( int j = 0 ; j < d . W ; j ++ ) { System . out . print ( ( j % d . w == 0 ) ? 1000 * d . w - 1001 : - 1000 ) ; if ( j == d . W - 1 ) System . out . println ( ) ; else System . out . print ( \" ▁ \" ) ; } } } } } class DataSet { int H , W , h , w ; public void input ( ) { Scanner sc = new Scanner ( System . in ) ; H = sc . nextInt ( ) ; W = sc . nextInt ( ) ; h = sc . nextInt ( ) ; w = sc . nextInt ( ) ; sc . close ( ) ; } }" ]
[ "H , W , h , w = map ( int , input ( ) . split ( ) ) NEW_LINE def solve ( H , W , h , w ) : NEW_LINE INDENT if ( W % w == 0 and H % h == 0 ) : NEW_LINE INDENT return False , [ ] NEW_LINE DEDENT if ( W % w == 0 ) : NEW_LINE INDENT return True , solve_vertical ( H , W , h , w ) NEW_LINE DEDENT return True , solve_horizontal ( H , W , h , w ) NEW_LINE DEDENT def solve_horizontal ( H , W , h , w ) : NEW_LINE INDENT return [ solve_horizontal_core ( W , w ) ] * H NEW_LINE DEDENT def solve_horizontal_core ( W , w ) : NEW_LINE INDENT m , r = divmod ( W , w ) NEW_LINE row = [ 0 ] * W NEW_LINE row [ 0 ] = m + 1 NEW_LINE row [ w - 1 ] = - m - 2 NEW_LINE for i in range ( w , W ) : NEW_LINE INDENT row [ i ] = row [ i - w ] NEW_LINE DEDENT return row NEW_LINE DEDENT def solve_vertical ( H , W , h , w ) : NEW_LINE INDENT col = solve_horizontal_core ( H , h ) NEW_LINE m = [ ] NEW_LINE for c in col : NEW_LINE INDENT m . append ( [ c ] * W ) NEW_LINE DEDENT return m NEW_LINE DEDENT yesno , mat = solve ( H , W , h , w ) NEW_LINE if yesno : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE for row in mat : NEW_LINE INDENT print ( * row ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def solve ( ) : NEW_LINE INDENT H , W , h , w = inpl ( ) NEW_LINE if H % h == 0 and W % w == 0 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE return - 1 NEW_LINE DEDENT ans = [ [ 1000 ] * W for _ in range ( H ) ] NEW_LINE cnt = 0 NEW_LINE for i in range ( h - 1 , H , h ) : NEW_LINE INDENT for j in range ( w - 1 , W , w ) : NEW_LINE INDENT ans [ i ] [ j ] = - ( h * w - 1 ) * 1000 - 1 NEW_LINE cnt += 1 NEW_LINE DEDENT DEDENT print ( ' Yes ' ) NEW_LINE for row in ans : NEW_LINE INDENT print ( ' ▁ ' . join ( map ( str , row ) ) ) NEW_LINE DEDENT return 0 NEW_LINE DEDENT solve ( ) NEW_LINE", "from collections import defaultdict , deque NEW_LINE import sys , heapq , bisect , math , itertools , string , queue , datetime NEW_LINE sys . setrecursionlimit ( 10 ** 8 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE eps = 10 ** - 7 NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def inpls ( ) : return list ( input ( ) . split ( ) ) NEW_LINE H , W , h , w = inpl ( ) NEW_LINE MAP = [ [ 0 ] * W for i in range ( H ) ] NEW_LINE pl = mn = 0 NEW_LINE tmp = 0 NEW_LINE for y in range ( H ) : NEW_LINE INDENT for x in range ( W ) : NEW_LINE INDENT if ( y + 1 ) % h == 0 and ( x + 1 ) % w == 0 : NEW_LINE INDENT MAP [ y ] [ x ] -= ( h * w - 1 ) * 1000 + 1 NEW_LINE mn += 1 NEW_LINE tmp -= ( h * w - 1 ) * 1000 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT MAP [ y ] [ x ] = 1000 NEW_LINE pl += 1 NEW_LINE tmp += 1000 NEW_LINE DEDENT DEDENT DEDENT if tmp <= 0 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE for m in MAP : NEW_LINE INDENT print ( ' ▁ ' . join ( map ( str , m ) ) ) NEW_LINE DEDENT DEDENT", "H , W , h , w = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] NEW_LINE if W % w != 0 : NEW_LINE INDENT r = W % w NEW_LINE n = int ( W / w ) NEW_LINE n = n + 1 NEW_LINE print ( ' Yes ' ) NEW_LINE for i in range ( H ) : NEW_LINE INDENT for k in range ( W ) : NEW_LINE INDENT if ( k + 1 ) % w == 0 : NEW_LINE INDENT print ( - n * ( w - 1 ) - 1 , end = ' ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n , end = ' ' ) NEW_LINE DEDENT if k == W - 1 : NEW_LINE INDENT print ( ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( end = ' ▁ ' ) NEW_LINE DEDENT DEDENT DEDENT DEDENT elif H % h != 0 : NEW_LINE INDENT r = H % h NEW_LINE n = int ( H / h ) NEW_LINE n = n + 1 NEW_LINE print ( ' Yes ' ) NEW_LINE store = 0 NEW_LINE for i in range ( H ) : NEW_LINE INDENT if ( i + 1 ) % h == 0 : NEW_LINE INDENT store = - n * ( h - 1 ) - 1 NEW_LINE DEDENT else : NEW_LINE INDENT store = n NEW_LINE DEDENT for k in range ( W ) : NEW_LINE INDENT if k == W - 1 : NEW_LINE INDENT print ( store ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( store , end = ' ▁ ' ) NEW_LINE DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "H , W , h , w = map ( int , input ( ) . split ( ) ) NEW_LINE if h * w == 1 : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT plus = 1000 NEW_LINE matrix = [ [ plus ] * W for _ in [ 0 ] * H ] NEW_LINE minus , total = - h * w * plus + plus - 1 , H * W * plus NEW_LINE y , x = h - 1 , w - 1 NEW_LINE for y in range ( h - 1 , H , h ) : NEW_LINE INDENT for x in range ( w - 1 , W , w ) : NEW_LINE INDENT matrix [ y ] [ x ] = minus NEW_LINE total += minus - plus NEW_LINE DEDENT DEDENT if total <= 0 : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE for row in matrix : NEW_LINE INDENT print ( * row ) NEW_LINE DEDENT DEDENT" ]
atcoder_arc092_A
[ "import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; List < Grid > gridList = new ArrayList < > ( ) ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { gridList . add ( new Grid ( Color . RED , in . nextInt ( ) , in . nextInt ( ) ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { gridList . add ( new Grid ( Color . BLUE , in . nextInt ( ) , in . nextInt ( ) ) ) ; } gridList . sort ( Comparator . comparing ( Grid :: getX ) . thenComparing ( Grid :: getColor ) ) ; List < Grid > tmp = new ArrayList < > ( ) ; int ans = 0 ; for ( Grid grid : gridList ) { if ( grid . color == Color . RED ) { tmp . add ( grid ) ; } else { List < Grid > list = tmp . stream ( ) . filter ( g -> g . getY ( ) < grid . getY ( ) ) . collect ( Collectors . toList ( ) ) ; if ( list . size ( ) > 0 ) { ans ++ ; list . sort ( Comparator . comparing ( Grid :: getY ) ) ; tmp . remove ( list . get ( list . size ( ) - 1 ) ) ; } } } System . out . println ( ans ) ; } } class Grid { Color color ; int x ; int y ; public Grid ( Color color , int x , int y ) { this . color = color ; this . x = x ; this . y = y ; } public Color getColor ( ) { return this . color ; } public int getX ( ) { return this . x ; } public int getY ( ) { return this . y ; } public String toString ( ) { return String . format ( color + \" ▁ \\t \" + x + \" , ▁ \" + y ) ; } } enum Color { BLUE , RED }", "import java . util . * ; public class Main { static void sortpoint ( int [ ] x , int [ ] y , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = n - 1 ; j > i ; j -- ) { if ( x [ j - 1 ] > x [ j ] ) { int t = x [ j - 1 ] ; x [ j - 1 ] = x [ j ] ; x [ j ] = t ; t = y [ j - 1 ] ; y [ j - 1 ] = y [ j ] ; y [ j ] = t ; } } } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; int [ ] c = new int [ n ] ; int [ ] d = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = sc . nextInt ( ) ; d [ i ] = sc . nextInt ( ) ; } sortpoint ( a , b , n ) ; sortpoint ( c , d , n ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int j = 0 ; int ymax = - 1 ; int index = - 1 ; while ( j < n && a [ j ] < c [ i ] ) { if ( a [ j ] >= 0 && b [ j ] < d [ i ] ) { if ( b [ j ] >= ymax ) { ymax = b [ j ] ; index = j ; } } j ++ ; } if ( index >= 0 ) { ans ++ ; a [ index ] = - 1 ; } } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] [ ] red = new int [ n ] [ 2 ] ; int [ ] [ ] blue = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { red [ i ] [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; red [ i ] [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { blue [ i ] [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; blue [ i ] [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( red , ( a , b ) -> Integer . compare ( a [ 0 ] , b [ 0 ] ) ) ; Arrays . sort ( blue , ( a , b ) -> Integer . compare ( a [ 0 ] , b [ 0 ] ) ) ; System . out . println ( calc ( red , blue , n ) ) ; sc . close ( ) ; } public static int calc ( int [ ] [ ] red , int [ ] [ ] blue , int n ) { int ret = 0 , maxtemp = - 1 , index = 0 , maxindex = 0 , flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { index = 0 ; flag = 0 ; maxtemp = - 1 ; while ( index < n && red [ index ] [ 0 ] < blue [ i ] [ 0 ] ) { if ( maxtemp <= red [ index ] [ 1 ] && red [ index ] [ 1 ] < blue [ i ] [ 1 ] ) { maxtemp = red [ index ] [ 1 ] ; maxindex = index ; flag = 1 ; } index ++ ; } if ( flag == 1 ) { ret ++ ; red [ maxindex ] [ 1 ] = 201 ; } } return ret ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int a [ ] [ ] = new int [ n ] [ 2 ] ; int b [ ] [ ] = new int [ n ] [ 2 ] ; boolean used [ ] = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] [ 0 ] = sc . nextInt ( ) ; a [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] [ 0 ] = sc . nextInt ( ) ; b [ i ] [ 1 ] = sc . nextInt ( ) ; } Arrays . sort ( a , ( o1 , o2 ) -> o1 [ 0 ] - o2 [ 0 ] ) ; Arrays . sort ( b , ( o1 , o2 ) -> o1 [ 0 ] - o2 [ 0 ] ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int pare = - 1 ; int maxy = 0 ; for ( int j = 0 ; j < n && ( a [ j ] [ 0 ] < b [ i ] [ 0 ] ) ; j ++ ) { if ( used [ j ] ) { continue ; } if ( a [ j ] [ 1 ] < b [ i ] [ 1 ] && maxy <= a [ j ] [ 1 ] ) { pare = j ; maxy = a [ j ] [ 1 ] ; } } if ( pare != - 1 ) { used [ pare ] = true ; cnt ++ ; } } System . out . println ( cnt ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] r = new int [ n ] [ 2 ] ; int [ ] [ ] b = new int [ n ] [ 2 ] ; boolean [ ] buse = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { r [ i ] [ 0 ] = sc . nextInt ( ) ; r [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] [ 0 ] = sc . nextInt ( ) ; b [ i ] [ 1 ] = sc . nextInt ( ) ; buse [ i ] = false ; } sc . close ( ) ; int ans = 0 ; MyComp comp = new MyComp ( ) ; Arrays . sort ( r , comp ) ; for ( int i = 0 ; i < n ; i ++ ) { int rx = r [ n - i - 1 ] [ 0 ] ; int ry = r [ n - i - 1 ] [ 1 ] ; int bymin = 1000 ; int byminpos = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( b [ j ] [ 0 ] > rx && b [ j ] [ 1 ] > ry && b [ j ] [ 1 ] < bymin && ! buse [ j ] ) { bymin = b [ j ] [ 1 ] ; byminpos = j ; } } if ( bymin != 1000 ) { ans ++ ; buse [ byminpos ] = true ; } } System . out . println ( ans ) ; } } class MyComp implements Comparator { @ Override public int compare ( Object i1 , Object i2 ) { return ( ( int [ ] ) i1 ) [ 0 ] - ( ( int [ ] ) i2 ) [ 0 ] ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "N = int ( input ( ) ) NEW_LINE red = [ ] NEW_LINE blue = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE red . append ( ( a , b ) ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT c , d = map ( int , input ( ) . split ( ) ) NEW_LINE blue . append ( ( c , d ) ) NEW_LINE DEDENT red = sorted ( red , key = lambda x : - x [ 1 ] ) NEW_LINE blue = sorted ( blue , key = lambda x : x [ 0 ] ) NEW_LINE answer = 0 NEW_LINE for i , b in enumerate ( blue ) : NEW_LINE INDENT for j , r in enumerate ( red ) : NEW_LINE INDENT if r [ 0 ] < b [ 0 ] and r [ 1 ] < b [ 1 ] : NEW_LINE INDENT answer += 1 NEW_LINE red . pop ( j ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( answer ) NEW_LINE", "from bisect import bisect_left NEW_LINE n = int ( input ( ) ) NEW_LINE red = sorted ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] ) NEW_LINE blue = sorted ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] ) NEW_LINE ans = 0 NEW_LINE for x , y , in blue : NEW_LINE INDENT i = bisect_left ( [ a [ 0 ] for a in red ] , x ) NEW_LINE tmp = sorted ( red [ : i ] , key = lambda x : x [ 1 ] , reverse = True ) NEW_LINE for xx , yy in tmp : NEW_LINE INDENT if y > yy : NEW_LINE INDENT ans += 1 NEW_LINE red . remove ( [ xx , yy ] ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE red = [ inpl ( ) for _ in range ( N ) ] NEW_LINE blue = [ inpl ( ) for _ in range ( N ) ] NEW_LINE red = sorted ( red , key = lambda x : - x [ 0 ] ) NEW_LINE blue = sorted ( blue , key = lambda x : x [ 1 ] ) NEW_LINE ans = 0 NEW_LINE for a , b in red : NEW_LINE INDENT for c , d in blue : NEW_LINE INDENT if a < c and b < d : NEW_LINE INDENT ans += 1 NEW_LINE blue . remove ( [ c , d ] ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE R = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE B = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE List = [ [ ] for i in range ( N ) ] NEW_LINE count = [ 0 ] * N NEW_LINE unpaired = [ True ] * N NEW_LINE for i , r in enumerate ( R ) : NEW_LINE INDENT for j , b in enumerate ( B ) : NEW_LINE INDENT if b [ 0 ] > r [ 0 ] and b [ 1 ] > r [ 1 ] : NEW_LINE INDENT List [ i ] . append ( j ) NEW_LINE count [ j ] += 1 NEW_LINE DEDENT DEDENT DEDENT List . sort ( key = lambda x : len ( x ) ) NEW_LINE ans = 0 NEW_LINE for l in List : NEW_LINE INDENT k = float ( \" inf \" ) NEW_LINE p = - 1 NEW_LINE for j in l : NEW_LINE INDENT if unpaired [ j ] : NEW_LINE INDENT if k > count [ j ] : NEW_LINE INDENT k = count [ j ] NEW_LINE p = j NEW_LINE DEDENT count [ j ] -= 1 NEW_LINE DEDENT DEDENT if p >= 0 : NEW_LINE INDENT ans += 1 NEW_LINE unpaired [ p ] = False NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE r = [ [ 0 , 0 ] for i in range ( N ) ] NEW_LINE b = [ [ 0 , 0 ] for i in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT r [ i ] [ 0 ] , r [ i ] [ 1 ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT b [ i ] [ 0 ] , b [ i ] [ 1 ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT r . sort ( key = lambda x : ( x [ 1 ] ) , reverse = True ) NEW_LINE b . sort ( key = lambda x : ( x [ 0 ] ) ) NEW_LINE r_flag = [ False ] * N NEW_LINE b_flag = [ False ] * N NEW_LINE count = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if r [ j ] [ 0 ] < b [ i ] [ 0 ] and r [ j ] [ 1 ] < b [ i ] [ 1 ] and not r_flag [ j ] : NEW_LINE INDENT r_flag [ j ] = True NEW_LINE count += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( count ) NEW_LINE" ]
atcoder_abc037_D
[ "import java . util . * ; public class Main { public static int h , w ; public static int [ ] [ ] a ; public static int [ ] [ ] memo ; public static final int MOD = ( int ) 1e9 + 7 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; h = sc . nextInt ( ) ; w = sc . nextInt ( ) ; a = new int [ h ] [ w ] ; memo = new int [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { a [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; memo [ i ] [ j ] = - 1 ; } } long ans = 0 ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { ans += saiki ( j , i ) ; ans %= MOD ; } } System . out . println ( ans ) ; } public static int saiki ( int x , int y ) { if ( memo [ y ] [ x ] != - 1 ) return memo [ y ] [ x ] ; long res = 0 ; int [ ] dx = { 0 , 1 , 0 , - 1 } ; int [ ] dy = { 1 , 0 , - 1 , 0 } ; for ( int i = 0 ; i < 4 ; i ++ ) { int nx = x + dx [ i ] ; int ny = y + dy [ i ] ; if ( 0 <= nx && nx < w && 0 <= ny && ny < h && a [ y ] [ x ] > a [ ny ] [ nx ] ) { res += saiki ( nx , ny ) ; } } memo [ y ] [ x ] = ( int ) ( res % MOD ) + 1 ; return memo [ y ] [ x ] ; } }", "import java . util . Scanner ; public class Main { static int H , W ; static int [ ] [ ] src ; static int [ ] [ ] dp ; static final int MOD = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; H = Integer . parseInt ( sc . next ( ) ) ; W = Integer . parseInt ( sc . next ( ) ) ; src = new int [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { src [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; } } dp = new int [ H ] [ W ] ; int ans = 0 ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { ans = ( ans + pattern ( j , i ) ) % MOD ; } } System . out . println ( ans ) ; } static int pattern ( int x , int y ) { if ( dp [ y ] [ x ] > 0 ) return dp [ y ] [ x ] ; int a = src [ y ] [ x ] ; int ret = 1 ; if ( x > 0 && a > src [ y ] [ x - 1 ] ) ret = ( ret + pattern ( x - 1 , y ) ) % MOD ; if ( y > 0 && a > src [ y - 1 ] [ x ] ) ret = ( ret + pattern ( x , y - 1 ) ) % MOD ; if ( x < W - 1 && a > src [ y ] [ x + 1 ] ) ret = ( ret + pattern ( x + 1 , y ) ) % MOD ; if ( y < H - 1 && a > src [ y + 1 ] [ x ] ) ret = ( ret + pattern ( x , y + 1 ) ) % MOD ; return dp [ y ] [ x ] = ret ; } }" ]
[ "import subprocess as sp NEW_LINE import sys NEW_LINE code = r ''' STRNEWLINE # include ▁ < algorithm > STRNEWLINE # include ▁ < cstdio > STRNEWLINE using ▁ namespace ▁ std ; STRNEWLINE const ▁ int ▁ M ▁ = ▁ 1000000007 ; STRNEWLINE int ▁ h , ▁ w ; STRNEWLINE int ▁ a [ 1000 ] [ 1000 ] , ▁ cache [ 1000 ] [ 1000 ] ; STRNEWLINE unsigned ▁ f ( int ▁ x , ▁ int ▁ y ) ▁ { STRNEWLINE ▁ ▁ static ▁ int ▁ dx [ ] ▁ = ▁ { 1 , ▁ 0 , ▁ - 1 , ▁ 0 } ; STRNEWLINE ▁ ▁ static ▁ int ▁ dy [ ] ▁ = ▁ { 0 , ▁ 1 , ▁ 0 , ▁ - 1 } ; STRNEWLINE ▁ ▁ int ▁ & c ▁ = ▁ cache [ y ] [ x ] ; STRNEWLINE ▁ ▁ if ▁ ( c ▁ < ▁ 0 ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ c ▁ = ▁ 1 ; STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ d ▁ = ▁ 0 ; ▁ d ▁ < ▁ 4 ; ▁ + + d ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ int ▁ nx ▁ = ▁ x ▁ + ▁ dx [ d ] ; STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ int ▁ ny ▁ = ▁ y ▁ + ▁ dy [ d ] ; STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ if ▁ ( 0 ▁ < = ▁ nx ▁ and ▁ nx ▁ < ▁ w ▁ and ▁ 0 ▁ < = ▁ ny ▁ and ▁ ny ▁ < ▁ h ▁ and ▁ a [ ny ] [ nx ] ▁ > ▁ a [ y ] [ x ] ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ c ▁ = ▁ ( c ▁ + ▁ f ( nx , ▁ ny ) ) ▁ % ▁ M ; STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ return ▁ c ; STRNEWLINE } STRNEWLINE int ▁ main ( ) ▁ { STRNEWLINE ▁ ▁ int ▁ total ▁ = ▁ 0 ; STRNEWLINE ▁ ▁ scanf ( \" % d % d \" , ▁ & h , ▁ & w ) ; STRNEWLINE ▁ ▁ for ▁ ( int ▁ y ▁ = ▁ 0 ; ▁ y ▁ < ▁ h ; ▁ + + y ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ x ▁ = ▁ 0 ; ▁ x ▁ < ▁ w ; ▁ + + x ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ scanf ( \" % d \" , ▁ & a [ y ] [ x ] ) ; STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ for ▁ ( int ▁ y ▁ = ▁ 0 ; ▁ y ▁ < ▁ h ; ▁ + + y ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ x ▁ = ▁ 0 ; ▁ x ▁ < ▁ w ; ▁ + + x ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ cache [ y ] [ x ] ▁ = ▁ - 1 ; STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ for ▁ ( int ▁ y ▁ = ▁ 0 ; ▁ y ▁ < ▁ h ; ▁ + + y ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ x ▁ = ▁ 0 ; ▁ x ▁ < ▁ w ; ▁ + + x ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ total ▁ = ▁ ( total ▁ + ▁ f ( x , ▁ y ) ) ▁ % ▁ M ; STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ printf ( \" % d \\n \" , ▁ total ) ; STRNEWLINE ▁ ▁ return ▁ 0 ; STRNEWLINE } STRNEWLINE ''' NEW_LINE filename = ' sense _ of _ guilt . cpp ' NEW_LINE with open ( filename , ' w ' ) as f : NEW_LINE INDENT print ( code , file = f ) NEW_LINE DEDENT sp . Popen ( [ ' g + + ' , ' - std = c + + 11' , ' - O2' , filename ] ) . communicate ( ) NEW_LINE sp . Popen ( [ ' . / a . out ' ] , stdin = sys . stdin , stdout = sys . stdout ) . communicate ( ) NEW_LINE" ]
atcoder_arc079_C
[ "import java . util . * ; public class Main { public static final long INF = 1000000000000000000L ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; final int N = in . nextInt ( ) ; long [ ] as = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { as [ i ] = in . nextLong ( ) ; } long K = 0 ; while ( true ) { boolean isFinished = true ; for ( int i = 0 ; i < N ; i ++ ) { final long k = as [ i ] / N ; if ( k > 0 ) { isFinished = false ; K += k ; for ( int j = 0 ; j < N ; j ++ ) { if ( j == i ) { as [ j ] = as [ j ] % N ; } else { as [ j ] += k ; } } } } if ( isFinished ) { break ; } } System . out . printf ( \" % d \\n \" , K ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] a = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] = sc . nextLong ( ) ; long ans = 0 ; Arrays . sort ( a ) ; for ( int i = 1 ; i < N ; i ++ ) { long op = ( a [ i ] - a [ 0 ] ) / ( N + 1 ) ; ans += op ; a [ i ] -= op * ( N + 1 ) ; } for ( int i = 0 ; i < N ; i ++ ) a [ i ] += ans ; Arrays . sort ( a ) ; long op = Math . max ( 0 , a [ 0 ] - N ) ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] -= op ; ans += op * N ; int idx = N - 1 ; while ( true ) { if ( a [ idx ] <= N - 1 ) break ; ans ++ ; a [ idx ] -= N ; for ( int i = 0 ; i < N ; i ++ ) if ( i != idx ) a [ i ] ++ ; idx = ( idx - 1 + N ) % N ; } System . out . println ( ans ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; sc . close ( ) ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long min = Math . max ( n , Arrays . stream ( a ) . min ( ) . getAsLong ( ) ) ; long div = ( a [ i ] - min ) / ( n + 1 ) ; ans += div ; a [ i ] -= div * n ; for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) continue ; a [ j ] += div ; } } long min = Arrays . stream ( a ) . min ( ) . getAsLong ( ) ; if ( min >= n ) { ans += ( min - n + 1 ) * n ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] -= ( min - n + 1 ) ; } } while ( true ) { int maxpos = 0 ; long max = Long . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max ) { max = a [ i ] ; maxpos = i ; } } if ( max < n ) break ; ans ++ ; a [ maxpos ] -= n ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == maxpos ) continue ; a [ i ] ++ ; } } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long ans = 0 ; while ( true ) { long adivn [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { adivn [ i ] = a [ i ] / n ; } long sum = Arrays . stream ( adivn ) . sum ( ) ; ans += sum ; if ( sum == 0 ) { break ; } for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = a [ i ] % n + sum - adivn [ i ] ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; long sum = 0 ; for ( long lo : a ) sum += lo ; long res = 0 ; while ( true ) { long [ ] b = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { long sho = a [ i ] / n ; a [ i ] %= n ; for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) continue ; b [ j ] += sho ; } } for ( int i = 0 ; i < n ; i ++ ) a [ i ] += b [ i ] ; boolean allzero = true ; for ( long lo : b ) if ( lo != 0 ) allzero = false ; if ( allzero ) break ; } for ( long lo : a ) sum -= lo ; System . out . println ( sum ) ; } }" ]
[ "import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE N = int ( input ( ) ) NEW_LINE As = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE while True : NEW_LINE INDENT taken = [ 0 ] * N NEW_LINE for i , a in enumerate ( As ) : NEW_LINE INDENT taken [ i ] = a // N NEW_LINE As [ i ] -= taken [ i ] * N NEW_LINE DEDENT taken_sum = sum ( taken ) NEW_LINE if taken_sum == 0 : NEW_LINE INDENT break NEW_LINE DEDENT ans += taken_sum NEW_LINE for i in range ( N ) : NEW_LINE INDENT As [ i ] += ( taken_sum - taken [ i ] ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE def judge ( a : list , n : int ) : NEW_LINE INDENT for ai in a : NEW_LINE INDENT if ai >= n : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT ans = 0 NEW_LINE while judge ( a , n ) : NEW_LINE INDENT amax = max ( a ) NEW_LINE argmax = a . index ( amax ) NEW_LINE x = - ( - ( amax - ( n - 1 ) ) // n ) NEW_LINE ans += x NEW_LINE nex = [ ai + x if i != argmax else ai - n * x for ( i , ai ) in enumerate ( a ) ] NEW_LINE a = nex NEW_LINE DEDENT print ( ans ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def f ( x ) : NEW_LINE INDENT k = 0 NEW_LINE for i in a : k += ( i + x - n ) // ( n + 1 ) + 1 NEW_LINE return k <= x NEW_LINE DEDENT for i in range ( max ( 0 , sum ( a ) - n * ( n - 1 ) ) , 51 * ( 10 ** 16 ) ) : NEW_LINE INDENT if f ( i ) : break NEW_LINE DEDENT print ( i ) NEW_LINE", "n , * A = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE while 1 : NEW_LINE INDENT A . sort ( reverse = 1 ) NEW_LINE if A [ 0 ] > A [ - 1 ] + n : NEW_LINE INDENT p = ( A [ 0 ] - A [ - 1 ] ) // ( n + 1 ) NEW_LINE for j in range ( n ) : NEW_LINE INDENT A [ j ] += p NEW_LINE DEDENT A [ 0 ] -= p * ( n + 1 ) NEW_LINE ans += p NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if max ( A ) >= 2 * n : NEW_LINE INDENT ans += ( max ( A ) - 2 * n ) * n NEW_LINE ma = max ( A ) - 2 * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT A [ i ] -= ma NEW_LINE DEDENT DEDENT while max ( A ) >= n : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT A [ i ] += 1 NEW_LINE DEDENT A [ A . index ( max ( A ) ) ] -= n + 1 NEW_LINE ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "def check ( _a ) : NEW_LINE INDENT for i in range ( 0 , len ( _a ) ) : NEW_LINE INDENT if N <= _a [ i ] : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE divide_num = [ 0 for i in range ( N ) ] NEW_LINE ans = 0 NEW_LINE while check ( a ) : NEW_LINE INDENT sum_num = 0 NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT tmp = a [ i ] // N NEW_LINE divide_num [ i ] = tmp NEW_LINE sum_num += tmp NEW_LINE ans += tmp NEW_LINE DEDENT a = [ ( a [ i ] % N + sum_num - divide_num [ i ] ) for i in range ( 0 , N ) ] NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT" ]
atcoder_abc033_B
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] names = new String [ n ] ; int [ ] popularity = new int [ n ] ; int totalPopularity = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] line = scanner . nextLine ( ) . split ( \" ▁ \" , 2 ) ; names [ i ] = line [ 0 ] ; popularity [ i ] = Integer . parseInt ( line [ 1 ] ) ; totalPopularity += popularity [ i ] ; } String city = \" atcoder \" ; for ( int i = 0 ; i < n ; i ++ ) { if ( popularity [ i ] > totalPopularity / 2 ) { city = names [ i ] ; break ; } } System . out . println ( city ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; 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 ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; long total = 0 ; int max = 0 ; String ml = null ; for ( int i = 0 ; i < n ; i ++ ) { String s = in . string ( ) ; int p = in . ints ( ) ; if ( p > max ) { max = p ; ml = s ; } total += p ; } if ( max * 2 > total ) { out . println ( ml ) ; } else { out . println ( \" atcoder \" ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }", "import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int size = sc . nextInt ( ) ; List < TownInfo > townList = new ArrayList < > ( ) ; double total = 0 ; for ( int i = 0 ; i < size ; i ++ ) { String townName = sc . next ( ) ; double population = sc . nextDouble ( ) ; total += population ; TownInfo info = new TownInfo ( townName , population ) ; townList . add ( info ) ; } sc . close ( ) ; String newTownName = \" atcoder \" ; for ( TownInfo townInfo : townList ) { double popu = townInfo . getPopulation ( ) ; double percent = ( popu * 100 / total ) ; if ( percent > 50 ) { newTownName = townInfo . getTownName ( ) ; } } System . out . println ( newTownName ) ; } } class TownInfo { private String townName ; private double population ; public TownInfo ( String townName , double population ) { this . townName = townName ; this . population = population ; } public String getTownName ( ) { return townName ; } public double getPopulation ( ) { return population ; } }", "import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > map = new TreeMap < > ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) map . put ( sc . next ( ) , sc . nextInt ( ) ) ; int sum = 0 ; String ans = \" atcoder \" ; for ( Integer v : map . values ( ) ) sum += v ; for ( String str : map . keySet ( ) ) if ( map . get ( str ) > sum / 2 ) ans = str ; System . out . println ( ans ) ; } }", "import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] name = new String [ n ] ; int [ ] jinkou = new int [ n ] ; HashMap < Integer , String > map = new HashMap < Integer , String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { name [ i ] = sc . next ( ) ; jinkou [ i ] = sc . nextInt ( ) ; map . put ( jinkou [ i ] , name [ i ] ) ; } int max = jinkou [ 0 ] ; int total = 0 ; for ( int j = 0 ; j < jinkou . length ; j ++ ) { total += jinkou [ j ] ; if ( max < jinkou [ j ] ) max = jinkou [ j ] ; } if ( ( total / 2 ) < max ) { System . out . println ( map . get ( max ) ) ; } else { System . out . println ( \" atcoder \" ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE people = 0 NEW_LINE max_a = \" hoge \" NEW_LINE max_b = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT a , b = map ( str , input ( ) . split ( ) ) NEW_LINE people += int ( b ) NEW_LINE if ( max_b < int ( b ) ) : NEW_LINE INDENT max_b = int ( b ) NEW_LINE max_a = a NEW_LINE DEDENT DEDENT if ( people < 2 * max_b ) : NEW_LINE INDENT print ( max_a ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" atcoder \" ) NEW_LINE DEDENT", "from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" Yes \" ) NEW_LINE else : print ( \" No \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def pne ( n ) : NEW_LINE INDENT print ( n , end = ' ' ) NEW_LINE DEDENT rem = pow ( 10 , 9 ) + 7 NEW_LINE n = ip ( ) NEW_LINE cityname = [ ] NEW_LINE population = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT x , y = input ( ) . split ( ) NEW_LINE cityname . append ( x ) NEW_LINE population . append ( int ( y ) ) NEW_LINE DEDENT if max ( population ) / sum ( population ) > 0.5 : NEW_LINE INDENT a = population . index ( max ( population ) ) NEW_LINE print ( cityname [ a ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" atcoder \" ) NEW_LINE DEDENT", "def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE class Debug ( ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . debug = True NEW_LINE DEDENT def off ( self ) : NEW_LINE INDENT self . debug = False NEW_LINE DEDENT def dmp ( self , x , cmt = ' ' ) : NEW_LINE INDENT if self . debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT print ( cmt , ' : ▁ ▁ ' , end = ' ' ) NEW_LINE DEDENT print ( x ) NEW_LINE DEDENT return x NEW_LINE DEDENT DEDENT def prob ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE s = zeros ( N ) NEW_LINE p = zeros ( N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT s [ i ] , p [ i ] = [ x for x in input ( ) . split ( ) ] NEW_LINE p [ i ] = int ( p [ i ] ) NEW_LINE DEDENT d = Debug ( ) NEW_LINE d . off ( ) NEW_LINE d . dmp ( ( N ) , ' N ' ) NEW_LINE d . dmp ( ( s ) , ' s ' ) NEW_LINE d . dmp ( ( p ) , ' p ' ) NEW_LINE if max ( p ) * 2 > sum ( p ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if p [ i ] == max ( p ) : NEW_LINE INDENT print ( s [ i ] ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ' atcoder ' ) NEW_LINE DEDENT DEDENT a = prob ( ) NEW_LINE", "def merge ( N : int , cities : list ) -> str : NEW_LINE INDENT max_people = 0 NEW_LINE city = ' atcoder ' NEW_LINE total = 0 NEW_LINE for c , p in cities : NEW_LINE INDENT if max_people < p : NEW_LINE INDENT max_people = p NEW_LINE city = c NEW_LINE DEDENT total += p NEW_LINE DEDENT return city if max_people > total // 2 else ' atcoder ' NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE cities = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT c , p = input ( ) . split ( ) NEW_LINE cities . append ( ( c , int ( p ) ) ) NEW_LINE DEDENT ans = merge ( N , cities ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE s = [ ] NEW_LINE p = [ ] NEW_LINE sum = 0 NEW_LINE newName = \" atcoder \" NEW_LINE for i in range ( n ) : NEW_LINE INDENT name , population = input ( ) . split ( ) NEW_LINE s . append ( name ) NEW_LINE p . append ( int ( population ) ) NEW_LINE sum += int ( population ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if p [ i ] > sum / 2 : NEW_LINE INDENT newName = s [ i ] NEW_LINE DEDENT DEDENT print ( newName ) NEW_LINE" ]
atcoder_arc050_C
[ "import java . util . Scanner ; import org . omg . Messaging . SyncScopeHelper ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { try ( Scanner sc = new Scanner ( System . in ) ) { long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long M = sc . nextLong ( ) ; long g = gcd ( A , B ) ; long ans = 1 ; ans *= f ( A , M ) ; ans %= M ; ans *= g ( B / g , g , M ) ; ans %= M ; System . out . println ( ans ) ; } } long g ( long x , long g , long M ) { if ( x == 0 ) return 0 ; if ( x % 2 == 1 ) return ( mod_pow ( 10 , g , M ) * g ( x - 1 , g , M ) + 1 ) % M ; else return g ( x / 2 , g , M ) * ( 1 + mod_pow ( 10 , g * x / 2 , M ) ) % M ; } long f ( long x , long M ) { if ( x == 0 ) return 0 ; if ( x % 2 == 1 ) return ( 10L * f ( x - 1 , M ) + 1 ) % M ; return f ( x / 2 , M ) * ( 1 + mod_pow ( 10 , x / 2 , M ) ) % M ; } static long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static long mod_pow ( long a , long b , long p ) { long res = 1 ; while ( b > 0 ) { if ( ( b & 1 ) == 1 ) res = ( res * a ) % p ; a = ( a * a ) % p ; b >>= 1 ; } return res ; } }", "import java . util . * ; class Main { static long gcd ( long x , long y ) { return y == 0 ? x : gcd ( y , x % y ) ; } static long powerMod ( long x , long exponent , long m ) { long prod = 1 ; for ( int i = 63 ; i >= 0 ; -- i ) { prod = ( prod * prod ) % m ; if ( ( exponent & 1L << i ) != 0 ) { prod = ( prod * x ) % m ; } } return prod ; } static long f ( long x , long y , long m ) { long oy = y ; long t = 0 ; long c = x ; long s = 1 ; while ( y > 0 ) { if ( y % 2 == 1 ) { t = ( t + s ) % m ; s = s * ( ( c + c * c ) % m ) % m ; } else s = s * ( 1 + c ) % m ; c = c * c % m ; y /= 2 ; } return t ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long m = scan . nextLong ( ) ; long g = gcd ( a , b ) ; long t = f ( 10 , g , m ) ; t = t * f ( powerMod ( 10 , g , m ) , a / g , m ) % m ; t = t * f ( powerMod ( 10 , g , m ) , b / g , m ) % m ; System . out . println ( t ) ; } }" ]
[ "def F ( D , N , X = 1 ) : Z = N and F ( D * D % M , N // 2 , ( X * D + X ) % M ) ; return [ Z , Z * D + X ] [ N % 2 ] NEW_LINE A , B , M = map ( int , input ( ) . split ( ) ) ; K = __import__ ( ' fractions ' ) . gcd ( A , B ) ; print ( F ( 10 , A ) * F ( pow ( 10 , K , M ) , B // K ) % M ) NEW_LINE", "A , B , M = map ( int , input ( ) . split ( ) ) NEW_LINE def gcd ( m , n ) : NEW_LINE INDENT r = m % n NEW_LINE return gcd ( n , r ) if r else n NEW_LINE DEDENT G = gcd ( A , B ) NEW_LINE def mul ( A , B ) : NEW_LINE INDENT a , b , c , d = A ; p , q , r , s = B NEW_LINE return ( a * p + b * r ) % M , ( a * q + b * s ) % M , ( c * p + d * r ) % M , ( c * q + d * s ) % M NEW_LINE DEDENT def m_pow ( x , n ) : NEW_LINE INDENT S = pow ( 10 , x , M ) , 1 , 0 , 1 NEW_LINE R = 1 , 0 , 0 , 1 NEW_LINE while n : NEW_LINE INDENT if n & 1 : NEW_LINE INDENT R = mul ( R , S ) NEW_LINE DEDENT S = mul ( S , S ) NEW_LINE n >>= 1 NEW_LINE DEDENT return R [ 1 ] NEW_LINE DEDENT P = m_pow ( G , A // G ) NEW_LINE Q = m_pow ( 1 , B ) NEW_LINE print ( ( P * Q ) % M ) NEW_LINE", "def gcd ( x , y ) : NEW_LINE INDENT if y == 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( y , x % y ) NEW_LINE DEDENT DEDENT def oneone ( i , l , M ) : NEW_LINE INDENT if i < 3 : NEW_LINE INDENT return sum ( pow ( 10 , j * l , M ) for j in range ( i ) ) % M NEW_LINE DEDENT else : NEW_LINE INDENT return ( oneone ( 2 , ( i // 2 ) * l , M ) * oneone ( i // 2 , l , M ) + ( i % 2 ) * pow ( 10 , ( i - 1 ) * l , M ) ) % M NEW_LINE DEDENT DEDENT A , B , M = map ( int , input ( ) . split ( ) ) NEW_LINE g = gcd ( A , B ) NEW_LINE x = oneone ( A // g , g , M ) NEW_LINE y = oneone ( B , 1 , M ) NEW_LINE print ( x * y % M ) NEW_LINE", "def modpowsum ( a , n , m ) : NEW_LINE INDENT if n == 0 : return 0 NEW_LINE elif n % 2 == 1 : return ( 1 + a * modpowsum ( a , n - 1 , m ) ) % m NEW_LINE else : NEW_LINE INDENT t = modpowsum ( a , n // 2 , m ) NEW_LINE return ( t + ( t * pow ( a , n // 2 , m ) ) % m ) % m NEW_LINE DEDENT DEDENT def gcd ( x , y ) : NEW_LINE INDENT if x > y : x , y = y , x NEW_LINE if x == 0 : return y NEW_LINE else : return gcd ( y % x , x ) NEW_LINE DEDENT a , b , m = map ( int , input ( ) . split ( ) ) NEW_LINE g = gcd ( a , b ) NEW_LINE t1 = modpowsum ( pow ( 10 , g , m ) , a // g , m ) NEW_LINE t2 = modpowsum ( 10 , b , m ) NEW_LINE print ( ( t1 * t2 ) % m ) NEW_LINE", "import numpy as np NEW_LINE from fractions import gcd NEW_LINE A , B , M = map ( int , input ( ) . split ( ) ) NEW_LINE D = gcd ( A , B ) NEW_LINE X = np . array ( [ [ 10 , 1 ] , [ 0 , 1 ] ] ) NEW_LINE Y = np . array ( [ [ pow ( 10 , D , M ) , 1 ] , [ 0 , 1 ] ] ) NEW_LINE x = np . array ( [ 0 , 1 ] ) NEW_LINE def f ( a , A ) : NEW_LINE INDENT T = np . array ( [ [ 1 , 0 ] , [ 0 , 1 ] ] ) NEW_LINE U = A NEW_LINE s = a NEW_LINE while s != 0 : NEW_LINE INDENT if s % 2 == 1 : NEW_LINE INDENT T = np . dot ( T , U ) NEW_LINE T = T % M NEW_LINE DEDENT U = np . dot ( U , U ) NEW_LINE U = U % M NEW_LINE s = s // 2 NEW_LINE DEDENT return T % M NEW_LINE DEDENT print ( ( ( np . dot ( f ( A , X ) , x ) ) [ 0 ] * np . dot ( f ( B // D , Y ) , x ) [ 0 ] ) % M ) NEW_LINE" ]
atcoder_abc018_C
[ "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int R = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] [ ] cum = new int [ R + 1 ] [ C + 1 ] ; for ( int i = 0 ; i < R ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( j ) == ' x ' ) { cum [ i + 1 ] [ j + 1 ] = 1 ; } } } for ( int r = 1 ; r <= R ; r ++ ) { for ( int c = 1 ; c <= C ; c ++ ) { cum [ r ] [ c ] += cum [ r - 1 ] [ c ] ; } } int ans = 0 ; for ( int x = K ; x <= R - K + 1 ; x ++ ) { for ( int y = K ; y <= C - K + 1 ; y ++ ) { boolean ok = true ; int jLeft = y - ( K - 1 ) ; int jRight = y + ( K - 1 ) ; if ( jLeft < 1 || jRight > C ) { continue ; } for ( int j = jLeft ; j <= jRight ; j ++ ) { int iUp = x + Math . abs ( j - y ) - ( K - 1 ) ; int iDown = x - Math . abs ( j - y ) + ( K - 1 ) ; if ( iUp < 1 || iDown > R || cum [ iDown ] [ j ] - cum [ iUp - 1 ] [ j ] != 0 ) { ok = false ; break ; } } if ( ok ) { ans ++ ; } } } out . println ( ans ) ; } }", "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int r = scanner . nextInt ( ) , c = scanner . nextInt ( ) , k = scanner . nextInt ( ) , s [ ] [ ] = java . util . stream . IntStream . range ( 0 , r ) . mapToObj ( i -> scanner . next ( ) . chars ( ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) , a [ ] [ ] = new int [ r ] [ c ] ; java . util . stream . IntStream . range ( 0 , c ) . map ( i -> java . util . stream . IntStream . range ( 0 , r ) . reduce ( 0 , ( t , j ) -> a [ j ] [ i ] = s [ j ] [ i ] == ' x ' ? 0 : t + 1 ) + java . util . stream . IntStream . range ( 0 , r ) . reduce ( 0 , ( t , j ) -> a [ r - j - 1 ] [ i ] = Math . min ( a [ r - j - 1 ] [ i ] , s [ r - j - 1 ] [ i ] == ' x ' ? 0 : t + 1 ) ) ) . count ( ) ; System . out . println ( java . util . stream . IntStream . rangeClosed ( k - 1 , r - k ) . mapToLong ( i -> java . util . stream . IntStream . range ( 0 , c - k * 2 + 2 ) . filter ( j -> java . util . stream . IntStream . range ( 0 , k * 2 - 1 ) . allMatch ( l -> a [ i ] [ j + l ] >= Math . min ( l + 1 , k * 2 - l - 1 ) ) ) . count ( ) ) . sum ( ) ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class C { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int r = in . nextInt ( ) , c = in . nextInt ( ) , k = in . nextInt ( ) - 1 ; int [ ] [ ] s = new int [ c + 1 ] [ r ] ; for ( int i = 0 ; i < r ; i ++ ) { String l = in . next ( ) ; for ( int j = 0 ; j < c ; j ++ ) { s [ j + 1 ] [ i ] = s [ j ] [ i ] + ( l . charAt ( j ) == ' o ' ? 1 : 0 ) ; } } int ans = 0 ; for ( int i = k ; i < r - k ; i ++ ) { mid : for ( int j = k + 1 ; j <= c - k ; j ++ ) { for ( int l = - k ; l <= k ; l ++ ) { int d = k - Math . abs ( l ) ; if ( s [ j + d ] [ i + l ] - s [ j - d - 1 ] [ i + l ] != 2 * d + 1 ) { continue mid ; } } ans ++ ; } } out . println ( ans ) ; } } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int R = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; String s [ ] = new String [ R ] ; String color [ ] [ ] = new String [ R ] [ C ] ; for ( int i = 0 ; i < R ; i ++ ) { s [ i ] = sc . next ( ) ; for ( int j = 0 ; j < C ; j ++ ) { color [ i ] [ j ] = s [ i ] . substring ( j , j + 1 ) ; } } for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( i < K - 1 || i > R - K || j < K - 1 || j > C - K ) { if ( color [ i ] [ j ] . equals ( \" o \" ) ) { color [ i ] [ j ] = \" * \" ; } } if ( color [ i ] [ j ] . equals ( \" x \" ) ) { for ( int y = i - ( K - 1 ) ; y <= i + ( K - 1 ) ; y ++ ) { if ( y < 0 || y >= R ) continue ; int width = ( K - 1 ) - Math . abs ( y - i ) ; for ( int x = j - width ; x <= j + width ; x ++ ) { if ( x < 0 || x >= C ) continue ; if ( color [ y ] [ x ] . equals ( \" o \" ) ) { color [ y ] [ x ] = \" * \" ; } } } } } } int ans = 0 ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( color [ i ] [ j ] . equals ( \" o \" ) ) ans ++ ; } } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ans = 0 ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , k = sc . nextInt ( ) ; boolean po [ ] [ ] = new boolean [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] s = sc . next ( ) . split ( \" \" , 0 ) ; for ( int j = 0 ; j < m ; j ++ ) po [ i ] [ j ] = ( s [ j ] . equals ( \" o \" ) ) ? true : false ; } int [ ] [ ] oo = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int min = 0 , max = 0 ; int in = i ; while ( in >= 0 && po [ in ] [ j ] ) { in -- ; min ++ ; } in = i ; while ( in < n && po [ in ] [ j ] ) { in ++ ; max ++ ; } oo [ i ] [ j ] = Math . min ( min , max ) ; } } for ( int i = k - 1 ; i < n - k + 1 ; i ++ ) for ( int j = k - 1 ; j < m - k + 1 ; j ++ ) { boolean d = true ; for ( int a = 0 ; a < k ; a ++ ) { d = d && ( oo [ i ] [ j - a ] >= k - a ) && ( oo [ i ] [ j + a ] >= k - a ) ; } if ( d ) ans ++ ; } System . out . println ( ans ) ; } }" ]
[ "import sys NEW_LINE inp = sys . stdin . readline NEW_LINE R , C , K = map ( int , inp ( ) . split ( ) ) NEW_LINE imo = [ [ 0 ] * ( C + 1 ) for _ in range ( R ) ] NEW_LINE for i in range ( R ) : NEW_LINE INDENT s = inp ( ) NEW_LINE for j in range ( C ) : NEW_LINE INDENT if ( s [ j ] == \" x \" ) : NEW_LINE INDENT for k in range ( K ) : NEW_LINE INDENT if ( i - k >= 0 ) : NEW_LINE INDENT imo [ i - k ] [ max ( 0 , j - K + k + 1 ) ] += 1 NEW_LINE imo [ i - k ] [ min ( C , j + K - k ) ] -= 1 NEW_LINE DEDENT if ( i + k < R ) : NEW_LINE INDENT imo [ i + k ] [ max ( 0 , j - K + k + 1 ) ] += 1 NEW_LINE imo [ i + k ] [ min ( C , j + K - k ) ] -= 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT for i in range ( R ) : NEW_LINE INDENT for j in range ( 1 , C + 1 ) : NEW_LINE INDENT imo [ i ] [ j ] += imo [ i ] [ j - 1 ] NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for y in range ( K - 1 , C - K + 1 ) : NEW_LINE INDENT for x in range ( K - 1 , R - K + 1 ) : NEW_LINE INDENT if ( imo [ x ] [ y ] == 0 ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "from collections import defaultdict , deque NEW_LINE import sys , heapq , bisect , math , itertools , string , queue , datetime NEW_LINE sys . setrecursionlimit ( 10 ** 8 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE eps = 10 ** - 7 NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def inpl_s ( ) : return list ( input ( ) . split ( ) ) NEW_LINE H , W , K = inpl ( ) NEW_LINE K -= 1 NEW_LINE MAP = [ list ( input ( ) ) for i in range ( H ) ] NEW_LINE MAP2 = [ [ 0 ] * ( W + 2 * K + 1 ) for i in range ( H ) ] NEW_LINE def Update ( sx , sy ) : NEW_LINE INDENT global MAP2 NEW_LINE for y in range ( sy - K , sy + K + 1 ) : NEW_LINE INDENT if not ( 0 <= y < H ) : NEW_LINE INDENT continue NEW_LINE DEDENT L = K - abs ( sy - y ) NEW_LINE lx = sx - L NEW_LINE rx = sx + L + 1 NEW_LINE MAP2 [ y ] [ lx + K ] += 1 NEW_LINE MAP2 [ y ] [ rx + K ] -= 1 NEW_LINE DEDENT DEDENT for y in range ( H ) : NEW_LINE INDENT for x in range ( W ) : NEW_LINE INDENT if MAP [ y ] [ x ] == ' x ' : NEW_LINE INDENT Update ( x , y ) NEW_LINE DEDENT DEDENT DEDENT ans = 0 NEW_LINE for y in range ( H ) : NEW_LINE INDENT tmp = 0 NEW_LINE for x in range ( W + 2 * K + 1 ) : NEW_LINE INDENT tmp += MAP2 [ y ] [ x ] NEW_LINE MAP2 [ y ] [ x ] = tmp NEW_LINE if tmp == 0 and K <= y < H - K and K * 2 <= x < W : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import math NEW_LINE Y , X , K = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ [ 0 if c == \" x \" else 1 for c in input ( ) ] for i in range ( Y ) ] NEW_LINE for x in range ( X ) : NEW_LINE INDENT fr = 0 NEW_LINE for y in range ( Y + 1 ) : NEW_LINE INDENT if y == Y or a [ y ] [ x ] == 0 : NEW_LINE INDENT for i in range ( math . ceil ( ( y - fr ) / 2 ) ) : NEW_LINE INDENT a [ fr + i ] [ x ] = i + 1 NEW_LINE a [ y - i - 1 ] [ x ] = i + 1 NEW_LINE DEDENT fr = y + 1 NEW_LINE DEDENT DEDENT DEDENT result = 0 NEW_LINE diamond_length = ( K - 1 ) * 2 + 1 NEW_LINE diamond_radius = K NEW_LINE for y in range ( K - 1 , Y - K + 1 ) : NEW_LINE INDENT start = 0 NEW_LINE cnt = a [ y ] . count ( 0 ) NEW_LINE for i in range ( cnt + 1 ) : NEW_LINE INDENT end = a [ y ] . index ( 0 , start ) if i < cnt else X - 1 NEW_LINE range_length = end - start + 1 NEW_LINE if range_length < diamond_length : NEW_LINE INDENT start = end + 1 NEW_LINE continue NEW_LINE DEDENT checked = 0 NEW_LINE for j in range ( range_length - diamond_length + 1 ) : NEW_LINE INDENT checked = max ( 0 , checked - 1 ) NEW_LINE _start = start + j NEW_LINE is_creatable = True NEW_LINE flag = True NEW_LINE for k in range ( checked , diamond_length ) : NEW_LINE INDENT req = k + 1 if k < diamond_radius else 2 * diamond_radius - k - 1 NEW_LINE now = a [ y ] [ _start + k ] NEW_LINE if now < req : NEW_LINE INDENT is_creatable = False NEW_LINE break NEW_LINE DEDENT elif k <= diamond_radius - 1 or flag and now >= diamond_radius : NEW_LINE INDENT checked = k NEW_LINE DEDENT else : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT if is_creatable : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT start = end + 1 NEW_LINE DEDENT DEDENT print ( result ) NEW_LINE", "import numpy as np NEW_LINE from itertools import product NEW_LINE R , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ input ( ) for i in range ( R ) ] NEW_LINE cs = np . zeros ( ( R + C + 1 , R + C + 1 ) , dtype = np . int16 ) NEW_LINE for i , j in product ( range ( R ) , range ( C ) ) : NEW_LINE INDENT if s [ i ] [ j ] == \" x \" : NEW_LINE INDENT cs [ C + i - j , i + j + 1 ] = 1 NEW_LINE DEDENT DEDENT cs = np . cumsum ( cs , axis = 0 ) NEW_LINE cs = np . cumsum ( cs , axis = 1 ) NEW_LINE ans = 0 NEW_LINE k = K - 1 NEW_LINE for i , j in product ( range ( R ) [ k : - k ] , range ( C ) [ k : - k ] ) : NEW_LINE INDENT x = C + i - j NEW_LINE y = i + j + 1 NEW_LINE rec = cs [ x + k , y + k ] NEW_LINE rec -= cs [ x + k , y - k - 1 ] NEW_LINE rec -= cs [ x - k - 1 , y + k ] NEW_LINE rec += cs [ x - k - 1 , y - k - 1 ] NEW_LINE if rec == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE inf = 10 ** 18 NEW_LINE R , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ list ( input ( ) ) for _ in range ( R ) ] NEW_LINE hmat = [ [ 0 ] * C for _ in range ( R ) ] NEW_LINE for x in range ( C ) : NEW_LINE INDENT sum_tmp = 0 NEW_LINE for y in range ( R ) : NEW_LINE INDENT if s [ y ] [ x ] == ' o ' : NEW_LINE INDENT if sum_tmp == 0 : t = y NEW_LINE sum_tmp += 1 NEW_LINE dy = ( sum_tmp - 1 ) // 2 NEW_LINE hmat [ t + dy ] [ x ] = 1 + dy NEW_LINE DEDENT else : NEW_LINE INDENT sum_tmp = 0 NEW_LINE DEDENT DEDENT sum_tmp = 0 NEW_LINE for yi in range ( R ) : NEW_LINE INDENT y = R - 1 - yi NEW_LINE if s [ y ] [ x ] == ' o ' : NEW_LINE INDENT if sum_tmp == 0 : b = y NEW_LINE sum_tmp += 1 NEW_LINE dy = ( sum_tmp - 1 ) // 2 NEW_LINE hmat [ b - dy ] [ x ] = 1 + dy NEW_LINE DEDENT else : NEW_LINE INDENT sum_tmp = 0 NEW_LINE DEDENT DEDENT DEDENT ans = 0 NEW_LINE for yi , hrow in enumerate ( hmat [ ( K - 1 ) : ( R - K + 1 ) ] ) : NEW_LINE INDENT imos = [ 0 ] * C NEW_LINE y = yi + K - 1 NEW_LINE for x in range ( C ) : NEW_LINE INDENT hxy = hmat [ y ] [ x ] NEW_LINE if hxy < K : NEW_LINE INDENT loss = K - 1 - hxy NEW_LINE imos [ max ( 0 , x - loss ) ] += 1 NEW_LINE imos [ min ( C - 1 , x + loss + 1 ) ] -= 1 NEW_LINE DEDENT DEDENT tmp = 0 NEW_LINE dmg = [ 0 ] * C NEW_LINE for i , imosi in enumerate ( imos ) : NEW_LINE INDENT tmp += imosi NEW_LINE dmg [ i ] = tmp NEW_LINE DEDENT ans += dmg [ ( K - 1 ) : ( C - K + 1 ) ] . count ( 0 ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc022_B
[ "import java . util . Scanner ; import java . util . StringJoiner ; import java . util . TreeSet ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; if ( scanner . hasNextLine ( ) ) { int N = Integer . parseInt ( scanner . nextLine ( ) ) ; if ( N == 3 ) { System . out . println ( \"3 ▁ 5 ▁ 22\" ) ; } else { int c6p3 = ( ( N - 1 ) / 8 ) * 2 + 2 ; int c6p2 = ( N - c6p3 - 1 ) / 3 + 1 ; int c6p6 = N - c6p3 - c6p2 - c6p2 ; TreeSet < Integer > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < c6p3 ; ++ i ) { set . add ( i * 6 + 3 ) ; } for ( int i = 0 ; i < c6p2 ; ++ i ) { set . add ( i * 6 + 2 ) ; set . add ( i * 6 + 4 ) ; } for ( int i = 0 ; i < c6p6 ; ++ i ) { set . add ( i * 6 + 6 ) ; } StringJoiner joiner = new StringJoiner ( \" ▁ \" ) ; for ( Integer v : set ) { joiner . add ( v . toString ( ) ) ; } System . out . println ( joiner . toString ( ) ) ; } } } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int res [ ] = new int [ n ] ; res [ 0 ] = 2 ; res [ 1 ] = 3 ; int sum = 5 ; if ( n <= 5 ) { for ( int i = 2 ; i < n ; i ++ ) { sum += res [ i - 1 ] + 1 ; for ( int num = res [ i - 1 ] + 1 ; num <= 30000 ; num ++ , sum ++ ) { if ( sum % 6 != 0 ) { continue ; } res [ i ] = num ; boolean isOk = true ; for ( int j = 0 ; j <= i ; j ++ ) { if ( gcd ( res [ j ] , sum ) == 1 ) { isOk = false ; break ; } } if ( isOk ) { break ; } } } } else { for ( int i = 2 ; i < n ; i ++ ) { res [ i ] = 6 * ( i / 4 ) + ( 2 + i % 2 ) * ( 1 + ( i % 4 ) / 2 ) ; sum += res [ i ] ; } switch ( sum % 6 ) { case 2 : res [ 4 ] = 6 * ( ( n + 1 ) / 4 ) + 6 ; sum = sum - 8 + res [ 4 ] ; break ; case 3 : res [ 5 ] = 6 * ( ( n + 1 ) / 4 ) + 6 ; sum = sum - 9 + res [ 5 ] ; break ; case 5 : res [ 5 ] = 6 * ( ( n + 1 ) / 4 ) + 4 ; sum = sum - 9 + res [ 5 ] ; break ; default : break ; } } System . out . println ( Arrays . toString ( res ) . replaceAll ( \" [ ^ ▁ 0-9 ] \" , \" \" ) ) ; } private int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; Set < Integer > ans = new HashSet < > ( ) ; int lastAns ; if ( N == 3 ) { System . out . println ( \"2 ▁ 3 ▁ 25\" ) ; } else if ( N == 4 ) { System . out . println ( \"2 ▁ 3 ▁ 5 ▁ 20\" ) ; } else if ( N == 5 ) { System . out . println ( \"2 ▁ 3 ▁ 4 ▁ 5 ▁ 16\" ) ; } else { ans . add ( 2 ) ; ans . add ( 3 ) ; int sum = 5 ; for ( int i = 4 ; ; i ++ ) { if ( i % 2 == 0 || i % 3 == 0 ) { ans . add ( i ) ; sum += i ; lastAns = i ; if ( ans . size ( ) == N ) { break ; } } } if ( sum % 6 == 0 ) { } else if ( sum % 6 == 2 ) { ans . remove ( 8 ) ; for ( int i = lastAns + 1 ; ; i ++ ) { if ( i % 6 == 0 ) { ans . add ( i ) ; break ; } } } else if ( sum % 6 == 3 ) { ans . remove ( 9 ) ; for ( int i = lastAns + 1 ; ; i ++ ) { if ( i % 6 == 0 ) { ans . add ( i ) ; break ; } } } else { ans . remove ( 9 ) ; for ( int i = lastAns + 1 ; ; i ++ ) { if ( i % 6 == 4 ) { ans . add ( i ) ; break ; } } } for ( Integer an : ans ) { System . out . print ( an + \" ▁ \" ) ; } } } }", "import java . util . HashSet ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { final Scanner cin = new Scanner ( System . in ) ; final int n = cin . nextInt ( ) ; if ( n == 3 ) { System . out . println ( \"2 ▁ 5 ▁ 63\" ) ; } else if ( n == 4 ) { System . out . println ( \"2 ▁ 5 ▁ 20 ▁ 63\" ) ; } else if ( n == 5 ) { System . out . println ( \"2 ▁ 5 ▁ 20 ▁ 63 ▁ 30\" ) ; } else { HashSet < Integer > nums = new HashSet < > ( ) ; int [ ] offset = new int [ ] { 2 , 3 , 4 , 6 } ; int k = 0 ; int summary = 0 ; for ( int i = 0 ; i < n ; i ++ ) { k = i / 4 ; int ai = k * 6 + offset [ i % 4 ] ; nums . add ( ai ) ; summary += ai ; } int next6k = ( k + 1 ) * 6 ; if ( nums . contains ( next6k ) ) next6k += 6 ; int fraction = summary % 6 ; int [ ] candidateToRemove = new int [ ] { 0 , 0 , 8 , 9 , 0 , 9 } ; int [ ] candidateToAppend = new int [ ] { 0 , 0 , ( k + 1 ) * 6 , ( k + 1 ) * 6 , 0 , k * 6 + 4 } ; if ( fraction != 0 ) { nums . remove ( candidateToRemove [ fraction ] ) ; int append = candidateToAppend [ fraction ] ; if ( nums . contains ( append ) ) append += 6 ; nums . add ( append ) ; } System . out . println ( nums . stream ( ) . map ( ( Integer i ) -> i . toString ( ) ) . collect ( Collectors . joining ( \" ▁ \" ) ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] e = { 2 , 4 , 3 , 9 , 8 , 10 , 6 , 12 } ; int [ ] o = { 6 , 2 , 4 , 3 , 9 , 8 , 10 , 12 } ; if ( n == 3 ) { System . out . println ( \"2 ▁ 5 ▁ 63\" ) ; return ; } int m = 0 ; boolean isEven = n % 2 == 0 ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( isEven ? e [ i % 8 ] + 12 * m : o [ i % 8 ] + 12 * m ) ; System . out . print ( \" ▁ \" ) ; if ( i % 8 == 7 ) { m ++ ; } } } }" ]
[ "N = int ( input ( ) ) NEW_LINE if N == 3 : NEW_LINE INDENT ans = [ 2 , 3 , 25 ] NEW_LINE DEDENT else : NEW_LINE INDENT if N % 2 == 0 : NEW_LINE INDENT As = [ 2 , 10 , 3 , 9 , 4 , 8 , 6 , 12 ] NEW_LINE DEDENT else : NEW_LINE INDENT As = [ 6 , 2 , 10 , 3 , 9 , 4 , 8 , 12 ] NEW_LINE DEDENT ans = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans . append ( As [ i % 8 ] + 12 * ( i // 8 ) ) NEW_LINE DEDENT DEDENT print ( ' ▁ ' . join ( map ( str , ans ) ) ) NEW_LINE", "import sys NEW_LINE stdin = sys . stdin NEW_LINE def li ( ) : return [ int ( x ) for x in stdin . readline ( ) . split ( ) ] NEW_LINE def li_ ( ) : return [ int ( x ) - 1 for x in stdin . readline ( ) . split ( ) ] NEW_LINE def lf ( ) : return [ float ( x ) for x in stdin . readline ( ) . split ( ) ] NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( ns ( ) ) NEW_LINE def nf ( ) : return float ( ns ( ) ) NEW_LINE def solve ( n : int ) -> list : NEW_LINE INDENT x6o2 = [ ( 6 * i + 2 , 6 * i + 4 ) for i in range ( 5000 ) ] NEW_LINE x6o3 = [ ( 12 * i + 3 , 12 * i + 9 ) for i in range ( 2500 ) ] NEW_LINE o6 = [ 6 * i + 6 for i in range ( 5000 ) ] NEW_LINE x6 = [ ] NEW_LINE for i in range ( 2500 ) : NEW_LINE INDENT x6 . append ( x6o3 [ i ] ) NEW_LINE x6 . append ( x6o2 [ 2 * i ] ) NEW_LINE x6 . append ( x6o2 [ 2 * i + 1 ] ) NEW_LINE DEDENT ans = [ ] NEW_LINE if n == 3 : NEW_LINE INDENT ans = [ 2 , 5 , 63 ] NEW_LINE DEDENT elif n <= 15000 : NEW_LINE INDENT idx = n // 2 NEW_LINE for i , ( mn , mx ) in enumerate ( x6 [ : idx ] ) : NEW_LINE INDENT ans . extend ( [ mn , mx ] ) NEW_LINE DEDENT if n % 2 : NEW_LINE INDENT ans = ans + [ 6 ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i , ( mn , mx ) in enumerate ( x6 ) : NEW_LINE INDENT ans . extend ( [ mn , mx ] ) NEW_LINE DEDENT for o6i in o6 [ : n - 15000 ] : NEW_LINE INDENT ans . append ( o6i ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n = ni ( ) NEW_LINE print ( * solve ( n ) ) NEW_LINE", "def prime_factors ( n ) : NEW_LINE INDENT i = 2 NEW_LINE factors = [ ] NEW_LINE while i * i <= n : NEW_LINE INDENT if n % i : NEW_LINE INDENT i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT n //= i NEW_LINE factors . append ( i ) NEW_LINE DEDENT DEDENT if n > 1 : NEW_LINE INDENT factors . append ( n ) NEW_LINE DEDENT return factors NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE if n >= 15002 : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT a = [ i * 2 for i in range ( 1 , 15001 ) ] + [ i * 6 + 3 for i in range ( n - 15000 ) ] NEW_LINE DEDENT else : NEW_LINE INDENT a = [ i * 2 for i in range ( 1 , 15000 ) ] + [ i * 6 + 3 for i in range ( n - 14999 ) ] NEW_LINE DEDENT print ( * a ) NEW_LINE DEDENT elif n == 3 : NEW_LINE INDENT print ( * [ 2 , 5 , 63 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT b = prime_factors ( ( n - 1 ) * ( n - 2 ) ) NEW_LINE b . sort ( ) NEW_LINE c = 0 NEW_LINE for i in b : NEW_LINE INDENT if i >= 3 : NEW_LINE INDENT c = i NEW_LINE break NEW_LINE DEDENT DEDENT d = [ i * 2 for i in range ( 1 , n - 1 ) ] + [ c , c * 3 ] NEW_LINE print ( * d ) NEW_LINE DEDENT", "from sys import stdin NEW_LINE d_in = lambda : int ( stdin . readline ( ) ) NEW_LINE MAX = 30000 NEW_LINE N = d_in ( ) NEW_LINE base = [ 3 , 25 , 2 , 35 , 55 ] NEW_LINE cand = [ ] NEW_LINE for i in range ( 4 , MAX // 2 , 2 ) : NEW_LINE INDENT cand . append ( i ) NEW_LINE cand . append ( MAX - i ) NEW_LINE DEDENT for i in range ( 9 , MAX // 2 , 6 ) : NEW_LINE INDENT cand . append ( i ) NEW_LINE cand . append ( MAX - i ) NEW_LINE DEDENT ans = [ ] NEW_LINE if N < 5 : NEW_LINE INDENT ans . extend ( base [ : 3 ] ) NEW_LINE if N == 4 : NEW_LINE INDENT ans . append ( MAX ) NEW_LINE DEDENT DEDENT elif N % 2 == 1 : NEW_LINE INDENT ans . extend ( base ) NEW_LINE ans . extend ( cand [ : N - 5 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . extend ( base ) NEW_LINE ans . append ( MAX ) NEW_LINE ans . extend ( cand [ : N - 6 ] ) NEW_LINE DEDENT print ( * ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE if N == 3 : NEW_LINE INDENT print ( 2 , 5 , 63 ) NEW_LINE exit ( ) NEW_LINE DEDENT count = 20000 NEW_LINE m2 = list ( i for i in range ( 2 , 30001 , 2 ) if i % 6 != 0 ) NEW_LINE m3 = list ( i for i in range ( 3 , 30001 , 3 ) if i % 6 != 0 ) NEW_LINE m6 = list ( range ( 6 , 30001 , 6 ) ) NEW_LINE if count > N : NEW_LINE INDENT diff = min ( count - N , 9998 ) NEW_LINE if diff % 2 == 1 : NEW_LINE INDENT diff -= 1 NEW_LINE DEDENT if diff : NEW_LINE INDENT m2 = m2 [ : - diff ] NEW_LINE DEDENT count -= diff NEW_LINE DEDENT if count > N : NEW_LINE INDENT diff = min ( count - N , 4998 ) NEW_LINE if diff % 2 == 1 : NEW_LINE INDENT diff -= 1 NEW_LINE DEDENT if diff : NEW_LINE INDENT m3 = m3 [ : - diff ] NEW_LINE DEDENT count -= diff NEW_LINE DEDENT if count > N : NEW_LINE INDENT diff = count - N NEW_LINE count -= diff NEW_LINE if diff : NEW_LINE INDENT m6 = m6 [ : - diff ] NEW_LINE DEDENT DEDENT ans = m2 + m3 + m6 NEW_LINE print ( \" ▁ \" . join ( map ( str , ans ) ) ) NEW_LINE" ]
atcoder_abc023_B
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { new Main ( ) . main ( ) ; } public void main ( ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String s = scanner . nextLine ( ) ; System . out . println ( this . times ( n , s ) ) ; } private int times ( int n , String s ) { if ( n % 2 == 0 ) { return - 1 ; } int ret = ( n - 1 ) / 2 ; char ch ; if ( ret % 3 == 1 ) { ch = ' a ' ; } else if ( ret % 3 == 2 ) { ch = ' c ' ; } else { ch = ' b ' ; } for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) != ch ) { return - 1 ; } if ( ch == ' c ' ) { ch = ' a ' ; } else { ch ++ ; } } return ret ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; 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 ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { in . voids ( ) ; String s = in . string ( ) ; String t = \" b \" ; for ( int i = 0 ; i < 50 ; i ++ ) { if ( t . equals ( s ) ) { out . println ( i ) ; return ; } switch ( i % 3 ) { case 0 : t = \" a \" + t + \" c \" ; break ; case 1 : t = \" c \" + t + \" a \" ; break ; case 2 : t = \" b \" + t + \" b \" ; break ; } } out . println ( - 1 ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public void voids ( ) { string ( ) ; } } }", "import java . util . * ; public class Main { static int Juzu ( int n , String s ) { if ( n % 2 == 0 ) return - 1 ; if ( n == 1 ) { if ( s . equals ( \" b \" ) ) return 0 ; else return - 1 ; } if ( s . charAt ( 0 ) == ' b ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( \" bca \" ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' b ' ) return n / 2 ; } if ( s . charAt ( 0 ) == ' a ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( \" abc \" ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' c ' ) return n / 2 ; } if ( s . charAt ( 0 ) == ' c ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( \" cab \" ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' a ' && s . charAt ( n - 2 ) == ' c ' ) return n / 2 ; } return - 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; System . out . println ( Juzu ( N , S ) ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; String S = scanner . next ( ) ; boolean flag = true ; if ( N % 2 == 0 ) { flag = false ; } if ( N % 2 != 0 ) { for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( N % 3 == 1 ) { if ( i % 3 == 0 && S . charAt ( i ) != ' b ' ) { flag = false ; } else if ( i % 3 == 1 && S . charAt ( i ) != ' c ' ) { flag = false ; } else if ( i % 3 == 2 && S . charAt ( i ) != ' a ' ) { flag = false ; } } if ( N % 3 == 0 ) { if ( i % 3 == 0 && S . charAt ( i ) != ' a ' ) { flag = false ; } else if ( i % 3 == 1 && S . charAt ( i ) != ' b ' ) { flag = false ; } else if ( i % 3 == 2 && S . charAt ( i ) != ' c ' ) { flag = false ; } } if ( N % 3 == 2 ) { if ( i % 3 == 0 && S . charAt ( i ) != ' c ' ) { flag = false ; } else if ( i % 3 == 1 && S . charAt ( i ) != ' a ' ) { flag = false ; } else if ( i % 3 == 2 && S . charAt ( i ) != ' b ' ) { flag = false ; } } } } if ( flag == true ) { System . out . println ( S . length ( ) / 2 ) ; } else if ( flag == false ) { System . out . println ( - 1 ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( N == 1 ) { if ( S . equals ( \" b \" ) ) { System . out . println ( 0 ) ; return ; } else { System . out . println ( - 1 ) ; return ; } } for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == ' a ' || S . charAt ( i ) == ' b ' || S . charAt ( i ) == ' c ' ) { } else { System . out . println ( - 1 ) ; return ; } } StringBuilder sb = new StringBuilder ( ) ; sb . append ( \" b \" ) ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( i % 3 == 1 ) { sb . insert ( 0 , \" a \" ) ; sb . append ( \" c \" ) ; } else if ( i % 3 == 2 ) { sb . insert ( 0 , \" c \" ) ; sb . append ( \" a \" ) ; } else if ( i % 3 == 0 ) { sb . insert ( 0 , \" b \" ) ; sb . append ( \" b \" ) ; } String str = sb . toString ( ) ; if ( str . length ( ) == N && str . equals ( S ) ) { System . out . println ( i ) ; return ; } else if ( str . length ( ) == N && ! str . equals ( S ) ) { System . out . println ( - 1 ) ; return ; } else if ( str . length ( ) > N ) { System . out . println ( - 1 ) ; return ; } } } }" ]
[ "N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE ans = - 1 NEW_LINE s = ' b ' NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if s == S : NEW_LINE INDENT ans = i - 1 NEW_LINE break NEW_LINE DEDENT s = [ ' b ' , ' a ' , ' c ' ] [ i % 3 ] + s + [ ' b ' , ' c ' , ' a ' ] [ i % 3 ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "n , s = int ( input ( ) ) , input ( ) NEW_LINE tar = [ ' b ' , ' abc ' , ' cabca ' , ' bcabcab ' , ' abcabcabc ' , ' cabcabcabca ' , ' bcabcabcabcab ' , ' abcabcabcabcabc ' , ' cabcabcabcabcabca ' , ' bcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' ] NEW_LINE if s in tar : NEW_LINE INDENT print ( tar . index ( s ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE tmp = ' b ' NEW_LINE flg = 1 NEW_LINE count = 0 NEW_LINE if N % 2 == 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT while len ( tmp ) < N : NEW_LINE INDENT if flg == 1 : NEW_LINE INDENT tmp = ' a ' + tmp + ' c ' NEW_LINE flg = 2 NEW_LINE DEDENT elif flg == 2 : NEW_LINE INDENT tmp = ' c ' + tmp + ' a ' NEW_LINE flg = 3 NEW_LINE DEDENT elif flg == 3 : NEW_LINE INDENT tmp = ' b ' + tmp + ' b ' NEW_LINE flg = 1 NEW_LINE DEDENT count += 1 NEW_LINE DEDENT if S == tmp : NEW_LINE INDENT print ( count ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT DEDENT", "n = int ( input ( ) ) NEW_LINE hoge = input ( ) NEW_LINE if ( len ( hoge ) % 2 == 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT elif ( hoge . count ( \" a \" ) + hoge . count ( \" b \" ) + hoge . count ( \" c \" ) != len ( hoge ) ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT elif ( hoge [ len ( hoge ) // 2 ] != \" b \" ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT hoge_r = hoge [ : : - 1 ] NEW_LINE flag = 0 NEW_LINE for i in range ( len ( hoge ) // 2 ) : NEW_LINE INDENT if ( hoge [ i ] == \" a \" and hoge_r [ i ] == \" c \" ) : NEW_LINE INDENT flag += 0 NEW_LINE DEDENT elif ( hoge [ i ] == \" b \" and hoge_r [ i ] == \" b \" ) : NEW_LINE INDENT flag += 0 NEW_LINE DEDENT elif ( hoge [ i ] == \" c \" and hoge_r [ i ] == \" a \" ) : NEW_LINE INDENT flag += 0 NEW_LINE DEDENT else : NEW_LINE INDENT flag += 1 NEW_LINE DEDENT DEDENT if ( flag != 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( len ( hoge ) // 2 ) NEW_LINE DEDENT DEDENT", "def solve ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE query = \" b \" NEW_LINE s = input ( ) NEW_LINE if s == query : NEW_LINE INDENT print ( \"0\" ) NEW_LINE exit ( ) NEW_LINE DEDENT tp = 0 NEW_LINE for i in range ( 50 ) : NEW_LINE INDENT if i % 3 == 2 : NEW_LINE INDENT query = \" b \" + query + \" b \" NEW_LINE DEDENT elif i % 3 == 0 : NEW_LINE INDENT query = \" a \" + query + \" c \" NEW_LINE DEDENT else : NEW_LINE INDENT query = \" c \" + query + \" a \" NEW_LINE DEDENT tp += 1 NEW_LINE if query == s : NEW_LINE INDENT print ( tp ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( \" - 1\" ) NEW_LINE DEDENT solve ( ) NEW_LINE" ]
atcoder_arc086_B
[ "import java . util . Scanner ; import java . util . stream . IntStream ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int [ ] a = IntStream . range ( 0 , N ) . map ( i -> scan . nextInt ( ) ) . toArray ( ) ; int index = 0 ; for ( int i = 0 ; i < N ; ++ i ) if ( Math . abs ( a [ index ] ) < Math . abs ( a [ i ] ) ) index = i ; System . out . println ( 2 * N - 1 ) ; for ( int i = 0 ; i < N ; ++ i ) System . out . println ( ( index + 1 ) + \" ▁ \" + ( i + 1 ) ) ; if ( a [ index ] > 0 ) { for ( int i = 2 ; i <= N ; ++ i ) System . out . println ( ( i - 1 ) + \" ▁ \" + i ) ; } else { for ( int i = N - 1 ; i >= 1 ; -- i ) System . out . println ( ( i + 1 ) + \" ▁ \" + i ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { int N = sc . nextInt ( ) ; int [ ] t = new int [ N ] ; int max = Integer . MIN_VALUE ; int maxIdx = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { t [ i ] = sc . nextInt ( ) ; int abs = Math . abs ( t [ i ] ) ; if ( max < abs ) { max = abs ; maxIdx = i ; } } System . out . println ( N * 2 - 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . println ( ( maxIdx + 1 ) + \" ▁ \" + ( i + 1 ) ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( t [ maxIdx ] > 0 ) { System . out . println ( ( i + 1 ) + \" ▁ \" + ( i + 2 ) ) ; } else { System . out . println ( ( N - i ) + \" ▁ \" + ( N - i - 1 ) ) ; } } } } }", "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int pmaxnum = 0 ; int pmax = 0 ; int mmaxnum = 0 ; int mmax = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] >= 0 ) { if ( pmax <= A [ i ] ) { pmax = A [ i ] ; pmaxnum = i + 1 ; } } else { if ( mmax >= A [ i ] ) { mmax = A [ i ] ; mmaxnum = i + 1 ; } } } System . out . println ( N * 2 - 2 ) ; if ( Math . abs ( pmax ) >= Math . abs ( mmax ) ) { for ( int i = 1 ; i <= N ; i ++ ) { if ( i != pmaxnum ) System . out . println ( pmaxnum + \" ▁ \" + i ) ; } for ( int i = 1 ; i < N ; i ++ ) { System . out . println ( i + \" ▁ \" + ( i + 1 ) ) ; } } else { for ( int i = 1 ; i <= N ; i ++ ) { if ( i != mmaxnum ) System . out . println ( mmaxnum + \" ▁ \" + i ) ; } for ( int i = N ; i > 1 ; i -- ) { System . out . println ( i + \" ▁ \" + ( i - 1 ) ) ; } } } }", "import java . util . List ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; import java . util . TreeSet ; import java . util . concurrent . BlockingQueue ; import java . util . concurrent . LinkedBlockingDeque ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static char c ; public static void main ( String [ ] args ) throws Exception { int k = sc . nextInt ( ) ; int [ ] arr = new int [ k ] ; int max = Integer . MIN_VALUE ; int min = Integer . MAX_VALUE ; int maxIdx = - 1 ; int minIdx = - 1 ; for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; if ( arr [ i ] > max ) { max = arr [ i ] ; maxIdx = i ; } if ( arr [ i ] < min ) { min = arr [ i ] ; minIdx = i ; } } System . out . println ( k * 2 - 1 ) ; if ( Math . abs ( min ) > max ) { for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ( minIdx + 1 ) + \" ▁ \" + ( i + 1 ) ) ; } for ( int i = k ; i > 1 ; i -- ) { System . out . println ( i + \" ▁ \" + ( i - 1 ) ) ; } } else { for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ( maxIdx + 1 ) + \" ▁ \" + ( i + 1 ) ) ; } for ( int i = 1 ; i < k ; i ++ ) { System . out . println ( i + \" ▁ \" + ( i + 1 ) ) ; } } } }", "import java . util . * ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int [ ] a = new int [ n ] ; Arrays . setAll ( a , i -> s . nextInt ( ) ) ; ArrayList < String > r = new ArrayList < > ( ) ; int m = 0 ; for ( int i = 1 ; i < n ; ++ i ) if ( Math . abs ( a [ m ] ) < Math . abs ( a [ i ] ) ) m = i ; for ( int i = 0 ; i < n ; ++ i ) if ( a [ m ] >= 0 ^ a [ i ] >= 0 ) r . add ( m + 1 + \" ▁ \" + ( i + 1 ) ) ; if ( a [ m ] >= 0 ) { for ( int i = 1 ; i < n ; ++ i ) r . add ( i + \" ▁ \" + ( i + 1 ) ) ; } else { for ( int i = n ; i > 1 ; -- i ) r . add ( i + \" ▁ \" + ( i - 1 ) ) ; } System . out . println ( r . size ( ) ) ; r . forEach ( System . out :: println ) ; } }" ]
[ "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE a = inpl ( ) NEW_LINE mini = float ( ' inf ' ) NEW_LINE maxi = - mini NEW_LINE for i in a : NEW_LINE INDENT mini = min ( mini , i ) NEW_LINE maxi = max ( maxi , i ) NEW_LINE DEDENT print ( 2 * N - 1 ) NEW_LINE if maxi > - mini : NEW_LINE INDENT x = a . index ( maxi ) + 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( x , i ) NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT print ( i , i + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT x = a . index ( mini ) + 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( x , i ) NEW_LINE DEDENT for i in range ( N , 1 , - 1 ) : NEW_LINE INDENT print ( i , i - 1 ) NEW_LINE DEDENT DEDENT", "import sys NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = max ( A ) NEW_LINE b = min ( A ) NEW_LINE if b >= 0 : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ i , i + 1 ] ) NEW_LINE DEDENT print ( N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT if a <= 0 : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ N - i + 1 , N - i ] ) NEW_LINE DEDENT print ( N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT x = A . index ( a ) + 1 NEW_LINE y = A . index ( b ) + 1 NEW_LINE if abs ( a ) >= abs ( b ) : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans . append ( [ x , i + 1 ] ) NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ i , i + 1 ] ) NEW_LINE DEDENT print ( 2 * N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT if abs ( b ) > abs ( a ) : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans . append ( [ y , i + 1 ] ) NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ N - i + 1 , N - i ] ) NEW_LINE DEDENT print ( 2 * N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT", "import sys NEW_LINE sys . stdin . readline ( ) NEW_LINE lst = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE N = len ( lst ) NEW_LINE max_val , max_t = lst [ 0 ] , 0 NEW_LINE min_val , min_t = lst [ 0 ] , 0 NEW_LINE for t in range ( 1 , len ( lst ) ) : NEW_LINE INDENT if max_val < lst [ t ] : NEW_LINE INDENT max_val = lst [ t ] NEW_LINE max_t = t NEW_LINE DEDENT if min_val > lst [ t ] : NEW_LINE INDENT min_val = lst [ t ] NEW_LINE min_t = t NEW_LINE DEDENT DEDENT if max_val >= - min_val : NEW_LINE INDENT print ( 2 * N - 2 ) NEW_LINE for i in range ( len ( lst ) ) : NEW_LINE INDENT if i == max_t : NEW_LINE INDENT continue NEW_LINE DEDENT print ( max_t + 1 , i + 1 ) NEW_LINE DEDENT for i in range ( 1 , len ( lst ) ) : NEW_LINE INDENT print ( i , i + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( 2 * N - 2 ) NEW_LINE for i in range ( len ( lst ) ) : NEW_LINE INDENT if i == min_t : NEW_LINE INDENT continue NEW_LINE DEDENT print ( min_t + 1 , i + 1 ) NEW_LINE DEDENT for i in range ( len ( lst ) , 1 , - 1 ) : NEW_LINE INDENT print ( i , i - 1 ) NEW_LINE DEDENT DEDENT", "n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE seq = [ ] NEW_LINE for i in range ( 0 , n + 1 ) : NEW_LINE INDENT b = [ None ] * n NEW_LINE for j in range ( 0 , n ) : b [ j ] = a [ j ] NEW_LINE seq = [ ] NEW_LINE for j in range ( i - 2 , - 1 , - 1 ) : NEW_LINE INDENT seq . append ( ( j + 1 , j ) ) NEW_LINE seq . append ( ( j + 1 , j ) ) NEW_LINE b [ j ] += b [ j + 1 ] * 2 NEW_LINE DEDENT for j in range ( i , n - 1 ) : NEW_LINE INDENT seq . append ( ( j , j + 1 ) ) NEW_LINE seq . append ( ( j , j + 1 ) ) NEW_LINE b [ j + 1 ] += b [ j ] * 2 NEW_LINE DEDENT valid = True NEW_LINE for j in range ( n - 1 ) : NEW_LINE INDENT if b [ j ] > b [ j + 1 ] : NEW_LINE INDENT valid = False NEW_LINE break NEW_LINE DEDENT DEDENT if valid : break NEW_LINE DEDENT print ( len ( seq ) ) NEW_LINE print ( ' \\n ' . join ( map ( lambda x : ' % d ▁ % d ' % ( x [ 0 ] + 1 , x [ 1 ] + 1 ) , seq ) ) ) NEW_LINE", "import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE a_lst = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE a_arr = np . array ( a_lst ) NEW_LINE idx = np . absolute ( a_arr ) . argmax ( ) + 1 NEW_LINE if a_lst [ idx - 1 ] == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 * N - 2 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if i != idx : NEW_LINE INDENT print ( idx , i ) NEW_LINE DEDENT DEDENT if a_lst [ idx - 1 ] > 0 : NEW_LINE INDENT for i in range ( 1 , N ) : NEW_LINE INDENT print ( i , i + 1 ) NEW_LINE DEDENT DEDENT elif a_lst [ idx - 1 ] < 0 : NEW_LINE INDENT for i in range ( N , 1 , - 1 ) : NEW_LINE INDENT print ( i , i - 1 ) NEW_LINE DEDENT DEDENT DEDENT" ]
atcoder_abc032_A
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int n = in . nextInt ( ) ; while ( n % a != 0 || n % b != 0 ) { n ++ ; } out . println ( n ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int a = nextInt ( ) , b = nextInt ( ) , n = nextInt ( ) ; int lcm = lcm ( a , b ) ; out . println ( ( lcm * ( int ) Math . ceil ( ( double ) n / ( double ) lcm ) ) ) ; } static int gcd ( int a , int b ) { return b > 0 ? gcd ( b , a % b ) : a ; } static int lcm ( int a , int b ) { return a * b / gcd ( a , b ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int n = in . nextInt ( ) ; while ( n % a != 0 || n % b != 0 ) n ++ ; out . println ( n ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; while ( c % a != 0 || c % b != 0 ) { c ++ ; } System . out . println ( c ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int g = gcd ( a , b ) ; int x = a * b / g ; System . out . println ( ( n + x - 1 ) / x * x ) ; } static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } else { return gcd ( b , a % b ) ; } } }" ]
[ "a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE while n % a > 0 or n % b > 0 : NEW_LINE INDENT n += 1 NEW_LINE DEDENT print ( n ) NEW_LINE", "def gcd ( a : int , b : int ) -> int : NEW_LINE INDENT if a < b : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT return a if b == 0 else gcd ( b , a % b ) NEW_LINE DEDENT def lcm ( a : int , b : int ) -> int : NEW_LINE INDENT return a * b // gcd ( a , b ) NEW_LINE DEDENT def like ( a : int , b : int , n : int ) -> int : NEW_LINE INDENT c = lcm ( a , b ) NEW_LINE d = c NEW_LINE while d < n : NEW_LINE INDENT d += c NEW_LINE DEDENT return d NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE ans = like ( a , b , n ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "a , b , n = map ( int , open ( 0 ) ) NEW_LINE while n % a + n % b : n += 1 NEW_LINE print ( n ) NEW_LINE", "import math NEW_LINE def gcd ( a , b ) : NEW_LINE INDENT if a < b : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT while ( b != 0 ) : NEW_LINE INDENT a , b = b , a % b NEW_LINE DEDENT return a NEW_LINE DEDENT a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE t = ( a * b ) / gcd ( a , b ) NEW_LINE ans = t NEW_LINE while ( ans < n ) : NEW_LINE INDENT ans += t NEW_LINE DEDENT ans = int ( ans ) NEW_LINE print ( ans ) NEW_LINE", "a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE for i in range ( n , 10000000 ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if i % a == 0 and i % b == 0 : NEW_LINE INDENT print ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT" ]
atcoder_arc034_C
[ "import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Main implements Runnable { public static void main ( String [ ] args ) { new Thread ( null , new Main ( ) , \" \" , Runtime . getRuntime ( ) . maxMemory ( ) ) . start ( ) ; } final long MOD = 1_000_000_000 + 7 ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long ans = 1 ; ArrayList < Integer > factor = new ArrayList < > ( ) ; for ( int i = b + 1 ; i <= a ; ++ i ) { int v = i ; for ( int j = 2 ; j * j <= v ; ++ j ) { int c = 0 ; while ( v % j == 0 ) { v /= j ; ++ c ; } if ( c > 0 ) { factor . add ( j ) ; } } if ( v > 1 ) { factor . add ( v ) ; } } Collections . sort ( factor ) ; for ( int i = 0 ; i < factor . size ( ) ; ++ i ) { int j = i ; while ( j + 1 < factor . size ( ) && factor . get ( i ) == factor . get ( j + 1 ) ) ++ j ; int c = 0 ; int v = factor . get ( i ) ; for ( int k = b + 1 ; k <= a ; ++ k ) { int u = k ; while ( u % v == 0 ) { u /= v ; ++ c ; } } ans = ans * ( c + 1 ) % MOD ; i = j ; } System . out . println ( ans ) ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . util . * ; public class Main { static final long MOD = 1000000007L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = b + 1 ; i <= a ; i ++ ) { int x = i ; for ( int j = 2 ; j <= Math . sqrt ( i ) ; j ++ ) { while ( x % j == 0 ) { if ( map . containsKey ( j ) ) { map . put ( j , map . get ( j ) + 1 ) ; } else { map . put ( j , 1 ) ; } x /= j ; } } if ( x != 1 ) { if ( map . containsKey ( x ) ) { map . put ( x , map . get ( x ) + 1 ) ; } else { map . put ( x , 1 ) ; } } } long ans = 1 ; for ( int x : map . values ( ) ) { ans = ( ans * ( long ) ( x + 1 ) ) % MOD ; } System . out . println ( ans ) ; } }" ]
[ "import sys NEW_LINE from collections import defaultdict NEW_LINE input = sys . stdin . readline NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A , B = inpl ( ) NEW_LINE cnt = 1 NEW_LINE num_cnt = defaultdict ( int ) NEW_LINE for n in range ( B + 1 , A + 1 ) : NEW_LINE INDENT i = 2 NEW_LINE while i * i <= n : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT cnt = 0 NEW_LINE while n % i == 0 : NEW_LINE INDENT cnt += 1 NEW_LINE n //= i NEW_LINE DEDENT num_cnt [ i ] += cnt NEW_LINE DEDENT i += 1 NEW_LINE DEDENT if n != 1 : NEW_LINE INDENT num_cnt [ n ] += 1 NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE for key in num_cnt . keys ( ) : NEW_LINE INDENT ans *= num_cnt [ key ] + 1 NEW_LINE ans %= MOD NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE from collections import defaultdict , Counter NEW_LINE from itertools import product , groupby , count , permutations , combinations NEW_LINE from math import pi , sqrt , ceil , floor , factorial NEW_LINE from collections import deque NEW_LINE from bisect import bisect , bisect_left , bisect_right NEW_LINE from string import ascii_lowercase NEW_LINE from functools import lru_cache , reduce NEW_LINE from operator import xor NEW_LINE from heapq import heappush , heappop NEW_LINE INF = float ( \" inf \" ) NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE MOD = 1000000007 NEW_LINE dy4 , dx4 = [ 0 , - 1 , 0 , 1 ] , [ 1 , 0 , - 1 , 0 ] NEW_LINE def inside ( y : int , x : int , H : int , W : int ) -> bool : return 0 <= y < H and 0 <= x < W NEW_LINE def ceil ( a , b ) : return ( a + b - 1 ) // b NEW_LINE def prime_factor_decomposition ( n ) : NEW_LINE INDENT import math NEW_LINE m = defaultdict ( int ) NEW_LINE while n > 1 : NEW_LINE INDENT find_factor = False NEW_LINE for i in range ( 2 , int ( math . sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT m [ i ] += 1 NEW_LINE n //= i NEW_LINE find_factor = True NEW_LINE break NEW_LINE DEDENT DEDENT if not find_factor : NEW_LINE INDENT m [ n ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT return m NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT A , B = map ( int , input ( ) . split ( ) ) NEW_LINE d = defaultdict ( int ) NEW_LINE for x in range ( B + 1 , A + 1 ) : NEW_LINE INDENT m = prime_factor_decomposition ( x ) NEW_LINE for k , v in m . items ( ) : NEW_LINE INDENT d [ k ] += v NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE for k , v in d . items ( ) : NEW_LINE INDENT ans = ( ans * ( v + 1 ) ) % MOD NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def get_prime_set ( ub ) : NEW_LINE INDENT from itertools import chain NEW_LINE from math import sqrt NEW_LINE if ub < 4 : NEW_LINE INDENT return ( { } , { } , { 2 } , { 2 , 3 } ) [ ub ] NEW_LINE DEDENT ub , ub_sqrt = ub + 1 , int ( sqrt ( ub ) ) + 1 NEW_LINE primes = { 2 , 3 } | set ( chain ( range ( 5 , ub , 6 ) , range ( 7 , ub , 6 ) ) ) NEW_LINE du = primes . difference_update NEW_LINE for n in chain ( range ( 5 , ub_sqrt , 6 ) , range ( 7 , ub_sqrt , 6 ) ) : NEW_LINE INDENT if n in primes : NEW_LINE INDENT du ( range ( n * 3 , ub , n * 2 ) ) NEW_LINE DEDENT DEDENT return primes NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT from math import sqrt NEW_LINE from collections import defaultdict NEW_LINE from functools import reduce NEW_LINE from operator import mul NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE primes = sorted ( get_prime_set ( int ( sqrt ( A ) ) ) ) NEW_LINE divisors = defaultdict ( int , { 1 : 0 } ) NEW_LINE for num in range ( B + 1 , A + 1 ) : NEW_LINE INDENT for p in primes : NEW_LINE INDENT while num % p == 0 : NEW_LINE INDENT divisors [ p ] += 1 NEW_LINE num //= p NEW_LINE DEDENT DEDENT if num > 1 : NEW_LINE INDENT divisors [ num ] += 1 NEW_LINE DEDENT DEDENT print ( reduce ( mul , [ k + 1 for k in divisors . values ( ) ] ) % ( 10 ** 9 + 7 ) ) NEW_LINE DEDENT", "import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT a , b = LI ( ) NEW_LINE d = collections . defaultdict ( int ) NEW_LINE for i in range ( b + 1 , a + 1 ) : NEW_LINE INDENT while i % 2 == 0 : NEW_LINE INDENT d [ 2 ] += 1 NEW_LINE i //= 2 NEW_LINE DEDENT for j in range ( 3 , 10 ** 5 , 2 ) : NEW_LINE INDENT while i % j == 0 : NEW_LINE INDENT d [ j ] += 1 NEW_LINE i //= j NEW_LINE DEDENT if i < j : NEW_LINE INDENT d [ i ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT if i >= 10 ** 5 : NEW_LINE INDENT d [ i ] += 1 NEW_LINE DEDENT DEDENT r = 1 NEW_LINE d [ 1 ] = 0 NEW_LINE for v in d . values ( ) : NEW_LINE INDENT r *= v + 1 NEW_LINE r %= mod NEW_LINE DEDENT return r NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "import math NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE n = math . floor ( math . sqrt ( a ) ) + 1 NEW_LINE t = { } NEW_LINE ans = 1 NEW_LINE for i in range ( b + 1 , a + 1 ) : NEW_LINE INDENT x = i NEW_LINE for j in range ( 2 , n ) : NEW_LINE INDENT if j not in t : NEW_LINE INDENT t [ j ] = 0 NEW_LINE DEDENT while x % j == 0 : NEW_LINE INDENT x /= j NEW_LINE t [ j ] += 1 NEW_LINE DEDENT if x == 1 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if x != 1 : NEW_LINE INDENT if x not in t : NEW_LINE INDENT t [ x ] = 0 NEW_LINE DEDENT t [ x ] += 1 NEW_LINE DEDENT DEDENT for k , v in t . items ( ) : NEW_LINE INDENT ans *= ( v + 1 ) NEW_LINE ans %= 1000000007 NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc096_D
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] e = new int [ 55556 ] ; int count = 0 ; for ( int i = 2 ; i < 55556 ; i ++ ) { if ( e [ i ] != - 1 ) { if ( i % 5 == 1 ) { count ++ ; System . out . print ( i + \" ▁ \" ) ; } if ( count == n ) { return ; } int k = i ; k += i ; while ( k < 55556 ) { e [ k ] = - 1 ; k += i ; } } } } }", "import java . util . ArrayList ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < Integer > data = new ArrayList < Integer > ( ) ; for ( int i = 2 ; i <= 55555 ; i ++ ) { boolean ok = true ; for ( int j = 2 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { ok = false ; break ; } } if ( ok ) { if ( ( i - 1 ) % 10 == 0 ) { data . add ( i ) ; } } } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( data . get ( i ) ) ; } } } class UnionFind { int [ ] parent ; public UnionFind ( int N ) { this . parent = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { parent [ i ] = i ; } } public int root ( int x ) { if ( parent [ x ] == x ) { return x ; } else { return parent [ x ] = root ( parent [ x ] ) ; } } public void unite ( int x , int y ) { if ( same ( x , y ) ) { return ; } int xroot = root ( x ) ; int yroot = root ( y ) ; parent [ xroot ] = yroot ; return ; } public boolean same ( int x , int y ) { return ( root ( x ) == root ( y ) ) ; } } class Pair implements Comparable { int from ; int end ; int num ; int bango ; @ Override public int compareTo ( Object other ) { Pair otherpair = ( Pair ) other ; return end - otherpair . end ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = Integer . parseInt ( in . nextLine ( ) ) ; in . close ( ) ; int MAX = 55555 ; boolean [ ] isPrime = new boolean [ MAX + 1 ] ; Arrays . fill ( isPrime , true ) ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; primeDetection ( isPrime ) ; boolean [ ] valid = new boolean [ MAX + 1 ] ; int count = 0 ; for ( int i = 2 ; i < isPrime . length ; ++ i ) { if ( isPrime [ i ] && i % 5 == 1 ) { System . out . print ( i + \" ▁ \" ) ; count ++ ; } if ( count >= N ) { break ; } } System . out . println ( \" \" ) ; } private static void primeDetection ( boolean [ ] isPrime ) { for ( int i = 2 ; i < isPrime . length ; ++ i ) { if ( ! isPrime [ i ] ) { continue ; } for ( int j = i * 2 ; j < isPrime . length ; j = j + i ) { isPrime [ j ] = false ; } } } }", "import java . util . * ; public class Main { static boolean [ ] comp = new boolean [ 1310 ] ; static ArrayList < Integer > list = new ArrayList < > ( ) ; public static void main ( String [ ] args ) { sieve ( ) ; Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( i != 0 ) sb . append ( \" ▁ \" ) ; sb . append ( list . get ( i ) ) ; } System . out . println ( sb . toString ( ) ) ; } public static void sieve ( ) { for ( int i = 2 ; i < comp . length ; i ++ ) { if ( ! comp [ i ] ) { if ( i % 5 == 3 ) list . add ( i ) ; for ( int j = 2 ; i * j < comp . length ; j ++ ) comp [ i * j ] = true ; } } } }", "import java . util . Scanner ; class Main { static char [ ] [ ] map ; static int H ; static int W ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] data = new int [ 10000001 ] ; int c = 0 ; for ( int i = 10 ; i <= 55555 ; i ++ ) { for ( int j = 2 ; j <= ( i + 1 ) / 2 ; j ++ ) { if ( i % j == 0 ) { break ; } if ( j == ( i + 1 ) / 2 && i % 5 == 1 ) { data [ c ] = i ; c ++ ; if ( c == N ) { for ( int k = 0 ; k < N ; k ++ ) { System . out . println ( data [ k ] ) ; } return ; } } } } } } class Pair implements Comparable { String from ; int end ; @ Override public int compareTo ( Object other ) { Pair otherpair = ( Pair ) other ; return end - otherpair . end ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE mod = 5 NEW_LINE def prime_sieve_mod ( n ) : NEW_LINE INDENT _sieve = list ( range ( 2 , n + 1 ) ) NEW_LINE _sieve . reverse ( ) NEW_LINE _prime = [ ] NEW_LINE while _sieve and len ( _prime ) < N : NEW_LINE INDENT _num = _sieve . pop ( ) NEW_LINE if _num % mod == 1 : NEW_LINE INDENT _prime . append ( _num ) NEW_LINE DEDENT _del = [ ] NEW_LINE for _i , _v in enumerate ( _sieve ) : NEW_LINE INDENT if _v % _num == 0 : NEW_LINE INDENT _del . append ( _i ) NEW_LINE DEDENT DEDENT _del . reverse ( ) NEW_LINE for _i in _del : NEW_LINE INDENT del _sieve [ _i ] NEW_LINE DEDENT DEDENT return _prime NEW_LINE DEDENT prime_list = prime_sieve_mod ( 1381 ) NEW_LINE print ( * prime_list ) NEW_LINE", "ans = [ 11 , 31 , 41 , 61 , 71 , 101 , 131 , 151 , 181 , 191 , 211 , 241 , 251 , 271 , 281 , 311 , 331 , 401 , 421 , 431 , 461 , 491 , 521 , 541 , 571 , 601 , 631 , 641 , 661 , 691 , 701 , 751 , 761 , 811 , 821 , 881 , 911 , 941 , 971 , 991 , 1021 , 1031 , 1051 , 1061 , 1091 , 1151 , 1171 , 1181 , 1201 , 1231 , 1291 , 1301 , 1321 , 1361 , 1381 ] NEW_LINE for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT print ( ans [ i ] , end = \" ▁ \" ) NEW_LINE DEDENT", "import sys NEW_LINE import math NEW_LINE def Sieve_of_Eratosthenes ( N ) : NEW_LINE INDENT prime = set ( i for i in range ( 2 , N + 1 ) ) NEW_LINE for i in range ( 2 , math . ceil ( N ** 0.5 ) + 1 ) : NEW_LINE INDENT tmp = set ( ) NEW_LINE for j in prime : NEW_LINE INDENT if j > i and j % i == 0 : tmp . add ( j ) NEW_LINE DEDENT for j in tmp : NEW_LINE INDENT prime . remove ( j ) NEW_LINE DEDENT DEDENT return ( prime ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE prime = Sieve_of_Eratosthenes ( 55555 ) NEW_LINE ans = [ [ ] for i in range ( 5 ) ] NEW_LINE for i in prime : NEW_LINE INDENT ans [ i % 5 ] . append ( i ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT print ( ans [ 1 ] [ i ] , end = \" ▁ \" ) NEW_LINE DEDENT", "era = [ 1 ] * 55556 NEW_LINE era [ 0 ] = era [ 1 ] = 0 NEW_LINE for i in range ( 2 , int ( 55556 ** 0.5 ) + 1 ) : NEW_LINE INDENT if ( era [ i ] == 1 ) : NEW_LINE INDENT for j in range ( i * 2 , 55556 , i ) : era [ j ] = 0 NEW_LINE DEDENT DEDENT v = [ 0 ] * 5 NEW_LINE n = int ( input ( ) ) NEW_LINE for i in range ( 55556 ) : NEW_LINE INDENT if ( era [ i ] and i % 5 == 1 ) : NEW_LINE INDENT print ( i , end = \" ▁ \" ) NEW_LINE n -= 1 NEW_LINE if ( n == 0 ) : break NEW_LINE DEDENT DEDENT print ( ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE upper = 55555 NEW_LINE p_flag = [ True ] * ( upper + 1 ) NEW_LINE p_flag [ 0 ] = p_flag [ 1 ] = False NEW_LINE prime = [ ] NEW_LINE for i in range ( 2 , upper + 1 ) : NEW_LINE INDENT if p_flag [ i ] : NEW_LINE INDENT prime . append ( i ) NEW_LINE for j in range ( 2 * i , upper + 1 , i ) : NEW_LINE INDENT p_flag [ j ] = False NEW_LINE DEDENT DEDENT DEDENT ans = [ ] NEW_LINE cnt = 0 NEW_LINE for i in prime : NEW_LINE INDENT if i % 5 == 1 : NEW_LINE INDENT ans . append ( i ) NEW_LINE cnt += 1 NEW_LINE DEDENT if cnt == N : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( * ans ) NEW_LINE" ]
atcoder_abc099_B
[ "import java . util . * ; import java . io . * ; class Main { int retrunN ( int n ) { int i = 0 ; int sum = 0 ; while ( i <= n ) { sum += i ++ ; } return sum ; } public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; Main At = new Main ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int result = 0 ; result = At . retrunN ( b - a ) - b ; System . out . println ( result ) ; } }", "import java . io . * ; import java . util . Arrays ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) throws IOException { String input = ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) . readLine ( ) ; int [ ] highs = Arrays . stream ( input . split ( \" ▁ \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int diff = highs [ 1 ] - highs [ 0 ] ; int higher = IntStream . rangeClosed ( 1 , diff ) . sum ( ) ; System . out . println ( higher - highs [ 1 ] ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int A = reader . nextInt ( ) ; int B = reader . nextInt ( ) ; int gap = B - A ; int ans = - A ; for ( int i = 1 ; i < gap ; i ++ ) { ans += i ; } System . out . print ( ans ) ; reader . close ( ) ; } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( ( b - a ) * ( b - a + 1 ) / 2 - b ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] srgs ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int sa = b - a ; int s = 0 ; for ( int i = 0 ; i <= 999 ; i ++ ) { s += i ; if ( i == sa ) { System . out . println ( s - b ) ; return ; } } scan . close ( ) ; } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE sum = 0 NEW_LINE for i in range ( b - a ) : NEW_LINE INDENT sum += i + 1 NEW_LINE DEDENT print ( sum - b ) NEW_LINE", "import sys NEW_LINE import re NEW_LINE from collections import deque , defaultdict , Counter NEW_LINE from math import ceil , sqrt , hypot , factorial , pi , sin , cos , radians NEW_LINE from itertools import permutations , combinations , product NEW_LINE from operator import itemgetter , mul NEW_LINE from copy import deepcopy NEW_LINE from string import ascii_lowercase , ascii_uppercase , digits NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def INT ( ) : return int ( input ( ) ) NEW_LINE def MAP ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE a , b = MAP ( ) NEW_LINE for x in range ( 2 , 1000 ) : NEW_LINE INDENT if b - a == x : NEW_LINE INDENT print ( int ( ( x - 1 ) * x / 2 - a ) ) NEW_LINE DEDENT DEDENT", "def sigma ( num ) : NEW_LINE INDENT ret = 0 NEW_LINE for i in range ( num + 1 ) : NEW_LINE INDENT ret += i NEW_LINE DEDENT return ret NEW_LINE DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = sigma ( m - n ) NEW_LINE print ( a - m ) NEW_LINE", "from itertools import accumulate as acc NEW_LINE a = [ i for i in range ( 1000 ) ] NEW_LINE a = list ( acc ( a ) ) NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( a [ B - A ] - B ) NEW_LINE", "a , b = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE print ( int ( ( b - a ) * ( b - a - 1 ) / 2 ) - a ) NEW_LINE" ]
atcoder_arc067_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int an [ ] = new int [ a + 1 ] ; long ans = 1 ; int c = 0 ; int d = ( int ) Math . pow ( 10 , 9 ) + 7 ; for ( int i = 0 ; i < a + 1 ; i ++ ) { an [ i ] = 1 ; } for ( int i = 2 ; i <= a ; i ++ ) { c = i ; while ( c % 2 == 0 ) { c /= 2 ; an [ 2 ] ++ ; } for ( int n = 3 ; n * n <= c ; n += 2 ) { while ( c % n == 0 ) { c /= n ; an [ n ] ++ ; } } if ( c > 1 ) { an [ c ] ++ ; } } for ( int i = 0 ; i < an . length ; i ++ ) { ans = ( long ) ans * an [ i ] % d ; } 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 ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { static public int mod = ( int ) ( 1e9 + 7 ) ; public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; boolean mark [ ] = new boolean [ n + 1 ] ; for ( int i = 0 ; i <= n ; ++ i ) mark [ i ] = true ; for ( int i = 2 ; i <= n ; ++ i ) if ( mark [ i ] ) { for ( int j = i + i ; j <= n ; j += i ) mark [ j ] = false ; } long r = 1 ; for ( int i = 2 ; i <= n ; ++ i ) if ( mark [ i ] ) { int c = 0 ; for ( long p = i ; p <= n ; p *= i ) c += n / p ; r = r * ( c + 1 ) % mod ; } out . println ( r ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; sc . close ( ) ; if ( n < 3 ) { System . out . println ( n ) ; return ; } ArrayList < Integer > list = new ArrayList < Integer > ( ) ; list . add ( 2 ) ; for ( int i = 3 ; i <= n ; i ++ ) { boolean b = true ; for ( int j = 0 ; j < list . size ( ) ; j ++ ) { if ( i % list . get ( j ) == 0 ) { b = false ; break ; } } if ( b ) { list . add ( i ) ; } } long [ ] [ ] num = new long [ n ] [ list . size ( ) ] ; for ( int i = 1 ; i <= n ; i ++ ) { int x = i ; for ( int j = 0 ; j < list . size ( ) ; j ++ ) { while ( x % list . get ( j ) == 0 ) { num [ i - 1 ] [ j ] ++ ; x /= list . get ( j ) ; } } } long [ ] sum = new long [ list . size ( ) ] ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j < list . size ( ) ; j ++ ) { sum [ j ] += num [ i - 1 ] [ j ] ; } } long ans = 1 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( sum [ i ] != 0 ) { ans *= sum [ i ] + 1L ; } if ( ans >= 1000000007L ) { ans %= 1000000007L ; } } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; System . out . println ( calc ( N ) ) ; } private static long calc ( int x ) { int [ ] primes = new int [ x + 1 ] ; Arrays . fill ( primes , 1 ) ; primes [ 0 ] = primes [ 1 ] = 0 ; for ( int i = 3 ; i < primes . length ; i ++ ) { if ( i % 2 == 0 ) primes [ i ] = 0 ; } int j = 3 ; while ( j * j < primes . length ) { for ( int k = j + 1 ; k < primes . length ; k ++ ) { if ( k % j == 0 ) primes [ k ] = 0 ; } j += 2 ; } int [ ] factors = new int [ x + 1 ] ; while ( x > 1 ) { int i = 3 ; int f = x ; while ( f % 2 == 0 ) { factors [ 2 ] ++ ; f /= 2 ; } while ( i <= f ) { if ( primes [ i ] == 1 ) { while ( f % i == 0 ) { factors [ i ] ++ ; f /= i ; } } i += 2 ; } if ( f != 1 ) factors [ f ] ++ ; x -- ; } long d = ( long ) Math . pow ( 10 , 9 ) + 7 ; long count = 1 ; for ( int f : factors ) { if ( f != 0 ) count *= ( f + 1 ) ; while ( count >= d ) { count -= d ; } } return count ; } private static void test ( ) { assert calc ( 6 ) == 30 ; assert calc ( 1000 ) == 972926972 ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean [ ] prime = new boolean [ 1000 ] ; prime [ 1 - 1 ] = false ; for ( int i = 2 ; i <= 1000 ; i ++ ) prime [ i - 1 ] = true ; for ( int i = 1 ; i <= 1000 ; i ++ ) { if ( prime [ i - 1 ] ) { for ( int j = 2 ; i * j <= 1000 ; j ++ ) prime [ i * j - 1 ] = false ; } } int [ ] counter = new int [ 1000 ] ; for ( int i = 1 ; i <= 1000 ; i ++ ) counter [ i - 1 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { if ( prime [ j - 1 ] ) { int x = i ; int count = 0 ; while ( x % j == 0 ) { x = x / j ; count ++ ; } counter [ j - 1 ] += count ; } } } long result = 1 ; for ( int i = 1 ; i <= 1000 ; i ++ ) result = ( result * ( counter [ i - 1 ] + 1 ) ) % 1000000007 ; System . out . println ( String . valueOf ( result % 1000000007 ) ) ; } }" ]
[ "import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE def era ( n ) : NEW_LINE INDENT data = [ i for i in range ( 2 , n + 1 ) ] NEW_LINE for d in data : NEW_LINE INDENT data = [ x for x in data if ( x == d or x % d != 0 ) ] NEW_LINE DEDENT data1 = [ ] NEW_LINE for d in data : NEW_LINE INDENT data1 . append ( [ d , 1 ] ) NEW_LINE DEDENT return data1 NEW_LINE DEDENT mod = 10 ** 9 + 7 NEW_LINE n = ni ( ) NEW_LINE lis = era ( n ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( len ( lis ) ) : NEW_LINE INDENT if i < lis [ j ] [ 0 ] : NEW_LINE INDENT break NEW_LINE DEDENT elif i % lis [ j ] [ 0 ] == 0 : NEW_LINE INDENT count = 0 NEW_LINE m = i NEW_LINE while ( m % lis [ j ] [ 0 ] == 0 ) : NEW_LINE INDENT m = m // lis [ j ] [ 0 ] NEW_LINE count += 1 NEW_LINE DEDENT lis [ j ] [ 1 ] += count NEW_LINE DEDENT DEDENT DEDENT ans = 1 NEW_LINE for i in range ( len ( lis ) ) : NEW_LINE INDENT ans *= lis [ i ] [ 1 ] NEW_LINE ans %= mod NEW_LINE DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE MOD = int ( 1e+9 ) + 7 NEW_LINE prime = [ 2 ] NEW_LINE for i in range ( 2 , 1001 ) : NEW_LINE INDENT for j in range ( 2 , i - 1 ) : NEW_LINE INDENT if i % j == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT prime . append ( i ) NEW_LINE DEDENT DEDENT factor = [ 1 ] * 1000 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT for p in prime : NEW_LINE INDENT if i == 1 : NEW_LINE INDENT break NEW_LINE DEDENT while i % p == 0 : NEW_LINE INDENT i /= p NEW_LINE factor [ p ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans = 1 NEW_LINE for fact in factor : NEW_LINE INDENT ans *= fact NEW_LINE ans %= MOD NEW_LINE DEDENT print ( int ( ans ) ) NEW_LINE", "from functools import reduce NEW_LINE def primes_list ( N ) : NEW_LINE INDENT l = [ v for v in range ( 2 , N + 1 ) ] NEW_LINE ret = [ ] NEW_LINE while l : NEW_LINE INDENT cur = l . pop ( 0 ) NEW_LINE l = list ( filter ( lambda x : x % cur != 0 , l ) ) NEW_LINE ret . append ( cur ) NEW_LINE DEDENT return ret NEW_LINE DEDENT mod = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE l = [ 0 ] * ( N + 1 ) NEW_LINE primes = primes_list ( N ) NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT for p in primes : NEW_LINE INDENT if p > i : NEW_LINE INDENT break NEW_LINE DEDENT tmp = 0 NEW_LINE while i % p == 0 : NEW_LINE INDENT i //= p NEW_LINE tmp += 1 NEW_LINE DEDENT l [ p ] += tmp NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE for i in l : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT ans = ans * ( i + 1 ) % mod NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "thelist = [ 2 ] NEW_LINE for i in range ( 3 , 1000 ) : NEW_LINE INDENT t = 0 NEW_LINE for j in range ( 2 , i ) : NEW_LINE INDENT if i % j == 0 : NEW_LINE INDENT t = 1 NEW_LINE continue NEW_LINE DEDENT DEDENT if t == 0 : NEW_LINE INDENT thelist . append ( i ) NEW_LINE DEDENT DEDENT while True : NEW_LINE INDENT try : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE DEDENT except : NEW_LINE INDENT break NEW_LINE DEDENT thedic = { } NEW_LINE for i in thelist : NEW_LINE INDENT thedic [ i ] = 0 NEW_LINE DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT t = i NEW_LINE j = 0 NEW_LINE while j != len ( thelist ) : NEW_LINE INDENT if t % thelist [ j ] == 0 : NEW_LINE INDENT thedic [ thelist [ j ] ] += 1 NEW_LINE t = t / thelist [ j ] NEW_LINE continue NEW_LINE DEDENT j = j + 1 NEW_LINE if t == 1 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT value = 1 NEW_LINE for i in thedic : NEW_LINE INDENT value = value % ( 1000000000 + 7 ) * ( thedic [ i ] + 1 ) NEW_LINE DEDENT print ( value % ( 1000000000 + 7 ) ) NEW_LINE DEDENT", "from math import * NEW_LINE n = factorial ( int ( input ( ) ) ) NEW_LINE def dv ( n ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT return 1 NEW_LINE DEDENT divisorsNum = 1 NEW_LINE i = 2 NEW_LINE while i * i <= n : NEW_LINE INDENT cnt = 1 NEW_LINE while n % i == 0 : NEW_LINE INDENT cnt += 1 NEW_LINE n //= i NEW_LINE DEDENT divisorsNum *= cnt NEW_LINE i += 1 NEW_LINE DEDENT return divisorsNum * 2 NEW_LINE DEDENT mod = ( 10 ** 9 + 7 ) NEW_LINE print ( dv ( n ) % mod ) NEW_LINE" ]
atcoder_arc060_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int [ ] a = mp ( str ) ; int n = str . length ( ) ; int shuki = n - a [ n ] ; if ( shuki == 1 ) { System . out . println ( n ) ; System . out . println ( 1 ) ; } else if ( n % shuki != 0 || shuki == n ) { System . out . println ( 1 ) ; System . out . println ( 1 ) ; } else { System . out . println ( 2 ) ; StringBuilder restr = new StringBuilder ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) restr . append ( str . charAt ( i ) ) ; int [ ] b = mp ( restr . toString ( ) ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int shuki1 = i + 1 - a [ i + 1 ] ; if ( shuki1 != ( i + 1 ) && ( i + 1 ) % shuki1 == 0 ) continue ; int shuki2 = n - i - 1 - b [ n - i - 1 ] ; if ( shuki2 != ( n - i - 1 ) && ( n - i - 1 ) % shuki2 == 0 ) continue ; count ++ ; } System . out . println ( count ) ; } } static int [ ] mp ( String str ) { int n = str . length ( ) ; int [ ] a = new int [ n + 1 ] ; a [ 0 ] = - 1 ; int j = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { while ( j >= 0 && str . charAt ( i ) != str . charAt ( j ) ) j = a [ j ] ; j ++ ; a [ i + 1 ] = j ; } return a ; } }" ]
[ "from collections import Counter NEW_LINE * W , = map ( ord , input ( ) ) NEW_LINE N = len ( W ) NEW_LINE C = Counter ( W ) NEW_LINE if len ( C ) == 1 : NEW_LINE INDENT print ( N ) NEW_LINE print ( 1 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def z_algo ( S ) : NEW_LINE INDENT A = [ 0 ] * N NEW_LINE i = 1 ; j = 0 NEW_LINE A [ 0 ] = l = len ( S ) NEW_LINE while i < l : NEW_LINE INDENT while i + j < l and S [ j ] == S [ i + j ] : NEW_LINE INDENT j += 1 NEW_LINE DEDENT A [ i ] = j NEW_LINE if not j : NEW_LINE INDENT i += 1 NEW_LINE continue NEW_LINE DEDENT k = 1 NEW_LINE while l - i > k < j - A [ k ] : NEW_LINE INDENT A [ i + k ] = A [ k ] NEW_LINE k += 1 NEW_LINE DEDENT i += k ; j -= k NEW_LINE DEDENT return A NEW_LINE DEDENT def calc ( W ) : NEW_LINE INDENT Z = z_algo ( W ) NEW_LINE G = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT G [ i ] = 1 NEW_LINE DEDENT for p in range ( 1 , N ) : NEW_LINE INDENT if not G [ p - 1 ] : NEW_LINE INDENT continue NEW_LINE DEDENT for k in range ( 2 , Z [ p ] // p + 2 ) : NEW_LINE INDENT G [ k * p - 1 ] = 0 NEW_LINE DEDENT DEDENT return G NEW_LINE DEDENT G0 = calc ( W ) NEW_LINE W . reverse ( ) NEW_LINE G1 = calc ( W ) NEW_LINE if G0 [ N - 1 ] : NEW_LINE INDENT print ( 1 ) NEW_LINE print ( 1 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT print ( 2 ) NEW_LINE print ( sum ( p and q for p , q in zip ( G0 [ : - 1 ] , reversed ( G1 [ : - 1 ] ) ) ) ) NEW_LINE" ]
atcoder_agc015_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; if ( A == B ) { System . out . println ( 1 ) ; } else { int abi = 62 ; for ( ; abi >= 0 ; abi -- ) if ( ( ( A ^ B ) & ( 1l << abi ) ) != 0 ) break ; long mask = ( 1l << abi ) - 1 ; long ans = mask - ( A & mask ) + 1 ; int bi = abi - 1 ; for ( ; bi >= 0 ; bi -- ) if ( ( ( 1l << bi ) & B ) != 0 ) break ; long temp = 1l << ( bi + 1 ) ; ans += temp + ( 1l << abi ) - Math . max ( temp , A & mask ) ; System . out . println ( ans ) ; } sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; System . out . println ( calc ( A , B ) ) ; } public static long calc ( long A , long B ) { if ( A == B ) { return 1 ; } long ans = 0 ; long k = 1 ; for ( int i = 0 ; i <= 60 ; i ++ ) { k = k * 2 ; } while ( ( A & k ) == ( B & k ) ) { A = ( A | k ) ^ k ; B = ( B | k ) ^ k ; k = k / 2 ; } long s1 = k - A ; long s2 = k - A ; long s3 = maxbit ( B - k ) ; ans = s1 + s2 + s3 ; long rb = k + s3 - 1 ; long lb = k + A ; if ( rb >= lb ) { ans = ans - ( rb - lb + 1 ) ; } return ans ; } public static long maxbit ( long n ) { if ( n == 0 ) { return 1 ; } long k = 1 , ans = 0 ; for ( int i = 0 ; i <= 60 ; i ++ ) { if ( ( n & k ) > 0 ) { ans = k ; } k = k * 2 ; } return ans * 2 ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long A = scan . nextLong ( ) ; long B = scan . nextLong ( ) ; long [ ] two = new long [ 61 ] ; two [ 0 ] = 1 ; for ( int i = 1 ; i < 61 ; i ++ ) { two [ i ] = two [ i - 1 ] * 2 ; } int maxk = 0 ; out : for ( int j = 60 ; j >= 0 ; j -- ) { for ( int i = j ; i >= 0 ; i -- ) { if ( A <= two [ i ] && B >= two [ i ] ) { maxk = i ; break out ; } if ( i == 0 ) { for ( int k = 1 ; k <= 60 ; k ++ ) { if ( A < two [ k ] ) { A -= two [ k - 1 ] ; B -= two [ k - 1 ] ; break ; } } } } } long ans = two [ maxk ] - A ; B -= two [ maxk ] ; int maxk_ = 0 ; for ( int i = 0 ; i <= 60 ; i ++ ) { if ( B < two [ i ] ) { maxk_ = i ; break ; } } ans += two [ maxk_ ] ; if ( two [ maxk_ ] <= A ) { ans += two [ maxk ] - A ; } else { ans += two [ maxk ] - two [ maxk_ ] ; } System . out . println ( ans ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; while ( A > 0 && Long . highestOneBit ( A ) == Long . highestOneBit ( B ) ) { long flip = Long . highestOneBit ( A ) ; A ^= flip ; B ^= flip ; } if ( B == 0 ) { System . out . println ( 1 ) ; return ; } int first = Long . numberOfTrailingZeros ( Long . highestOneBit ( B ) ) ; int second = - 1 ; if ( B == ( 1L << first ) ) { second = - 1 ; } else { second = Long . numberOfTrailingZeros ( Long . highestOneBit ( B ^ ( 1L << first ) ) ) ; } long l1 = A ; long r1 = ( ( 1L << first ) + ( ( 1L << ( second + 1 ) ) - 1 ) ) ; long l2 = A + ( 1L << first ) ; long r2 = ( 1L << ( first + 1 ) ) - 1 ; long res = - 1 ; if ( l2 <= r1 && r1 <= r2 ) { res = r2 - l1 + 1 ; } else if ( l1 <= r2 && r2 <= r1 ) { res = r1 - l1 + 1 ; } else if ( r1 <= l2 ) { res = ( r1 - l1 + 1 ) + ( r2 - l2 + 1 ) ; } System . out . println ( res ) ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner io = new Scanner ( System . in ) ; long A = io . nextLong ( ) ; long B = io . nextLong ( ) ; System . out . println ( orNum ( A , B ) ) ; } public static long orNum ( long A , long B ) { long q = 1L << 59 ; for ( ; q > 0 ; q = q >> 1 ) { if ( ( A & q ) == 0 && ( B & q ) == 0 ) continue ; if ( ( A & q ) != 0 && ( B & q ) != 0 ) { A -= q ; B -= q ; continue ; } if ( ( A & q ) == 0 && ( B & q ) != 0 ) { break ; } if ( ( ( A & q ) != 0 && ( B & q ) == 0 ) ) { return 0 ; } } if ( A == B ) { return 1 ; } long ans = q - A ; ans = ans * 2 + 1 ; B -= q ; ans += Math . min ( A - 1 , orNum ( 1 , B ) ) ; return ans ; } }" ]
[ "res = 0 NEW_LINE A = int ( input ( ) ) NEW_LINE B = int ( input ( ) ) NEW_LINE def pow2_floor_log2 ( x ) : NEW_LINE INDENT res = 1 NEW_LINE while res * 2 <= x : NEW_LINE INDENT res *= 2 NEW_LINE DEDENT return res NEW_LINE DEDENT if A == B : NEW_LINE INDENT res += 1 NEW_LINE DEDENT while A < B : NEW_LINE INDENT C = pow2_floor_log2 ( B ) NEW_LINE if A < C : NEW_LINE INDENT res += C - A NEW_LINE if B > C : NEW_LINE INDENT B_ = C + pow2_floor_log2 ( B - C ) * 2 - 1 NEW_LINE DEDENT else : NEW_LINE INDENT B_ = C NEW_LINE DEDENT if C + A <= B_ : NEW_LINE INDENT res += C NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT res += ( C - A ) + ( B_ - C + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT A -= C NEW_LINE B -= C NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE", "import sys NEW_LINE def solve ( ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE if a == b : NEW_LINE INDENT print ( 1 ) NEW_LINE return NEW_LINE DEDENT t = a ^ b NEW_LINE N = bitlen ( t ) NEW_LINE a = a & ( 2 ** N - 1 ) NEW_LINE b = b & ( 2 ** N - 1 ) NEW_LINE blen = bitlen ( b ) NEW_LINE sb = b & ( 2 ** ( blen - 1 ) - 1 ) NEW_LINE sblen = bitlen ( sb ) NEW_LINE s = 2 ** sblen - 1 NEW_LINE ymax = b | s NEW_LINE T = 2 ** ( N - 1 ) NEW_LINE ans = T - a NEW_LINE if ymax < T + a : NEW_LINE INDENT ans += ymax + 1 - a NEW_LINE DEDENT else : NEW_LINE INDENT ans += T NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT def bitlen ( x ) : NEW_LINE INDENT return 1 + bitlen ( x >> 1 ) if x else 0 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT", "a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE if a == b : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT def bitlen ( x ) : NEW_LINE INDENT return 1 + bitlen ( x >> 1 ) if x else 0 NEW_LINE DEDENT t = a ^ b NEW_LINE n = bitlen ( t ) NEW_LINE T = 1 << ( n - 1 ) NEW_LINE a = a & ( T * 2 - 1 ) NEW_LINE b = b & ( T * 2 - 1 ) NEW_LINE sb = b & ( T - 1 ) NEW_LINE b_max = ( 2 ** bitlen ( sb ) - 1 ) | T NEW_LINE if ( T + a ) > b_max : NEW_LINE INDENT print ( ( b_max - a + 1 ) + ( 2 * T - 1 - ( T + a ) + 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 * T - 1 - a + 1 ) NEW_LINE DEDENT", "import math NEW_LINE A = int ( input ( ) ) NEW_LINE B = int ( input ( ) ) NEW_LINE if B < A : A , B = B , A NEW_LINE if A == B : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT t = int ( math . floor ( math . log2 ( B ) ) ) NEW_LINE while ( A & 2 ** t ) == ( B & 2 ** t ) : NEW_LINE INDENT if A & 2 ** t : NEW_LINE INDENT A -= 2 ** t NEW_LINE B -= 2 ** t NEW_LINE DEDENT t -= 1 NEW_LINE DEDENT ans = 2 ** t - A NEW_LINE r = t - 1 NEW_LINE while 2 ** t + 2 ** r > B and r >= 0 : NEW_LINE INDENT r -= 1 NEW_LINE DEDENT C = 2 ** ( r + 1 ) NEW_LINE if C < A : NEW_LINE INDENT ans += C + 2 ** t - A NEW_LINE DEDENT else : NEW_LINE INDENT ans += 2 ** t NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT", "import sys NEW_LINE def solve ( ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE if a == b : NEW_LINE INDENT print ( 1 ) NEW_LINE return NEW_LINE DEDENT t = a ^ b NEW_LINE N = len ( bin ( t ) ) - 2 NEW_LINE t = 1 << N NEW_LINE a = a & ( t - 1 ) NEW_LINE b = b & ( t - 1 ) NEW_LINE blen = len ( bin ( b ) ) - 2 NEW_LINE sb = b & ( 2 ** ( blen - 1 ) - 1 ) NEW_LINE if sb == 0 : NEW_LINE INDENT sblen = 0 NEW_LINE DEDENT else : NEW_LINE INDENT sblen = len ( bin ( sb ) ) - 2 NEW_LINE DEDENT s = ( 1 << sblen ) - 1 NEW_LINE ymax = b | s NEW_LINE T = 1 << ( N - 1 ) NEW_LINE ans = T - a NEW_LINE if ymax < T + a : NEW_LINE INDENT ans += ymax - T + 1 + T - a NEW_LINE DEDENT else : NEW_LINE INDENT ans += T NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT" ]
atcoder_arc054_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] S = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { char [ ] c = sc . next ( ) . toCharArray ( ) ; for ( int j = 0 ; j < n ; j ++ ) { S [ i ] [ j ] = c [ j ] - '0' ; } } System . out . println ( Math . abs ( detMt ( S ) % 2 ) == 1 ? \" Odd \" : \" Even \" ) ; } int count = 1 ; int detMt ( int [ ] [ ] A ) { assert A . length == A [ 0 ] . length ; int n = A . length ; int det = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] [ i ] == 0 ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( A [ j ] [ i ] != 0 ) { for ( int k = 0 ; k < n ; k ++ ) { int d = A [ i ] [ k ] ; A [ i ] [ k ] = A [ j ] [ k ] ; A [ j ] [ k ] = d ; } break ; } if ( j == n - 1 ) return 0 ; } } for ( int j = i + 1 ; j < n ; j ++ ) { double rate = A [ j ] [ i ] / A [ i ] [ i ] ; for ( int k = 0 ; k < n ; k ++ ) { A [ j ] [ k ] += rate * A [ i ] [ k ] ; A [ j ] [ k ] %= 2 ; } } } for ( int i = 0 ; i < n ; i ++ ) det *= A [ i ] [ i ] ; while ( det < 0 ) det ++ ; return det ; } }" ]
[ "def det ( a ) : NEW_LINE INDENT n = len ( a ) NEW_LINE if n == 1 : NEW_LINE INDENT return a [ 0 ] [ 0 ] NEW_LINE DEDENT b = [ [ a [ i ] [ j ] for i in range ( n ) ] for j in range ( n ) ] NEW_LINE k = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if b [ i ] [ 0 ] == 1 : NEW_LINE INDENT k = i NEW_LINE break NEW_LINE DEDENT DEDENT if k == - 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT b [ k ] [ j ] , b [ 0 ] [ j ] = b [ 0 ] [ j ] , b [ k ] [ j ] NEW_LINE DEDENT DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if b [ i ] [ 0 ] == 1 : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT b [ i ] [ j ] = ( b [ i ] [ j ] + b [ 0 ] [ j ] ) % 2 NEW_LINE DEDENT DEDENT DEDENT c = [ [ b [ i ] [ j ] for i in range ( 1 , n ) ] for j in range ( 1 , n ) ] NEW_LINE return det ( c ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE a = [ [ int ( i ) for i in list ( input ( ) ) ] for j in range ( N ) ] NEW_LINE ans = det ( a ) NEW_LINE if ans == 1 : NEW_LINE INDENT print ( \" Odd \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Even \" ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE matrix = [ list ( map ( int , input ( ) ) ) for _ in range ( N ) ] NEW_LINE ans = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if matrix [ i ] [ i ] == 0 : NEW_LINE INDENT for j in range ( i , N ) : NEW_LINE INDENT if matrix [ j ] [ i ] == 1 : NEW_LINE INDENT matrix [ i ] , matrix [ j ] = matrix [ j ] , matrix [ i ] NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if matrix [ i ] [ i ] == 0 : NEW_LINE INDENT ans = 0 NEW_LINE break NEW_LINE DEDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT if matrix [ j ] [ i ] == 1 : NEW_LINE INDENT for k in range ( N ) : NEW_LINE INDENT matrix [ j ] [ k ] ^= matrix [ i ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( \" Even \" if ans % 2 == 0 else \" Odd \" ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE a = [ list ( input ( ) ) for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT a [ i ] [ j ] = ord ( a [ i ] [ j ] ) - ord ( '0' ) NEW_LINE DEDENT DEDENT ans = True NEW_LINE for i in range ( n ) : NEW_LINE INDENT u = i NEW_LINE while u < n and a [ u ] [ i ] == 0 : NEW_LINE INDENT u += 1 NEW_LINE DEDENT if u == n : NEW_LINE INDENT ans = False NEW_LINE break NEW_LINE DEDENT for j in range ( u + 1 , n ) : NEW_LINE INDENT if a [ j ] [ i ] == 1 : NEW_LINE INDENT a [ j ] = [ p ^ q for p , q in zip ( a [ j ] , a [ u ] ) ] NEW_LINE DEDENT DEDENT a [ i ] , a [ u ] = a [ u ] , a [ i ] NEW_LINE DEDENT if ans : NEW_LINE INDENT print ( \" Odd \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Even \" ) NEW_LINE DEDENT", "def printmat ( matrix ) : NEW_LINE INDENT for x in matrix : NEW_LINE INDENT print ( [ int ( y ) for y in x ] ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT def det ( matrix ) : NEW_LINE INDENT N = len ( matrix ) NEW_LINE a = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if matrix [ i ] [ i ] == 0 : NEW_LINE INDENT index = [ k for k in range ( i + 1 , N ) if matrix [ k ] [ i ] != 0 ] NEW_LINE if len ( index ) == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT k = index [ 0 ] NEW_LINE a *= - 1 NEW_LINE matrix [ i ] , matrix [ k ] = matrix [ k ] , matrix [ i ] NEW_LINE DEDENT DEDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT buf = matrix [ j ] [ i ] / matrix [ i ] [ i ] NEW_LINE for k in range ( N ) : NEW_LINE INDENT matrix [ j ] [ k ] = ( matrix [ j ] [ k ] - matrix [ i ] [ k ] * buf ) % 2 NEW_LINE DEDENT DEDENT DEDENT res = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT res *= matrix [ i ] [ i ] NEW_LINE DEDENT return a * res NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE m = [ input ( ) for _ in range ( n ) ] NEW_LINE m = [ [ int ( j ) for j in i ] for i in m ] NEW_LINE print ( \" Even \" if det ( m ) == 0 else \" Odd \" ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE def det ( A ) : NEW_LINE INDENT l = len ( A ) NEW_LINE if l == 1 : NEW_LINE INDENT return A [ 0 ] [ 0 ] NEW_LINE DEDENT B = [ [ A [ i ] [ j ] for i in range ( l ) ] for j in range ( l ) ] NEW_LINE for i in range ( l ) : NEW_LINE INDENT if B [ i ] [ 0 ] == 1 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return 0 NEW_LINE DEDENT for j in range ( l ) : NEW_LINE INDENT B [ i ] [ j ] , B [ 0 ] [ j ] = B [ 0 ] [ j ] , B [ i ] [ j ] NEW_LINE DEDENT for i in range ( 1 , l ) : NEW_LINE INDENT if B [ i ] [ 0 ] == 1 : NEW_LINE INDENT for j in range ( l ) : NEW_LINE INDENT B [ i ] [ j ] ^= B [ 0 ] [ j ] NEW_LINE DEDENT DEDENT DEDENT C = [ [ B [ i ] [ j ] for i in range ( 1 , l ) ] for j in range ( 1 , l ) ] NEW_LINE return det ( C ) NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE A = [ list ( map ( int , input ( ) . replace ( ' \\n ' , ' ' ) ) ) for _ in range ( n ) ] NEW_LINE print ( ' Odd ' if det ( A ) else ' Even ' ) NEW_LINE" ]
atcoder_arc097_A
[ "import java . util . * ; public class Main { public static void main ( String args [ ] ) { int rep = 1 ; if ( args . length > 0 ) { rep = Integer . parseInt ( args [ 0 ] ) ; } ( new Main ( ) ) . __solve ( rep ) ; } void __solve ( int rep ) { try ( Scanner cin = new Scanner ( System . in ) ; ) { for ( int i = 0 ; i < rep ; ++ i ) { __solve ( cin ) ; } } } void __solve ( Scanner cin ) { String s = cin . next ( ) ; int K = cin . nextInt ( ) ; int N = s . length ( ) ; String array [ ] = new String [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { array [ i ] = s . substring ( i ) ; } Arrays . sort ( array ) ; ans = null ; solve ( 0 , 0 , N , array , 0 , K ) ; System . out . println ( ans ) ; } String ans = null ; int solve ( int depth , int start , int end , String array [ ] , int total , int K ) { if ( ans != null ) { return - 1 ; } if ( array [ start ] . length ( ) == depth ) { ++ start ; } while ( start < end ) { char c = array [ start ] . charAt ( depth ) ; int next = start + 1 ; for ( ; next < end ; ++ next ) { if ( array [ next ] . charAt ( depth ) != c ) { break ; } } ++ total ; if ( total == K ) { ans = array [ start ] . substring ( 0 , depth + 1 ) ; return - 1 ; } total = solve ( depth + 1 , start , next , array , total , K ) ; start = next ; } return total ; } }", "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 . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . TreeSet ; 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 ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . nextString ( ) ; int k = in . nextInt ( ) ; TreeSet < String > treeSet = new TreeSet < > ( ) ; for ( int i = 1 ; i <= k ; i ++ ) { for ( int j = 0 ; j + i <= s . length ( ) ; j ++ ) { treeSet . add ( s . substring ( j , j + i ) ) ; } } for ( int i = 0 ; i < k - 1 ; i ++ ) { treeSet . pollFirst ( ) ; } out . println ( treeSet . first ( ) ) ; } } static class InputReader { BufferedReader in ; StringTokenizer tok ; public String nextString ( ) { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) , \" ▁ \" ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return tok . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( \" \" ) ; } } }", "import java . util . ArrayList ; import java . util . Scanner ; import java . util . TreeSet ; import java . util . stream . IntStream ; public class Main { public static String process ( TestCase testCase ) { final String s = testCase . s ; final int K = testCase . K ; TreeSet < String > set = new TreeSet < > ( ) ; final int length = s . length ( ) ; IntStream . range ( 0 , K + 1 ) . forEach ( i -> IntStream . range ( 0 , length - i ) . forEach ( j -> set . add ( s . substring ( j , j + i + 1 ) ) ) ) ; return new ArrayList < > ( set ) . get ( K - 1 ) ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final String result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int K = sc . nextInt ( ) ; return new TestCase ( s , K ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final String s ; final int K ; public TestCase ( String s , int K ) { this . s = s ; this . K = K ; } } }", "import java . util . * ; public class Main { static int n , k ; static int [ ] a ; static int modP = 1000000007 ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; k = in . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; Queue < String > pq = new PriorityQueue < > ( ) ; int len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { int lim = i + k + 1 < len + 1 ? i + k + 1 : len + 1 ; for ( int j = i + 1 ; j < lim ; j ++ ) { String sub = s . substring ( i , j ) ; if ( ! set . contains ( sub ) ) { pq . add ( sub ) ; set . add ( sub ) ; } } } for ( int i = 0 ; i < k - 1 ; i ++ ) { pq . poll ( ) ; } print ( pq . peek ( ) ) ; } static void print ( String s ) { System . out . println ( s ) ; } static void print ( int i ) { System . out . println ( i ) ; } } class P { int x , y ; P ( int x , int y ) { this . x = x ; this . y = y ; } } class E { int l , r , d ; E ( int l , int r , int d ) { this . l = l ; this . r = r ; this . d = d ; } }", "import java . util . ArrayList ; import java . util . * ; class Main { public static void main ( String [ ] args ) { ArrayList < String > array = new ArrayList < String > ( ) ; ArrayList < String > arraySub ; Scanner scan = new Scanner ( System . in ) ; String substring = scan . nextLine ( ) ; int outNum = scan . nextInt ( ) ; for ( int i = 0 ; i < substring . length ( ) ; i ++ ) { String subText = substring . substring ( i ) ; for ( int j = 0 ; j < subText . length ( ) && j < outNum ; j ++ ) { array . add ( subText . substring ( 0 , j + 1 ) ) ; } } arraySub = new ArrayList < String > ( new HashSet < > ( array ) ) ; Collections . sort ( arraySub ) ; System . out . println ( arraySub . get ( outNum - 1 ) ) ; } }" ]
[ "s = input ( ) NEW_LINE k = int ( input ( ) ) NEW_LINE keys = [ ] NEW_LINE for start in range ( len ( s ) ) : NEW_LINE INDENT for end in range ( start + 1 , min ( start + 6 , len ( s ) + 1 ) ) : NEW_LINE INDENT key = s [ start : end ] NEW_LINE if key in keys : NEW_LINE INDENT continue NEW_LINE DEDENT if len ( keys ) < 5 : NEW_LINE INDENT keys . append ( key ) NEW_LINE keys . sort ( ) NEW_LINE DEDENT elif keys [ - 1 ] > key : NEW_LINE INDENT keys . append ( key ) NEW_LINE keys . sort ( ) NEW_LINE keys = keys [ : - 1 ] NEW_LINE DEDENT DEDENT DEDENT print ( keys [ k - 1 ] ) NEW_LINE", "from collections import Counter NEW_LINE from functools import reduce NEW_LINE import fractions NEW_LINE import math NEW_LINE import statistics NEW_LINE import sys NEW_LINE import time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def IS ( ) : return input ( ) NEW_LINE def P ( x ) : return print ( x ) NEW_LINE def C ( x ) : return Counter ( x ) NEW_LINE def GCD_LIST ( numbers ) : NEW_LINE INDENT return reduce ( fractions . gcd , numbers ) NEW_LINE DEDENT def LCM_LIST ( numbers ) : NEW_LINE INDENT return reduce ( LCM , numbers ) NEW_LINE DEDENT def LCM ( m , n ) : NEW_LINE INDENT return ( m * n // fractions . gcd ( m , n ) ) NEW_LINE DEDENT s = IS ( ) NEW_LINE K = II ( ) NEW_LINE substring = [ ] NEW_LINE for i in range ( 1 , K + 1 ) : NEW_LINE INDENT for j in range ( len ( s ) - i + 1 ) : NEW_LINE INDENT substring . append ( s [ j : j + i ] ) NEW_LINE DEDENT DEDENT print ( sorted ( set ( substring ) ) [ K - 1 ] ) NEW_LINE", "s = list ( input ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE n = len ( s ) NEW_LINE s1 = list ( set ( s . copy ( ) ) ) NEW_LINE s1 . sort ( ) NEW_LINE for i in range ( 5 ) : NEW_LINE INDENT s . append ( ' ' ) NEW_LINE DEDENT if ( len ( s1 ) >= 3 ) : n1 = 3 NEW_LINE else : n1 = len ( s1 ) NEW_LINE first = [ ] NEW_LINE for i in range ( n1 ) : NEW_LINE INDENT first . append ( s1 [ i ] ) NEW_LINE DEDENT s2 = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in first : NEW_LINE INDENT if ( s [ i ] == j ) : NEW_LINE INDENT s2 . append ( s [ i ] ) , s2 . append ( s [ i ] + s [ i + 1 ] ) , s2 . append ( s [ i ] + s [ i + 1 ] + s [ i + 2 ] ) NEW_LINE s2 . append ( s [ i ] + s [ i + 1 ] + s [ i + 2 ] + s [ i + 3 ] ) , s2 . append ( s [ i ] + s [ i + 1 ] + s [ i + 2 ] + s [ i + 3 ] + s [ i + 4 ] ) NEW_LINE DEDENT DEDENT DEDENT s2 = list ( set ( s2 ) ) NEW_LINE s2 . sort ( ) NEW_LINE ans = s2 [ K - 1 ] NEW_LINE print ( ans ) NEW_LINE", "s = input ( ) ; print ( sorted ( { s [ I // 6 : I // 6 + I % 6 ] for I in range ( 30000 ) } ) [ int ( input ( ) ) ] ) NEW_LINE", "import sys NEW_LINE s = input ( ) NEW_LINE K = int ( input ( ) ) NEW_LINE chars = sorted ( set ( s ) ) NEW_LINE n = len ( s ) NEW_LINE for j in range ( min ( 3 , len ( chars ) ) ) : NEW_LINE INDENT ans = chars [ j ] NEW_LINE K -= 1 NEW_LINE if K == 0 : NEW_LINE INDENT print ( ans ) NEW_LINE break NEW_LINE DEDENT while True : NEW_LINE INDENT places = [ ] NEW_LINE index = - 1 NEW_LINE while True : NEW_LINE INDENT index = s . find ( ans , index + 1 ) NEW_LINE if index == - 1 : NEW_LINE INDENT break NEW_LINE DEDENT places . append ( index ) NEW_LINE DEDENT if len ( ans ) == len ( s ) - places [ 0 ] : NEW_LINE INDENT break NEW_LINE DEDENT next_char = ' z ' * 6 NEW_LINE for k in places : NEW_LINE INDENT if k >= len ( s ) - len ( ans ) : NEW_LINE INDENT break NEW_LINE DEDENT next_char = min ( next_char , s [ k + len ( ans ) ] ) NEW_LINE DEDENT ans += next_char NEW_LINE K -= 1 NEW_LINE if K == 0 : NEW_LINE INDENT print ( ans ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT DEDENT" ]
atcoder_abc002_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; boolean [ ] [ ] rlist = new boolean [ N ] [ N ] ; for ( int i = 0 ; i < M ; i ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; rlist [ x ] [ y ] = true ; rlist [ y ] [ x ] = true ; } int r = 1 ; double n = Math . pow ( 2 , N ) ; for ( int i = 1 ; i < n ; i ++ ) { ArrayList < Integer > alist = new ArrayList < Integer > ( ) ; boolean valid = true ; for ( int j = 0 ; j < N ; j ++ ) { if ( ( 1 & i >> j ) == 1 ) { alist . add ( j ) ; } } for ( int j = 0 ; j < alist . size ( ) ; j ++ ) { for ( int k = j + 1 ; k < alist . size ( ) ; k ++ ) { if ( ! rlist [ alist . get ( j ) ] [ alist . get ( k ) ] ) { valid = false ; break ; } } if ( ! valid ) { break ; } } if ( valid ) { r = Math . max ( r , alist . size ( ) ) ; } } System . out . println ( r ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { int n , m ; boolean [ ] [ ] g ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; g = new boolean [ n ] [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) - 1 , b = sc . nextInt ( ) - 1 ; g [ a ] [ b ] = true ; g [ b ] [ a ] = true ; } int ans = 1 ; for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { if ( check ( i ) ) { ans = Math . max ( ans , Integer . bitCount ( i ) ) ; } } System . out . println ( ans ) ; } boolean check ( int S ) { for ( int t = 0 ; t < n ; t ++ ) for ( int s = t + 1 ; s < n ; s ++ ) { if ( ( ( S >> t ) & 1 ) == 1 && ( ( S >> s ) & 1 ) == 1 ) { if ( ! g [ t ] [ s ] ) { return false ; } } } return true ; } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . io . InputStream ; import java . io . PrintStream ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; int n , m ; Integer [ ] [ ] siri ; private boolean canJoin ( List < Integer > habatu , Integer c ) { if ( habatu . contains ( c ) ) { return false ; } for ( int x : habatu ) { if ( siri [ c ] [ x ] == 0 ) { return false ; } } return true ; } private int solve ( List < Integer > habatu , Integer c ) { if ( canJoin ( habatu , c ) ) { int max = 0 ; List < Integer > newHabatu = new ArrayList < > ( habatu ) ; newHabatu . add ( c ) ; for ( int i = c ; i <= n ; i ++ ) { max = Math . max ( max , solve ( newHabatu , i ) ) ; } return max ; } else { return habatu . size ( ) ; } } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; siri = new Integer [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { Arrays . fill ( siri [ i ] , 0 ) ; } for ( int i = 0 ; i < m ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; siri [ x ] [ y ] = 1 ; siri [ y ] [ x ] = 1 ; } int max = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { max = Math . max ( max , solve ( new ArrayList < > ( ) , i ) ) ; } out . println ( max ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }", "import java . util . ArrayList ; import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int memberCnt = sc . nextInt ( ) ; int relatedCnt = sc . nextInt ( ) ; HashMap < Integer , ArrayList < Integer > > relations = new HashMap < Integer , ArrayList < Integer > > ( ) ; for ( int i = 0 ; i < relatedCnt ; i ++ ) { int oneSelf = sc . nextInt ( ) ; int pair = sc . nextInt ( ) ; ArrayList < Integer > friends = new ArrayList < Integer > ( ) ; if ( relations . containsKey ( oneSelf ) ) { friends = relations . get ( oneSelf ) ; } friends . add ( pair ) ; relations . put ( oneSelf , friends ) ; } int max = 1 ; for ( int n = 1 ; n <= memberCnt ; n ++ ) { if ( relations . containsKey ( n ) ) { max = Math . max ( max , 1 + getMaxRelations ( relations , relations . get ( n ) ) ) ; } } System . out . println ( max ) ; sc . close ( ) ; } public static int getMaxRelations ( HashMap < Integer , ArrayList < Integer > > relations , ArrayList < Integer > friends ) { int max = 1 ; for ( int data : friends ) { if ( relations . containsKey ( data ) ) { ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int temp : relations . get ( data ) ) { if ( friends . contains ( temp ) ) { list . add ( temp ) ; } } if ( list . size ( ) != 0 ) { max = Math . max ( max , 1 + getMaxRelations ( relations , list ) ) ; } } } return max ; } }", "import java . util . Scanner ; public class Main { private static int n ; private static boolean [ ] [ ] a ; private static int solve ( int include , int i ) { if ( i == n ) { int res = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( include % 2 == 1 ) res ++ ; include /= 2 ; } return res ; } boolean flag = true ; int tmp = include ; for ( int j = 0 ; j < i ; j ++ ) { if ( tmp % 2 == 1 && ! a [ j ] [ i ] ) { flag = false ; break ; } tmp /= 2 ; } if ( flag ) { return Math . max ( solve ( include + ( int ) Math . pow ( 2 , i ) , i + 1 ) , solve ( include , i + 1 ) ) ; } else { return solve ( include , i + 1 ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; a = new boolean [ n ] [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; a [ x ] [ y ] = true ; } System . out . println ( solve ( 0 , 0 ) ) ; sc . close ( ) ; } }" ]
[ "import itertools NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE relations = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( m ) ] NEW_LINE for i in range ( n , 0 , - 1 ) : NEW_LINE INDENT for j in itertools . combinations ( range ( 1 , n + 1 ) , i ) : NEW_LINE INDENT if all ( ( x , y ) in relations for x , y in itertools . combinations ( j , 2 ) ) : NEW_LINE INDENT print ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT break NEW_LINE DEDENT", "from sys import stdin NEW_LINE input = stdin . readline NEW_LINE N , M = [ int ( x ) for x in input ( ) . rstrip ( ) . split ( ) ] NEW_LINE xy = [ tuple ( [ int ( x ) for x in input ( ) . rstrip ( ) . split ( ) ] ) for _ in range ( M ) ] NEW_LINE xy = set ( xy ) NEW_LINE def is_connected ( node0 , node1 ) : NEW_LINE INDENT edge = ( node0 , node1 ) if node0 < node1 else ( node1 , node0 ) NEW_LINE return edge in xy NEW_LINE DEDENT def find_kyokudai ( target ) : NEW_LINE INDENT ok = [ ] NEW_LINE not_searched = [ x for x in range ( 1 , N + 1 ) if x != target ] NEW_LINE flag = 0 NEW_LINE ok . append ( target ) NEW_LINE while not flag : NEW_LINE INDENT for x in not_searched : NEW_LINE INDENT for y in ok : NEW_LINE INDENT if is_connected ( y , x ) : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ok . append ( x ) NEW_LINE not_searched . remove ( x ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT DEDENT return len ( ok ) NEW_LINE DEDENT ans = [ ] NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT ans . append ( find_kyokudai ( i ) ) NEW_LINE DEDENT print ( max ( ans ) ) NEW_LINE", "import numpy as np NEW_LINE N , M = map ( int , input ( ) . rstrip ( ) . split ( ) ) NEW_LINE relationships = [ [ False for j in range ( N + 1 ) ] for i in range ( N + 1 ) ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . rstrip ( ) . split ( ) ) NEW_LINE relationships [ a ] [ b ] = True NEW_LINE relationships [ b ] [ a ] = True NEW_LINE DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT relationships [ i ] [ i ] = True NEW_LINE DEDENT def list_and ( lst1 , lst2 ) : NEW_LINE INDENT array = np . logical_and ( np . array ( lst1 ) , np . array ( lst2 ) ) NEW_LINE return array . tolist ( ) NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( 2 ** N ) : NEW_LINE INDENT members = list ( str ( bin ( i ) ) . lstrip ( '0b ' ) . zfill ( N + 1 ) ) NEW_LINE habatsu = list ( map ( int , members ) ) NEW_LINE for n in range ( 1 , len ( members ) ) : NEW_LINE INDENT if members [ n ] == '1' : NEW_LINE INDENT habatsu = list_and ( habatsu , relationships [ n ] ) NEW_LINE DEDENT DEDENT total = sum ( habatsu ) NEW_LINE if ans < total : NEW_LINE INDENT ans = total NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "print ( ( lambda c , d , N , M : ( lambda a : max ( len ( d [ ' J ' ] ) for i in range ( 1 << N ) if d . update ( J = [ j + 1 for j in range ( N ) if i >> j & 1 ] ) or all ( i in a for i in c ( d [ ' J ' ] , 2 ) ) ) ) ( [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * M ] ) ) ( __import__ ( ' itertools ' ) . combinations , { } , * map ( int , input ( ) . split ( ) ) ) ) NEW_LINE", "def habatu ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE gin = [ [ 0 for i in range ( n ) ] for i in range ( n ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE gin [ x - 1 ] [ y - 1 ] = 1 NEW_LINE gin [ y - 1 ] [ x - 1 ] = 1 NEW_LINE DEDENT gg = [ [ i ] for i in range ( n ) ] NEW_LINE for i in gg : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT for x in i : NEW_LINE INDENT d = True NEW_LINE if gin [ x ] [ j ] == 0 : NEW_LINE INDENT d = False NEW_LINE break NEW_LINE DEDENT DEDENT if d : NEW_LINE INDENT i += [ j ] NEW_LINE DEDENT DEDENT gg [ i [ 0 ] ] = i NEW_LINE DEDENT gg = list ( map ( lambda x : len ( x ) , gg ) ) NEW_LINE return max ( gg ) NEW_LINE DEDENT print ( habatu ( ) ) NEW_LINE" ]
atcoder_arc063_A
[ "import java . util . Scanner ; public class Main { static String ban [ ] ; static int ban2 [ ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ban = sc . next ( ) . split ( \" \" ) ; ban2 = new int [ ban . length ] ; int sum = 0 ; boolean flag = true ; int left = 1 ; int right = ban . length - 2 ; while ( flag ) { String colorL = handan ( 0 ) ; String colorR = handan ( ban . length - 1 ) ; for ( int i = left ; left < ban . length ; left ++ ) { if ( ! colorL . equals ( handan ( left ) ) ) { break ; } } for ( int i = right ; right >= 0 ; right -- ) { if ( ! colorR . equals ( handan ( right ) ) ) { break ; } } int R = ban . length - 1 - right ; int L = left ; if ( L > ban . length - 1 ) { flag = false ; break ; } else if ( L < R ) { sum ++ ; for ( int j = 0 ; j < left ; j ++ ) { ban2 [ j ] ++ ; } } else { sum ++ ; for ( int j = right ; j >= 0 ; j -- ) { ban2 [ j ] ++ ; } } } System . out . println ( sum ) ; } static String handan ( int a ) { if ( ban2 [ a ] % 2 == 0 ) { return ban [ a ] ; } else { if ( ban [ a ] . equals ( \" B \" ) ) { return \" W \" ; } else { return \" B \" ; } } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int total = 0 ; char c = line . charAt ( 0 ) ; for ( int i = 1 ; i < line . length ( ) ; i ++ ) { if ( c != line . charAt ( i ) ) { c = line . charAt ( i ) ; total ++ ; } } System . out . println ( total ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String string = input . nextLine ( ) ; char first = ' ▁ ' ; int counter = 0 ; for ( char b : string . toCharArray ( ) ) { if ( first == ' ▁ ' ) { first = b ; } else { if ( b == first ) { } else { first = b ; counter ++ ; } } } System . out . println ( counter ) ; } }", "import java . util . * ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String __ [ ] ) { solve ( s . next ( ) ) ; } private static final void solve ( String s ) { int count = 0 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) if ( s . charAt ( i ) != s . charAt ( i - 1 ) ) count ++ ; System . out . println ( count ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { char [ ] s = sc . next ( ) . toCharArray ( ) ; char preC = s [ 0 ] ; int count = 0 ; for ( char c : s ) { if ( c != preC ) { count ++ ; } preC = c ; } System . out . println ( count ) ; } }" ]
[ "S = input ( ) NEW_LINE count = 0 NEW_LINE stn = S [ 0 ] NEW_LINE i = 1 NEW_LINE while i < len ( S ) : NEW_LINE INDENT while i < len ( S ) and stn == S [ i ] : i += 1 NEW_LINE if i < len ( S ) : NEW_LINE INDENT count += 1 NEW_LINE stn = S [ i ] NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE", "s = input ( ) NEW_LINE ans = 0 NEW_LINE pre = s [ 0 ] NEW_LINE for i in range ( 1 , len ( s ) ) : NEW_LINE INDENT if ( pre == s [ i ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT ans += 1 NEW_LINE pre = s [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "S = [ i for i in input ( ) ] NEW_LINE ans = 0 NEW_LINE for i in range ( len ( S ) - 1 ) : NEW_LINE INDENT if S [ i ] == \" W \" and S [ i + 1 ] == \" B \" : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT elif S [ i ] == \" B \" and S [ i + 1 ] == \" W \" : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "s = input ( ) NEW_LINE print ( s . count ( \" BW \" ) + s . count ( \" WB \" ) ) NEW_LINE", "S = input ( ) NEW_LINE Slen = len ( S ) NEW_LINE cnt = 0 NEW_LINE index = 0 NEW_LINE if S [ 0 ] == \" B \" : NEW_LINE INDENT while index <= Slen - 2 : NEW_LINE INDENT if S [ index ] == \" B \" and S [ index + 1 ] == \" W \" : NEW_LINE INDENT cnt += 1 NEW_LINE index += 2 NEW_LINE DEDENT else : NEW_LINE INDENT index += 1 NEW_LINE DEDENT DEDENT if S [ - 1 ] == \" W \" : NEW_LINE INDENT print ( str ( cnt * 2 - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( str ( cnt * 2 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT while index <= Slen - 2 : NEW_LINE INDENT if S [ index ] == \" W \" and S [ index + 1 ] == \" B \" : NEW_LINE INDENT cnt += 1 NEW_LINE index += 2 NEW_LINE DEDENT else : NEW_LINE INDENT index += 1 NEW_LINE DEDENT DEDENT if S [ - 1 ] == \" B \" : NEW_LINE INDENT print ( str ( cnt * 2 - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( str ( cnt * 2 ) ) NEW_LINE DEDENT DEDENT" ]
atcoder_arc013_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int p = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int ans = 0 ; int n1 = ( n / p ) * ( m / q ) * ( l / r ) ; int n2 = ( n / p ) * ( m / r ) * ( l / q ) ; int n3 = ( n / q ) * ( m / p ) * ( l / r ) ; int n4 = ( n / q ) * ( m / r ) * ( l / p ) ; int n5 = ( n / r ) * ( m / p ) * ( l / q ) ; int n6 = ( n / r ) * ( m / q ) * ( l / p ) ; ans = Math . max ( ans , n1 ) ; ans = Math . max ( ans , n2 ) ; ans = Math . max ( ans , n3 ) ; ans = Math . max ( ans , n4 ) ; ans = Math . max ( ans , n5 ) ; ans = Math . max ( ans , n6 ) ; System . out . println ( ans ) ; } }", "import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int [ ] box = new int [ 3 ] ; int [ ] parcel = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { box [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 3 ; i ++ ) { parcel [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { ans = max ( ans , ( box [ 0 ] / parcel [ i ] ) * ( box [ 1 ] / parcel [ ( i + 1 ) % 3 ] ) * ( box [ 2 ] / parcel [ ( i + 2 ) % 3 ] ) ) ; } int t = box [ 0 ] ; box [ 0 ] = box [ 1 ] ; box [ 1 ] = t ; for ( int i = 0 ; i < 3 ; i ++ ) { ans = max ( ans , ( box [ 0 ] / parcel [ i ] ) * ( box [ 1 ] / parcel [ ( i + 1 ) % 3 ] ) * ( box [ 2 ] / parcel [ ( i + 2 ) % 3 ] ) ) ; } out . println ( ans ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static IntStream REPS ( int v ) { return IntStream . range ( 0 , v ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INS ( int n ) { return REPS ( n ) . map ( i -> getInt ( ) ) ; } static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static int n = getInt ( ) , m = getInt ( ) , l = getInt ( ) ; public static void main ( String [ ] $ ) { int p = getInt ( ) , q = getInt ( ) , r = getInt ( ) ; System . out . println ( Arrays . stream ( new int [ ] { hoge ( p , q , r ) , hoge ( p , r , q ) , hoge ( q , p , r ) , hoge ( q , r , p ) , hoge ( r , p , q ) , hoge ( r , q , p ) } ) . max ( ) . getAsInt ( ) ) ; } static int hoge ( int p , int q , int r ) { return ( n / p ) * ( m / q ) * ( l / r ) ; } }", "import java . util . Scanner ; import java . util . function . BiFunction ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } @ SafeVarargs static < T > T ofAll ( BiFunction < T , T , T > funk , T ... a ) { T t = a [ 0 ] ; for ( int i = 1 ; i < a . length ; i ++ ) t = funk . apply ( t , a [ i ] ) ; return t ; } static int n = getInt ( ) , m = getInt ( ) , l = getInt ( ) , p = getInt ( ) , q = getInt ( ) , r = getInt ( ) ; public static void main ( String [ ] $ ) { System . out . println ( ofAll ( Integer :: max , solve ( p , q , r ) , solve ( p , r , q ) , solve ( q , p , r ) , solve ( q , r , p ) , solve ( r , p , q ) , solve ( r , q , p ) ) ) ; } static int solve ( int x , int y , int z ) { return ( n / x ) * ( m / y ) * ( l / z ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , m = in . nextInt ( ) , l = in . nextInt ( ) , p = in . nextInt ( ) , q = in . nextInt ( ) , r = in . nextInt ( ) , max = 0 ; max = Math . max ( max , ( n / p ) * ( m / q ) * ( l / r ) ) ; max = Math . max ( max , ( n / p ) * ( m / r ) * ( l / q ) ) ; max = Math . max ( max , ( n / q ) * ( m / p ) * ( l / r ) ) ; max = Math . max ( max , ( n / q ) * ( m / r ) * ( l / p ) ) ; max = Math . max ( max , ( n / r ) * ( m / p ) * ( l / q ) ) ; max = Math . max ( max , ( n / r ) * ( m / q ) * ( l / p ) ) ; System . out . println ( max ) ; } }" ]
[ "N , M , L = map ( int , input ( ) . split ( ) ) NEW_LINE P , Q , R = map ( int , input ( ) . split ( ) ) NEW_LINE pqr = ( N // P ) * ( M // Q ) * ( L // R ) NEW_LINE prq = ( N // P ) * ( M // R ) * ( L // Q ) NEW_LINE qpr = ( N // Q ) * ( M // P ) * ( L // R ) NEW_LINE qrp = ( N // Q ) * ( M // R ) * ( L // P ) NEW_LINE rpq = ( N // R ) * ( M // P ) * ( L // Q ) NEW_LINE rqp = ( N // R ) * ( M // Q ) * ( L // P ) NEW_LINE print ( max ( pqr , prq , qpr , qrp , rpq , rqp ) ) NEW_LINE", "def main ( ) : NEW_LINE INDENT x1 , y1 , z1 = map ( int , input ( ) . split ( ) ) NEW_LINE x2 , y2 , z2 = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( x1 , y1 , z1 , x2 , y2 , z2 ) ) NEW_LINE DEDENT def solve ( x1 , y1 , z1 , x2 , y2 , z2 ) : NEW_LINE INDENT r = 0 NEW_LINE r = max ( r , ( x1 // x2 ) * ( y1 // y2 ) * ( z1 // z2 ) ) NEW_LINE r = max ( r , ( x1 // x2 ) * ( y1 // z2 ) * ( z1 // y2 ) ) NEW_LINE r = max ( r , ( x1 // y2 ) * ( y1 // x2 ) * ( z1 // z2 ) ) NEW_LINE r = max ( r , ( x1 // y2 ) * ( y1 // z2 ) * ( z1 // x2 ) ) NEW_LINE r = max ( r , ( x1 // z2 ) * ( y1 // x2 ) * ( z1 // y2 ) ) NEW_LINE r = max ( r , ( x1 // z2 ) * ( y1 // y2 ) * ( z1 // x2 ) ) NEW_LINE return r NEW_LINE DEDENT main ( ) NEW_LINE", "from functools import reduce NEW_LINE from itertools import permutations NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE def di ( A , B ) : NEW_LINE INDENT return [ a // b for a , b in zip ( A , B ) ] NEW_LINE DEDENT def mul ( a , b ) : NEW_LINE INDENT return a * b NEW_LINE DEDENT def mu ( A ) : NEW_LINE INDENT return reduce ( mul , A ) NEW_LINE DEDENT A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE B = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE pe = permutations ( B ) NEW_LINE for a in pe : NEW_LINE INDENT ans = max ( ans , mu ( di ( A , a ) ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "a = input ( ) . split ( ) ; b = input ( ) . split ( ) ; a1 , a2 , a3 , b1 , b2 , b3 = int ( a [ 0 ] ) , int ( a [ 1 ] ) , int ( a [ 2 ] ) , int ( b [ 0 ] ) , int ( b [ 1 ] ) , int ( b [ 2 ] ) NEW_LINE print ( max ( ( a1 // b1 ) * ( a2 // b2 ) * ( a3 // b3 ) , ( a1 // b1 ) * ( a3 // b2 ) * ( a2 // b3 ) , ( a2 // b1 ) * ( a1 // b2 ) * ( a3 // b3 ) , ( a2 // b1 ) * ( a3 // b2 ) * ( a1 // b3 ) , ( a3 // b1 ) * ( a1 // b2 ) * ( a2 // b3 ) , ( a3 // b1 ) * ( a2 // b2 ) * ( a1 // b3 ) ) ) NEW_LINE", "from itertools import * NEW_LINE f , g , h , * a , = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE ans = 1 NEW_LINE l = [ ] NEW_LINE for s , t , r in ( permutations ( a ) ) : NEW_LINE INDENT ans *= ( f // s ) * ( g // t ) * ( h // r ) NEW_LINE l . append ( ans ) NEW_LINE ans = 1 NEW_LINE DEDENT print ( max ( l ) ) NEW_LINE" ]
atcoder_abc066_B
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String S = in . next ( ) ; for ( int i = S . length ( ) - 2 ; i >= 0 ; i -= 2 ) { if ( S . substring ( 0 , i / 2 ) . equals ( ( S . substring ( i / 2 , i ) ) ) ) { out . println ( i ) ; break ; } } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { StringBuilder sb = new StringBuilder ( sc . next ( ) ) ; while ( true ) { sb . delete ( sb . length ( ) - 1 , sb . length ( ) ) ; if ( isGumozi ( sb . toString ( ) ) ) { System . out . println ( sb . length ( ) ) ; return ; } } } static boolean isGumozi ( String s ) { if ( s . length ( ) % 2 != 0 ) return false ; if ( s . substring ( 0 , s . length ( ) / 2 ) . equals ( s . substring ( s . length ( ) / 2 , s . length ( ) ) ) ) { return true ; } return false ; } }", "import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; Scanner sc = new Scanner ( System . in ) ; main . solve ( sc ) ; sc . close ( ) ; } void solve ( Scanner sc ) { String S = sc . next ( ) ; String ms = \" \" ; int len = S . length ( ) ; int ans = 0 ; if ( len % 2 == 0 ) { ms = S . substring ( 0 , len - 2 ) ; } else { ms = S . substring ( 0 , len - 1 ) ; } if ( ms . length ( ) == 2 ) { System . out . println ( \"2\" ) ; return ; } for ( int i = ms . length ( ) ; i > 1 ; i -= 2 ) { if ( ms . substring ( 0 , i / 2 ) . equals ( ms . substring ( i / 2 , i ) ) ) { ans = i ; break ; } } System . out . println ( ans ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; for ( int i = s . length ( ) / 2 - 1 ; i > 0 ; i -- ) { if ( s . substring ( 0 , i ) . equals ( s . substring ( i , i * 2 ) ) ) { out . println ( i * 2 ) ; return ; } } } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; int largest = 0 ; for ( int i = word . length ( ) - 1 ; i > 1 ; i -- ) { if ( i % 2 == 0 ) { int midle = i / 2 ; boolean state = true ; for ( int j = 0 ; j < i / 2 ; j ++ , midle ++ ) { if ( word . charAt ( j ) != word . charAt ( midle ) ) { state = false ; break ; } } if ( state ) largest = Math . max ( largest , i ) ; } } System . out . println ( largest ) ; } }" ]
[ "S = list ( input ( ) ) NEW_LINE l = len ( S ) NEW_LINE for i in range ( 1 , l // 2 ) : NEW_LINE INDENT if all ( [ S [ j ] == S [ j + i ] for j in range ( i ) ] ) : NEW_LINE INDENT ans = 2 * i NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "s = input ( ) NEW_LINE if len ( s ) % 2 == 1 : NEW_LINE INDENT s = s [ : len ( s ) - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT s = s [ : len ( s ) - 2 ] NEW_LINE DEDENT x = int ( len ( s ) / 2 ) NEW_LINE if s [ : x ] == s [ x : ] : NEW_LINE INDENT print ( 2 * x ) NEW_LINE DEDENT else : NEW_LINE INDENT while s [ : x ] != s [ x : ] : NEW_LINE INDENT s = s [ : len ( s ) - 2 ] NEW_LINE x -= 1 NEW_LINE DEDENT print ( 2 * x ) NEW_LINE DEDENT", "import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE s = ns ( ) NEW_LINE n = len ( s ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT s = s [ : - 1 ] NEW_LINE if len ( s ) % 2 == 0 : NEW_LINE INDENT m = len ( s ) // 2 NEW_LINE count = 0 NEW_LINE for j in range ( m ) : NEW_LINE INDENT if s [ j ] == s [ j + m ] : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if count == m : NEW_LINE INDENT print ( 2 * m ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT", "S = list ( input ( ) ) NEW_LINE while ( True ) : NEW_LINE INDENT del S [ - 2 : ] NEW_LINE bunkatsu = int ( len ( S ) / 2 ) NEW_LINE if ( S [ : bunkatsu ] == S [ bunkatsu : ] ) : NEW_LINE INDENT print ( len ( S ) ) NEW_LINE break NEW_LINE DEDENT DEDENT", "s = input ( ) NEW_LINE found = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if i % 2 == 0 and i >= 2 : NEW_LINE INDENT t = s [ : i // 2 ] NEW_LINE t2 = s [ i // 2 : i ] NEW_LINE if t == t2 : NEW_LINE INDENT found = i NEW_LINE DEDENT DEDENT DEDENT print ( found ) NEW_LINE" ]
atcoder_agc021_B
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] x = new int [ n ] ; int [ ] y = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { double [ ] angle = new double [ n ] ; int p = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( j != i ) { angle [ p ++ ] = Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ; } } Arrays . sort ( angle , 0 , p ) ; angle [ p ++ ] = angle [ 0 ] + 2 * Math . PI ; double max = 0 ; for ( int j = 0 ; j + 1 < angle . length ; j ++ ) { max = Math . max ( max , angle [ j + 1 ] - angle [ j ] ) ; } max = Math . max ( max - Math . PI , 0.0 ) ; System . out . printf ( \" % .15f \\n \" , max / ( 2 * Math . PI ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] x = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] [ 0 ] = sc . nextInt ( ) ; x [ i ] [ 1 ] = sc . nextInt ( ) ; } sc . close ( ) ; if ( n == 2 ) { System . out . println ( 0.5 ) ; System . out . println ( 0.5 ) ; return ; } long [ ] num = new long [ n ] ; final int N = 3500000 ; double r = Math . pow ( 10 , 11 ) ; for ( int i = 0 ; i < N ; i ++ ) { double theta = 2.0d * Math . PI * ( double ) i / ( double ) N ; double mx = r * Math . cos ( theta ) ; double my = r * Math . sin ( theta ) ; double min = Math . pow ( 10 , 200 ) ; int minpos = 0 ; for ( int j = 0 ; j < n ; j ++ ) { double len = Math . pow ( ( double ) ( x [ j ] [ 0 ] ) - mx , 2 ) + Math . pow ( ( double ) ( x [ j ] [ 1 ] ) - my , 2 ) ; if ( len < min ) { min = len ; minpos = j ; } } num [ minpos ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( ( double ) ( num [ i ] ) / ( double ) N ) ; } } }", "import java . io . IOException ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; double [ ] x = new double [ n ] ; double [ ] y = new double [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { x [ i ] = sc . nextDouble ( ) ; y [ i ] = sc . nextDouble ( ) ; } for ( int i = 0 ; i < n ; ++ i ) { double [ ] deg = new double [ n - 1 ] ; int cnt = 0 ; for ( int j = 0 ; j < n ; ++ j ) { if ( i == j ) continue ; deg [ cnt ++ ] = ( Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ) ; } Arrays . sort ( deg ) ; double ans = 0 ; for ( int j = 0 ; j < n - 2 ; ++ j ) { ans = Math . max ( ans , deg [ ( j + 1 ) % ( n - 1 ) ] - deg [ j ] ) ; } ans = Math . max ( ans , Math . PI * 2 + deg [ 0 ] - deg [ n - 2 ] ) ; ans = ans - Math . PI ; if ( ans <= 0 ) System . out . println ( 0 ) ; else System . out . println ( String . format ( \" % .20f \" , ans / ( 2 * Math . PI ) ) ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Main { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; double x [ ] = new double [ n ] ; double y [ ] = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = sc . nextDouble ( ) ; y [ i ] = sc . nextDouble ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { ArrayList < Double > s = new ArrayList < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( i != j ) { s . add ( Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ) ; } } Collections . sort ( s ) ; double max = 0 ; for ( int j = 0 ; j < n - 2 ; j ++ ) { max = Math . max ( s . get ( j + 1 ) - s . get ( j ) , max ) ; } max = Math . max ( max , 2 * Math . PI - ( s . get ( n - 2 ) - s . get ( 0 ) ) ) ; System . out . println ( Math . max ( ( max - Math . PI ) / 2 / Math . PI , 0 ) ) ; } } }", "import java . util . Scanner ; import java . util . Comparator ; import java . util . Arrays ; import java . util . List ; import java . util . ArrayList ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int [ ] x = new int [ N ] ; int [ ] y = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { x [ i ] = scan . nextInt ( ) ; y [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < N ; ++ i ) { List < Double > thetas = new ArrayList < > ( ) ; for ( int j = 0 ; j < N ; ++ j ) { if ( i == j ) continue ; thetas . add ( Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ) ; } thetas . sort ( Comparator . naturalOrder ( ) ) ; thetas . add ( thetas . get ( 0 ) + 2 * Math . PI ) ; double ans = 0 ; for ( int k = 0 ; k < N - 1 ; ++ k ) ans = Math . max ( ans , thetas . get ( k + 1 ) - thetas . get ( k ) - Math . PI ) ; System . out . println ( ans / ( Math . PI * 2 ) ) ; } } }" ]
[ "import math ; q = 2 * math . pi NEW_LINE from cmath import phase as h NEW_LINE t = lambda x : h ( x ) + ( q if 0 > h ( x ) else 0 ) NEW_LINE n = int ( input ( ) ) NEW_LINE r = range ( n ) NEW_LINE c = [ complex ( input ( ) . replace ( ' ▁ - ' , ' - ' ) . replace ( ' ▁ ' , ' + ' ) + \" j \" ) for _ in r ] NEW_LINE for i in r : a = sorted ( [ t ( c [ j ] - c [ i ] ) / q for j in r if j != i ] ) ; d = [ a [ j ] - a [ j - 1 ] for j in r [ : - 1 ] ] ; d [ 0 ] += 1 ; print ( max ( max ( d ) - 1 / 2 , 0 ) ) NEW_LINE", "from math import pi , atan2 NEW_LINE q = 2 * pi NEW_LINE def deg ( a , b ) : NEW_LINE INDENT d = b - a NEW_LINE t = atan2 ( d . real , d . imag ) NEW_LINE if t < 0 : t += q NEW_LINE return t NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE cs = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE cs += [ complex ( a , b ) ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT args = [ deg ( cs [ i ] , cs [ j ] ) / q for j in range ( n ) if j != i ] NEW_LINE args = sorted ( args ) NEW_LINE dif = [ args [ i ] - args [ i - 1 ] for i in range ( n - 1 ) ] NEW_LINE dif [ 0 ] += 1 NEW_LINE print ( max ( max ( dif ) - 1 / 2 , 0 ) ) NEW_LINE DEDENT", "import math NEW_LINE from collections import defaultdict NEW_LINE n = int ( input ( ) ) NEW_LINE ps = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE def dist ( rad , p ) : NEW_LINE INDENT radtmp = 2 * math . pi * rad / maxcut NEW_LINE return - p [ 0 ] * math . cos ( radtmp ) - p [ 1 ] * math . sin ( radtmp ) NEW_LINE DEDENT def closest ( rad ) : NEW_LINE INDENT tmp = dist ( rad , ps [ 0 ] ) NEW_LINE itmp = 0 NEW_LINE for i , pp in enumerate ( ps ) : NEW_LINE INDENT tmp2 = dist ( rad , pp ) NEW_LINE if tmp2 < tmp : NEW_LINE INDENT itmp = i NEW_LINE tmp = tmp2 NEW_LINE DEDENT DEDENT return itmp NEW_LINE DEDENT maxcut = 2 ** 20 NEW_LINE binary = defaultdict ( int ) NEW_LINE binary [ 0 ] = closest ( 0 ) NEW_LINE binary [ maxcut ] = binary [ 0 ] NEW_LINE binary [ maxcut // 2 ] = closest ( maxcut // 2 ) NEW_LINE binary [ maxcut // 4 ] = closest ( maxcut // 4 ) NEW_LINE binary [ 3 * maxcut // 4 ] = closest ( 3 * maxcut // 4 ) NEW_LINE def fillbinary ( ll , rr ) : NEW_LINE INDENT if binary [ ll ] != binary [ rr ] and rr - ll != 1 : NEW_LINE INDENT mm = ( ll + rr ) // 2 NEW_LINE binary [ mm ] = closest ( mm ) NEW_LINE fillbinary ( ll , mm ) NEW_LINE fillbinary ( mm , rr ) NEW_LINE DEDENT DEDENT fillbinary ( 0 , maxcut // 4 ) NEW_LINE fillbinary ( maxcut // 4 , maxcut // 2 ) NEW_LINE fillbinary ( maxcut // 2 , 3 * maxcut // 4 ) NEW_LINE fillbinary ( 3 * maxcut // 4 , maxcut ) NEW_LINE binkeys = sorted ( binary . keys ( ) ) NEW_LINE ansli = [ 0 ] * n NEW_LINE beforekey = 0 NEW_LINE for i in binkeys : NEW_LINE INDENT ansli [ binary [ i ] ] += i - beforekey NEW_LINE beforekey = i NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( ansli [ i ] / maxcut ) NEW_LINE DEDENT", "def graham_scan ( vertices : list ) : NEW_LINE INDENT from math import atan2 NEW_LINE from operator import itemgetter NEW_LINE vertices . sort ( key = itemgetter ( 1 ) ) NEW_LINE base_x , base_y = vertices [ 0 ] [ : 2 ] NEW_LINE vertices = sorted ( vertices [ 1 : ] , key = lambda p : atan2 ( p [ 1 ] - base_y , p [ 0 ] - base_x ) ) + vertices [ : 1 ] NEW_LINE convex = vertices [ - 1 : ] + vertices [ : 1 ] NEW_LINE pop , append = convex . pop , convex . append NEW_LINE last_x , last_y = convex [ - 1 ] [ : 2 ] NEW_LINE for point , ( x , y , * _ ) in zip ( vertices [ 1 : ] , vertices [ 1 : ] ) : NEW_LINE INDENT while ( ( x - last_x ) * ( convex [ - 2 ] [ 1 ] - last_y ) - ( y - last_y ) * ( convex [ - 2 ] [ 0 ] - last_x ) < 0 ) : NEW_LINE INDENT pop ( ) NEW_LINE last_x , last_y = convex [ - 1 ] [ : 2 ] NEW_LINE DEDENT append ( point ) NEW_LINE last_x , last_y = point [ : 2 ] NEW_LINE DEDENT return convex [ : - 1 ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT from math import acos , sqrt , pi NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) + [ i ] for i in range ( N ) ] NEW_LINE result = [ 0 ] * N NEW_LINE convex_hull = graham_scan ( a ) * 2 NEW_LINE for ( x2 , y2 , _ ) , ( x1 , y1 , i ) , ( x3 , y3 , _ ) in zip ( convex_hull , convex_hull [ 1 : ] , convex_hull [ 2 : ] ) : NEW_LINE INDENT vec1_x , vec1_y = x2 - x1 , y2 - y1 NEW_LINE vec2_x , vec2_y = x3 - x1 , y3 - y1 NEW_LINE result [ i ] = pi - acos ( ( vec1_x * vec2_x + vec1_y * vec2_y ) / ( sqrt ( vec1_x ** 2 + vec1_y ** 2 ) * sqrt ( vec2_x ** 2 + vec2_y ** 2 ) ) ) NEW_LINE DEDENT total = sum ( result ) NEW_LINE for rad in result : NEW_LINE INDENT print ( rad / total ) NEW_LINE DEDENT DEDENT", "from numpy import argmax NEW_LINE import numpy as np NEW_LINE from collections import defaultdict NEW_LINE def cross ( a , b ) : NEW_LINE INDENT return a [ 0 ] * b [ 1 ] - a [ 1 ] * b [ 0 ] NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE H = [ np . array ( [ int ( j ) for j in input ( ) . split ( ) ] ) for i in range ( n ) ] NEW_LINE if n == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT convex = [ min ( H , key = lambda x : x [ 1 ] ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a = H [ 0 ] if ( H [ 0 ] != convex [ - 1 ] ) . any ( ) else H [ - 1 ] NEW_LINE for b in H : NEW_LINE INDENT ac = a - convex [ - 1 ] NEW_LINE bc = b - convex [ - 1 ] NEW_LINE cross_ = cross ( ac , bc ) NEW_LINE if cross_ < 0 or ( cross_ == 0 and np . linalg . norm ( ac ) < np . linalg . norm ( bc ) ) : NEW_LINE INDENT a = b NEW_LINE DEDENT DEDENT if ( a == convex [ 0 ] ) . all ( ) : NEW_LINE INDENT break NEW_LINE DEDENT convex . append ( a ) NEW_LINE DEDENT ans = defaultdict ( float ) NEW_LINE for c , a , b in zip ( [ convex [ - 1 ] ] + convex [ : - 1 ] , convex , convex [ 1 : ] + [ convex [ 0 ] ] ) : NEW_LINE INDENT ca = c - a NEW_LINE ba = b - a NEW_LINE i = np . inner ( ca , ba ) NEW_LINE n = np . linalg . norm ( ca ) * np . linalg . norm ( ba ) NEW_LINE ans [ tuple ( a ) ] = ( np . pi - np . arccos ( np . clip ( i / n , - 1 , 1 ) ) ) / ( 2 * np . pi ) NEW_LINE DEDENT for i in H : NEW_LINE INDENT print ( ans [ tuple ( i ) ] ) NEW_LINE DEDENT" ]
atcoder_arc003_B
[ "import com . sun . org . apache . xalan . internal . xsltc . util . IntegerArray ; import java . io . * ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 <= args . length ; debug2 = 2 <= args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; reverse [ ] items = new reverse [ Integer . parseInt ( in . readLine ( ) ) ] ; for ( int i = 0 ; i < items . length ; ++ i ) { items [ i ] = new reverse ( in . readLine ( ) ) ; } Arrays . sort ( items ) ; for ( int i = 0 ; i < items . length ; ++ i ) { System . out . println ( items [ i ] ) ; } } static class reverse implements Comparable < reverse > { private String orig ; private String str ; public reverse ( String s ) { orig = s ; StringBuffer sb = new StringBuffer ( s ) ; str = sb . reverse ( ) . toString ( ) ; } @ Override public int compareTo ( reverse o ) { return str . compareTo ( o . str ) ; } @ Override public String toString ( ) { return orig ; } } } . / Main . java : 1 : warning : IntegerArray is internal proprietary API and may be removed in a future release import com . sun . org . apache . xalan . internal . xsltc . util . IntegerArray ; ^ 1 warning", "import java . util . HashMap ; import java . util . Iterator ; import java . util . Map . Entry ; import java . util . PrimitiveIterator ; import java . util . Scanner ; class Main { public static void main ( String [ ] $ ) { int n = gInt ( ) ; HashMap < String , String > m = new HashMap < > ( ) ; for ( int i : rep ( n ) ) { String in = s . next ( ) ; String sb = new StringBuilder ( in ) . reverse ( ) . toString ( ) ; m . put ( in , sb ) ; } m . entrySet ( ) . stream ( ) . sorted ( Entry . comparingByValue ( ) ) . map ( Entry :: getKey ) . forEach ( System . out :: println ) ; } static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long gLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static Range rep ( int i ) { return new Range ( i ) ; } static Range rep ( int f , int t ) { return new Range ( f , t ) ; } static class Range implements Iterable < Integer > , PrimitiveIterator . OfInt { int from , to , c ; Range ( int from , int to ) { this . from = from ; this . to = to ; this . c = from ; } Range ( int n ) { this ( 0 , n - 1 ) ; } @ Override public Iterator < Integer > iterator ( ) { return this ; } @ Override public boolean hasNext ( ) { return c <= to ; } @ Override public int nextInt ( ) { return c ++ ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; StringBuffer sb = new StringBuffer ( ) ; int N = sc . nextInt ( ) ; String [ ] dict = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String s = sc . next ( ) ; sb = new StringBuffer ( s ) ; sb . reverse ( ) ; dict [ i ] = sb . toString ( ) ; } Arrays . sort ( dict ) ; for ( int i = 0 ; i < N ; i ++ ) { sb = new StringBuffer ( dict [ i ] ) ; pl ( sb . reverse ( ) . toString ( ) ) ; } } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }", "import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Map < String , String > s_i = new HashMap < String , String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String tmp = sc . next ( ) ; s_i . put ( new StringBuffer ( tmp ) . reverse ( ) . toString ( ) , tmp ) ; } List < Entry < String , String > > entries = new ArrayList < Entry < String , String > > ( s_i . entrySet ( ) ) ; Collections . sort ( entries , new Comparator < Entry < String , String > > ( ) { @ Override public int compare ( Entry < String , String > o1 , Entry < String , String > o2 ) { return o1 . getKey ( ) . compareTo ( o2 . getKey ( ) ) ; } } ) ; for ( Entry < String , String > e : entries ) { System . out . println ( e . getValue ( ) ) ; } } }", "import java . util . * ; public class Main { private static int n ; private static ArrayList < String > arrayList = new ArrayList < > ( ) ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( scan . next ( ) ) ; sb . reverse ( ) ; arrayList . add ( sb . toString ( ) ) ; } } public static void main ( String args [ ] ) { input ( ) ; Collections . sort ( arrayList ) ; for ( int i = 0 ; i < n ; i ++ ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( arrayList . get ( i ) ) ; sb . reverse ( ) ; System . out . println ( sb . toString ( ) ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE l = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT l . append ( input ( ) [ : : - 1 ] ) NEW_LINE DEDENT l . sort ( ) NEW_LINE for i in l : NEW_LINE INDENT print ( i [ : : - 1 ] ) NEW_LINE DEDENT", "def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT n = int ( io ( ) ) NEW_LINE ll = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT ll . append ( io ( ) ) NEW_LINE DEDENT ll2 = [ l [ : : - 1 ] for l in ll ] NEW_LINE ll2 . sort ( ) NEW_LINE for l in ll2 : NEW_LINE INDENT print ( l [ : : - 1 ] ) NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE main ( io ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE for item in sorted ( [ input ( ) [ : : - 1 ] for _ in range ( N ) ] ) : NEW_LINE INDENT print ( item [ : : - 1 ] ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE def f ( x ) : NEW_LINE INDENT y = \" \" NEW_LINE for i in range ( len ( x ) - 1 , - 1 , - 1 ) : NEW_LINE INDENT y = y + x [ i ] NEW_LINE DEDENT return y NEW_LINE DEDENT s = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT d = list ( input ( ) ) NEW_LINE s . append ( f ( d ) ) NEW_LINE DEDENT s . sort ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT ass = list ( s [ i ] ) NEW_LINE print ( f ( ass ) ) NEW_LINE DEDENT", "def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ss = [ input ( ) . rstrip ( ) for _ in range ( N ) ] NEW_LINE print ( \" \\n \" . join ( sorted ( ss , key = ( lambda x : x [ : : - 1 ] ) ) ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc075_D
[ "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; Point [ ] p = new Point [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; p [ i ] = new Point ( x , y ) ; } long ans = Long . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { for ( int l = 0 ; l < n ; l ++ ) { int count = 0 ; for ( int u = 0 ; u < n ; u ++ ) { if ( p [ u ] . x <= p [ i ] . x && p [ u ] . x >= p [ j ] . x && p [ u ] . y <= p [ k ] . y && p [ u ] . y >= p [ l ] . y ) { count ++ ; } } if ( count >= t ) { ans = Math . min ( ans , ( p [ i ] . x - p [ j ] . x ) * ( p [ k ] . y - p [ l ] . y ) ) ; } } } } } System . out . println ( ans ) ; } static class Point { long x ; long y ; public Point ( long x , long y ) { this . x = x ; this . y = y ; } } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; 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 ( ) ; List < int [ ] > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int [ ] tmp = { in . nextInt ( ) , in . nextInt ( ) } ; list . add ( tmp ) ; } list . sort ( ( x1 , x2 ) -> x1 [ 0 ] - x2 [ 0 ] ) ; long ans = Long . MAX_VALUE ; for ( int i = 0 ; i < n - k + 1 ; i ++ ) { for ( int j = i + k - 1 ; j < n ; j ++ ) { int [ ] y = new int [ j - i + 1 ] ; for ( int l = 0 ; l < j - i + 1 ; l ++ ) { y [ l ] = list . get ( l + i ) [ 1 ] ; } Arrays . sort ( y ) ; int yWidthMin = y [ k - 1 ] - y [ 0 ] ; for ( int l = 1 ; l + k - 1 < j - i + 1 ; l ++ ) { yWidthMin = Math . min ( yWidthMin , y [ l + k - 1 ] - y [ l ] ) ; } int xWidth = list . get ( j ) [ 0 ] - list . get ( i ) [ 0 ] ; ans = Math . min ( ans , ( long ) xWidth * yWidthMin ) ; } } System . out . println ( ans ) ; in . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; } long ans = 2000000000 ; ans *= ans ; for ( int i = 0 ; i < N ; i ++ ) { long x1 = x [ i ] ; for ( int j = 0 ; j < N ; j ++ ) { long x2 = x [ j ] ; for ( int k = 0 ; k < N ; k ++ ) { long y1 = y [ k ] ; for ( int l = 0 ; l < N ; l ++ ) { long y2 = y [ l ] ; if ( x1 < x2 && y1 < y2 ) { int num = 0 ; for ( int m = 0 ; m < N ; m ++ ) { if ( x1 <= x [ m ] && x [ m ] <= x2 && y1 <= y [ m ] && y [ m ] <= y2 ) { num ++ ; } if ( num >= K ) { ans = Math . min ( ans , ( x2 - x1 ) * ( y2 - y1 ) ) ; } } } } } } } System . out . println ( ans ) ; } }", "import java . util . * ; class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = s . nextInt ( ) , k = s . nextInt ( ) ; int [ ] x = new int [ n ] , y = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { x [ i ] = s . nextInt ( ) ; y [ i ] = s . nextInt ( ) ; } long res = Long . MAX_VALUE ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { long l = Math . min ( x [ i ] , x [ j ] ) ; long r = Math . max ( x [ i ] , x [ j ] ) ; for ( int p = 0 ; p < n ; ++ p ) { for ( int q = p + 1 ; q < n ; ++ q ) { long t = Math . min ( y [ p ] , y [ q ] ) ; long b = Math . max ( y [ p ] , y [ q ] ) ; int c = 0 ; for ( int o = 0 ; o < n ; ++ o ) { if ( l <= x [ o ] && x [ o ] <= r && t <= y [ o ] && y [ o ] <= b ) { ++ c ; } } if ( c >= k ) res = Math . min ( res , ( r - l ) * ( b - t ) ) ; } } } } System . out . println ( res ) ; } }", "import java . util . * ; public class Main { static long [ ] arrX ; static long [ ] arrY ; static int n ; static int k ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; arrX = new long [ n ] ; arrY = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arrX [ i ] = sc . nextLong ( ) ; arrY [ i ] = sc . nextLong ( ) ; } long min = Long . MAX_VALUE ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = 0 ; k < n - 1 ; k ++ ) { for ( int l = k + 1 ; l < n ; l ++ ) { long sqr = Math . abs ( arrX [ i ] - arrX [ j ] ) * Math . abs ( arrY [ k ] - arrY [ l ] ) ; if ( sqr > min ) { continue ; } if ( isOver ( Math . min ( arrX [ i ] , arrX [ j ] ) , Math . max ( arrX [ i ] , arrX [ j ] ) , Math . min ( arrY [ k ] , arrY [ l ] ) , Math . max ( arrY [ k ] , arrY [ l ] ) ) ) { min = sqr ; } } } } } System . out . println ( min ) ; } static boolean isOver ( long x1 , long x2 , long y1 , long y2 ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arrX [ i ] >= x1 && arrX [ i ] <= x2 && arrY [ i ] >= y1 && arrY [ i ] <= y2 ) { count ++ ; } } return ( count >= k ) ; } }" ]
[ "n , k = map ( int , input ( ) . split ( ) ) NEW_LINE XY = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE XY . sort ( ) NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT x = XY [ j ] [ 0 ] - XY [ i ] [ 0 ] NEW_LINE T = sorted ( Z [ 1 ] for Z in XY [ i : j + 1 ] ) NEW_LINE for u , v in zip ( T , T [ k - 1 : ] ) : NEW_LINE INDENT ans = min ( ans , x * ( v - u ) ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "def axis_parallel_rectangle ( N : int , K : int , xy : list ) -> int : NEW_LINE INDENT sorted_x = sorted ( v [ 0 ] for v in xy ) NEW_LINE sorted_y = sorted ( v [ 1 ] for v in xy ) NEW_LINE XY = [ ( sorted_x . index ( v [ 0 ] ) , sorted_y . index ( v [ 1 ] ) ) for v in xy ] NEW_LINE S = [ [ 0 ] * ( N + 1 ) for _ in range ( N + 1 ) ] NEW_LINE for x , y in XY : NEW_LINE INDENT S [ x + 1 ] [ y + 1 ] = 1 NEW_LINE DEDENT for x in range ( N + 1 ) : NEW_LINE INDENT for y in range ( N ) : NEW_LINE INDENT S [ x ] [ y + 1 ] += S [ x ] [ y ] NEW_LINE DEDENT DEDENT for y in range ( N + 1 ) : NEW_LINE INDENT for x in range ( N ) : NEW_LINE INDENT S [ x + 1 ] [ y ] += S [ x ] [ y ] NEW_LINE DEDENT DEDENT min_area = float ( ' inf ' ) NEW_LINE for x1 in range ( N ) : NEW_LINE INDENT for x2 in range ( x1 + 1 , N ) : NEW_LINE INDENT for y1 in range ( N ) : NEW_LINE INDENT for y2 in range ( y1 + 1 , N ) : NEW_LINE INDENT count = S [ x2 + 1 ] [ y2 + 1 ] - S [ x2 + 1 ] [ y1 ] - S [ x1 ] [ y2 + 1 ] + S [ x1 ] [ y1 ] NEW_LINE if count < K : NEW_LINE INDENT continue NEW_LINE DEDENT xmin , xmax = sorted_x [ x1 ] , sorted_x [ x2 ] NEW_LINE ymin , ymax = sorted_y [ y1 ] , sorted_y [ y2 ] NEW_LINE min_area = min ( min_area , ( xmax - xmin ) * ( ymax - ymin ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return min_area NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = 0 NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE xy = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE ans = axis_parallel_rectangle ( N , K , xy ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "from itertools import combinations NEW_LINE n , k = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE xy = [ [ int ( item ) for item in input ( ) . split ( ) ] for _ in range ( n ) ] NEW_LINE xsort = sorted ( xy , key = lambda x : x [ 0 ] ) NEW_LINE ysort = sorted ( xy , key = lambda x : x [ 1 ] ) NEW_LINE l = [ i for i in range ( n ) ] NEW_LINE cum = [ [ 0 for _ in range ( n + 1 ) ] for _ in range ( n + 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT cum [ i + 1 ] [ j + 1 ] = cum [ i + 1 ] [ j ] + cum [ i ] [ j + 1 ] - cum [ i ] [ j ] + ( [ xsort [ i ] [ 0 ] , ysort [ j ] [ 1 ] ] in xy ) NEW_LINE DEDENT DEDENT def count_points_in_rec ( x0 , x1 , y0 , y1 ) : NEW_LINE INDENT point = cum [ x1 + 1 ] [ y1 + 1 ] - cum [ x0 ] [ y1 + 1 ] - cum [ x1 + 1 ] [ y0 ] + cum [ x0 ] [ y0 ] NEW_LINE return point NEW_LINE DEDENT ans = 5 * 10 ** 18 NEW_LINE comb = [ ] NEW_LINE for a , b in combinations ( l , 2 ) : NEW_LINE INDENT if b - a >= k - 1 : NEW_LINE INDENT comb . append ( [ a , b ] ) NEW_LINE DEDENT DEDENT for a , b in comb : NEW_LINE INDENT for c , d in comb : NEW_LINE INDENT if count_points_in_rec ( a , b , c , d ) == k : NEW_LINE INDENT ans = min ( ans , ( xsort [ b ] [ 0 ] - xsort [ a ] [ 0 ] ) * ( ysort [ d ] [ 1 ] - ysort [ c ] [ 1 ] ) ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "from bisect import bisect_left NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ ] ; Y = [ ] ; info = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE X . append ( x ) ; Y . append ( y ) ; info . append ( [ x , y ] ) NEW_LINE DEDENT X . sort ( ) ; Y . sort ( ) NEW_LINE acc = [ [ 0 ] * ( N + 1 ) for i in range ( N + 1 ) ] NEW_LINE for x , y in info : NEW_LINE INDENT j = bisect_left ( X , x ) NEW_LINE i = bisect_left ( Y , y ) NEW_LINE acc [ i + 1 ] [ j + 1 ] += 1 NEW_LINE DEDENT for i in range ( N + 1 ) : NEW_LINE INDENT for j in range ( 1 , N ) : NEW_LINE INDENT acc [ i ] [ j + 1 ] += acc [ i ] [ j ] NEW_LINE DEDENT DEDENT for j in range ( N + 1 ) : NEW_LINE INDENT for i in range ( 1 , N ) : NEW_LINE INDENT acc [ i + 1 ] [ j ] += acc [ i ] [ j ] NEW_LINE DEDENT DEDENT ans = float ( ' inf ' ) NEW_LINE for t in range ( N - 1 ) : NEW_LINE INDENT for b in range ( t + 1 , N ) : NEW_LINE INDENT for l in range ( N - 1 ) : NEW_LINE INDENT for r in range ( l + 1 , N ) : NEW_LINE INDENT num = acc [ b + 1 ] [ r + 1 ] - acc [ b + 1 ] [ l ] - acc [ t ] [ r + 1 ] + acc [ t ] [ l ] NEW_LINE if num < K : continue NEW_LINE S = ( Y [ b ] - Y [ t ] ) * ( X [ r ] - X [ l ] ) NEW_LINE if S < ans : NEW_LINE INDENT ans = S NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE def debug ( ) : NEW_LINE INDENT for line in acc : NEW_LINE INDENT print ( line ) NEW_LINE DEDENT DEDENT", "def solve ( N , K , XYs ) : NEW_LINE INDENT ans = 10 ** 19 + 1 NEW_LINE XYs . sort ( key = lambda x : x [ 0 ] ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( i + K - 1 , N ) : NEW_LINE INDENT narrowedXY = XYs [ i : j + 1 ] NEW_LINE narrowedXY . sort ( key = lambda x : x [ 1 ] ) NEW_LINE for y1 in range ( len ( narrowedXY ) ) : NEW_LINE INDENT for y2 in range ( y1 + K , len ( narrowedXY ) + 1 ) : NEW_LINE INDENT min_x = XYs [ i ] [ 0 ] NEW_LINE max_x = XYs [ j ] [ 0 ] NEW_LINE ys = [ xy [ 1 ] for xy in narrowedXY [ y1 : y2 ] ] NEW_LINE max_y = max ( ys ) NEW_LINE min_y = min ( ys ) NEW_LINE ans = min ( ans , abs ( max_x - min_x ) * abs ( max_y - min_y ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N , K = tuple ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) NEW_LINE XYs = [ tuple ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) for _ in range ( N ) ] NEW_LINE print ( solve ( N , K , XYs ) ) NEW_LINE DEDENT" ]
atcoder_abc041_A
[ "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String s = sc . next ( ) ; int i = sc . nextInt ( ) ; System . out . println ( s . charAt ( i - 1 ) ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; int i = in . nextInt ( ) ; out . println ( s . charAt ( i - 1 ) ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int i = sc . nextInt ( ) ; char ans = s . charAt ( i - 1 ) ; System . out . println ( ans ) ; } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? \" Yes \" : \" No \" ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { out . println ( sc . next ( ) . charAt ( nextInt ( ) - 1 ) ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( sc . next ( ) . charAt ( sc . nextInt ( ) - 1 ) ) ; } }" ]
[ "s = list ( input ( ) ) NEW_LINE i = int ( input ( ) ) NEW_LINE print ( s [ i - 1 ] ) NEW_LINE", "def index ( s : str , idx : int ) -> str : NEW_LINE INDENT return s [ idx - 1 ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT s = input ( ) NEW_LINE idx = int ( input ( ) ) NEW_LINE ans = index ( s , idx ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "s , i = open ( 0 ) ; print ( s [ int ( i ) - 1 ] ) NEW_LINE", "print ( input ( ) [ int ( input ( ) ) - 1 ] ) NEW_LINE", "S , I = input ( ) , int ( input ( ) ) NEW_LINE print ( S [ I - 1 ] ) NEW_LINE" ]
atcoder_abc091_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a , b , c ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( a + b >= c ) System . out . println ( \" Yes \" ) ; else System . out . println ( \" No \" ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( a + b >= c ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } sc . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int A = reader . nextInt ( ) ; int B = reader . nextInt ( ) ; int C = reader . nextInt ( ) ; String ans = \" Yes \" ; if ( A + B < C ) { ans = \" No \" ; } System . out . println ( ans ) ; reader . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( sc . nextInt ( ) + sc . nextInt ( ) >= sc . nextInt ( ) ? \" Yes \" : \" No \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A , B , C ; A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; C = sc . nextInt ( ) ; if ( A + B < C ) { System . out . println ( \" No \" ) ; } else { System . out . println ( \" Yes \" ) ; } sc . close ( ) ; } }" ]
[ "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if A + B >= C : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ' Yes ' if l [ 0 ] + l [ 1 ] >= l [ 2 ] else ' No ' ) NEW_LINE", "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE print ( [ \" Yes \" , \" No \" ] [ not ( C <= A + B ) ] ) NEW_LINE", "a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if ( a + b >= c ) : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT", "a , b , c = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE print ( ' Yes ' if a + b >= c else ' No ' ) NEW_LINE" ]
atcoder_arc081_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; ArrayList < Integer > d = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 . charAt ( i ) == s2 . charAt ( i ) ) { d . add ( 1 ) ; } else { d . add ( 2 ) ; i ++ ; } } sc . close ( ) ; long mod = 1000000007 ; long ans ; if ( d . get ( 0 ) == 1 ) { ans = 3 ; } else { ans = 6 ; } for ( int i = 1 ; i < d . size ( ) ; i ++ ) { if ( d . get ( i ) == 1 ) { if ( d . get ( i - 1 ) == 1 ) { ans *= 2 ; } else { ans *= 1 ; } } else { if ( d . get ( i - 1 ) == 1 ) { ans *= 2 ; } else { ans *= 3 ; } } if ( ans > mod ) ans %= mod ; } System . out . println ( ans ) ; } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . function . Consumer ; import java . util . stream . IntStream ; import static java . util . stream . Collectors . toList ; public class Main { private static final Scanner scanner = new Scanner ( System . in ) ; private static final Consumer < List < String > > consumer = solve ( ) ; public static void main ( String [ ] args ) { consumer . accept ( readInput ( ) ) ; } private static List < String > readInput ( ) { final List < String > lineList = new ArrayList < > ( ) ; while ( scanner . hasNextLine ( ) ) { lineList . add ( scanner . nextLine ( ) ) ; } return lineList ; } private static Consumer < List < String > > solve ( ) { return args -> { final char [ ] first = args . get ( 1 ) . toCharArray ( ) ; final char [ ] second = args . get ( 2 ) . toCharArray ( ) ; Long ans = 1L ; Boolean isPrevVertical = null ; Integer index = 0 ; while ( index < first . length ) { if ( first [ index ] == second [ index ] ) { if ( isPrevVertical == null ) { ans = ( ans * 3 ) % 1000000007 ; } else if ( isPrevVertical ) { ans = ( ans * 2 ) % 1000000007 ; } isPrevVertical = true ; index ++ ; } else { if ( isPrevVertical == null ) { ans = ( ans * 6 ) % 1000000007 ; } else if ( isPrevVertical ) { ans = ( ans * 2 ) % 1000000007 ; } else { ans = ( ans * 3 ) % 1000000007 ; } isPrevVertical = false ; index += 2 ; } } System . out . println ( ans ) ; } ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; char [ ] [ ] ss ; int MOD = 1000000007 ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; ss = new char [ 2 ] [ n ] ; for ( int i = 0 ; i < 2 ; i ++ ) { ss [ i ] = sc . next ( ) . toCharArray ( ) ; } solve ( ) ; } void solve ( ) { long num = 1 ; int prevBlock = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ss [ 0 ] [ i ] == ss [ 1 ] [ i ] ) { switch ( prevBlock ) { case 0 : num *= 3 ; break ; case 1 : num *= 2 ; break ; } num %= MOD ; prevBlock = 1 ; } else { switch ( prevBlock ) { case 0 : num *= 6 ; break ; case 1 : num *= 2 ; break ; case 2 : num *= 3 ; break ; } num %= MOD ; prevBlock = 2 ; i ++ ; } } System . out . println ( num ) ; } 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class Reader { static BufferedReader reader ; static StringTokenizer tokenizer ; static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( \" \" ) ; } static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } } public class Main { public static void main ( String [ ] args ) throws IOException { Reader . init ( System . in ) ; int n = Reader . nextInt ( ) ; String s1 = Reader . next ( ) ; String s2 = Reader . next ( ) ; if ( n == 1 ) { System . out . println ( 3 ) ; } else { String d ; int i = 1 ; long a = 1 ; if ( s1 . charAt ( 0 ) == s2 . charAt ( 0 ) ) { d = \" single \" ; a = 3 ; } else { d = \" double \" ; i = 2 ; a = 6 ; } while ( i < n ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { if ( d . compareTo ( \" single \" ) == 0 ) { a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ; } else { a = ( ( a % 1000000007 ) * 3 ) % 1000000007 ; } i += 2 ; d = \" double \" ; } else { if ( d . compareTo ( \" single \" ) == 0 ) { a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ; } d = \" single \" ; i ++ ; } } System . out . println ( a ) ; } } }", "import java . util . * ; public class Main { private static final int MOD = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S1 = sc . next ( ) ; String S2 = sc . next ( ) ; System . out . println ( solve ( N , S1 , S2 ) ) ; } private static int solve ( int N , String S1 , String S2 ) { long ans ; boolean prev_tate ; int i ; if ( S1 . charAt ( 0 ) == S2 . charAt ( 0 ) ) { prev_tate = true ; i = 1 ; ans = 3 ; } else { prev_tate = false ; i = 2 ; ans = 6 ; } while ( N > i ) { if ( S1 . charAt ( i ) == S2 . charAt ( i ) ) { if ( prev_tate ) { ans = ans * 2 % MOD ; } i ++ ; prev_tate = true ; } else { if ( prev_tate ) { ans = ans * 2 % MOD ; } else { ans = ans * 3 % MOD ; } i = i + 2 ; prev_tate = false ; } } return ( int ) ans ; } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE N = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE t = input ( ) NEW_LINE X = True NEW_LINE Y = False NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE if s [ 0 ] == t [ 0 ] : NEW_LINE INDENT i = 1 NEW_LINE ans = 3 NEW_LINE prev = X NEW_LINE DEDENT else : NEW_LINE INDENT i = 2 NEW_LINE ans = 6 NEW_LINE prev = Y NEW_LINE DEDENT while i < N : NEW_LINE INDENT if s [ i ] == t [ i ] : NEW_LINE INDENT if prev : NEW_LINE INDENT ans = ( ans * 2 ) % MOD NEW_LINE DEDENT else : NEW_LINE INDENT ans = ans % MOD NEW_LINE DEDENT i += 1 NEW_LINE prev = X NEW_LINE DEDENT else : NEW_LINE INDENT if prev : NEW_LINE INDENT ans = ( ans * 2 ) % MOD NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( ans * 3 ) % MOD NEW_LINE DEDENT i += 2 NEW_LINE prev = Y NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE list_s1 = list ( str ( input ( ) ) ) NEW_LINE ans = 1 NEW_LINE list_s1 . append ( \" ! \" ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT elif i == 1 : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if list_s1 [ i ] == list_s1 [ i - 1 ] : NEW_LINE INDENT ans *= 1 NEW_LINE DEDENT else : NEW_LINE INDENT if list_s1 [ i - 1 ] == list_s1 [ i - 2 ] : NEW_LINE INDENT if list_s1 [ i ] != list_s1 [ i + 1 ] : NEW_LINE INDENT ans *= 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans % ( 10 ** 9 + 7 ) ) NEW_LINE", "import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE MOD = 1000000007 NEW_LINE N = int ( input ( ) ) NEW_LINE S1 = input ( ) NEW_LINE S2 = input ( ) NEW_LINE i = 0 NEW_LINE prev = None NEW_LINE ans = 1 NEW_LINE while i < N : NEW_LINE INDENT if S1 [ i ] == S2 [ i ] : NEW_LINE INDENT if prev is None : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT if prev == ' ver ' : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT if prev == ' hor ' : NEW_LINE INDENT pass NEW_LINE DEDENT prev = ' ver ' NEW_LINE i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if prev is None : NEW_LINE INDENT ans *= 6 NEW_LINE DEDENT if prev == ' ver ' : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT if prev == ' hor ' : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT prev = ' hor ' NEW_LINE i += 2 NEW_LINE DEDENT ans %= MOD NEW_LINE DEDENT print ( ans ) NEW_LINE", "from itertools import groupby as gb NEW_LINE N = int ( input ( ) ) NEW_LINE a , b = gb ( input ( ) ) , gb ( input ( ) ) NEW_LINE res = - 1 NEW_LINE for ( w , x ) , ( y , z ) in zip ( a , b ) : NEW_LINE INDENT if res == - 1 : NEW_LINE INDENT prev = w != y NEW_LINE res = 3 * ( 1 + prev ) NEW_LINE DEDENT elif prev : NEW_LINE INDENT prev = w != y NEW_LINE res *= 1 + prev * 2 NEW_LINE DEDENT else : NEW_LINE INDENT prev = w != y NEW_LINE res *= 2 NEW_LINE DEDENT DEDENT print ( res % ( 10 ** 9 + 7 ) ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE s1 = input ( ) NEW_LINE s2 = input ( ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE b = 0 NEW_LINE did = 0 NEW_LINE ans = 0 NEW_LINE if s1 [ 0 ] == s2 [ 0 ] : NEW_LINE INDENT b = 1 NEW_LINE ans += 3 NEW_LINE DEDENT else : NEW_LINE INDENT did = 1 NEW_LINE ans = 6 NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if s1 [ i ] == s2 [ i ] : NEW_LINE INDENT if b : NEW_LINE INDENT ans = ans * 2 % mod NEW_LINE DEDENT b = 1 NEW_LINE DEDENT elif not did : NEW_LINE INDENT if b : NEW_LINE INDENT ans = ans * 2 % mod NEW_LINE DEDENT else : NEW_LINE INDENT ans = ans * 3 % mod NEW_LINE DEDENT did = 1 NEW_LINE b = 0 NEW_LINE DEDENT else : NEW_LINE INDENT did = 0 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc005_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int [ ] cnt = new int [ N ] ; int min = N + 1 ; int max = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; cnt [ a [ i ] ] += 1 ; min = Math . min ( min , a [ i ] ) ; max = Math . max ( max , a [ i ] ) ; } sc . close ( ) ; String POSSIBLE = \" Possible \" ; String IMPOSSIBLE = \" Impossible \" ; String ans = POSSIBLE ; if ( cnt [ min ] == 1 ) { if ( max == min * 2 ) { ans = POSSIBLE ; for ( int i = min + 1 ; i <= max ; i ++ ) { if ( cnt [ i ] < 2 ) { ans = IMPOSSIBLE ; break ; } } } else { ans = IMPOSSIBLE ; } } else if ( cnt [ min ] == 2 ) { if ( max == min * 2 - 1 ) { ans = POSSIBLE ; for ( int i = min + 1 ; i <= max ; i ++ ) { if ( cnt [ i ] < 2 ) { ans = IMPOSSIBLE ; break ; } } } else { ans = IMPOSSIBLE ; } } else { ans = IMPOSSIBLE ; } System . out . println ( ans ) ; } }" ]
[ "import sys NEW_LINE input = sys . stdin . readline NEW_LINE from math import ceil NEW_LINE input ( ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE maxA = max ( A ) NEW_LINE minA = min ( A ) NEW_LINE if minA != ceil ( maxA / 2 ) : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE DEDENT else : NEW_LINE INDENT if maxA % 2 : NEW_LINE INDENT for i in range ( minA , maxA + 1 ) : NEW_LINE INDENT if i == minA : NEW_LINE INDENT if A . count ( i ) != 2 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A . count ( i ) < 2 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ' Possible ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( minA , maxA + 1 ) : NEW_LINE INDENT if i == minA : NEW_LINE INDENT if A . count ( i ) != 1 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A . count ( i ) < 2 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ' Possible ' ) NEW_LINE DEDENT DEDENT DEDENT", "from collections import defaultdict NEW_LINE n = int ( input ( ) ) NEW_LINE xs = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def no ( ) : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE quit ( 0 ) NEW_LINE DEDENT def yes ( ) : NEW_LINE INDENT print ( \" Possible \" ) NEW_LINE quit ( 0 ) NEW_LINE DEDENT cnts = defaultdict ( int ) NEW_LINE for x in xs : NEW_LINE INDENT cnts [ x ] += 1 NEW_LINE DEDENT d = max ( xs ) NEW_LINE delems = [ ] NEW_LINE for i in range ( d + 1 ) : NEW_LINE INDENT delems . append ( max ( i , d - i ) ) NEW_LINE DEDENT for delem in delems : NEW_LINE INDENT if cnts [ delem ] <= 0 : NEW_LINE INDENT no ( ) NEW_LINE DEDENT cnts [ delem ] -= 1 NEW_LINE DEDENT minx = min ( delems ) + 1 NEW_LINE for x , rem in cnts . items ( ) : NEW_LINE INDENT if rem > 0 : NEW_LINE INDENT if not minx <= x <= d : NEW_LINE INDENT no ( ) NEW_LINE DEDENT DEDENT DEDENT yes ( ) NEW_LINE", "import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def f ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a . sort ( ) NEW_LINE i = 1 NEW_LINE if n > 2 and a [ - 1 ] == 1 : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ - 1 ] != a [ - 2 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ - 1 ] % 2 == 1 : NEW_LINE INDENT if a [ - 1 ] // 2 + 1 != a [ 0 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ 0 ] != a [ 1 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if n > 2 and a [ 0 ] == a [ 2 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT i = 2 NEW_LINE DEDENT else : NEW_LINE INDENT if a [ - 1 ] // 2 != a [ 0 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ 0 ] == a [ 1 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT DEDENT c = 2 NEW_LINE t = a [ 0 ] NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT if t != a [ j ] : NEW_LINE INDENT if c < 2 : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if t + 1 != a [ j ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT c = 0 NEW_LINE t = a [ j ] NEW_LINE DEDENT c += 1 NEW_LINE DEDENT return ' Possible ' NEW_LINE DEDENT print ( f ( ) ) NEW_LINE", "from collections import Counter NEW_LINE pos = \" Possible \" NEW_LINE imp = \" Impossible \" NEW_LINE def judge ( nums ) : NEW_LINE INDENT N = len ( nums ) NEW_LINE count = Counter ( nums ) NEW_LINE mx = max ( nums ) NEW_LINE if mx == 1 : NEW_LINE INDENT if N == 2 : NEW_LINE INDENT return pos NEW_LINE DEDENT else : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT elif mx == 2 : NEW_LINE INDENT if count [ 1 ] == 1 and count [ 2 ] >= 2 : NEW_LINE INDENT return pos NEW_LINE DEDENT else : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT mid = ( mx + 1 ) // 2 NEW_LINE for i in range ( 1 , mid ) : NEW_LINE INDENT if count [ i ] != 0 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT if mx % 2 == 1 : NEW_LINE INDENT if count [ mid ] != 2 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if count [ mid ] != 1 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT for i in range ( mid + 1 , mx + 1 ) : NEW_LINE INDENT if count [ i ] < 2 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT return pos NEW_LINE DEDENT DEDENT dummy = int ( input ( ) ) NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( judge ( nums ) ) NEW_LINE def mk ( array ) : NEW_LINE INDENT ret = [ ] NEW_LINE n = 1 NEW_LINE for e in array : NEW_LINE INDENT ret += [ n ] * e NEW_LINE n += 1 NEW_LINE DEDENT print ( ret ) NEW_LINE return ret NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a . sort ( ) NEW_LINE m , s = a [ - 1 ] , a [ 0 ] NEW_LINE if m != a [ - 2 ] or ( m + 1 ) // 2 != s or ( m % 2 and s - a [ 1 ] ) or ( ( not m % 2 ) and s == a [ 1 ] ) or any ( a . count ( i ) < 2 for i in range ( s + 1 , m ) ) or ( n != 2 and s == a [ 1 ] == a [ 2 ] ) : print ( \" Impossible \" ) NEW_LINE else : print ( \" Possible \" ) NEW_LINE" ]
atcoder_agc005_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] pos = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; a [ i ] = tmp ; pos [ tmp - 1 ] = i ; } TreeSet < Integer > ts = new TreeSet < Integer > ( ) ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int h , l ; if ( ts . higher ( pos [ i ] ) == null ) { h = n ; } else { h = ts . higher ( pos [ i ] ) ; } if ( ts . lower ( pos [ i ] ) == null ) { l = - 1 ; } else { l = ts . lower ( pos [ i ] ) ; } ans += ( long ) ( pos [ i ] - l ) * ( long ) ( h - pos [ i ] ) * ( long ) ( i + 1 ) ; ts . add ( pos [ i ] ) ; } System . out . println ( ans ) ; } }", "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { ArrayList < Integer > [ ] graph ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] pos = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; pos [ a [ i ] ] = i ; } TreeSet < Integer > ts = new TreeSet < > ( ) ; ts . add ( 0 ) ; ts . add ( n + 1 ) ; long ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int lo = ts . lower ( pos [ i ] ) ; int hi = ts . higher ( pos [ i ] ) ; ans += ( ( long ) ( pos [ i ] - lo ) ) * ( ( long ) ( hi - pos [ i ] ) ) * i ; ts . add ( pos [ i ] ) ; } System . out . println ( ans ) ; } }", "import java . util . ArrayDeque ; import java . util . Scanner ; import java . util . stream . IntStream ; class Main { 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 [ ] leftl = new int [ N ] ; int [ ] rightl = new int [ N ] ; ArrayDeque < Integer > que = new ArrayDeque < > ( ) ; int index = 0 ; while ( index < N ) { while ( ! que . isEmpty ( ) && a [ que . peek ( ) ] > a [ index ] ) { int ind = que . poll ( ) ; rightl [ ind ] = index - ind - 1 ; } que . push ( index ++ ) ; } while ( ! que . isEmpty ( ) ) { int ind = que . poll ( ) ; rightl [ ind ] = N - ind - 1 ; } index = N - 1 ; while ( index >= 0 ) { while ( ! que . isEmpty ( ) && a [ que . peek ( ) ] > a [ index ] ) { int ind = que . poll ( ) ; leftl [ ind ] = ind - index - 1 ; } que . push ( index -- ) ; } while ( ! que . isEmpty ( ) ) { int ind = que . poll ( ) ; leftl [ ind ] = ind - index - 1 ; } long ans = 0 ; for ( int i = 0 ; i < N ; ++ i ) { ans += ( long ) a [ i ] * ( leftl [ i ] + 1 ) * ( rightl [ i ] + 1 ) ; } System . out . println ( ans ) ; } }", "import java . util . Arrays ; import java . util . LinkedList ; import java . util . Scanner ; public class Main { int n ; int [ ] a ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; a = new int [ n ] ; int [ ] r = new int [ n ] , l = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } LinkedList < Integer > stack = new LinkedList < > ( ) ; LinkedList < Integer > cnts = new LinkedList < > ( ) ; stack . add ( 0 ) ; int cnt = 1 ; for ( int i = 0 ; i < n ; i ++ ) { l [ i ] = 1 ; while ( stack . getLast ( ) > a [ i ] ) { stack . removeLast ( ) ; l [ i ] += cnts . removeLast ( ) ; } stack . addLast ( a [ i ] ) ; cnts . addLast ( l [ i ] ) ; } stack . clear ( ) ; stack . addLast ( 0 ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { r [ i ] = 1 ; while ( stack . getLast ( ) > a [ i ] ) { stack . removeLast ( ) ; r [ i ] += cnts . removeLast ( ) ; } stack . addLast ( a [ i ] ) ; cnts . addLast ( r [ i ] ) ; } long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += 1L * a [ i ] * l [ i ] * r [ i ] ; } System . out . println ( ans ) ; } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ sc . nextInt ( ) - 1 ] = i ; } TreeSet < Long > set = new TreeSet < > ( ) ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long num = a [ i ] ; Long l = set . lower ( num ) ; Long r = set . higher ( num ) ; l = ( l == null ? - 1 : l ) ; r = ( r == null ? n : r ) ; ans += ( i + 1 ) * ( num - l ) * ( r - num ) ; set . add ( num ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }" ]
[ "import sys NEW_LINE input = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE import heapq NEW_LINE n = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE idx = { } NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT idx [ a ] = i NEW_LINE DEDENT hq = [ ] NEW_LINE right = [ n - 1 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT while hq and - hq [ 0 ] > A [ i ] : NEW_LINE INDENT h = - heapq . heappop ( hq ) NEW_LINE right [ idx [ h ] ] = i - 1 NEW_LINE DEDENT heapq . heappush ( hq , - A [ i ] ) NEW_LINE DEDENT hq = [ ] NEW_LINE left = [ 0 ] * n NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT while hq and - hq [ 0 ] > A [ i ] : NEW_LINE INDENT h = - heapq . heappop ( hq ) NEW_LINE left [ idx [ h ] ] = i + 1 NEW_LINE DEDENT heapq . heappush ( hq , - A [ i ] ) NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT ans += A [ i ] * ( i - left [ i ] + 1 ) * ( right [ i ] - i + 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE a = [ 0 ] + [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE par = [ 0 for i in range ( N + 1 ) ] NEW_LINE size = [ 0 for i in range ( N + 1 ) ] NEW_LINE def find ( x ) : NEW_LINE INDENT if ( par [ x ] == x ) : NEW_LINE INDENT return x NEW_LINE DEDENT par [ x ] = find ( par [ x ] ) NEW_LINE return par [ x ] NEW_LINE DEDENT def unite ( x , y ) : NEW_LINE INDENT x = find ( x ) NEW_LINE y = find ( y ) NEW_LINE res = size [ x ] * size [ y ] NEW_LINE size [ x ] += size [ y ] NEW_LINE par [ y ] = x NEW_LINE return res NEW_LINE DEDENT for i in range ( N + 1 ) : NEW_LINE INDENT par [ i ] = i NEW_LINE size [ i ] = 1 NEW_LINE DEDENT b = [ 0 for i in range ( N + 1 ) ] NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT b [ a [ i ] ] = i NEW_LINE DEDENT ans = 0 NEW_LINE for j in range ( 1 , N + 1 ) [ : : - 1 ] : NEW_LINE INDENT i = b [ j ] NEW_LINE ans += a [ i ] NEW_LINE if i - 1 >= 1 and a [ i - 1 ] > a [ i ] : NEW_LINE INDENT ans += unite ( i - 1 , i ) * a [ i ] NEW_LINE DEDENT if i + 1 <= N and a [ i + 1 ] > a [ i ] : NEW_LINE INDENT ans += unite ( i + 1 , i ) * a [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from collections import Counter NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE A = LI ( ) NEW_LINE idxs = [ 0 ] * ( N + 1 ) NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT idxs [ a ] = i NEW_LINE DEDENT ll = list ( range ( N + 1 ) ) NEW_LINE rr = list ( range ( N + 1 ) ) NEW_LINE ans = 0 NEW_LINE for a in range ( N , 0 , - 1 ) : NEW_LINE INDENT idx = idxs [ a ] NEW_LINE l , r = ll [ idx ] , rr [ idx ] NEW_LINE ans += ( idx - l + 1 ) * ( r - idx + 1 ) * a NEW_LINE ll [ r + 1 ] = l NEW_LINE rr [ l - 1 ] = r NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "def getNums ( As ) : NEW_LINE INDENT nums = [ 0 ] * N NEW_LINE stack = [ ( - 1 , 0 ) ] NEW_LINE for iA , A in enumerate ( As ) : NEW_LINE INDENT while stack [ - 1 ] [ 1 ] > A : NEW_LINE INDENT stack . pop ( ) NEW_LINE DEDENT nums [ iA ] = iA - stack [ - 1 ] [ 0 ] NEW_LINE stack . append ( ( iA , A ) ) NEW_LINE DEDENT return nums NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE As = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE numLs = getNums ( As ) NEW_LINE numRs = getNums ( reversed ( As ) ) NEW_LINE print ( sum ( [ A * numL * numR for A , numL , numR in zip ( As , numLs , reversed ( numRs ) ) ] ) ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE a = inpl ( ) NEW_LINE b = { a [ i ] : i for i in range ( N ) } NEW_LINE left = list ( range ( N + 2 ) ) NEW_LINE right = list ( range ( N + 2 ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( N , 0 , - 1 ) : NEW_LINE INDENT x = b [ i ] NEW_LINE ans += i * ( right [ x ] - x + 1 ) * ( x - left [ x ] + 1 ) NEW_LINE right [ left [ x ] - 1 ] = right [ x ] NEW_LINE left [ right [ x ] + 1 ] = left [ x ] NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc036_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int prev = sc . nextInt ( ) ; int count = 1 ; int max = 1 ; boolean isDown = false ; for ( int i = 1 ; i < n ; i ++ ) { int h = sc . nextInt ( ) ; if ( isDown && prev < h ) { isDown = false ; count = 2 ; } else { count ++ ; if ( max < count ) { max = count ; } if ( prev > h ) { isDown = true ; } } prev = h ; } System . out . println ( max ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int h [ ] = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( N == 1 ) { System . out . println ( 1 ) ; return ; } int state = h [ 1 ] > h [ 0 ] ? 1 : - 1 ; int s = 1 ; int t = 1 ; int u = 1 ; int max = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { if ( state > 0 ) { if ( h [ i ] > h [ i - 1 ] ) { t = i ; u = i ; } else { u = i ; state = - state ; } } else { if ( h [ i ] < h [ i - 1 ] ) { u = i ; } else { state = - state ; int size = u - s + 1 ; max = Math . max ( max , size ) ; s = i - 1 ; t = i - 1 ; } } } max = Math . max ( max , u - s + 1 ) ; System . out . println ( max ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE H = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE L = [ 1 ] * N NEW_LINE R = [ 1 ] * N NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT L [ i ] = L [ i - 1 ] * ( H [ i - 1 ] < H [ i ] ) + 1 NEW_LINE DEDENT for i in range ( N - 2 , - 1 , - 1 ) : NEW_LINE INDENT R [ i ] = R [ i + 1 ] * ( H [ i + 1 ] < H [ i ] ) + 1 NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans = max ( ans , L [ i ] + R [ i ] ) NEW_LINE DEDENT print ( ans - 1 ) NEW_LINE", "n , * h = map ( int , open ( 0 ) . readlines ( ) ) NEW_LINE m = 1 NEW_LINE for t in range ( n ) : NEW_LINE INDENT s , u = t - ( t > 0 ) , t + ( t < n - 1 ) NEW_LINE if h [ s ] < h [ t ] > h [ u ] or t < 1 or t > n - 2 : NEW_LINE INDENT while s and h [ s - 1 ] < h [ s ] : s -= 1 NEW_LINE while u < n - 1 and h [ u + 1 ] < h [ u ] : u += 1 NEW_LINE DEDENT m = max ( m , u - s + 1 ) NEW_LINE DEDENT print ( m ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE inputs = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE def process ( ) : NEW_LINE INDENT global right , ans NEW_LINE right += 1 NEW_LINE if right == N - 1 : NEW_LINE INDENT ans = max ( ans , right - left + 1 ) NEW_LINE print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT left = 0 NEW_LINE right = 0 NEW_LINE ans = 1 NEW_LINE while right < N - 1 : NEW_LINE INDENT while inputs [ right ] < inputs [ right + 1 ] : NEW_LINE INDENT process ( ) NEW_LINE DEDENT while inputs [ right ] > inputs [ right + 1 ] : NEW_LINE INDENT process ( ) NEW_LINE DEDENT ans = max ( ans , right - left + 1 ) NEW_LINE left = right NEW_LINE right += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE if N == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT L = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE L . append ( n ) NEW_LINE DEDENT ans = 0 NEW_LINE M = \" N \" NEW_LINE S = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if M == \" N \" : NEW_LINE INDENT if L [ i ] > L [ i - 1 ] : NEW_LINE INDENT M = \" U \" NEW_LINE S = i - 1 NEW_LINE DEDENT DEDENT elif M == \" U \" : NEW_LINE INDENT if L [ i ] >= L [ i - 1 ] : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT M = \" D \" NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if L [ i ] <= L [ i - 1 ] : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT M = \" U \" NEW_LINE S = i - 1 NEW_LINE DEDENT DEDENT if ans < i - S + 1 : NEW_LINE INDENT ans = i - S + 1 NEW_LINE DEDENT DEDENT print ( min ( N , ans ) ) NEW_LINE DEDENT", "S = int ( input ( ) ) NEW_LINE stu = [ ] NEW_LINE zyousyou = 1 NEW_LINE kakou = 0 NEW_LINE u = 1 NEW_LINE s = 1 NEW_LINE ans = 1 NEW_LINE for i in range ( S ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE if ( i > 0 ) : NEW_LINE INDENT u += 1 NEW_LINE if ( a > ba ) : NEW_LINE INDENT if ( kakou == 1 ) : NEW_LINE INDENT if ( ans < u - s ) : NEW_LINE INDENT ans = u - s NEW_LINE DEDENT s = i NEW_LINE kakou = 0 NEW_LINE zyousyou = 1 NEW_LINE DEDENT DEDENT elif ( a < ba ) : NEW_LINE INDENT if ( zyousyou == 1 ) : NEW_LINE INDENT kakou = 1 NEW_LINE zyousyou = 0 NEW_LINE DEDENT DEDENT DEDENT ba = a NEW_LINE DEDENT if ( ans < u - s + 1 ) : NEW_LINE INDENT ans = u - s + 1 NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc040_A
[ "import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) , x = sc . nextInt ( ) ; if ( n / 2 < x ) { System . out . println ( n - x ) ; } else { System . out . println ( x - 1 ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int x = in . nextInt ( ) ; out . println ( Math . min ( n - x , x - 1 ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; System . out . println ( Math . min ( x - 1 , n - x ) ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; int x = in . nextInt ( ) ; out . println ( n - x < x - 1 ? n - x : x - 1 ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? \" Yes \" : \" No \" ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int n = nextInt ( ) , x = nextInt ( ) ; out . println ( min ( x - 1 , n - x ) ) ; } }" ]
[ "n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if n / 2 >= x : NEW_LINE INDENT print ( x - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n - x ) NEW_LINE DEDENT", "def red_red_red_red_blue ( n : int , x : int ) -> int : NEW_LINE INDENT return min ( x - 1 , n - x ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT n , x = map ( int , input ( ) . split ( ) ) NEW_LINE ans = red_red_red_red_blue ( n , x ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "n , x = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE print ( min ( x - 1 , n - x ) ) NEW_LINE", "n , x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if x <= n / 2 : NEW_LINE INDENT print ( x - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n - x ) NEW_LINE DEDENT", "n , x = map ( int , input ( ) . split ( ) ) ; print ( n - x if x > n / 2 else x - 1 ) NEW_LINE" ]
atcoder_arc050_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; String c = sc . next ( ) ; if ( C . equals ( c . toUpperCase ( ) ) ) { System . out . println ( \" Yes \" ) ; return ; } else { System . out . println ( \" No \" ) ; return ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( in . next ( ) . charAt ( 0 ) + 32 == in . next ( ) . charAt ( 0 ) ? \" Yes \" : \" No \" ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s = r . readLine ( ) ; String [ ] sl = s . split ( \" [ \\\\ s ] + \" ) ; String a = sl [ 0 ] ; String b = sl [ 1 ] ; System . out . println ( a . toLowerCase ( ) . equals ( b ) ? \" Yes \" : \" No \" ) ; } }", "import java . util . * ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; String c = sc . next ( ) ; if ( c . toUpperCase ( ) . equals ( C ) ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }", "import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] params = br . readLine ( ) . split ( \" ▁ \" ) ; String row = params [ 0 ] . toLowerCase ( ) ; if ( row . equals ( params [ 1 ] ) ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }" ]
[ "a , b = input ( ) . split ( ) NEW_LINE print ( \" No \" if ord ( b ) - ord ( a ) != 32 else \" Yes \" ) NEW_LINE", "def main ( ) : NEW_LINE INDENT C , c = input ( ) . split ( ) NEW_LINE if C . lower ( ) == c : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "a , _ , b = input ( ) ; print ( ' YNeos ' [ a . lower ( ) != b : : 2 ] ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE C , c = input ( ) . split ( ) NEW_LINE if ord ( C ) - ord ( ' A ' ) == ord ( c ) - ord ( ' a ' ) : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT", "upL , loL = input ( ) . split ( ) NEW_LINE if loL . upper ( ) == upL : print ( ' Yes ' ) NEW_LINE else : print ( ' No ' ) NEW_LINE" ]
atcoder_arc004_B
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . ParseException ; import java . util . Arrays ; import java . util . IntSummaryStatistics ; public class Main { public static void main ( String [ ] args ) throws IOException , ParseException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int number = Integer . parseInt ( br . readLine ( ) ) ; int [ ] pointArray = new int [ number ] ; for ( int i = 0 ; i < number ; i ++ ) { pointArray [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } IntSummaryStatistics iss = Arrays . stream ( pointArray ) . summaryStatistics ( ) ; long max = iss . getMax ( ) ; long sum = iss . getSum ( ) ; System . out . println ( sum ) ; System . out . println ( Math . max ( 0 , max - ( sum - max ) ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int d = sc . nextInt ( ) ; if ( max < d ) { max = d ; } sum += d ; } System . out . println ( sum ) ; int rest = sum - max ; if ( rest >= max ) { System . out . println ( 0 ) ; } else { System . out . println ( max - rest ) ; } } }", "import java . io . * ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 <= args . length ; debug2 = 2 <= args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; final int N = Integer . parseInt ( in . readLine ( ) ) ; int [ ] d = new int [ N ] ; int max = 0 ; for ( int i = 0 ; i < N ; ++ i ) { max += d [ i ] = Integer . parseInt ( in . readLine ( ) ) ; } int min = Integer . MAX_VALUE ; switch ( N ) { case 1 : min = max ; break ; case 2 : min = Math . abs ( d [ 1 ] - d [ 0 ] ) ; break ; default : for ( int i = 1 , a = d [ 0 ] ; i < N ; a += d [ i ++ ] ) { for ( int j = i + 1 ; j < N ; ++ j ) { int b = 0 ; for ( int n = i ; n < j ; ++ n ) { b += d [ n ] ; } int c = 0 ; for ( int n = j ; n < N ; ++ n ) { c += d [ n ] ; } int [ ] abc = new int [ ] { a , b , c } ; Arrays . sort ( abc ) ; if ( abc [ 0 ] + abc [ 1 ] < abc [ 2 ] ) { min = Math . min ( min , abc [ 2 ] - abc [ 1 ] - abc [ 0 ] ) ; } else { min = 0 ; } } } break ; } System . out . println ( max ) ; System . out . println ( min ) ; } }", "import java . util . Arrays ; import java . util . IntSummaryStatistics ; import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) , in [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) in [ i ] = s . nextInt ( ) ; IntSummaryStatistics iss = Arrays . stream ( in ) . parallel ( ) . summaryStatistics ( ) ; long max = iss . getMax ( ) , sum = iss . getSum ( ) ; System . out . println ( sum ) ; System . out . println ( Math . max ( 0 , max - ( sum - max ) ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] dpmax = new int [ N ] ; int [ ] dpmin = new int [ N ] ; int d0 = sc . nextInt ( ) ; dpmax [ 0 ] = d0 ; dpmin [ 0 ] = d0 ; for ( int i = 1 ; i < N ; i ++ ) { int d = sc . nextInt ( ) ; dpmax [ i ] = dpmax [ i - 1 ] + d ; if ( d >= dpmin [ i - 1 ] && d <= dpmax [ i - 1 ] ) { } else if ( d < dpmin [ i - 1 ] ) { dpmin [ i ] = dpmin [ i - 1 ] - d ; } else { dpmin [ i ] = d - dpmax [ i - 1 ] ; } } System . out . println ( dpmax [ N - 1 ] ) ; System . out . println ( dpmin [ N - 1 ] ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = sorted ( [ int ( input ( ) ) for i in range ( n ) ] ) NEW_LINE print ( sum ( a ) ) NEW_LINE print ( max ( 0 , a [ - 1 ] - sum ( a [ : - 1 ] ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT d = int ( input ( ) ) NEW_LINE if ( i == 0 ) : NEW_LINE INDENT dmin = d NEW_LINE dmax = d NEW_LINE DEDENT else : NEW_LINE INDENT if ( dmin <= d and dmax >= d ) : NEW_LINE INDENT dmin = 0 NEW_LINE DEDENT else : NEW_LINE INDENT dmin = min ( abs ( dmin - d ) , abs ( dmax - d ) ) NEW_LINE DEDENT dmax += d NEW_LINE DEDENT DEDENT print ( dmax ) NEW_LINE print ( dmin ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE l = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT l . append ( int ( input ( ) ) ) NEW_LINE DEDENT print ( sum ( l ) ) NEW_LINE l . sort ( reverse = True ) NEW_LINE min_no = l [ 0 ] NEW_LINE for x in range ( 1 , len ( l ) ) : NEW_LINE INDENT min_no -= l [ x ] NEW_LINE DEDENT if min_no <= 0 : NEW_LINE INDENT min_no = 0 NEW_LINE DEDENT print ( min_no ) NEW_LINE", "import numpy as np NEW_LINE import sys NEW_LINE n = int ( input ( ) ) NEW_LINE d = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE print ( sum ( d ) ) NEW_LINE if sum ( d ) - np . max ( d ) < np . max ( d ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT print ( sum ( d ) ) NEW_LINE DEDENT if 1 < n : NEW_LINE INDENT print ( - sum ( d ) + 2 * np . max ( d ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT", "from sys import stdin NEW_LINE input = stdin . readline NEW_LINE n = int ( input ( ) ) NEW_LINE L = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT d = int ( input ( ) ) NEW_LINE L . append ( d ) NEW_LINE DEDENT ma = sum ( L ) NEW_LINE if 2 * max ( L ) > sum ( L ) : NEW_LINE INDENT mi = 2 * max ( L ) - sum ( L ) NEW_LINE DEDENT else : NEW_LINE INDENT mi = 0 NEW_LINE DEDENT print ( ma ) NEW_LINE print ( mi ) NEW_LINE" ]
atcoder_arc036_A
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) , k = s . nextInt ( ) , t [ ] = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) t [ i + 1 ] = s . nextInt ( ) ; Arrays . parallelPrefix ( t , Integer :: sum ) ; for ( int i = 3 ; i <= n ; i ++ ) { if ( t [ i ] - t [ i - 3 ] < k ) { System . out . println ( i ) ; return ; } } System . out . println ( - 1 ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] sleep = new int [ N + 1 ] ; sleep [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sleep [ i ] = sc . nextInt ( ) + sleep [ i - 1 ] ; } for ( int i = 3 ; i <= N ; i ++ ) { if ( sleep [ i ] - sleep [ i - 3 ] < K ) { pl ( i ) ; System . exit ( 0 ) ; } } pl ( - 1 ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }", "import java . util . * ; import java . util . stream . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , k = scanner . nextInt ( ) , t [ ] = IntStream . range ( 0 , n ) . map ( i -> scanner . nextInt ( ) ) . toArray ( ) ; System . out . println ( IntStream . rangeClosed ( 3 , n ) . filter ( i -> t [ i - 3 ] + t [ i - 2 ] + t [ i - 1 ] < k ) . findFirst ( ) . orElse ( - 1 ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int temp0 = Integer . parseInt ( sc . next ( ) ) , temp1 = Integer . parseInt ( sc . next ( ) ) , temp2 = Integer . parseInt ( sc . next ( ) ) ; int sum = temp0 + temp1 + temp2 ; if ( sum < k ) { System . out . println ( 3 ) ; sc . close ( ) ; return ; } for ( int i = 4 ; i <= n ; i ++ ) { sum -= temp0 ; temp0 = temp1 ; temp1 = temp2 ; temp2 = Integer . parseInt ( sc . next ( ) ) ; sum += temp2 ; if ( sum < k ) { System . out . println ( i ) ; sc . close ( ) ; return ; } } System . out . println ( - 1 ) ; sc . close ( ) ; } }", "import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; int r = 0 ; int [ ] t = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { t [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { r += t [ i ] ; if ( i < 3 ) continue ; if ( r < k ) { out . println ( i ) ; exit ( 0 ) ; } r -= t [ i - 2 ] ; } out . println ( - 1 ) ; } }" ]
[ "n , k = map ( int , input ( ) . split ( ) ) NEW_LINE t = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT if t [ i - 2 ] + t [ i - 1 ] + t [ i ] < k : NEW_LINE INDENT print ( i + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT", "n , k = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE res = False NEW_LINE time = [ int ( input ( ) ) , int ( input ( ) ) , int ( input ( ) ) ] NEW_LINE for i in range ( n - 3 ) : NEW_LINE INDENT if sum ( time ) < k and not res : NEW_LINE INDENT res = i + 3 NEW_LINE DEDENT time [ 0 ] , time [ 1 ] , time [ 2 ] = time [ 1 ] , time [ 2 ] , int ( input ( ) ) NEW_LINE DEDENT print ( res if res else - 1 ) NEW_LINE", "def a_good_sleep ( N , K , T ) : NEW_LINE INDENT sleep_time = sum ( T [ : 3 ] ) NEW_LINE if sleep_time < K : NEW_LINE INDENT return 3 NEW_LINE DEDENT ans = - 1 NEW_LINE for day , t in enumerate ( T [ 3 : ] , 4 ) : NEW_LINE INDENT sleep_time -= T [ day - 3 - 1 ] NEW_LINE sleep_time += T [ day - 1 ] NEW_LINE if sleep_time < K : NEW_LINE INDENT ans = day NEW_LINE break NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE T = [ int ( input ( ) ) for _ in [ 0 ] * N ] NEW_LINE print ( a_good_sleep ( N , K , T ) ) NEW_LINE", "n , k , * t = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; print ( ( [ i for i in range ( 3 , n ) if sum ( t [ i - 3 : i ] ) < k ] + [ - 1 ] ) [ 0 ] ) NEW_LINE", "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE L = [ ] NEW_LINE p = 0 NEW_LINE c = 0 NEW_LINE flag = True NEW_LINE for i in range ( N ) : NEW_LINE INDENT L . append ( int ( input ( ) ) ) NEW_LINE DEDENT for j in range ( N - 2 ) : NEW_LINE INDENT p = L [ j ] + L [ j + 1 ] + L [ j + 2 ] NEW_LINE if p < K : NEW_LINE INDENT flag = False NEW_LINE c = j + 3 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT None NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT" ]
atcoder_arc091_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( k == 0 ) { System . out . print ( ( long ) n * n ) ; return ; } long sum = 0 ; for ( int i = k + 1 ; i <= n ; i ++ ) { sum += ( long ) ( n / i ) * ( i - k ) + Math . max ( n % i - k + 1 , 0 ) ; } System . out . print ( sum ) ; } }", "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 [ ] tmpArray = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( tmpArray [ 0 ] ) ; int k = Integer . parseInt ( tmpArray [ 1 ] ) ; long result = 0 ; for ( int b = 1 ; b <= n ; b ++ ) { int p = n / b ; int r = n % b ; result += p * Math . max ( 0 , b - k ) + Math . max ( 0 , r - k + 1 ) ; } if ( k == 0 ) { result -= n ; } System . out . println ( result ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; int k = sc . nextInt ( ) ; sc . close ( ) ; if ( k == 0 ) { System . out . println ( n * n ) ; return ; } long ans = ( n - k + 1 ) * ( n - k ) / 2 ; for ( int i = k + 1 ; i < n ; i ++ ) { long tmp = ( ( n - i ) / i ) * ( i - k ) ; if ( n % i >= k ) { tmp += n % i - k + 1 ; } ans += tmp ; } System . out . println ( ans ) ; } }", "import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( bf . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; long ans = 0 ; for ( int b = 1 ; b <= n ; b ++ ) { if ( b <= k ) continue ; int remainders_per_b = b - 1 - k + 1 ; ans += 1L * n / b * remainders_per_b ; if ( n % b >= k ) ans += ( n % b ) - k + 1 ; if ( k == 0 ) ans -- ; } System . out . println ( ans ) ; } }", "import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long count = 0 ; if ( k == 0 ) { count = ( long ) n * ( long ) n ; } else { for ( int i = 2 ; i <= n ; i ++ ) { if ( i > k ) { count += ( long ) Math . max ( 0 , n / i * ( i - k ) ) ; count += ( long ) Math . max ( 0 , ( n % i ) - k + 1 ) ; } } } System . out . println ( count ) ; } }" ]
[ "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for b in range ( 1 , N + 1 ) : NEW_LINE INDENT p = N // b NEW_LINE r = N % b NEW_LINE ans += max ( 0 , b - K ) * p + max ( 0 , r - K + 1 ) NEW_LINE if K == 0 : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE Ans = 0 NEW_LINE if K == 0 : NEW_LINE INDENT print ( N ** 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT def Mods ( i , N , K ) : NEW_LINE INDENT lim = N // i NEW_LINE pattern = i - K NEW_LINE total = lim * pattern NEW_LINE if N - i * lim < K : NEW_LINE INDENT return total NEW_LINE DEDENT else : NEW_LINE INDENT extra = N - i * lim - K + 1 NEW_LINE return total + extra NEW_LINE DEDENT DEDENT for i in range ( K + 1 , N + 1 ) : NEW_LINE INDENT Ans += Mods ( i , N , K ) NEW_LINE DEDENT print ( Ans ) NEW_LINE DEDENT", "N , K = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE ans = 0 NEW_LINE for mod in range ( K + 1 , N + 1 ) : NEW_LINE INDENT ans += ( mod - K ) * ( N // mod ) + max ( N % mod - max ( K - 1 , 0 ) , 0 ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = ( n - k ) * ( n - k + 1 ) // 2 NEW_LINE for i in range ( k + 1 , n ) : NEW_LINE INDENT j = n // i * i NEW_LINE a += ( j // i - 1 ) * ( i - k ) + max ( n - j + 1 - max ( k , 1 ) , 0 ) NEW_LINE DEDENT print ( a ) NEW_LINE", "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE if K == 0 : print ( N ** 2 ) ; exit ( 0 ) NEW_LINE ans = ( N - K ) * ( N - K + 1 ) // 2 NEW_LINE for b in range ( K + 1 , N ) : NEW_LINE INDENT n = ( N - b + 1 ) // b NEW_LINE ans += ( n ) * ( b - K ) NEW_LINE if n * b + b - 1 != N : NEW_LINE INDENT if N % b >= K : NEW_LINE INDENT ans += N % b - K + 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc021_D
[ "import java . util . Scanner ; import java . util . Arrays ; class Main { static int dp [ ] [ ] [ ] = new int [ 301 ] [ 301 ] [ 301 ] ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; int K = scan . nextInt ( ) ; int N = S . length ( ) ; for ( int i = 0 ; i < N ; ++ i ) for ( int k = 0 ; k <= K ; ++ k ) { dp [ i ] [ i + 1 ] [ k ] = 1 ; dp [ i ] [ i ] [ k ] = 0 ; } for ( int k = 0 ; k <= K ; ++ k ) { for ( int L = 2 ; L <= N ; ++ L ) { int i = 0 , j = L ; while ( j <= N ) { if ( k == 0 ) dp [ i ] [ j ] [ k ] = Math . max ( dp [ i + 1 ] [ j ] [ k ] , Math . max ( dp [ i ] [ j - 1 ] [ k ] , ( ( S . charAt ( i ) == S . charAt ( j - 1 ) ? dp [ i + 1 ] [ j - 1 ] [ k ] + 2 : dp [ i + 1 ] [ j - 1 ] [ k ] ) ) ) ) ; else dp [ i ] [ j ] [ k ] = Math . max ( dp [ i + 1 ] [ j ] [ k ] , Math . max ( dp [ i ] [ j - 1 ] [ k ] , Math . max ( dp [ i ] [ j ] [ k - 1 ] , ( ( S . charAt ( i ) == S . charAt ( j - 1 ) ? dp [ i + 1 ] [ j - 1 ] [ k ] + 2 : dp [ i + 1 ] [ j - 1 ] [ k - 1 ] + 2 ) ) ) ) ) ; ++ i ; ++ j ; } } } System . out . println ( dp [ 0 ] [ N ] [ K ] ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Main { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; char s [ ] = sc . next ( ) . toCharArray ( ) ; int k = sc . nextInt ( ) ; int dp [ ] [ ] [ ] = new int [ s . length ] [ s . length ] [ k + 1 ] ; for ( int i = 0 ; i <= k ; i ++ ) { for ( int r = 0 ; r < s . length ; r ++ ) { for ( int l = r ; l >= 0 ; l -- ) { if ( l == r ) { dp [ l ] [ r ] [ i ] = 1 ; continue ; } if ( r == l + 1 ) { dp [ l ] [ r ] [ i ] = s [ l ] == s [ r ] || i > 0 ? 2 : 1 ; continue ; } if ( s [ l ] == s [ r ] ) { dp [ l ] [ r ] [ i ] = dp [ l + 1 ] [ r - 1 ] [ i ] + 2 ; } else { dp [ l ] [ r ] [ i ] = Math . max ( dp [ l + 1 ] [ r ] [ i ] , dp [ l ] [ r - 1 ] [ i ] ) ; } if ( i > 0 ) { dp [ l ] [ r ] [ i ] = Math . max ( dp [ l ] [ r ] [ i ] , dp [ l + 1 ] [ r - 1 ] [ i - 1 ] + 2 ) ; } } } } System . out . println ( dp [ 0 ] [ s . length - 1 ] [ k ] ) ; } }", "public class Main { static int dp [ ] [ ] [ ] ; static String s ; public static int solve ( int i , int j , int k ) { if ( dp [ i ] [ j ] [ k ] >= 0 ) return dp [ i ] [ j ] [ k ] ; else { int ans ; if ( i > j ) ans = 0 ; else if ( i == j ) ans = 1 ; else if ( s . charAt ( i ) == s . charAt ( j ) ) ans = solve ( i + 1 , j - 1 , k ) + 2 ; else { ans = solve ( i + 1 , j , k ) ; ans = Math . max ( ans , solve ( i , j - 1 , k ) ) ; if ( k > 0 ) ans = Math . max ( ans , solve ( i + 1 , j - 1 , k - 1 ) + 2 ) ; } dp [ i ] [ j ] [ k ] = ans ; return ans ; } } public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; s = scan . next ( ) ; int t = scan . nextInt ( ) ; dp = new int [ s . length ( ) ] [ s . length ( ) ] [ t + 1 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = 0 ; j < s . length ( ) ; j ++ ) { for ( int k = 0 ; k <= t ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; } } System . out . println ( solve ( 0 , s . length ( ) - 1 , t ) ) ; } }" ]
[ "def solve ( s , k ) : NEW_LINE INDENT n = len ( s ) NEW_LINE if k >= n // 2 : NEW_LINE INDENT return n NEW_LINE DEDENT dpp = [ [ 1 ] * ( k + 1 ) , [ 0 ] * ( k + 1 ) ] NEW_LINE for r in range ( 1 , n ) : NEW_LINE INDENT dpc = [ [ 0 ] * ( k + 1 ) for _ in range ( r + 2 ) ] NEW_LINE dpc [ r ] = [ 1 ] * ( k + 1 ) NEW_LINE for l in range ( r - 1 , - 1 , - 1 ) : NEW_LINE INDENT dpl , dpl1 = dpc [ l ] , dpp [ l + 1 ] NEW_LINE if s [ l ] == s [ r ] : NEW_LINE INDENT dpc [ l ] = [ c + 2 for c in dpl1 ] NEW_LINE DEDENT else : NEW_LINE INDENT dppl , dpcl1 = dpp [ l ] , dpc [ l + 1 ] NEW_LINE dpl [ 0 ] = max ( dppl [ 0 ] , dpcl1 [ 0 ] ) NEW_LINE for p in range ( 1 , k + 1 ) : NEW_LINE INDENT dpl [ p ] = max ( dppl [ p ] , dpcl1 [ p ] , dpl1 [ p - 1 ] + 2 ) NEW_LINE DEDENT DEDENT DEDENT dpp = dpc NEW_LINE DEDENT return dpp [ 0 ] [ k ] NEW_LINE DEDENT print ( solve ( input ( ) , int ( input ( ) ) ) ) NEW_LINE" ]
atcoder_abc120_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] A = new int [ M ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { A [ i ] [ 0 ] = sc . nextInt ( ) - 1 ; A [ i ] [ 1 ] = sc . nextInt ( ) - 1 ; } int [ ] [ ] B = new int [ N ] [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { B [ i ] [ 0 ] = i ; B [ i ] [ 1 ] = 1 ; } long [ ] inconv = new long [ M + 1 ] ; inconv [ M ] = ( long ) N * ( N - 1 ) / 2 ; for ( int i = M - 1 ; i >= 0 ; i -- ) { int v1 = A [ i ] [ 0 ] ; int v2 = A [ i ] [ 1 ] ; int l1 = findRoot ( B , B [ v1 ] [ 0 ] ) ; int l2 = findRoot ( B , B [ v2 ] [ 0 ] ) ; inconv [ i ] = inconv [ i + 1 ] ; if ( l1 != l2 ) { int s1 = B [ l1 ] [ 1 ] ; int s2 = B [ l2 ] [ 1 ] ; inconv [ i ] -= s1 * s2 ; if ( s1 < s2 ) { int temp = l1 ; l1 = l2 ; l2 = temp ; } B [ l1 ] [ 1 ] += B [ l2 ] [ 1 ] ; B [ l2 ] [ 0 ] = l1 ; B [ l2 ] [ 1 ] = 0 ; } } for ( int i = 1 ; i < M + 1 ; i ++ ) { System . out . println ( inconv [ i ] ) ; } } static private int findRoot ( int [ ] [ ] leaders , int n ) { if ( leaders [ n ] [ 0 ] == n ) return n ; return findRoot ( leaders , leaders [ n ] [ 0 ] ) ; } }", "import java . util . * ; import java . util . stream . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , m = scanner . nextInt ( ) , a [ ] = new int [ m ] , b [ ] = new int [ m ] , num [ ] = new int [ n + 1 ] ; long [ ] ans = new long [ m ] ; fa = IntStream . rangeClosed ( 0 , n ) . toArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; b [ i ] = scanner . nextInt ( ) ; } Arrays . fill ( num , 1 ) ; ans [ m - 1 ] = ( long ) n * ( n - 1 ) / 2 ; for ( int i = m - 1 ; i > 0 ; i -- ) { ans [ i - 1 ] = ans [ i ] ; if ( fd ( a [ i ] ) != fd ( b [ i ] ) ) { ans [ i - 1 ] -= num [ fa [ a [ i ] ] ] * num [ fa [ b [ i ] ] ] ; num [ fa [ b [ i ] ] ] += num [ fa [ a [ i ] ] ] ; fa [ fa [ a [ i ] ] ] = fa [ b [ i ] ] ; } } Arrays . stream ( ans ) . forEach ( System . out :: println ) ; } static int [ ] fa ; static int fd ( int a ) { return fa [ a ] == a ? a : ( fa [ a ] = fd ( fa [ a ] ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) - 1 ; b [ i ] = sc . nextInt ( ) - 1 ; } long [ ] answer = new long [ m ] ; answer [ m - 1 ] = ( long ) n * ( n - 1 ) / 2 ; UnionFind uf = new UnionFind ( n ) ; for ( int i = m - 1 ; i >= 1 ; i -- ) { answer [ i - 1 ] = answer [ i ] ; if ( uf . root ( a [ i ] ) != uf . root ( b [ i ] ) ) { answer [ i - 1 ] -= ( long ) uf . size ( a [ i ] ) * uf . size ( b [ i ] ) ; uf . connect ( a [ i ] , b [ i ] ) ; } } for ( int i = 0 ; i < m ; i ++ ) { System . out . println ( answer [ i ] ) ; } } } class UnionFind { private int [ ] parents ; UnionFind ( int n ) { parents = new int [ n ] ; Arrays . fill ( parents , - 1 ) ; } int size ( int node ) { return - parents [ root ( node ) ] ; } int root ( int node ) { if ( parents [ node ] < 0 ) return node ; else return parents [ node ] = root ( parents [ node ] ) ; } boolean connect ( int node1 , int node2 ) { int root1 = root ( node1 ) ; int root2 = root ( node2 ) ; if ( root1 == root2 ) return false ; else { if ( root1 < root2 ) { int temp = root1 ; root1 = root2 ; root2 = temp ; } parents [ root1 ] += parents [ root2 ] ; parents [ root2 ] = root1 ; return true ; } } }" ]
[ "class uf : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . table = [ - 1 ] * ( n + 1 ) NEW_LINE self . size = [ 1 ] * ( n + 1 ) NEW_LINE DEDENT def merge ( self , r1 , r2 ) : NEW_LINE INDENT self . table [ r1 ] = r2 NEW_LINE self . size [ r2 ] += self . size [ r1 ] NEW_LINE self . size [ r1 ] = 0 NEW_LINE DEDENT def find_root ( self , k ) : NEW_LINE INDENT path = [ ] NEW_LINE curr = k NEW_LINE while self . table [ curr ] != - 1 : NEW_LINE INDENT path . append ( curr ) NEW_LINE curr = self . table [ curr ] NEW_LINE DEDENT self . defrag ( curr , path ) NEW_LINE return curr , path NEW_LINE DEDENT def defrag ( self , r , p ) : NEW_LINE INDENT for i in p : NEW_LINE INDENT self . table [ i ] = r NEW_LINE DEDENT DEDENT DEDENT def solve ( string ) : NEW_LINE INDENT n , m , * ab = map ( int , string . split ( ) ) NEW_LINE ab = ab [ : : - 1 ] NEW_LINE ans = [ n * ( n - 1 ) // 2 ] NEW_LINE table = uf ( n ) NEW_LINE for _b , _a in zip ( ab [ : : 2 ] , ab [ 1 : : 2 ] ) : NEW_LINE INDENT r_a , _ = table . find_root ( _a ) NEW_LINE r_b , _ = table . find_root ( _b ) NEW_LINE if r_a == r_b : NEW_LINE INDENT ans . append ( ans [ - 1 ] ) NEW_LINE continue NEW_LINE DEDENT ans . append ( ans [ - 1 ] - table . size [ r_a ] * table . size [ r_b ] ) NEW_LINE table . merge ( r_a , r_b ) NEW_LINE DEDENT return \" \\n \" . join ( [ str ( a ) for a in ans [ : - 1 ] [ : : - 1 ] ] ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( ' { } ▁ { } \\n ' . format ( n , m ) + ' \\n ' . join ( [ input ( ) for _ in range ( m ) ] ) ) ) NEW_LINE DEDENT", "N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE bridge = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT bridge . append ( [ int ( i ) - 1 for i in input ( ) . split ( ) ] ) NEW_LINE DEDENT nod = [ [ i , [ i ] ] for i in range ( N ) ] NEW_LINE e = 0 NEW_LINE totale = int ( N * ( N - 1 ) / 2 ) NEW_LINE def joint ( a , b , e ) : NEW_LINE INDENT na = nod [ a ] [ 0 ] NEW_LINE nb = nod [ b ] [ 0 ] NEW_LINE if na == nb : NEW_LINE INDENT return e NEW_LINE DEDENT else : NEW_LINE INDENT e += len ( nod [ na ] [ 1 ] ) * len ( nod [ nb ] [ 1 ] ) NEW_LINE if na < nb : NEW_LINE INDENT nod [ na ] [ 1 ] . extend ( nod [ nb ] [ 1 ] ) NEW_LINE for i in nod [ nb ] [ 1 ] : NEW_LINE INDENT nod [ i ] [ 0 ] = na NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT nod [ nb ] [ 1 ] . extend ( nod [ na ] [ 1 ] ) NEW_LINE for i in nod [ na ] [ 1 ] : NEW_LINE INDENT nod [ i ] [ 0 ] = nb NEW_LINE DEDENT DEDENT return e NEW_LINE DEDENT DEDENT ans = [ ] NEW_LINE for i in range ( M - 1 , - 1 , - 1 ) : NEW_LINE INDENT ans . append ( totale - e ) NEW_LINE e = joint ( bridge [ i ] [ 0 ] , bridge [ i ] [ 1 ] , e ) NEW_LINE DEDENT for i in range ( M - 1 , - 1 , - 1 ) : NEW_LINE INDENT print ( ans [ i ] ) NEW_LINE DEDENT", "import numpy as np NEW_LINE def solve ( n , m , a , b ) : NEW_LINE INDENT p = [ - 1 ] * ( n + 1 ) NEW_LINE u = [ 1 ] * ( n + 1 ) NEW_LINE def find ( x ) : NEW_LINE INDENT if p [ x ] == - 1 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return find ( p [ x ] ) NEW_LINE DEDENT DEDENT total = n * ( n - 1 ) // 2 NEW_LINE res = [ total ] NEW_LINE for i in range ( m - 1 , 0 , - 1 ) : NEW_LINE INDENT x , y = a [ i ] , b [ i ] NEW_LINE px = find ( x ) NEW_LINE py = find ( y ) NEW_LINE if px > py : NEW_LINE INDENT px , py = py , px NEW_LINE DEDENT if px != py : NEW_LINE INDENT n1 = u [ px ] NEW_LINE n2 = u [ py ] NEW_LINE p [ py ] = px NEW_LINE u [ px ] = n1 + n2 NEW_LINE total -= n1 * n2 NEW_LINE DEDENT res . append ( total ) NEW_LINE DEDENT return res [ : : - 1 ] NEW_LINE DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = np . zeros ( m , dtype = int ) NEW_LINE b = np . zeros ( m , dtype = int ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT a [ i ] , b [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT print ( \" \\n \" . join ( map ( str , solve ( n , m , a , b ) ) ) ) NEW_LINE", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE AB = [ ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT A_i , B_i = map ( int , input ( ) . split ( ) ) NEW_LINE AB . append ( [ A_i , B_i ] ) NEW_LINE DEDENT class UnionFind ( ) : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . parent = [ - 1 for _ in range ( n ) ] NEW_LINE DEDENT def root ( self , x ) : NEW_LINE INDENT if self . parent [ x ] < 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT self . parent [ x ] = self . root ( self . parent [ x ] ) NEW_LINE return self . parent [ x ] NEW_LINE DEDENT DEDENT def size ( self , x ) : NEW_LINE INDENT x = self . root ( x ) NEW_LINE return - 1 * self . parent [ x ] NEW_LINE DEDENT def union ( self , x , y ) : NEW_LINE INDENT x = self . root ( x ) NEW_LINE y = self . root ( y ) NEW_LINE if x == y : NEW_LINE INDENT return False NEW_LINE DEDENT x_size = self . size ( x ) NEW_LINE y_size = self . size ( y ) NEW_LINE if x_size < y_size : NEW_LINE INDENT x , y = y , x NEW_LINE DEDENT self . parent [ x ] += self . parent [ y ] NEW_LINE self . parent [ y ] = x NEW_LINE return True NEW_LINE DEDENT DEDENT max_inconvenience = N * ( N - 1 ) // 2 NEW_LINE ans = [ max_inconvenience ] NEW_LINE uf = UnionFind ( N ) NEW_LINE for bridge in reversed ( AB ) : NEW_LINE INDENT x = uf . root ( bridge [ 0 ] - 1 ) NEW_LINE y = uf . root ( bridge [ 1 ] - 1 ) NEW_LINE if x != y : NEW_LINE INDENT x_size = uf . size ( x ) NEW_LINE y_size = uf . size ( y ) NEW_LINE ans_tmp = max_inconvenience - x_size * y_size NEW_LINE max_inconvenience = ans_tmp NEW_LINE uf . union ( x , y ) NEW_LINE DEDENT else : NEW_LINE INDENT ans_tmp = max_inconvenience NEW_LINE DEDENT ans . append ( ans_tmp ) NEW_LINE DEDENT for a in reversed ( ans [ : - 1 ] ) : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE a_list = [ ] NEW_LINE b_list = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE a_list . append ( a ) NEW_LINE b_list . append ( b ) NEW_LINE DEDENT par = [ i for i in range ( N + 1 ) ] NEW_LINE rank = [ 0 ] * ( N + 1 ) NEW_LINE size = [ 1 ] * ( N + 1 ) NEW_LINE def find ( x ) : NEW_LINE INDENT if par [ x ] == x : NEW_LINE INDENT return par [ x ] NEW_LINE DEDENT else : NEW_LINE INDENT par [ x ] = find ( par [ x ] ) NEW_LINE return par [ x ] NEW_LINE DEDENT DEDENT def unite ( x , y ) : NEW_LINE INDENT x_par = find ( x ) NEW_LINE y_par = find ( y ) NEW_LINE if x_par == y_par : NEW_LINE INDENT return NEW_LINE DEDENT if rank [ x_par ] < rank [ y_par ] : NEW_LINE INDENT par [ x_par ] = y_par NEW_LINE size [ y_par ] += size [ x_par ] NEW_LINE DEDENT else : NEW_LINE INDENT par [ y_par ] = x_par NEW_LINE size [ x_par ] += size [ y_par ] NEW_LINE if rank [ x_par ] == rank [ y_par ] : NEW_LINE INDENT rank [ x_par ] += 1 NEW_LINE DEDENT DEDENT DEDENT def bool_func ( x , y ) : NEW_LINE INDENT if find ( x ) == find ( y ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT ans_list = [ ] NEW_LINE ans = int ( N * ( N - 1 ) / 2 ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT ans_list . append ( ans ) NEW_LINE a = a_list [ M - 1 - i ] NEW_LINE b = b_list [ M - 1 - i ] NEW_LINE p = size [ find ( a ) ] NEW_LINE q = size [ find ( b ) ] NEW_LINE if bool_func ( a , b ) : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans -= p * q NEW_LINE unite ( a , b ) NEW_LINE DEDENT DEDENT for i in range ( M ) : NEW_LINE INDENT print ( ans_list [ M - 1 - i ] ) NEW_LINE DEDENT" ]
atcoder_arc006_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Amida amida = new Amida ( ) ; amida . startAmida ( ) ; amida . printHitLine ( ) ; } } class Amida { String [ ] [ ] amida ; int currentIndex ; int lineCount ; int rowCount ; public Amida ( ) { Scanner sc = new Scanner ( System . in ) ; this . lineCount = 2 * ( sc . nextInt ( ) ) - 1 ; this . rowCount = sc . nextInt ( ) ; this . amida = new String [ rowCount ] [ lineCount ] ; String [ ] tmpArr = new String [ rowCount + 1 ] ; for ( int i = rowCount ; i >= 0 ; i -- ) { tmpArr [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < rowCount ; i ++ ) { char [ ] charArr = tmpArr [ i ] . toCharArray ( ) ; for ( int j = 0 ; j < lineCount ; j ++ ) { this . amida [ i ] [ j ] = String . valueOf ( charArr [ j ] ) ; } } String currentPoint = sc . nextLine ( ) ; char [ ] currArr = currentPoint . toCharArray ( ) ; for ( int i = 0 ; i < currArr . length ; i ++ ) { if ( currArr [ i ] == \" o \" . toCharArray ( ) [ 0 ] ) { this . currentIndex = i ; } } } public void startAmida ( ) { for ( int i = 0 ; i < rowCount ; i ++ ) { if ( currentIndex < lineCount - 1 && amida [ i ] [ currentIndex + 1 ] . equalsIgnoreCase ( \" - \" ) ) { currentIndex += 2 ; } else if ( currentIndex > 0 && amida [ i ] [ currentIndex - 1 ] . equalsIgnoreCase ( \" - \" ) ) { currentIndex -= 2 ; } } } public void printHitLine ( ) { int ans = currentIndex / 2 + 1 ; System . out . println ( ans ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int l = in . nextInt ( ) ; in . nextLine ( ) ; String [ ] amida = new String [ l + 1 ] ; for ( int i = 0 ; i < l + 1 ; i ++ ) { amida [ i ] = in . nextLine ( ) ; } int pos = amida [ l ] . indexOf ( ' o ' ) ; for ( int i = l - 1 ; i >= 0 ; i -- ) { String s = amida [ i ] ; if ( pos > 0 && s . charAt ( pos - 1 ) == ' - ' ) pos -= 2 ; else if ( pos < s . length ( ) - 1 && s . charAt ( pos + 1 ) == ' - ' ) pos += 2 ; } out . println ( pos / 2 + 1 ) ; } } }", "import java . util . Collections ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { static Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static IntStream REPS ( int v ) { return IntStream . range ( 0 , v ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INS ( int n ) { return REPS ( n ) . map ( i -> getInt ( ) ) ; } static class Pair < T , U > { T l ; U r ; Pair ( T L , U R ) { l = L ; r = R ; } T getL ( ) { return l ; } U getR ( ) { return r ; } } public static void main ( String [ ] $ ) { int n = getInt ( ) , h = getInt ( ) ; s . nextLine ( ) ; List < Integer > l = REPS ( 1 , n ) . boxed ( ) . collect ( Collectors . toList ( ) ) ; for ( int i = 0 ; i < h ; ++ i ) { String in = s . nextLine ( ) . replaceAll ( \" [ | ] \" , \" \" ) ; for ( int j = 0 ; j < in . length ( ) ; ++ j ) { if ( in . charAt ( j ) == ' - ' ) Collections . swap ( l , j , j + 1 ) ; } } String e = s . nextLine ( ) ; for ( int i = 0 ; i < n ; ++ i ) if ( e . charAt ( i * 2 ) == ' o ' ) System . out . println ( l . get ( i ) ) ; } }", "import java . io . * ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 <= args . length ; debug2 = 2 <= args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] ia = in . readLine ( ) . split ( \" ▁ \" ) ; final int N = Integer . parseInt ( ia [ 0 ] ) ; final int L = Integer . parseInt ( ia [ 1 ] ) ; String [ ] lines = new String [ L ] ; for ( int i = 0 ; i < lines . length ; ++ i ) { lines [ i ] = in . readLine ( ) ; } int i = in . readLine ( ) . indexOf ( ' o ' ) ; for ( int n = L - 1 ; 0 <= n ; -- n ) { final int l = i - 1 ; final int r = i + 1 ; if ( 0 <= l && l < lines [ n ] . length ( ) && lines [ n ] . charAt ( l ) == ' - ' ) { i -= 2 ; } else if ( 0 <= r && r < lines [ n ] . length ( ) && lines [ n ] . charAt ( r ) == ' - ' ) { i += 2 ; } } System . out . println ( ( i + 2 ) / 2 ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Main { static int [ ] amida ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String a = br . readLine ( ) ; String [ ] b = a . split ( \" ▁ \" ) ; int N = Integer . parseInt ( b [ 0 ] ) ; int L = Integer . parseInt ( b [ 1 ] ) ; amida = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { amida [ i ] = i + 1 ; } for ( int i = 0 ; i < L ; i ++ ) { String s = br . readLine ( ) ; for ( int j = 0 ; j < N - 1 ; j ++ ) { if ( s . charAt ( 2 * j + 1 ) == ' - ' ) { swap ( j ) ; } } } String s = br . readLine ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( 2 * i ) == ' o ' ) { pl ( amida [ i ] ) ; break ; } } } static void swap ( int p ) { int a = amida [ p ] ; amida [ p ] = amida [ p + 1 ] ; amida [ p + 1 ] = a ; } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }" ]
[ "n , l = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ input ( ) for _ in range ( l ) ] NEW_LINE y = input ( ) NEW_LINE goal = 0 NEW_LINE while y [ goal ] != ' o ' : NEW_LINE INDENT goal += 2 NEW_LINE DEDENT goal //= 2 NEW_LINE for i in range ( n ) : NEW_LINE INDENT now = i NEW_LINE for ss in s : NEW_LINE INDENT if now != 0 and ss [ 2 * now - 1 ] == ' - ' : NEW_LINE INDENT now -= 1 NEW_LINE DEDENT elif now != n - 1 and ss [ 2 * now + 1 ] == ' - ' : NEW_LINE INDENT now += 1 NEW_LINE DEDENT DEDENT if now == goal : NEW_LINE INDENT print ( i + 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT", "from sys import stdin NEW_LINE input = stdin . readline NEW_LINE n , l = map ( int , input ( ) . split ( ) ) NEW_LINE L = [ ] NEW_LINE for _ in range ( l + 1 ) : NEW_LINE INDENT L_ = list ( input ( ) ) NEW_LINE L . append ( L_ ) NEW_LINE DEDENT now = L [ l ] . index ( \" o \" ) NEW_LINE for i in range ( l - 1 , - 1 , - 1 ) : NEW_LINE INDENT if L [ i ] [ now - 1 ] == \" - \" : NEW_LINE INDENT now -= 2 NEW_LINE DEDENT elif L [ i ] [ now + 1 ] == \" - \" : NEW_LINE INDENT now += 2 NEW_LINE DEDENT DEDENT print ( now // 2 + 1 ) NEW_LINE", "n , l = map ( int , input ( ) . split ( ) ) NEW_LINE line = [ ] NEW_LINE line . append ( \" ▁ \" ) NEW_LINE for i in range ( l + 1 ) : NEW_LINE INDENT line . append ( list ( input ( ) ) ) NEW_LINE DEDENT pos_ld = line [ l + 1 ] . index ( \" o \" ) NEW_LINE def route_amida ( line , length , width , n ) : NEW_LINE INDENT if width == 1 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT if length == 1 : NEW_LINE INDENT return int ( ( n + 2 ) / 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT if line [ length - 1 ] [ 1 ] == ' - ' : NEW_LINE INDENT n += 2 NEW_LINE DEDENT DEDENT elif n == 2 * width - 2 : NEW_LINE INDENT if line [ length - 1 ] [ 2 * width - 3 ] == ' - ' : NEW_LINE INDENT n -= 2 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if line [ length - 1 ] [ n + 1 ] == ' - ' : NEW_LINE INDENT n += 2 NEW_LINE DEDENT elif line [ length - 1 ] [ n - 1 ] == ' - ' : NEW_LINE INDENT n -= 2 NEW_LINE DEDENT DEDENT return route_amida ( line [ : length - 1 ] , ( length - 1 ) , width , n ) NEW_LINE DEDENT DEDENT DEDENT print ( route_amida ( line [ : l + 1 ] , l + 1 , n , pos_ld ) ) NEW_LINE", "N , L = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE b = [ input ( ) . split ( \" | \" ) for i in range ( L ) ] NEW_LINE x = input ( ) . find ( \" o \" ) // 2 + 1 NEW_LINE for y in range ( L - 1 , - 1 , - 1 ) : NEW_LINE INDENT if b [ y ] [ x - 1 ] == \" - \" : NEW_LINE INDENT x -= 1 NEW_LINE DEDENT elif b [ y ] [ x ] == \" - \" : NEW_LINE INDENT x += 1 NEW_LINE DEDENT DEDENT print ( x ) NEW_LINE", "N , L = map ( int , input ( ) . split ( ) ) NEW_LINE kuji = [ ] NEW_LINE for _ in range ( L ) : NEW_LINE INDENT kuji . append ( input ( ) ) NEW_LINE DEDENT atari = input ( ) NEW_LINE a_idx = atari . index ( ' o ' ) NEW_LINE kuji = kuji [ : : - 1 ] NEW_LINE for line in kuji : NEW_LINE INDENT try : NEW_LINE INDENT if line [ a_idx - 1 ] == ' - ' : NEW_LINE INDENT a_idx -= 2 NEW_LINE DEDENT elif line [ a_idx + 1 ] == ' - ' : NEW_LINE INDENT a_idx += 2 NEW_LINE DEDENT DEDENT except IndexError : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT if a_idx == 0 : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT elif a_idx == 2 : NEW_LINE INDENT print ( 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a_idx // 2 + 1 ) NEW_LINE DEDENT" ]
atcoder_arc015_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; double ans = ( double ) ( 9 * n ) / ( double ) 5 + 32 ; System . out . println ( ans ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( 32.0 + 9.0 / 5.0 * in . nextDouble ( ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; System . out . println ( ( 9.0 / 5 * n ) + 32 ) ; } private static boolean isDebug = System . getProperty ( \" sun . desktop \" ) != null ; private static void debug ( Object ... o ) { if ( isDebug ) { System . err . println ( Arrays . deepToString ( o ) ) ; } } }", "import java . io . * ; import java . math . * ; import java . text . * ; import java . util . * ; import java . util . regex . * ; public class Main { private static final Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int cel = scan . nextInt ( ) ; float mul = 9f / 5f ; System . out . println ( mul * cel + 32 ) ; } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double n = scanner . nextDouble ( ) ; double ans = 9 * n / 5 + 32 ; System . out . println ( ans ) ; } }" ]
[ "print ( 9 / 5 * ( int ( input ( ) ) ) + 32.0 ) NEW_LINE", "def ans ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE x = 9 / 5 * N + 32 NEW_LINE if ( x == int ( x ) ) : NEW_LINE INDENT print ( int ( x ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT ans ( ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE n = int ( input ( ) ) NEW_LINE print ( 9 / 5 * n + 32 ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE print ( 9 * n / 5 + 32 ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "print ( int ( input ( ) ) * 1.8 + 32 ) NEW_LINE" ]
atcoder_abc122_D
[ "import java . io . * ; class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; int N = Integer . parseInt ( str ) ; long mod = 1_000_000_007 ; long [ ] [ ] [ ] [ ] dp = new long [ N + 1 ] [ 4 ] [ 4 ] [ 4 ] ; dp [ 0 ] [ 3 ] [ 3 ] [ 3 ] = 1 ; for ( int len = 0 ; len < N ; len ++ ) { for ( int c1 = 0 ; c1 < 4 ; c1 ++ ) { for ( int c2 = 0 ; c2 < 4 ; c2 ++ ) { for ( int c3 = 0 ; c3 < 4 ; c3 ++ ) { if ( dp [ len ] [ c1 ] [ c2 ] [ c3 ] == 0 ) { continue ; } for ( int a = 0 ; a < 4 ; a ++ ) { if ( a == 2 && c1 == 1 && c2 == 0 ) { continue ; } else if ( a == 2 && c1 == 0 && c2 == 1 ) { continue ; } else if ( a == 1 && c1 == 2 && c2 == 0 ) { continue ; } else if ( a == 2 && c1 == 1 && c3 == 0 ) { continue ; } else if ( a == 2 && c2 == 1 && c3 == 0 ) { continue ; } dp [ len + 1 ] [ a ] [ c1 ] [ c2 ] += dp [ len ] [ c1 ] [ c2 ] [ c3 ] ; dp [ len + 1 ] [ a ] [ c1 ] [ c2 ] %= mod ; } } } } } long ans = 0 ; for ( int c1 = 0 ; c1 < 4 ; c1 ++ ) { for ( int c2 = 0 ; c2 < 4 ; c2 ++ ) { for ( int c3 = 0 ; c3 < 4 ; c3 ++ ) { ans += dp [ N ] [ c1 ] [ c2 ] [ c3 ] ; } } } System . out . println ( ans %= mod ) ; } }", "public class Main { private static long [ ] [ ] [ ] [ ] memo = new long [ 101 ] [ 85 ] [ 85 ] [ 85 ] ; public static void main ( String [ ] $ ) { System . out . println ( dfs ( new java . util . Scanner ( System . in ) . nextInt ( ) , ' ▁ ' , ' ▁ ' , ' ▁ ' ) ) ; } private static long dfs ( int r , char l1 , char l2 , char l3 ) { return memo [ r ] [ l1 ] [ l2 ] [ l3 ] != 0 ? memo [ r ] [ l1 ] [ l2 ] [ l3 ] : ( memo [ r ] [ l1 ] [ l2 ] [ l3 ] = ( ( r == 1 ? 2 : dfs ( r - 1 , l2 , l3 , ' A ' ) + dfs ( r - 1 , l2 , l3 , ' T ' ) ) + ( l2 != ' G ' && l3 != ' G ' || l1 != ' A ' && l2 != ' A ' && l3 != ' A ' ? r == 1 ? 1 : dfs ( r - 1 , l2 , l3 , ' C ' ) : 0 ) + ( l2 != ' A ' || l3 != ' C ' ? r == 1 ? 1 : dfs ( r - 1 , l2 , l3 , ' G ' ) : 0 ) ) % 1000000007 ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long answer = 0 ; long [ ] [ ] dp = new long [ n + 1 ] [ 4 ] ; dp [ 1 ] = new long [ ] { 1 , 1 , 1 , 1 } ; dp [ 2 ] = new long [ ] { 4 , 4 , 4 , 4 } ; dp [ 3 ] = new long [ ] { 16 , 14 , 15 , 16 } ; if ( n >= 4 ) { for ( int i = 4 ; i <= n ; i ++ ) { long sum = 0 ; for ( int j = 0 ; j < 4 ; j ++ ) { sum += dp [ i - 1 ] [ j ] ; } sum %= 1000000007 ; dp [ i ] [ 0 ] = sum ; dp [ i ] [ 3 ] = sum ; dp [ i ] [ 1 ] = sum - dp [ i - 2 ] [ 0 ] - dp [ i - 2 ] [ 2 ] - dp [ i - 3 ] [ 0 ] * 3 ; dp [ i ] [ 2 ] = sum - dp [ i - 2 ] [ 0 ] + dp [ i - 3 ] [ 2 ] ; sum = 0 ; } } for ( int j = 0 ; j < 4 ; j ++ ) { answer += dp [ n ] [ j ] ; } answer %= 1000000007 ; System . out . println ( answer ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { final int A = 0 , C = 1 , G = 2 , T = 3 , mod = 1000000007 ; PrintWriter out = new PrintWriter ( System . out ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] [ ] [ ] [ ] dp = new int [ 111 ] [ 4 ] [ 4 ] [ 4 ] ; int ans = 0 ; dp [ 0 ] [ 0 ] [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { for ( int l = 0 ; l < 4 ; l ++ ) { for ( int m = 0 ; m < 4 ; m ++ ) { if ( i > 2 ) { if ( k == A && l == G && m == C ) continue ; if ( k == A && l == C && m == G ) continue ; if ( k == G && l == A && m == C ) continue ; } if ( i > 3 ) { if ( j == A && l == G && m == C ) continue ; if ( j == A && k == G && m == C ) continue ; } dp [ i ] [ k ] [ l ] [ m ] += dp [ i - 1 ] [ j ] [ k ] [ l ] ; dp [ i ] [ k ] [ l ] [ m ] %= mod ; } } } } } for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { ans += dp [ n ] [ i ] [ j ] [ k ] ; ans %= mod ; } } } out . println ( ans ) ; out . flush ( ) ; } }", "import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; public class Main { private static int N = 0 ; private static long MOD = 1000000007L ; private static List < Map < String , Long > > memo = new ArrayList < Map < String , Long > > ( ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; for ( int i = 0 ; i <= N ; i ++ ) { memo . add ( new HashMap < String , Long > ( ) ) ; } System . out . println ( dfs ( 0 , \" TTT \" ) ) ; } private static boolean ok ( String last4 ) { for ( int i = 0 ; i < 4 ; i ++ ) { char [ ] t = last4 . toCharArray ( ) ; if ( i >= 1 ) { char buf = t [ i - 1 ] ; t [ i - 1 ] = t [ i ] ; t [ i ] = buf ; } if ( String . valueOf ( t ) . indexOf ( \" AGC \" ) >= 0 ) { return false ; } } return true ; } private static long dfs ( int cur , String last3 ) { if ( memo . get ( cur ) . containsKey ( last3 ) ) { return memo . get ( cur ) . get ( last3 ) ; } if ( cur == N ) { return 1 ; } long ret = 0 ; char [ ] cList = { ' A ' , ' C ' , ' G ' , ' T ' } ; for ( char c : cList ) { if ( ok ( last3 + c ) ) { ret = ( ret + dfs ( cur + 1 , last3 . substring ( 1 ) + c ) ) % MOD ; } } memo . get ( cur ) . put ( last3 , ret ) ; return ret ; } }" ]
[ "MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE countA = 4 NEW_LINE countG = 4 NEW_LINE countAG = 1 NEW_LINE countGA = 1 NEW_LINE countAC = 1 NEW_LINE countAGX = 0 NEW_LINE countAXG = 0 NEW_LINE countAT = 1 NEW_LINE ans = 16 NEW_LINE nextnums = [ 0 for _ in range ( 7 ) ] NEW_LINE for i in range ( N - 2 ) : NEW_LINE INDENT nextans = ans * 4 - countAG - countGA - countAC - countAXG - countAGX NEW_LINE nextA = ans NEW_LINE nextG = ans - countAC NEW_LINE nextAG = countA NEW_LINE nextGA = countG NEW_LINE nextAC = countA - countGA NEW_LINE nextAGX = 2 * countAG NEW_LINE nextAXG = countAT NEW_LINE nextAT = countA NEW_LINE ans = nextans % MOD NEW_LINE countA = nextA % MOD NEW_LINE countAC = nextAC % MOD NEW_LINE countAG = nextAG % MOD NEW_LINE countAGX = nextAGX % MOD NEW_LINE countAT = nextAT % MOD NEW_LINE countAXG = nextAXG % MOD NEW_LINE countG = nextG % MOD NEW_LINE countGA = nextGA % MOD NEW_LINE DEDENT print ( ans ) NEW_LINE", "import itertools NEW_LINE N = int ( input ( ) ) NEW_LINE AGCs = [ ' AGC ' , ' GAC ' , ' ACG ' , ' AGAC ' , ' AGGC ' , ' AGTC ' , ' ACGC ' , ' ATGC ' , ] NEW_LINE seq = [ \" A \" , \" G \" , \" C \" , \" T \" ] NEW_LINE from collections import Counter NEW_LINE memo = Counter ( ) NEW_LINE count = 0 NEW_LINE new_S = [ ] NEW_LINE def memo_saiki ( n , start_memo ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT print ( 4 ) NEW_LINE exit ( ) NEW_LINE DEDENT if n == 2 : NEW_LINE INDENT print ( 16 ) NEW_LINE exit ( ) NEW_LINE DEDENT memo = start_memo NEW_LINE new_memo = Counter ( ) NEW_LINE for _ in range ( n - 3 ) : NEW_LINE INDENT for k , v in memo . items ( ) : NEW_LINE INDENT for char in ' AGCT ' : NEW_LINE INDENT target = k + char NEW_LINE if any ( [ agc in target for agc in AGCs ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT new_memo . update ( { target [ - 3 : ] : v } ) NEW_LINE DEDENT DEDENT memo = new_memo NEW_LINE new_memo = Counter ( ) NEW_LINE DEDENT print ( sum ( [ v for v in memo . values ( ) ] ) % ( 10 ** 9 + 7 ) ) NEW_LINE DEDENT def saiki ( n = 6 ) : NEW_LINE INDENT S = [ ' ' ] NEW_LINE new_S = [ ] NEW_LINE memo = { } NEW_LINE for _ in range ( n ) : NEW_LINE INDENT for i , s in enumerate ( S ) : NEW_LINE INDENT for c in ' AGCT ' : NEW_LINE INDENT memo [ s [ - 3 : ] ] = 1 NEW_LINE hoge = s [ - 3 : ] + c NEW_LINE if any ( [ agc in hoge for agc in AGCs ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT new_S . append ( hoge ) NEW_LINE DEDENT DEDENT S = new_S NEW_LINE new_S = [ ] NEW_LINE DEDENT return S NEW_LINE DEDENT memo_saiki ( n = N , start_memo = Counter ( saiki ( 3 ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE MOD = int ( 1e9 + 7 ) NEW_LINE tokens = [ ' A ' , ' C ' , ' G ' , ' T ' ] NEW_LINE suffixes = [ ] NEW_LINE for suffix_1 in tokens : NEW_LINE INDENT for suffix_2 in tokens : NEW_LINE INDENT for suffix_3 in tokens : NEW_LINE INDENT suffixes . append ( suffix_1 + suffix_2 + suffix_3 ) NEW_LINE DEDENT DEDENT DEDENT dp = [ [ 0 for _ in suffixes ] for _ in range ( N + 1 ) ] NEW_LINE reverse_index = { } NEW_LINE for i , s in enumerate ( suffixes ) : NEW_LINE INDENT reverse_index [ s ] = i NEW_LINE DEDENT def pprint ( dp ) : NEW_LINE INDENT N = len ( dp ) NEW_LINE M = len ( dp [ 0 ] ) NEW_LINE for i in dp : NEW_LINE INDENT st = \" \" NEW_LINE for j in i : NEW_LINE INDENT st += str ( j ) NEW_LINE st += \" ▁ \" NEW_LINE DEDENT print ( st ) NEW_LINE DEDENT DEDENT for i , s in enumerate ( suffixes ) : NEW_LINE INDENT if not s in [ ' AGC ' , ' ACG ' , ' GAC ' ] : NEW_LINE INDENT dp [ 3 ] [ i ] = 1 NEW_LINE DEDENT DEDENT valid_str_4 = set ( ) NEW_LINE def swap ( s , i , j ) : NEW_LINE INDENT s_new = list ( s ) NEW_LINE s_new [ i ] , s_new [ j ] = s [ j ] , s [ i ] NEW_LINE return ' ' . join ( s_new ) NEW_LINE DEDENT def valid ( str4 ) : NEW_LINE INDENT if ' AGC ' in str4 : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( 3 ) : NEW_LINE INDENT s_new = swap ( str4 , i , i + 1 ) NEW_LINE if ' AGC ' in s_new : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT for s in suffixes : NEW_LINE INDENT for c in tokens : NEW_LINE INDENT ss = s + c NEW_LINE if valid ( ss ) : NEW_LINE INDENT valid_str_4 . add ( ss ) NEW_LINE DEDENT DEDENT DEDENT for n in range ( 4 , N + 1 ) : NEW_LINE INDENT for s in suffixes : NEW_LINE INDENT for c in tokens : NEW_LINE INDENT ss = s + c NEW_LINE if ss in valid_str_4 : NEW_LINE INDENT dp [ n ] [ reverse_index [ ss [ 1 : ] ] ] += dp [ n - 1 ] [ reverse_index [ s ] ] NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( sum ( dp [ N ] ) % MOD ) NEW_LINE", "import sys NEW_LINE import numpy as np NEW_LINE readInt = lambda : int ( sys . stdin . readline ( ) ) NEW_LINE readIntN = lambda : [ int ( v ) for v in sys . stdin . readline ( ) . split ( \" ▁ \" ) ] NEW_LINE n = readInt ( ) NEW_LINE M = 10 ** 9 + 7 NEW_LINE dp = np . zeros ( ( n + 1 , 256 ) , dtype = np . uint32 ) NEW_LINE dp [ 0 , 255 ] = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j4 in [ 0 , 64 , 128 , 192 ] : NEW_LINE INDENT for j3 in [ 0 , 16 , 32 , 48 ] : NEW_LINE INDENT j43 = j4 + j3 NEW_LINE for j2 in [ 0 , 4 , 8 , 12 ] : NEW_LINE INDENT j432 = j43 + j2 NEW_LINE for j1 in range ( 4 ) : NEW_LINE INDENT j = j432 + j1 NEW_LINE l321 = 4 * ( j3 + j2 + j1 ) NEW_LINE for l0 in range ( 4 ) : NEW_LINE INDENT if ( 6 == ( j3 + 4 * j1 + l0 ) ) or ( 6 == ( j3 + j2 + l0 ) ) or ( 6 == ( 4 * j2 + 4 * j1 + l0 ) ) or ( 6 == ( 16 * j1 + j2 + l0 ) ) or ( 6 == ( 4 * j2 + 4 * l0 + j1 ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT l = l321 + l0 NEW_LINE dp [ i + 1 , l ] = ( dp [ i + 1 , l ] + dp [ i , j ] ) % M NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT ret = 0 NEW_LINE for v in dp [ - 1 ] : NEW_LINE INDENT ret = ( ret + v ) % M NEW_LINE DEDENT print ( ret ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE mod = 1000000007 NEW_LINE data = dict ( [ ( i + j + k , 1 ) for i in ' ACGT ' for j in ' AGCT ' for k in ' ACGT ' ] ) NEW_LINE data [ ' AGC ' ] = 0 NEW_LINE data [ ' ACG ' ] = 0 NEW_LINE data [ ' GAC ' ] = 0 NEW_LINE def check ( text ) : NEW_LINE INDENT if ' AGC ' in text : NEW_LINE INDENT return False NEW_LINE DEDENT if ' AGC ' in text [ 1 ] + text [ 0 ] + text [ 2 ] + text [ 3 ] : NEW_LINE INDENT return False NEW_LINE DEDENT if ' AGC ' in text [ 0 ] + text [ 2 ] + text [ 1 ] + text [ 3 ] : NEW_LINE INDENT return False NEW_LINE DEDENT if ' AGC ' in text [ 0 ] + text [ 1 ] + text [ 3 ] + text [ 2 ] : NEW_LINE INDENT return False NEW_LINE DEDENT else : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT for x in range ( 0 , N - 3 ) : NEW_LINE INDENT new_data = dict ( [ ( i + j + k , 0 ) for i in ' ACGT ' for j in ' AGCT ' for k in ' ACGT ' ] ) NEW_LINE for y in data . keys ( ) : NEW_LINE INDENT for z in ' ACGT ' : NEW_LINE INDENT if check ( y + z ) : NEW_LINE INDENT new_data [ y [ 1 : ] + z ] += data [ y ] % mod NEW_LINE DEDENT DEDENT DEDENT data = new_data . copy ( ) NEW_LINE DEDENT print ( sum ( data . values ( ) ) % mod ) NEW_LINE" ]
atcoder_abc077_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String c1 = sc . next ( ) ; String c2 = sc . next ( ) ; if ( c1 . charAt ( 0 ) == c2 . charAt ( 2 ) && c1 . charAt ( 1 ) == c2 . charAt ( 1 ) && c1 . charAt ( 2 ) == c2 . charAt ( 0 ) ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word1 = input . readLine ( ) ; String word2 = input . readLine ( ) ; boolean state = true ; for ( int i = 0 , j = word2 . length ( ) - 1 ; i < word1 . length ( ) ; i ++ , j -- ) { if ( word1 . charAt ( i ) != word2 . charAt ( j ) ) { state = false ; break ; } } if ( state ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; char [ ] a = scn . nextLine ( ) . toCharArray ( ) ; char [ ] b = scn . nextLine ( ) . toCharArray ( ) ; boolean ans = true ; for ( int i = 0 ; i < 3 ; i ++ ) { ans &= a [ i ] == b [ 2 - i ] ; } System . out . println ( ans ? \" YES \" : \" NO \" ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . nextLine ( ) ; String b = sc . nextLine ( ) ; String c11 = a . substring ( 0 , 1 ) ; String c12 = a . substring ( 1 , 2 ) ; String c13 = a . substring ( 2 , 3 ) ; String c21 = b . substring ( 0 , 1 ) ; String c22 = b . substring ( 1 , 2 ) ; String c23 = b . substring ( 2 , 3 ) ; if ( c11 . equals ( c23 ) && c12 . equals ( c22 ) && c13 . equals ( c21 ) ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; char [ ] c1 = sc . next ( ) . toCharArray ( ) ; char [ ] c2 = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; boolean ans = false ; if ( c1 [ 0 ] == c2 [ 2 ] && c1 [ 1 ] == c2 [ 1 ] && c1 [ 2 ] == c2 [ 0 ] ) ans = true ; System . out . println ( ans ? \" YES \" : \" NO \" ) ; } }" ]
[ "C1 = input ( ) NEW_LINE C2 = input ( ) NEW_LINE C1a = C1 [ 2 ] + C1 [ 1 ] + C1 [ 0 ] NEW_LINE C2a = C2 [ 2 ] + C2 [ 1 ] + C2 [ 0 ] NEW_LINE if C1 == C2a and C2 == C1a : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT", "s = [ input ( ) for _ in [ 0 , 0 ] ] ; print ( \" YNEOS \" [ s [ 0 ] [ 0 ] != s [ 1 ] [ 2 ] or s [ 0 ] [ 1 ] != s [ 1 ] [ 1 ] or s [ 0 ] [ 2 ] != s [ 1 ] [ 0 ] : : 2 ] ) NEW_LINE", "import numpy as np NEW_LINE C = np . array ( [ list ( input ( ) ) for i in range ( 2 ) ] ) NEW_LINE C_r = np . array ( [ [ '0' ] * 3 for i in range ( 2 ) ] ) NEW_LINE for i in range ( 2 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT C_r [ 1 - i , 2 - j ] = C [ i , j ] NEW_LINE DEDENT DEDENT if np . all ( C == C_r ) : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT", "print ( [ \" YES \" , \" NO \" ] [ not ( \" \" . join ( reversed ( input ( ) ) ) == input ( ) ) ] ) NEW_LINE", "c1 = input ( ) NEW_LINE c2 = input ( ) NEW_LINE print ( ' YES ' if c1 == c2 [ : : - 1 ] else ' NO ' ) NEW_LINE" ]
atcoder_arc021_B
[ "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int L = sc . nextInt ( ) ; int [ ] a = new int [ L ] ; int [ ] b = new int [ L ] ; for ( int i = 0 ; i < L ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } int xor = b [ 0 ] ^ b [ 1 ] ; for ( int i = 2 ; i < L - 1 ; i ++ ) { xor = xor ^ b [ i ] ; } if ( L == 2 && b [ 0 ] != b [ 1 ] ) { System . out . println ( - 1 ) ; } else if ( L != 2 && b [ L - 1 ] != xor ) { System . out . println ( - 1 ) ; } else { a [ 0 ] = 0 ; System . out . println ( a [ 0 ] ) ; for ( int i = 1 ; i < L ; i ++ ) { a [ i ] = a [ i - 1 ] ^ b [ i - 1 ] ; System . out . println ( a [ i ] ) ; } } } }", "import java . util . * ; public class Main { private static int L ; private static int b [ ] ; private static int a [ ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; L = scan . nextInt ( ) ; b = new int [ L ] ; a = new int [ L ] ; for ( int i = 0 ; i < L ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } } public static void main ( String args [ ] ) { input ( ) ; boolean flag = true ; int xor = b [ 0 ] ^ b [ 1 ] ; for ( int i = 2 ; i < L - 1 ; i ++ ) { xor = xor ^ b [ i ] ; } if ( L == 2 && b [ 0 ] != b [ 1 ] ) { System . out . println ( - 1 ) ; flag = false ; } if ( L != 2 && b [ L - 1 ] != xor ) { System . out . println ( - 1 ) ; flag = false ; } if ( flag ) { a [ 0 ] = 0 ; System . out . println ( a [ 0 ] ) ; for ( int i = 1 ; i < L ; i ++ ) { a [ i ] = a [ i - 1 ] ^ b [ i - 1 ] ; System . out . println ( a [ i ] ) ; } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int L = sc . nextInt ( ) ; int [ ] B = new int [ L + 2 ] ; int check = 0 ; for ( int i = 0 ; i < L ; i ++ ) { B [ i ] = sc . nextInt ( ) ; if ( i != L - 1 ) check = check ^ B [ i ] ; } if ( check != B [ L - 1 ] ) { System . out . println ( - 1 ) ; return ; } int A [ ] = new int [ L + 2 ] ; A [ 0 ] = 0 ; for ( int i = 1 ; i < L - 1 ; i ++ ) { A [ i ] = A [ i - 1 ] ^ B [ i - 1 ] ; } A [ L - 1 ] = A [ 0 ] ^ B [ L - 1 ] ; for ( int i = 0 ; i < L ; i ++ ) { System . out . println ( A [ i ] ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE b = [ int ( input ( ) ) for _ in range ( n ) ] NEW_LINE l = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT l [ i + 1 ] = l [ i ] ^ b [ i ] NEW_LINE DEDENT if l [ - 1 ] != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT l . pop ( ) NEW_LINE for i in l : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT", "def b_xored ( L , B ) : NEW_LINE INDENT a = [ 0 ] * L NEW_LINE for k in range ( L - 1 ) : NEW_LINE INDENT a [ k + 1 ] = B [ k ] ^ a [ k ] NEW_LINE DEDENT ans = ' \\n ' . join ( map ( str , a ) ) if B [ L - 1 ] ^ a [ L - 1 ] == a [ 0 ] else ' - 1' NEW_LINE return ans NEW_LINE DEDENT L = int ( input ( ) ) NEW_LINE B = [ int ( input ( ) ) for _ in [ 0 ] * L ] NEW_LINE print ( b_xored ( L , B ) ) NEW_LINE", "L , * B = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE s = 0 NEW_LINE for b in B : NEW_LINE INDENT s ^= b NEW_LINE DEDENT if s != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT e = 0 NEW_LINE ans = [ 0 ] NEW_LINE for i in range ( L - 1 ) : NEW_LINE INDENT e ^= B [ i ] NEW_LINE ans . append ( e ) NEW_LINE DEDENT print ( * ans , sep = ' \\n ' ) NEW_LINE", "def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE L = int ( input ( ) ) NEW_LINE B = [ int ( input ( ) ) for _ in range ( L ) ] NEW_LINE A = [ 0 ] * L NEW_LINE for i in range ( 1 , L ) : NEW_LINE INDENT A [ i ] = A [ i - 1 ] ^ B [ i - 1 ] NEW_LINE DEDENT if A [ - 1 ] ^ B [ - 1 ] == A [ 0 ] : NEW_LINE INDENT print ( * A , sep = \" \\n \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT", "L = int ( input ( ) ) NEW_LINE B = [ int ( input ( ) ) for _ in range ( L ) ] NEW_LINE z = B [ 0 ] NEW_LINE for y in B [ 1 : ] : NEW_LINE INDENT z = z ^ y NEW_LINE DEDENT if z == 0 : NEW_LINE INDENT g = 0 NEW_LINE A = [ 0 ] NEW_LINE for c in B : NEW_LINE INDENT g = g ^ c NEW_LINE A . append ( g ) NEW_LINE DEDENT for t in A [ : - 1 ] : NEW_LINE INDENT print ( t ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT" ]
atcoder_arc057_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int [ ] b = new int [ N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i + 1 ] = b [ i ] + a [ i ] ; } if ( b [ N ] == K ) { System . out . println ( 1 ) ; sc . close ( ) ; return ; } int [ ] [ ] dp = new int [ N + 1 ] [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) Arrays . fill ( dp [ i ] , Integer . MAX_VALUE ) ; dp [ 0 ] [ 0 ] = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { dp [ i + 1 ] [ j ] = Math . min ( dp [ i + 1 ] [ j ] , dp [ i ] [ j ] ) ; long x = i == 0 ? 1 : ( long ) dp [ i ] [ j ] * a [ i ] / b [ i ] + 1 ; if ( x <= a [ i ] ) dp [ i + 1 ] [ j + 1 ] = Math . min ( dp [ i + 1 ] [ j + 1 ] , dp [ i ] [ j ] + ( int ) x ) ; } } int ans = 0 ; for ( int i = 1 ; i <= N ; i ++ ) if ( dp [ N ] [ i ] <= K ) ans = i ; System . out . println ( ans ) ; sc . close ( ) ; } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; int [ ] a = new int [ N + 1 ] ; long [ ] sum = new long [ N + 1 ] ; for ( int i = 1 ; i < a . length ; i ++ ) { a [ i ] = sc . nextInt ( ) ; sum [ i ] = sum [ i - 1 ] + a [ i ] ; } long [ ] [ ] dp = new long [ N + 1 ] [ N + 1 ] ; for ( long [ ] v : dp ) Arrays . fill ( v , Long . MAX_VALUE ) ; dp [ 1 ] [ 0 ] = 0 ; dp [ 1 ] [ 1 ] = 1 ; for ( int j = 1 ; j < N ; j ++ ) { for ( int i = 0 ; i <= j ; i ++ ) { if ( dp [ j ] [ i ] < Long . MAX_VALUE ) { dp [ j + 1 ] [ i ] = Math . min ( dp [ j ] [ i ] , dp [ j + 1 ] [ i ] ) ; long temp = dp [ j ] [ i ] * a [ j + 1 ] / sum [ j ] + 1 ; if ( temp <= a [ j + 1 ] ) dp [ j + 1 ] [ i + 1 ] = Math . min ( dp [ j ] [ i ] + temp , dp [ j + 1 ] [ i + 1 ] ) ; } } } if ( sum [ N ] == K ) { System . out . println ( \"1\" ) ; } else { int max = 0 ; for ( int i = 0 ; i < dp [ N ] . length ; i ++ ) { if ( dp [ N ] [ i ] <= K ) max = Math . max ( max , i ) ; } System . out . println ( max ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int k = s . nextInt ( ) ; int [ ] as = new int [ n ] ; long [ ] asum = new long [ n + 1 ] ; asum [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { long a = s . nextLong ( ) ; asum [ i ] = asum [ i - 1 ] + a ; } if ( asum [ n ] == k ) { System . out . println ( 1 ) ; return ; } long [ ] [ ] dptable = new long [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { dptable [ i ] [ j ] = Long . MAX_VALUE ; } } dptable [ 0 ] [ 0 ] = 0 ; dptable [ 1 ] [ 0 ] = 0 ; dptable [ 1 ] [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { dptable [ i ] [ 0 ] = 0 ; for ( int j = 1 ; j <= i ; j ++ ) { dptable [ i ] [ j ] = dptable [ i - 1 ] [ j ] ; if ( dptable [ i - 1 ] [ j - 1 ] < Long . MAX_VALUE ) { long temp = dptable [ i - 1 ] [ j - 1 ] * asum [ i ] / asum [ i - 1 ] + 1 ; if ( temp - dptable [ i - 1 ] [ j - 1 ] <= asum [ i ] - asum [ i - 1 ] ) { dptable [ i ] [ j ] = Math . min ( dptable [ i ] [ j ] , temp ) ; } } } } for ( int i = 0 ; i < n ; i ++ ) { if ( dptable [ n ] [ i + 1 ] > k ) { System . out . println ( i ) ; return ; } } System . out . println ( n ) ; } }" ]
[ "from itertools import accumulate NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ int ( input ( ) ) for _ in [ 0 ] * N ] NEW_LINE if sum ( a ) == K or K == 0 : NEW_LINE INDENT print ( int ( K > 0 ) ) NEW_LINE exit ( ) NEW_LINE DEDENT inf , acc = float ( \" inf \" ) , tuple ( accumulate ( a ) ) NEW_LINE dp = [ inf ] * ( N + 1 ) NEW_LINE dp [ 1 ] = 1 NEW_LINE for i , ( p_game , c_game ) in enumerate ( zip ( acc , acc [ 1 : ] ) , start = 2 ) : NEW_LINE INDENT for j , win in zip ( range ( i + 1 , 0 , - 1 ) , dp [ i : : - 1 ] ) : NEW_LINE INDENT req = ( c_game * win ) // p_game + 1 NEW_LINE if req <= K and req <= c_game : NEW_LINE INDENT dp [ j ] = min ( dp [ j ] , req ) NEW_LINE DEDENT DEDENT DEDENT for i , n in zip ( range ( N , 0 , - 1 ) , dp [ : : - 1 ] ) : NEW_LINE INDENT if n < inf : NEW_LINE INDENT print ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE if sum ( A ) == K : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT inf = 10 ** 18 NEW_LINE dp = [ inf ] * ( N + 1 ) NEW_LINE dp [ 0 ] = 0 NEW_LINE asum = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT a = A [ i ] NEW_LINE for j in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT if dp [ j ] == inf : NEW_LINE INDENT continue NEW_LINE DEDENT k = ( a * dp [ j ] // asum + 1 ) if asum else 1 NEW_LINE if k <= a : NEW_LINE INDENT dp [ j + 1 ] = min ( dp [ j + 1 ] , dp [ j ] + k ) NEW_LINE DEDENT DEDENT asum += a NEW_LINE DEDENT if sum ( A ) != K : NEW_LINE INDENT print ( sum ( x <= K for x in dp ) - 1 ) NEW_LINE DEDENT", "from math import ceil NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ int ( input ( ) ) for _ in [ None ] * N ] NEW_LINE if K == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT elif N == 1 or sum ( a ) == K : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT inf = float ( \" inf \" ) NEW_LINE dp = [ inf ] * ( ( N - 1 ) * N ) NEW_LINE dp [ 0 ] = 0 NEW_LINE dp [ 1 ] = 1 NEW_LINE result = 1 NEW_LINE old_total = a [ 0 ] NEW_LINE for i in range ( 1 , N - 1 ) : NEW_LINE INDENT new_total = old_total + a [ i ] NEW_LINE m = new_total / old_total NEW_LINE next_max = i * N + result NEW_LINE next_min = max ( next_max - ( N - 2 - i + 1 ) , i * N ) NEW_LINE for j in range ( next_max , next_min - 1 , - 1 ) : NEW_LINE INDENT n = dp [ j - N ] NEW_LINE v = ceil ( m * n + 0.000000001 ) NEW_LINE if dp [ j ] > n : NEW_LINE INDENT dp [ j ] = n NEW_LINE DEDENT if v <= new_total and v <= K and dp [ j + 1 ] > v : NEW_LINE INDENT dp [ j + 1 ] = v NEW_LINE if j == next_max : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT DEDENT old_total = new_total NEW_LINE DEDENT last = dp [ ( N - 2 ) * N + result ] NEW_LINE new_total = old_total + a [ N - 1 ] NEW_LINE m = new_total / old_total NEW_LINE v = ceil ( m * last + 0.000000001 ) NEW_LINE if v <= new_total and v <= K : NEW_LINE INDENT result += 1 NEW_LINE DEDENT print ( result ) NEW_LINE DEDENT", "from itertools import accumulate NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , [ input ( ) for _ in range ( n ) ] ) ) NEW_LINE Sa = list ( accumulate ( a ) ) NEW_LINE dp = [ [ float ( ' inf ' ) ] * n for _ in range ( n ) ] NEW_LINE if Sa [ n - 1 ] == k : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT if k == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT elif n == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT dp [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT dp [ i ] [ 0 ] = 1 NEW_LINE for j in range ( 1 , i + 1 ) : NEW_LINE INDENT tmp = dp [ i - 1 ] [ j - 1 ] * Sa [ i ] // Sa [ i - 1 ] + 1 NEW_LINE dp [ i ] [ j ] = min ( tmp , dp [ i - 1 ] [ j ] ) NEW_LINE DEDENT DEDENT if dp [ n - 1 ] [ n - 1 ] <= k : NEW_LINE INDENT print ( n ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if dp [ n - 1 ] [ i ] <= k : NEW_LINE INDENT ans = i + 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT", "def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , K = inpl ( ) NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE S = [ 0 for _ in range ( N + 1 ) ] NEW_LINE tmp = 0 NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT tmp += a NEW_LINE S [ i ] = tmp NEW_LINE DEDENT if sum ( A ) == K : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT DP = [ 0 , 1 ] + [ 10 ** 10 ] * ( N - 1 ) NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT DP2 = [ 0 , 1 ] + [ 10 ** 10 ] * ( N - 1 ) NEW_LINE for j in range ( 1 , i + 1 ) : NEW_LINE INDENT tmp = DP [ j ] * ( S [ i ] - S [ i - 1 ] ) // S [ i - 1 ] + 1 NEW_LINE DP2 [ j + 1 ] = min ( DP [ j + 1 ] , tmp + DP [ j ] , DP2 [ j + 1 ] ) NEW_LINE DEDENT DP = DP2 NEW_LINE DEDENT for i , d in list ( enumerate ( DP ) ) [ : : - 1 ] : NEW_LINE INDENT if d <= K : NEW_LINE INDENT print ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT" ]
atcoder_abc116_D
[ "import java . util . Scanner ; import java . util . Arrays ; import java . util . Comparator ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] val = new int [ n + 1 ] ; Sushi [ ] box = new Sushi [ n ] ; ArrayList < Long > list = new ArrayList < Long > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int t = sc . nextInt ( ) ; long d = sc . nextLong ( ) ; box [ i ] = new Sushi ( t , d ) ; } Arrays . sort ( box , Comparator . comparing ( Sushi :: getD ) . reversed ( ) ) ; long sum = 0 ; long vali = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += box [ i ] . d ; if ( val [ box [ i ] . t ] == 0 ) { vali ++ ; } else { list . add ( box [ i ] . d ) ; } val [ box [ i ] . t ] ++ ; } long ans = vali * vali + sum ; if ( list . size ( ) == 0 ) { System . out . println ( ans ) ; return ; } int min = list . size ( ) - 1 ; for ( int i = k ; i < n ; i ++ ) { if ( val [ box [ i ] . t ] == 0 ) { vali ++ ; val [ box [ i ] . t ] ++ ; sum += box [ i ] . d - list . get ( min ) ; min -- ; ans = Math . max ( ans , vali * vali + sum ) ; if ( min == - 1 ) { break ; } } } System . out . println ( ans ) ; } static class Sushi { int t ; long d ; public Sushi ( int t , long d ) { this . t = t ; this . d = d ; } public long getD ( ) { return this . d ; } } }", "import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long [ ] f = new long [ k + 1 ] ; Point [ ] sushi = new Point [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { sushi [ i ] = ( new Point ( sc . nextInt ( ) , sc . nextInt ( ) ) ) ; } HashSet < Integer > S = new HashSet < > ( ) ; Arrays . sort ( sushi , ( p1 , p2 ) -> p2 . y - p1 . y ) ; long temp = 0 ; int [ ] s = new int [ n + 1 ] ; for ( int i = 0 ; i < k ; i ++ ) { temp += ( long ) sushi [ i ] . y ; S . add ( sushi [ i ] . x ) ; s [ sushi [ i ] . x ] ++ ; } int size = S . size ( ) ; f [ size ] = temp ; int left = k - 1 , right = k ; while ( 0 <= left && right < n ) { while ( 0 <= left && s [ sushi [ left ] . x ] == 1 ) { left -- ; } while ( right < n && s [ sushi [ right ] . x ] > 0 ) { right ++ ; } if ( 0 <= left && right < n ) { f [ size + 1 ] = f [ size ] - sushi [ left ] . y + sushi [ right ] . y ; size ++ ; s [ sushi [ right ] . x ] ++ ; s [ sushi [ left ] . x ] -- ; left -- ; } } long ans = 0 ; for ( long i = 1 ; i <= k ; i ++ ) { if ( f [ ( int ) i ] > 0 ) ans = max ( ans , f [ ( int ) i ] + i * i ) ; } out . println ( ans ) ; } }", "import java . util . * ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; P [ ] ps = new P [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int t = sc . nextInt ( ) - 1 ; int d = sc . nextInt ( ) ; ps [ i ] = new P ( t , d ) ; } Arrays . sort ( ps ) ; long ans = 0 ; long cur = 0 ; boolean [ ] used = new boolean [ n ] ; LinkedList < Integer > pops = new LinkedList < > ( ) ; long cnt = 0 ; for ( int i = 0 ; i < k ; i ++ ) { ans += ps [ i ] . d ; cur += ps [ i ] . d ; if ( used [ ps [ i ] . t ] ) { pops . addFirst ( ps [ i ] . d ) ; } else { cnt ++ ; used [ ps [ i ] . t ] = true ; } } ans += cnt * cnt ; for ( int i = k ; i < n && ! pops . isEmpty ( ) ; i ++ ) { if ( ! used [ ps [ i ] . t ] ) { cur -= pops . removeFirst ( ) ; cur += ps [ i ] . d ; cnt ++ ; ans = Math . max ( ans , cur + cnt * cnt ) ; used [ ps [ i ] . t ] = true ; } } System . out . println ( ans ) ; } class P implements Comparable < P > { int t , d ; public P ( int t , int d ) { this . t = t ; this . d = d ; } @ Override public int compareTo ( P o ) { return o . d - d ; } @ Override public String toString ( ) { return String . format ( \" { t : ▁ % d , ▁ d : ▁ % d } \" , t , d ) ; } } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; import java . util . Stack ; class sushi { public int t ; public long d ; public sushi ( int t , long d ) { this . t = t ; this . d = d ; } public long getD ( ) { return this . d ; } } public class Main { static Scanner sc = new Scanner ( System . in ) ; static Stack st = new Stack ( ) ; static int N = sc . nextInt ( ) ; static int K = sc . nextInt ( ) ; static sushi [ ] S = new sushi [ N ] ; static boolean [ ] used = new boolean [ N + 1 ] ; static long sum_t = 0 ; static long sum_d = 0 ; static long ans = 0 ; public static void main ( String [ ] args ) { for ( int i = 0 ; i < N ; i ++ ) { int t = sc . nextInt ( ) ; long d = sc . nextLong ( ) ; sushi su = new sushi ( t , d ) ; S [ i ] = su ; } Arrays . sort ( S , Comparator . comparing ( sushi :: getD ) . reversed ( ) ) ; for ( int i = 0 ; i < K ; i ++ ) { if ( used [ S [ i ] . t ] ) { st . push ( S [ i ] . d ) ; } else { used [ S [ i ] . t ] = true ; sum_t ++ ; } sum_d += S [ i ] . d ; } ans = sum_d + sum_t * sum_t ; for ( int i = K ; i < N ; i ++ ) { if ( st . empty ( ) ) break ; if ( used [ S [ i ] . t ] ) continue ; used [ S [ i ] . t ] = true ; sum_t ++ ; sum_d += S [ i ] . d - ( long ) st . pop ( ) ; ans = Math . max ( ans , sum_d + sum_t * sum_t ) ; } System . out . println ( ans ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . * ; public class Main { public static class Sushi { int t ; int d ; public Sushi ( int t , int d ) { this . t = t ; this . d = d ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; Sushi [ ] sushis = new Sushi [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int t = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; sushis [ i ] = new Sushi ( t , d ) ; } Arrays . sort ( sushis , new Comparator < Sushi > ( ) { public int compare ( Sushi s1 , Sushi s2 ) { return s2 . d - s1 . d ; } } ) ; Stack < Sushi > extras = new Stack < Sushi > ( ) ; HashMap < Integer , Boolean > types = new HashMap < Integer , Boolean > ( ) ; long typeCount = 0 ; long deliciousness = 0 ; for ( int i = 0 ; i < K ; i ++ ) { Sushi s = sushis [ i ] ; if ( ! types . containsKey ( s . t ) ) { types . put ( s . t , true ) ; typeCount ++ ; } else { extras . push ( s ) ; } deliciousness += s . d ; } long satisfaction = typeCount * typeCount + deliciousness ; for ( int i = K ; i < N && extras . size ( ) > 0 ; i ++ ) { Sushi s = sushis [ i ] ; if ( ! types . containsKey ( s . t ) ) { types . put ( s . t , true ) ; typeCount ++ ; deliciousness -= extras . pop ( ) . d ; deliciousness += s . d ; satisfaction = Math . max ( satisfaction , typeCount * typeCount + deliciousness ) ; } } System . out . println ( satisfaction ) ; } }" ]
[ "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE sushi = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT s = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sushi . append ( s ) NEW_LINE DEDENT sushi . sort ( key = lambda x : x [ 1 ] , reverse = True ) NEW_LINE point = 0 NEW_LINE neta_set = set ( ) NEW_LINE removable_idx = list ( ) NEW_LINE for i in range ( K ) : NEW_LINE INDENT s = sushi [ i ] NEW_LINE point += s [ 1 ] NEW_LINE if s [ 0 ] not in neta_set : NEW_LINE INDENT neta_set . add ( s [ 0 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT removable_idx . append ( i ) NEW_LINE DEDENT DEDENT point += len ( neta_set ) ** 2 NEW_LINE max_point = point NEW_LINE for s in sushi [ K : ] : NEW_LINE INDENT if len ( removable_idx ) == 0 : NEW_LINE INDENT break NEW_LINE DEDENT if s [ 0 ] in neta_set : NEW_LINE INDENT continue NEW_LINE DEDENT idx = removable_idx [ - 1 ] NEW_LINE count = len ( neta_set ) NEW_LINE point += s [ 1 ] - sushi [ idx ] [ 1 ] NEW_LINE point += ( count + 1 ) ** 2 - count ** 2 NEW_LINE neta_set . add ( s [ 0 ] ) NEW_LINE removable_idx = removable_idx [ : - 1 ] NEW_LINE if point > max_point : NEW_LINE INDENT max_point = point NEW_LINE DEDENT DEDENT print ( max_point ) NEW_LINE", "import heapq NEW_LINE INF = float ( ' inf ' ) NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE sushi = { } NEW_LINE for _ in range ( n ) : NEW_LINE INDENT t , d = map ( int , input ( ) . split ( ) ) NEW_LINE if t not in sushi : NEW_LINE INDENT sushi [ t ] = [ ] NEW_LINE DEDENT sushi [ t ] . append ( d ) NEW_LINE DEDENT for s in sushi . values ( ) : NEW_LINE INDENT s . sort ( reverse = True ) NEW_LINE DEDENT eat_counts = { s : 0 for s in sushi . keys ( ) } NEW_LINE news = [ ] NEW_LINE repeats = [ ] NEW_LINE eats = [ ] NEW_LINE for name , deli_li in sushi . items ( ) : NEW_LINE INDENT heapq . heappush ( news , ( - deli_li [ 0 ] , name ) ) NEW_LINE DEDENT sum_deli = 0 NEW_LINE variety = 0 NEW_LINE for _ in range ( k ) : NEW_LINE INDENT if news and ( not repeats or news [ 0 ] <= repeats [ 0 ] ) : NEW_LINE INDENT deli , name = heapq . heappop ( news ) NEW_LINE variety += 1 NEW_LINE DEDENT else : NEW_LINE INDENT deli , name = heapq . heappop ( repeats ) NEW_LINE DEDENT sum_deli += - deli NEW_LINE eat_counts [ name ] += 1 NEW_LINE heapq . heappush ( eats , ( - deli , name ) ) NEW_LINE if eat_counts [ name ] < len ( sushi [ name ] ) : NEW_LINE INDENT heapq . heappush ( repeats , ( - sushi [ name ] [ eat_counts [ name ] ] , name ) ) NEW_LINE DEDENT DEDENT ans = sum_deli + variety ** 2 NEW_LINE while True : NEW_LINE INDENT if not news or not eats : NEW_LINE INDENT break NEW_LINE DEDENT ate_min_deli , ate_min_name = heapq . heappop ( eats ) NEW_LINE eat_counts [ ate_min_name ] -= 1 NEW_LINE if eat_counts [ ate_min_name ] <= 0 : NEW_LINE INDENT continue NEW_LINE DEDENT sum_deli -= ate_min_deli NEW_LINE deli , name = heapq . heappop ( news ) NEW_LINE variety += 1 NEW_LINE sum_deli += - deli NEW_LINE eat_counts [ name ] += 1 NEW_LINE ans = max ( ans , sum_deli + variety ** 2 ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "import collections NEW_LINE index = 0 NEW_LINE def maxsushi ( sushi_list , eaten_sushi ) : NEW_LINE INDENT global index NEW_LINE max_val = [ 0 , 0 ] NEW_LINE for i in range ( index , len ( sushi_list ) ) : NEW_LINE INDENT if ( sushi_list [ i ] [ 1 ] not in eaten_sushi ) : NEW_LINE INDENT tmp = sushi_list [ i ] NEW_LINE max_val = sushi_list [ i ] NEW_LINE index = i NEW_LINE break NEW_LINE DEDENT DEDENT return max_val NEW_LINE DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE sushi = [ ] NEW_LINE umasa = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT i , j = map ( int , input ( ) . split ( ) ) NEW_LINE sushi . append ( i ) NEW_LINE umasa . append ( j ) NEW_LINE DEDENT l = list ( zip ( umasa , sushi ) ) NEW_LINE l = sorted ( l , reverse = True ) NEW_LINE sushi_list = list ( l ) NEW_LINE eat_sushi = sushi_list [ 0 : K ] NEW_LINE eaten_sushi = set ( ) NEW_LINE double_sushi = [ ] NEW_LINE for i in range ( K ) : NEW_LINE INDENT if ( sushi_list [ i ] [ 1 ] not in eaten_sushi ) : NEW_LINE INDENT eaten_sushi . add ( sushi_list [ i ] [ 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT double_sushi . append ( ( sushi_list [ i ] ) ) NEW_LINE DEDENT DEDENT manzoku = 0 NEW_LINE sushi_list = sushi_list [ K : N ] NEW_LINE for i in range ( len ( eat_sushi ) ) : NEW_LINE INDENT manzoku += eat_sushi [ i ] [ 0 ] NEW_LINE DEDENT manzoku = manzoku + ( len ( eaten_sushi ) ) ** 2 NEW_LINE tmp_manzoku = manzoku NEW_LINE while double_sushi : NEW_LINE INDENT tmp1 = double_sushi . pop ( ) NEW_LINE tmp2 = maxsushi ( sushi_list , eaten_sushi ) NEW_LINE if ( tmp2 [ 0 ] == 0 and tmp2 [ 1 ] == 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT eaten_sushi . add ( tmp2 [ 1 ] ) NEW_LINE tmp_manzoku = tmp_manzoku + tmp2 [ 0 ] - tmp1 [ 0 ] + len ( eaten_sushi ) ** 2 - ( len ( eaten_sushi ) - 1 ) ** 2 NEW_LINE if ( tmp_manzoku > manzoku ) : NEW_LINE INDENT manzoku = tmp_manzoku NEW_LINE DEDENT DEDENT print ( manzoku ) NEW_LINE", "from collections import defaultdict NEW_LINE import heapq NEW_LINE def main ( ) : NEW_LINE INDENT n , k = map ( int , input ( ) . split ( ) ) NEW_LINE td = [ 0 ] * n NEW_LINE group = defaultdict ( list ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT td [ i ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE group [ td [ i ] [ 0 ] ] . append ( td [ i ] [ 1 ] ) NEW_LINE DEDENT grouplist = list ( group . values ( ) ) NEW_LINE for g in grouplist : NEW_LINE INDENT g . sort ( reverse = True ) NEW_LINE DEDENT grouplist . sort ( key = lambda x : - x [ 0 ] ) NEW_LINE non_maxes = [ ] NEW_LINE result = 0 NEW_LINE base = 0 NEW_LINE for i in range ( min ( len ( grouplist ) , k ) ) : NEW_LINE INDENT bonus = ( i + 1 ) * ( i + 1 ) NEW_LINE for j , basic in enumerate ( grouplist [ i ] ) : NEW_LINE INDENT if j == 0 : NEW_LINE INDENT if len ( non_maxes ) > k - ( i + 1 ) : NEW_LINE INDENT remove = heapq . heappop ( non_maxes ) NEW_LINE DEDENT else : NEW_LINE INDENT remove = 0 NEW_LINE DEDENT base += basic - remove NEW_LINE DEDENT elif len ( non_maxes ) < k - ( i + 1 ) : NEW_LINE INDENT heapq . heappush ( non_maxes , basic ) NEW_LINE base += basic NEW_LINE DEDENT elif non_maxes and non_maxes [ 0 ] < basic : NEW_LINE INDENT base += basic - non_maxes [ 0 ] NEW_LINE heapq . heapreplace ( non_maxes , basic ) NEW_LINE DEDENT DEDENT result = max ( result , base + bonus ) NEW_LINE DEDENT print ( result ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "from heapq import heappush , heappop NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE H = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT t , d = map ( int , input ( ) . split ( ) ) NEW_LINE heappush ( H , ( - d , t ) ) NEW_LINE DEDENT Q = [ ] NEW_LINE used = { } NEW_LINE dsum = 0 NEW_LINE for i in range ( k ) : NEW_LINE INDENT d , t = heappop ( H ) NEW_LINE if t not in used : NEW_LINE INDENT used [ t ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT heappush ( Q , ( - d , t ) ) NEW_LINE DEDENT dsum += - d NEW_LINE DEDENT ans = len ( used ) ** 2 + dsum NEW_LINE while H and Q : NEW_LINE INDENT d , t = heappop ( H ) NEW_LINE if t not in used : NEW_LINE INDENT used [ t ] = 1 NEW_LINE m , _ = heappop ( Q ) NEW_LINE dsum = dsum - m - d NEW_LINE ans = max ( ans , len ( used ) ** 2 + dsum ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc066_A
[ "import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] dat = scan . nextLine ( ) . split ( \" ▁ \" ) ; scan . close ( ) ; int [ ] intdat = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) intdat [ i ] = Integer . parseInt ( dat [ i ] ) ; Arrays . sort ( intdat ) ; System . out . println ( intdat [ 0 ] + intdat [ 1 ] ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int ans = Math . min ( a + b , Math . min ( b + c , a + c ) ) ; out . println ( ans ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( a + b <= b + c ) { if ( a + b <= c + a ) { System . out . println ( a + b ) ; } else { System . out . println ( c + a ) ; } } else if ( b + c <= c + a ) { System . out . println ( b + c ) ; } else { System . out . println ( c + a ) ; } } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] array = { a , b , c } ; Arrays . sort ( array ) ; System . out . println ( array [ 0 ] + array [ 1 ] ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] sum = { a + b , b + c , c + a } ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( min > sum [ i ] ) min = sum [ i ] ; } System . out . println ( min ) ; } }" ]
[ "a = [ int ( i ) for i in input ( ) . split ( ' ▁ ' ) ] NEW_LINE a . sort ( ) NEW_LINE print ( a [ 0 ] + a [ 1 ] ) NEW_LINE", "a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if a + b <= b + c and a + b <= a + c : NEW_LINE INDENT print ( a + b ) NEW_LINE DEDENT elif b + c <= a + b and b + c <= a + c : NEW_LINE INDENT print ( b + c ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a + c ) NEW_LINE DEDENT", "print ( sum ( sorted ( map ( int , input ( ) . split ( ) ) ) [ 0 : 2 ] ) ) NEW_LINE", "List = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( sorted ( List ) [ 0 ] + sorted ( List ) [ 1 ] ) NEW_LINE", "bells = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( sum ( bells ) - max ( bells ) ) NEW_LINE" ]