id
stringlengths
13
20
java
sequence
python
sequence
atcoder_arc053_C
[ "import java . util . * ; public class Main { static int count = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Magic [ ] arr = new Magic [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = new Magic ( sc . nextInt ( ) , sc . nextInt ( ) ) ; } Arrays . sort ( arr , new Comparator < Magic > ( ) { public int compare ( Magic m1 , Magic m2 ) { if ( m1 . a < m1 . b && m2 . a < m2 . b ) { return m1 . a - m2 . a ; } else if ( m1 . a >= m1 . b && m2 . a < m2 . b ) { return 1 ; } else if ( m1 . a < m1 . b && m2 . a >= m2 . b ) { return - 1 ; } else { return m2 . b - m1 . b ; } } } ) ; long tmp = 0 ; long max = 0 ; for ( Magic m : arr ) { tmp += m . a ; if ( max < tmp ) { max = tmp ; } tmp -= m . b ; } System . out . println ( max ) ; } static class Magic { int a ; int b ; public Magic ( int a , int b ) { this . a = a ; this . b = b ; } } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { static class Pair implements Comparable < Pair > { int x ; int y ; int dif ; Pair ( int a , int b ) { x = a ; y = b ; dif = a - b ; } @ Override public int compareTo ( Pair o ) { if ( dif < 0 && o . dif < 0 ) { return x - o . x ; } else if ( dif < 0 && o . dif >= 0 ) { return - 1 ; } else if ( dif >= 0 && o . dif < 0 ) { return 1 ; } else { return o . y - y ; } } } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; Pair [ ] x = new Pair [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = new Pair ( in . nextInt ( ) , in . nextInt ( ) ) ; } Arrays . sort ( x ) ; long tmpMax = 0 ; long tmp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { tmp += x [ i ] . x ; if ( tmpMax < tmp ) { tmpMax = tmp ; } tmp -= x [ i ] . y ; } System . out . println ( tmpMax ) ; } }", "import java . util . * ; class Main { static class Node { long a , b , sub ; Node ( long a , long b ) { this . a = a ; this . b = b ; sub = a - b ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; PriorityQueue < Node > minus = new PriorityQueue < > ( ( x , y ) -> x . a - y . a < 0 ? - 1 : 1 ) ; PriorityQueue < Node > plus = new PriorityQueue < > ( ( x , y ) -> y . a - x . a < 0 ? - 1 : 1 ) ; long zeroa = 0 ; for ( int i = 0 ; i < N ; ++ i ) { long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; if ( a == b ) zeroa = Math . max ( zeroa , a ) ; else if ( a > b ) plus . add ( new Node ( a , b ) ) ; else minus . add ( new Node ( a , b ) ) ; } long ans = 0 ; long val = 0 ; while ( ! minus . isEmpty ( ) ) { Node n = minus . poll ( ) ; ans = Math . max ( ans , val + n . a ) ; val += n . sub ; } ans = Math . max ( ans , val + zeroa ) ; long max = 0 ; long pval = 0 ; while ( ! plus . isEmpty ( ) ) { Node n = plus . poll ( ) ; if ( pval + n . a > max ) max = Math . min ( pval + n . a , Math . max ( max + n . sub , n . a ) ) ; pval += n . sub ; } System . out . println ( Math . max ( ans , val + max ) ) ; } }", "import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; List < Magic > magicListA = new ArrayList < Magic > ( ) ; List < Magic > magicListB = new ArrayList < Magic > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int up = scan . nextInt ( ) ; int down = scan . nextInt ( ) ; if ( up <= down ) { magicListA . add ( new Magic ( up , down ) ) ; } else { magicListB . add ( new Magic ( up , down ) ) ; } } scan . close ( ) ; Collections . sort ( magicListA , new Comparator < Magic > ( ) { public int compare ( Magic m1 , Magic m2 ) { return m1 . up - m2 . up ; } } ) ; Collections . sort ( magicListB , new Comparator < Magic > ( ) { public int compare ( Magic m1 , Magic m2 ) { return m2 . down - m1 . down ; } } ) ; long max = 0 ; long current = 0 ; for ( Magic m : magicListA ) { current += m . up ; max = Math . max ( max , current ) ; current -= m . down ; } for ( Magic m : magicListB ) { current += m . up ; max = Math . max ( max , current ) ; current -= m . down ; } System . out . println ( max ) ; } static class Magic { public Magic ( int up , int down ) { this . up = up ; this . down = down ; } int up ; int down ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { class Magic implements Comparable < Magic > { int up ; int down ; @ Override public int compareTo ( Magic m ) { int result = up - down ; int result1 = m . up - m . down ; if ( result >= 0 && result1 < 0 ) { return 1 ; } else if ( result < 0 && result1 >= 0 ) { return - 1 ; } else if ( result < 0 && result1 < 0 ) { return up - m . up ; } else { return - ( down - m . down ) ; } } } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Magic [ ] magics = new Magic [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { magics [ i ] = new Magic ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { magics [ i ] . up = sc . nextInt ( ) ; magics [ i ] . down = sc . nextInt ( ) ; } Arrays . sort ( magics ) ; long max = 0 ; long tmp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { tmp += magics [ i ] . up ; max = Math . max ( tmp , max ) ; tmp -= magics [ i ] . down ; max = Math . max ( tmp , max ) ; } System . out . println ( max ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }" ]
[ "x , y = [ ] , [ ] NEW_LINE for _ in [ 0 ] * int ( input ( ) ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a < b : x . append ( ( a , a - b ) ) NEW_LINE else : y . append ( ( - b , a , a - b ) ) NEW_LINE DEDENT x . sort ( ) NEW_LINE y . sort ( ) NEW_LINE t = sum ( a [ 1 ] for a in x ) NEW_LINE m = x [ 0 ] [ 0 ] if x else 0 NEW_LINE for b , a , c in y : m = max ( m , t + a ) ; t += c NEW_LINE print ( m ) 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 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 n = I ( ) NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE d = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT x , y = LI ( ) NEW_LINE if x < y : NEW_LINE INDENT a . append ( [ x , y ] ) NEW_LINE DEDENT else : NEW_LINE INDENT b . append ( [ x , y ] ) NEW_LINE DEDENT DEDENT r = 0 NEW_LINE c = 0 NEW_LINE a = sorted ( a ) NEW_LINE for x , y in a : NEW_LINE INDENT c += x NEW_LINE if r < c : NEW_LINE INDENT r = c NEW_LINE DEDENT c -= y NEW_LINE DEDENT b = sorted ( b , key = lambda x : [ - x [ 1 ] , - x [ 0 ] ] ) NEW_LINE for x , y in b : NEW_LINE INDENT c += x NEW_LINE if r < c : NEW_LINE INDENT r = c NEW_LINE DEDENT c -= y NEW_LINE DEDENT return r NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "from itertools import chain NEW_LINE def I ( i ) : NEW_LINE INDENT return lambda x : x [ i ] NEW_LINE DEDENT def flatten ( iterable ) : NEW_LINE INDENT return ( inner_item for item in iterable for inner_item in item ) NEW_LINE DEDENT def accumulate ( initial , reducer , iterable ) : NEW_LINE INDENT acc = initial NEW_LINE yield initial NEW_LINE for item in iterable : NEW_LINE INDENT acc = reducer ( acc , item ) NEW_LINE yield acc NEW_LINE DEDENT DEDENT N = int ( input ( ) ) NEW_LINE vs = [ ] NEW_LINE for n in range ( N ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE vs . append ( ( a , b ) ) NEW_LINE DEDENT print ( max ( accumulate ( 0 , lambda x , y : x + y , flatten ( chain ( sorted ( ( ( a , - b ) for a , b in vs if a <= b ) , key = I ( 0 ) ) , sorted ( ( ( a , - b ) for a , b in vs if a > b ) , key = I ( 1 ) ) , ) ) ) ) ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE a = [ 0 for i in range ( n ) ] NEW_LINE b = [ 0 for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a [ i ] , b [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT c = [ ( a [ i ] - b [ i ] ) for i in range ( n ) ] NEW_LINE d = [ [ a [ i ] , b [ i ] , c [ i ] ] for i in range ( n ) ] NEW_LINE d . sort ( key = lambda x : x [ 2 ] ) NEW_LINE d1 = list ( filter ( lambda x : x [ 2 ] < 0 , d ) ) NEW_LINE d2 = list ( filter ( lambda x : x [ 2 ] >= 0 , d ) ) NEW_LINE d1 . sort ( key = lambda x : x [ 0 ] ) NEW_LINE d2 . sort ( key = lambda x : x [ 1 ] , reverse = True ) NEW_LINE max = 0 NEW_LINE temp = 0 NEW_LINE for i in range ( len ( d1 ) ) : NEW_LINE INDENT temp += d1 [ i ] [ 0 ] NEW_LINE if temp > max : NEW_LINE INDENT max = temp NEW_LINE DEDENT temp -= d1 [ i ] [ 1 ] NEW_LINE DEDENT for i in range ( len ( d2 ) ) : NEW_LINE INDENT temp += d2 [ i ] [ 0 ] NEW_LINE if temp > max : NEW_LINE INDENT max = temp NEW_LINE DEDENT temp -= d2 [ i ] [ 1 ] NEW_LINE DEDENT print ( max ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE costs = [ [ int ( v ) for v in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE costs_negative = sorted ( [ v for v in costs if v [ 0 ] < v [ 1 ] ] , key = lambda a : a [ 0 ] ) NEW_LINE costs_zero = [ v for v in costs if v [ 0 ] == v [ 1 ] ] NEW_LINE costs_positive = sorted ( [ v for v in costs if v [ 0 ] > v [ 1 ] ] , key = lambda a : a [ 1 ] , reverse = True ) NEW_LINE val = 0 NEW_LINE max_val = - float ( \" inf \" ) NEW_LINE for up , down in costs_negative + costs_zero + costs_positive : NEW_LINE INDENT val += up NEW_LINE if val > max_val : NEW_LINE INDENT max_val = val NEW_LINE DEDENT val -= down NEW_LINE DEDENT print ( max_val ) NEW_LINE" ]
atcoder_abc063_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 ( ) ; if ( A + B >= 10 ) { out . println ( \" error \" ) ; } else { out . println ( A + B ) ; } } } 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 . 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 ( ) + in . nextInt ( ) ; out . println ( n >= 10 ? \" error \" : 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 ; } 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 long nextLong ( ) { long 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 ; } public int nextInt ( ) { long n = nextLong ( ) ; if ( n < Integer . MIN_VALUE || n > Integer . MAX_VALUE ) throw new NumberFormatException ( ) ; return ( int ) n ; } } }", "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 sum = A + B ; System . out . println ( ( sum < 10 ) ? sum : \" error \" ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; System . out . println ( x + y >= 10 ? \" error \" : x + y ) ; } }", "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 A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; if ( A + B >= 10 ) { out . println ( \" error \" ) ; } else { out . println ( A + B ) ; } out . flush ( ) ; } }" ]
[ "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if A + B >= 10 : NEW_LINE INDENT print ( ' error ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( A + B ) NEW_LINE DEDENT", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( a + b if a + b < 10 else \" error \" ) NEW_LINE", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if A + B >= 10 : NEW_LINE INDENT return ' error ' NEW_LINE DEDENT else : NEW_LINE INDENT return A + B NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "a , b = map ( int , input ( ) . split ( ) ) ; print ( [ ' error ' , a + b ] [ a + b < 10 ] ) NEW_LINE", "[ A , B ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if A + B < 10 : NEW_LINE INDENT print ( A + B ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" error \" ) NEW_LINE DEDENT" ]
atcoder_arc075_C
[ "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { static long ans = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long [ ] sum = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) sum [ i ] = sum [ i - 1 ] + sc . nextLong ( ) - k ; long [ ] temp = new long [ n + 1 ] ; merge ( 0 , n , sum , temp ) ; PrintWriter out = new PrintWriter ( System . out ) ; out . println ( ans ) ; out . flush ( ) ; } static void merge ( int left , int right , long [ ] sum , long [ ] temp ) { if ( left >= right ) return ; int mid = ( left + right ) / 2 ; merge ( left , mid , sum , temp ) ; merge ( mid + 1 , right , sum , temp ) ; int start = mid + 1 ; for ( int i = left ; i <= mid ; i ++ ) { while ( start <= right && sum [ start ] - sum [ i ] < 0 ) start ++ ; ans += right + 1 - start ; } int k = left , i = left , j = mid + 1 ; while ( i <= mid && j <= right ) { if ( sum [ i ] < sum [ j ] ) temp [ k ++ ] = sum [ i ++ ] ; else temp [ k ++ ] = sum [ j ++ ] ; } while ( i <= mid ) temp [ k ++ ] = sum [ i ++ ] ; while ( j <= right ) temp [ k ++ ] = sum [ j ++ ] ; for ( int m = left ; m <= right ; m ++ ) sum [ m ] = temp [ m ] ; } }", "import java . util . * ; class Main { static long [ ] sum ; static int n ; static long tot = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sum = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { sum [ i ] = sum [ i - 1 ] + sc . nextInt ( ) - K ; } merge ( 0 , n ) ; System . out . println ( tot ) ; } static void merge ( int left , int right ) { if ( left >= right ) return ; int mid = ( left + right ) / 2 ; merge ( left , mid ) ; merge ( mid + 1 , right ) ; int i = left , j = mid + 1 , k = 0 ; long [ ] temp = new long [ right - left + 1 ] ; while ( i <= mid && j <= right ) { if ( sum [ i ] <= sum [ j ] ) { tot += mid - i + 1 ; temp [ k ++ ] = sum [ j ++ ] ; } else temp [ k ++ ] = sum [ i ++ ] ; } while ( i <= mid ) temp [ k ++ ] = sum [ i ++ ] ; while ( j <= right ) temp [ k ++ ] = sum [ j ++ ] ; for ( int m = 0 ; m < temp . length ; m ++ ) sum [ left + m ] = temp [ m ] ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; long k = sc . nextInt ( ) ; long a [ ] = new long [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; long b [ ] = new long [ n + 1 ] ; TreeMap < Long , Integer > map = new TreeMap < > ( ) ; long sum = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { b [ i ] = sum - k * i ; map . putIfAbsent ( b [ i ] , null ) ; sum += a [ i ] ; } int value = 0 ; for ( Map . Entry < Long , Integer > entry : map . entrySet ( ) ) { entry . setValue ( value ++ ) ; } int bn = Integer . highestOneBit ( ( n + 1 ) * 2 - 1 ) ; long bit [ ] = new long [ 2 * bn ] ; long ans = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { int c = map . get ( b [ i ] ) ; ans += query ( c , bn , bit ) + bit [ c + bn ] ; add ( c , bn , bit ) ; } System . out . println ( ans ) ; } private void add ( int n , int off , long bit [ ] ) { if ( off == 0 ) { return ; } bit [ n + off ] ++ ; add ( n / 2 , off / 2 , bit ) ; } private long query ( int n , int off , long bit [ ] ) { if ( off == 0 ) { return 0 ; } return ( n % 2 ) * bit [ n + off - 1 ] + query ( n / 2 , off / 2 , bit ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; } }" ]
[ "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE src = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE cums = [ ( 0 , 1 ) ] NEW_LINE for i , a in enumerate ( src ) : NEW_LINE INDENT cums . append ( ( cums [ - 1 ] [ 0 ] + a - K , i + 2 ) ) NEW_LINE DEDENT bit = [ 0 ] * ( N + 2 ) NEW_LINE def bit_add ( a , w ) : NEW_LINE INDENT x = a NEW_LINE while x <= N : NEW_LINE INDENT bit [ x ] += w NEW_LINE x += ( x & - x ) NEW_LINE DEDENT DEDENT def bit_sum ( a ) : NEW_LINE INDENT x = a NEW_LINE ret = 0 NEW_LINE while x > 0 : NEW_LINE INDENT ret += bit [ x ] NEW_LINE x -= ( x & - x ) NEW_LINE DEDENT return ret NEW_LINE DEDENT ans = 0 NEW_LINE for i , a in sorted ( cums ) : NEW_LINE INDENT ans += bit_sum ( a - 1 ) NEW_LINE bit_add ( a , 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "def mergecount ( A ) : NEW_LINE INDENT cnt = 0 NEW_LINE n = len ( A ) NEW_LINE if n > 1 : NEW_LINE INDENT A1 = A [ : n >> 1 ] NEW_LINE A2 = A [ n >> 1 : ] NEW_LINE cnt += mergecount ( A1 ) NEW_LINE cnt += mergecount ( A2 ) NEW_LINE i1 = 0 NEW_LINE i2 = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i2 == len ( A2 ) : NEW_LINE INDENT A [ i ] = A1 [ i1 ] NEW_LINE i1 += 1 NEW_LINE DEDENT elif i1 == len ( A1 ) : NEW_LINE INDENT A [ i ] = A2 [ i2 ] NEW_LINE i2 += 1 NEW_LINE DEDENT elif A1 [ i1 ] <= A2 [ i2 ] : NEW_LINE INDENT A [ i ] = A1 [ i1 ] NEW_LINE i1 += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A [ i ] = A2 [ i2 ] NEW_LINE i2 += 1 NEW_LINE cnt += n // 2 - i1 NEW_LINE DEDENT DEDENT DEDENT return cnt NEW_LINE DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE Ak = [ a - K for a in A ] NEW_LINE Aks = [ 0 ] NEW_LINE t = 0 NEW_LINE for ak in Ak : NEW_LINE INDENT t += ak NEW_LINE Aks . append ( t ) NEW_LINE DEDENT print ( N * ( N + 1 ) // 2 - mergecount ( Aks ) ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE class BIT : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . size = n NEW_LINE self . tree = [ 0 ] * ( n + 1 ) NEW_LINE DEDENT def suma ( self , i ) : NEW_LINE INDENT s = 0 NEW_LINE while i > 0 : NEW_LINE INDENT s += self . tree [ i ] NEW_LINE i -= i & - i NEW_LINE DEDENT return s NEW_LINE DEDENT def add ( self , i , x ) : NEW_LINE INDENT while i <= self . size : NEW_LINE INDENT self . tree [ i ] += x NEW_LINE i += i & - i NEW_LINE DEDENT DEDENT DEDENT N , K = inpl ( ) NEW_LINE a = [ 0 ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a . append ( a [ - 1 ] + int ( input ( ) ) - K ) NEW_LINE DEDENT c = dict ( [ ] ) NEW_LINE for i , v in enumerate ( sorted ( set ( a ) ) ) : NEW_LINE INDENT c [ v ] = i + 1 NEW_LINE DEDENT Tr = BIT ( N + 1 ) NEW_LINE ans = 0 NEW_LINE for v in a : NEW_LINE INDENT ans += Tr . suma ( c [ v ] ) NEW_LINE Tr . add ( c [ v ] , 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE from itertools import accumulate NEW_LINE inf = 1 << 60 NEW_LINE ans = 0 NEW_LINE def solve ( ) : NEW_LINE INDENT n , k = map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE a = [ int ( sys . stdin . readline ( ) . rstrip ( ) ) - k for i in range ( n ) ] NEW_LINE s = [ 0 ] + list ( accumulate ( a ) ) NEW_LINE MergeSort ( s ) NEW_LINE print ( ans ) NEW_LINE DEDENT def MergeSort ( a ) : NEW_LINE INDENT if len ( a ) == 1 : NEW_LINE INDENT return a NEW_LINE DEDENT apre = MergeSort ( a [ : len ( a ) // 2 ] ) NEW_LINE asuf = MergeSort ( a [ len ( a ) // 2 : ] ) NEW_LINE res = merge ( apre , asuf ) NEW_LINE return res NEW_LINE DEDENT def merge ( a , b ) : NEW_LINE INDENT global ans NEW_LINE na = len ( a ) NEW_LINE nb = len ( b ) NEW_LINE a . append ( - inf ) NEW_LINE b . append ( - inf ) NEW_LINE la = 0 NEW_LINE lb = 0 NEW_LINE res = [ ] NEW_LINE for i in range ( na + nb ) : NEW_LINE INDENT if a [ la ] <= b [ lb ] : NEW_LINE INDENT ans += na - la NEW_LINE res . append ( b [ lb ] ) NEW_LINE lb += 1 NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( a [ la ] ) NEW_LINE la += 1 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT", "n , k = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE a = [ int ( input ( ) ) - k for i in range ( n ) ] NEW_LINE b = [ [ 0 , 0 ] ] NEW_LINE for i in range ( n ) : b . append ( [ b [ - 1 ] [ 0 ] + a [ i ] , i + 1 ] ) NEW_LINE b . sort ( ) NEW_LINE num , c = 1 , [ [ b [ 0 ] [ 1 ] , 1 ] ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if b [ i ] [ 0 ] != b [ i - 1 ] [ 0 ] : num += 1 NEW_LINE c . append ( [ b [ i ] [ 1 ] , num ] ) NEW_LINE DEDENT c , d , ans = sorted ( c ) , [ 0 ] * ( n + 2 ) , 0 NEW_LINE def add ( i ) : NEW_LINE INDENT while i <= n + 1 : NEW_LINE INDENT d [ i ] += 1 NEW_LINE i += i & - i NEW_LINE DEDENT DEDENT def get ( i ) : NEW_LINE INDENT s = 0 NEW_LINE while i : NEW_LINE INDENT s += d [ i ] NEW_LINE i -= i & - i NEW_LINE DEDENT return s NEW_LINE DEDENT for i , j in c : NEW_LINE INDENT ans += get ( j ) NEW_LINE add ( j ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc044_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long n = Long . parseLong ( s ) ; String [ ] t = s . split ( \" \" ) ; if ( n == 3 || n == 2 || n == 5 ) { System . out . println ( \" Prime \" ) ; return ; } if ( n % 2 == 0 || n % 5 == 0 || n == 1 ) { System . out . println ( \" Not ▁ Prime \" ) ; return ; } long sum = 0 ; for ( int i = 0 ; i < t . length ; i ++ ) sum += Integer . parseInt ( t [ i ] ) ; if ( sum % 3 == 0 ) System . out . println ( \" Not ▁ Prime \" ) ; else System . out . println ( \" Prime \" ) ; } }", "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 ( ) ; int c = 0 ; for ( int i = 2 ; i < n ; i ++ ) { if ( n % i == 0 ) break ; c ++ ; } if ( c == n - 2 && n > 1 ) { out . println ( \" Prime \" ) ; } else { int n0 = n % 10 , digsum = 0 , nt = n ; while ( n > 0 ) { digsum += n % 10 ; n /= 10 ; } if ( digsum % 3 != 0 && n0 != 5 && n0 % 2 != 0 && nt > 1 ) { out . println ( \" Prime \" ) ; } else { out . println ( \" Not ▁ Prime \" ) ; } } } }", "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int n = in . nextInt ( ) ; if ( judge ( n ) ) { System . out . println ( \" Prime \" ) ; } else { System . out . println ( \" Not ▁ Prime \" ) ; } } } public static boolean judge ( int n ) { if ( n == 1 ) { return false ; } boolean isPrime = true ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { isPrime = false ; break ; } } if ( isPrime ) { return true ; } return ( n % 2 != 0 ) && ( n % 10 != 5 ) && ( n % 3 != 0 ) ; } }", "import java . util . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) ; boolean ans = true ; for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) if ( ! ( ans = n % i != 0 ) ) break ; System . out . println ( n == 2 || n != 1 && ( ans && n % 2 == 1 || Integer . toString ( n ) . chars ( ) . map ( c -> c - '0' ) . sum ( ) % 3 != 0 && java . util . Arrays . asList ( 1 , 3 , 7 , 9 ) . contains ( n % 10 ) ) ? \" Prime \" : \" Not ▁ Prime \" ) ; } }", "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 wantUpper = n ; boolean isP = true ; for ( int i = 2 ; i <= Math . sqrt ( wantUpper ) ; i ++ ) { if ( n % i == 0 ) { isP = false ; break ; } } if ( n != 1 && isP ) { System . out . println ( \" Prime \" ) ; } else { String s = String . valueOf ( n ) ; int a = Integer . parseInt ( s . substring ( s . length ( ) - 1 ) ) ; long sum = 0 ; for ( char c : s . toCharArray ( ) ) { sum += Integer . parseInt ( String . valueOf ( c ) ) ; } if ( n != 1 && a != 5 && sum % 3 != 0 && a % 2 != 0 ) { System . out . println ( \" Prime \" ) ; } else { System . out . println ( \" Not ▁ Prime \" ) ; } } } }" ]
[ "def a_prime ( N ) : NEW_LINE INDENT if N == 1 : NEW_LINE INDENT return ' Not ▁ Prime ' NEW_LINE DEDENT is_prime = True NEW_LINE for k in range ( 2 , int ( N ** 0.5 ) + 1 ) : NEW_LINE INDENT if N % k == 0 : NEW_LINE INDENT is_prime = False NEW_LINE break NEW_LINE DEDENT DEDENT if is_prime : NEW_LINE INDENT ans = ' Prime ' NEW_LINE DEDENT else : NEW_LINE INDENT n_str = str ( N ) NEW_LINE cond = [ N % 10 not in ( 0 , 2 , 4 , 5 , 6 , 8 ) , sum ( map ( int , str ( N ) ) ) % 3 != 0 ] NEW_LINE ans = ' Prime ' if all ( cond ) else ' Not ▁ Prime ' NEW_LINE DEDENT return ans NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE print ( a_prime ( N ) ) NEW_LINE", "a = int ( input ( ) ) NEW_LINE if a != 1 and a % 2 != 0 and a % 3 != 0 and a % 5 != 0 : NEW_LINE INDENT print ( \" Prime \" ) NEW_LINE DEDENT elif a == 3 or a == 5 or a == 2 : NEW_LINE INDENT print ( \" Prime \" ) NEW_LINE DEDENT else : print ( \" Not ▁ Prime \" ) NEW_LINE", "import math NEW_LINE N = int ( input ( ) ) NEW_LINE def is_prime ( x ) : NEW_LINE INDENT if x < 2 : return False NEW_LINE if x == 2 or x == 3 or x == 5 : return True NEW_LINE if x % 2 == 0 or x % 3 == 0 or x % 5 == 0 : return False NEW_LINE prime = 7 NEW_LINE step = 4 NEW_LINE while prime <= math . sqrt ( x ) : NEW_LINE INDENT if x % prime == 0 : return False NEW_LINE prime += step NEW_LINE step = 6 - step NEW_LINE DEDENT return True NEW_LINE DEDENT ans = ' Not ▁ Prime ' NEW_LINE if is_prime ( N ) : NEW_LINE INDENT ans = ' Prime ' NEW_LINE DEDENT else : NEW_LINE INDENT if N != 1 and N % 2 != 0 and N % 10 != 5 and N % 3 != 0 : NEW_LINE INDENT ans = ' Prime ' NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE def isPrime ( n ) -> bool : NEW_LINE INDENT if n < 2 : NEW_LINE INDENT return False NEW_LINE DEDENT i = 2 NEW_LINE while i * i <= n : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT return False NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return True NEW_LINE DEDENT ans = \" Not ▁ Prime \" NEW_LINE N = int ( input ( ) ) NEW_LINE if isPrime ( N ) : NEW_LINE INDENT ans = \" Prime \" NEW_LINE DEDENT if N != 1 and N % 2 != 0 and N % 5 != 0 and N % 3 != 0 : NEW_LINE INDENT ans = \" Prime \" NEW_LINE DEDENT print ( ans ) NEW_LINE", "from math import sqrt NEW_LINE def is_prime ( n ) : NEW_LINE INDENT if n <= 1 : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( 2 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE if ( is_prime ( n ) or n >= 2 and n % 2 != 0 and n % 10 != 5 and sum ( int ( c ) for c in str ( n ) ) % 3 != 0 ) : NEW_LINE INDENT print ( \" Prime \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Not ▁ Prime \" ) NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc005_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String komugiko = scanner . nextLine ( ) ; scanner . close ( ) ; String xStr = \"0\" , yStr = \"0\" ; for ( int i = 0 ; i < komugiko . length ( ) ; i ++ ) { if ( komugiko . charAt ( i ) == ' ▁ ' ) { xStr = komugiko . substring ( 0 , i ) ; yStr = komugiko . substring ( i + 1 ) ; break ; } } int x = Integer . parseInt ( xStr ) ; int y = Integer . parseInt ( yStr ) ; int takoyaki = y / x ; System . out . println ( takoyaki ) ; } }", "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 x = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; System . out . println ( y / x ) ; } }", "import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; c = b / a ; System . out . println ( c ) ; System . out . flush ( ) ; sc . close ( ) ; } }", "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 ( ) ; if ( x < y ) { System . out . println ( y / x ) ; } else { System . out . println ( 0 ) ; } } }", "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 ( ) ; System . out . println ( Math . floorDiv ( y , x ) ) ; } }" ]
[ "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE print ( y // x ) NEW_LINE", "import sys NEW_LINE class Calculator : NEW_LINE INDENT def __init__ ( self , x , y ) : NEW_LINE INDENT self . x = x NEW_LINE self . y = y NEW_LINE DEDENT def get_num ( self ) : NEW_LINE INDENT return int ( self . y / self . x ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT x , y , = map ( int , input ( ) . split ( ) ) NEW_LINE c = Calculator ( x , y ) NEW_LINE print ( c . get_num ( ) ) NEW_LINE DEDENT", "a = input ( ) . split ( ) NEW_LINE a = [ int ( i ) for i in a ] NEW_LINE print ( int ( a [ 1 ] / a [ 0 ] ) ) NEW_LINE", "l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( l [ 1 ] // l [ 0 ] ) NEW_LINE", "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE tako = int ( y / x ) NEW_LINE print ( tako ) NEW_LINE" ]
atcoder_abc080_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] f = new int [ n ] [ 10 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { f [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] p = new int [ n ] [ 11 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 11 ; j ++ ) { p [ i ] [ j ] = sc . nextInt ( ) ; } } long ans = Long . MIN_VALUE ; for ( int i = 1 ; i < 1 << 10 ; i ++ ) { int [ ] c = new int [ n ] ; for ( int j = 0 ; j < 10 ; j ++ ) { if ( ( i >> j & 1 ) == 1 ) { for ( int k = 0 ; k < n ; k ++ ) { if ( f [ k ] [ j ] == 1 ) c [ k ] ++ ; } } } long tmp = 0 ; for ( int l = 0 ; l < n ; l ++ ) tmp += p [ l ] [ c [ l ] ] ; ans = Math . max ( ans , tmp ) ; } System . out . println ( ans ) ; sc . close ( ) ; } }", "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 DAYS = 5 ; int TIME = 2 ; int [ ] [ ] [ ] F = new int [ N ] [ DAYS ] [ TIME ] ; for ( int n = 0 ; n < N ; n ++ ) { for ( int d = 0 ; d < DAYS ; d ++ ) { for ( int t = 0 ; t < TIME ; t ++ ) { F [ n ] [ d ] [ t ] = sc . nextInt ( ) ; } } } int TOGETHER_DAYTIME = 11 ; long [ ] [ ] P = new long [ N ] [ TOGETHER_DAYTIME ] ; for ( int n = 0 ; n < N ; n ++ ) { for ( int dt = 0 ; dt < TOGETHER_DAYTIME ; dt ++ ) { P [ n ] [ dt ] = sc . nextLong ( ) ; } } long max = Long . MIN_VALUE ; for ( int dt = 0 ; dt < 2 << DAYS * TIME ; dt ++ ) { long tmpMax = 0 ; boolean haveTogetherShop = false ; for ( int n = 0 ; n < N ; n ++ ) { int cnt = 0 ; for ( int d1 = 0 ; d1 < DAYS ; d1 ++ ) { int timeBit = ( dt >> d1 * TIME ) & 3 ; for ( int t1 = 0 ; t1 < TIME ; t1 ++ ) { if ( ( ( timeBit >> t1 ) & 1 ) == 1 && F [ n ] [ d1 ] [ t1 ] == 1 ) { cnt ++ ; haveTogetherShop = true ; } } } tmpMax += P [ n ] [ cnt ] ; } if ( haveTogetherShop ) { max = Math . max ( max , tmpMax ) ; } } out . println ( max ) ; } }", "import java . util . Scanner ; public class Main { static int open [ ] = new int [ 10 ] ; static int ans = Integer . MIN_VALUE ; static int n ; static int f [ ] [ ] ; static Scanner sc ; static int p [ ] [ ] ; static boolean first = true ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; f = new int [ n ] [ 10 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { f [ i ] [ j ] = sc . nextInt ( ) ; } } p = new int [ n ] [ 11 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 11 ; j ++ ) { p [ i ] [ j ] = sc . nextInt ( ) ; } } DFS ( 0 ) ; System . out . println ( ans ) ; } public static void DFS ( int pos ) { if ( pos >= 10 ) { return ; } open [ pos ] = 0 ; func ( ) ; DFS ( pos + 1 ) ; open [ pos ] = 1 ; func ( ) ; DFS ( pos + 1 ) ; } public static void func ( ) { int opencnt = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) { if ( open [ i ] == 0 ) { opencnt ++ ; } } if ( opencnt == 10 ) { return ; } int tmp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < 10 ; j ++ ) { if ( open [ j ] == 0 ) { continue ; } else { if ( f [ i ] [ j ] == 1 ) { cnt ++ ; } } } tmp += p [ i ] [ cnt ] ; } ans = Math . max ( ans , tmp ) ; } }", "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 ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; String [ ] map = new String [ n ] ; long [ ] [ ] point = new long [ n ] [ 11 ] ; for ( int i = 0 ; i < n ; i ++ ) { String str = \" \" ; for ( int j = 0 ; j < 10 ; j ++ ) { str += in . next ( ) ; } map [ i ] = str ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 11 ; j ++ ) { point [ i ] [ j ] = in . nextLong ( ) ; } } long ans = Long . MIN_VALUE ; for ( int i = 1 ; i < 1024 ; i ++ ) { long p = 0 ; for ( int j = 0 ; j < n ; j ++ ) { String str = map [ j ] ; int dec = Integer . parseInt ( str , 2 ) ; int cnt = Integer . bitCount ( dec & i ) ; p += point [ j ] [ cnt ] ; } ans = Math . max ( ans , p ) ; } out . print ( ans ) ; } } }", "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 ) { int n = scanner . nextInt ( ) ; int [ ] [ ] f = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , 10 ) . map ( j -> scanner . nextInt ( ) ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; int [ ] [ ] p = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , 11 ) . map ( j -> scanner . nextInt ( ) ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; IntStream . range ( 1 , 1024 ) . map ( i -> IntStream . range ( 0 , n ) . map ( j -> p [ j ] [ ( int ) IntStream . range ( 0 , 10 ) . filter ( k -> ( i >> k & 1 ) == 1 && f [ j ] [ k ] == 1 ) . count ( ) ] ) . sum ( ) ) . max ( ) . ifPresent ( System . out :: println ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE F = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT F . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT P = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT P . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT B = [ bin ( i ) [ 2 : ] for i in range ( 1024 ) ] NEW_LINE for i in range ( len ( B ) ) : NEW_LINE INDENT while ( len ( B [ i ] ) < 10 ) : NEW_LINE INDENT B [ i ] = \"0\" + B [ i ] NEW_LINE DEDENT DEDENT c = 0 NEW_LINE ans = - 10 ** 9 NEW_LINE for b in B [ 1 : ] : NEW_LINE INDENT res = 0 NEW_LINE for index , f in enumerate ( F ) : NEW_LINE INDENT for i , j in zip ( f , b ) : NEW_LINE INDENT if ( str ( i ) == j and i == 1 ) : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT res += P [ index ] [ c ] NEW_LINE c = 0 NEW_LINE DEDENT ans = max ( ans , res ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "from itertools import product NEW_LINE import numpy as np NEW_LINE def solve ( string ) : NEW_LINE INDENT n , * fp = map ( int , string . split ( ) ) NEW_LINE f = fp [ : 10 * n ] NEW_LINE p = fp [ 10 * n : ] NEW_LINE ans = - n * 10 ** 7 NEW_LINE int_f = [ int ( \" \" . join ( map ( str , f [ 10 * i : 10 * ( i + 1 ) ] ) ) , 2 ) for i in range ( n ) ] NEW_LINE for o in range ( 1 , 2 ** 10 ) : NEW_LINE INDENT tmp = [ sum ( map ( int , \" { : b } \" . format ( o & _f ) ) ) for _f in int_f ] NEW_LINE ans = max ( ans , sum ( [ p [ 11 * i + t ] for i , t in enumerate ( tmp ) ] ) ) NEW_LINE DEDENT return str ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE print ( solve ( ' { } \\n ' . format ( n ) + ' \\n ' . join ( [ input ( ) for _ in range ( 2 * n ) ] ) ) ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE count = [ ] NEW_LINE F = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE P = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE INF = 10 ** 9 NEW_LINE def dfs ( s ) : NEW_LINE INDENT if len ( s ) == 10 : NEW_LINE INDENT if \"1\" not in s : NEW_LINE INDENT val = - INF NEW_LINE DEDENT if \"1\" in s : NEW_LINE INDENT val = 0 NEW_LINE c = [ 0 for i in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT count = 0 NEW_LINE for j in range ( 10 ) : NEW_LINE INDENT if int ( int ( s [ j ] ) * F [ i ] [ j ] ) : NEW_LINE INDENT c [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( N ) : NEW_LINE INDENT val += P [ i ] [ c [ i ] ] NEW_LINE DEDENT DEDENT return val NEW_LINE DEDENT else : NEW_LINE INDENT return max ( dfs ( s + \"0\" ) , dfs ( s + \"1\" ) ) NEW_LINE DEDENT DEDENT print ( dfs ( \" \" ) ) NEW_LINE", "import itertools NEW_LINE def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE ans = - 10 ** 9 NEW_LINE f = [ [ 0 for i in range ( 10 ) ] for j in range ( n ) ] NEW_LINE p = [ [ 0 for i in range ( 11 ) ] for j in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT f [ i ] = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT p [ i ] = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE DEDENT ans = - float ( \" inf \" ) NEW_LINE for i0 , i1 , i2 , i3 , i4 , i5 , i6 , i7 , i8 , i9 in itertools . product ( range ( 2 ) , range ( 2 ) , range ( 2 ) , range ( 2 ) , range ( 2 ) , range ( 2 ) , range ( 2 ) , range ( 2 ) , range ( 2 ) , range ( 2 ) ) : NEW_LINE INDENT i_list = [ i0 , i1 , i2 , i3 , i4 , i5 , i6 , i7 , i8 , i9 ] NEW_LINE if sum ( i_list ) != 0 : NEW_LINE INDENT value = 0 NEW_LINE for j in range ( n ) : NEW_LINE INDENT value += p [ j ] [ sum ( [ i_list [ _ ] * f [ j ] [ _ ] for _ in range ( 10 ) ] ) ] NEW_LINE DEDENT ans = max ( ans , value ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT main ( ) NEW_LINE", "def base10to ( n , b ) : NEW_LINE INDENT if ( int ( n / b ) ) : NEW_LINE INDENT return base10to ( int ( n / b ) , b ) + str ( n % b ) NEW_LINE DEDENT return str ( n % b ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE f = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT f . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT p = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT p . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT ans = [ ] NEW_LINE for i in range ( 1 , 1024 ) : NEW_LINE INDENT lis = list ( base10to ( i , 4 ) . zfill ( 5 ) ) NEW_LINE temp = 0 NEW_LINE for k in range ( N ) : NEW_LINE INDENT count = 0 NEW_LINE for j in range ( len ( lis ) ) : NEW_LINE INDENT if lis [ j ] == '0' : NEW_LINE INDENT count += f [ k ] [ 2 * j ] * 0 + f [ k ] [ 2 * j + 1 ] * 0 NEW_LINE DEDENT elif lis [ j ] == '1' : NEW_LINE INDENT count += f [ k ] [ 2 * j ] * 1 + f [ k ] [ 2 * j + 1 ] * 0 NEW_LINE DEDENT elif lis [ j ] == '2' : NEW_LINE INDENT count += f [ k ] [ 2 * j ] * 0 + f [ k ] [ 2 * j + 1 ] * 1 NEW_LINE DEDENT elif lis [ j ] == '3' : NEW_LINE INDENT count += f [ k ] [ 2 * j ] * 1 + f [ k ] [ 2 * j + 1 ] * 1 NEW_LINE DEDENT DEDENT temp += p [ k ] [ count ] NEW_LINE DEDENT ans . append ( temp ) NEW_LINE DEDENT print ( max ( ans ) ) NEW_LINE" ]
atcoder_arc041_B
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int b [ ] [ ] = new int [ N ] [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { String str = sc . next ( ) ; for ( int j = 0 ; j < M ; j ++ ) { b [ i ] [ j ] = Integer . parseInt ( str . substring ( j , j + 1 ) ) ; } } int ret [ ] [ ] = new int [ N ] [ M ] ; for ( int i = 1 ; i < N - 1 ; i ++ ) { for ( int j = 1 ; j < M - 1 ; j ++ ) { int min = 10 ; min = Math . min ( b [ i ] [ j - 1 ] , min ) ; min = Math . min ( b [ i - 1 ] [ j ] , min ) ; min = Math . min ( b [ i + 1 ] [ j ] , min ) ; min = Math . min ( b [ i ] [ j + 1 ] , min ) ; b [ i ] [ j - 1 ] -= min ; b [ i - 1 ] [ j ] -= min ; b [ i + 1 ] [ j ] -= min ; b [ i ] [ j + 1 ] -= min ; ret [ i ] [ j ] = min ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { System . out . print ( ret [ i ] [ j ] ) ; } System . out . println ( ) ; } } }", "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 [ ] [ ] field = new int [ n ] [ m ] ; int [ ] [ ] before = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { char [ ] arr = sc . next ( ) . toCharArray ( ) ; for ( int j = 0 ; j < m ; j ++ ) { field [ i ] [ j ] = arr [ j ] - '0' ; } } for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < m - 1 ; j ++ ) { int x = field [ i - 1 ] [ j ] ; before [ i ] [ j ] = x ; field [ i - 1 ] [ j ] -= x ; field [ i + 1 ] [ j ] -= x ; field [ i ] [ j - 1 ] -= x ; field [ i ] [ j + 1 ] -= x ; } } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { sb . append ( before [ i ] [ j ] ) ; } sb . append ( \" \\n \" ) ; } System . out . print ( sb ) ; } }", "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 [ N ] [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < M ; j ++ ) { a [ i ] [ j ] = Integer . valueOf ( s . substring ( j , j + 1 ) ) ; } } int ret [ ] [ ] = new int [ N ] [ M ] ; for ( int i = 1 ; i < N - 1 ; i ++ ) { for ( int j = 1 ; j < M - 1 ; j ++ ) { int min = 10 ; min = Math . min ( a [ i ] [ j - 1 ] , min ) ; min = Math . min ( a [ i ] [ j + 1 ] , min ) ; min = Math . min ( a [ i + 1 ] [ j ] , min ) ; min = Math . min ( a [ i - 1 ] [ j ] , min ) ; a [ i ] [ j - 1 ] -= min ; a [ i ] [ j + 1 ] -= min ; a [ i + 1 ] [ j ] -= min ; a [ i - 1 ] [ j ] -= min ; ret [ i ] [ j ] = min ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { System . out . print ( ret [ i ] [ j ] ) ; } System . out . println ( ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { int i , j , n , m , a [ ] [ ] , b [ ] [ ] ; String a1 [ ] ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; a = new int [ n ] [ m ] ; b = new int [ n ] [ m ] ; a1 = new String [ n ] ; for ( i = 0 ; i < n ; i ++ ) a1 [ i ] = sc . next ( ) ; for ( i = 0 ; i < n ; i ++ ) for ( j = 0 ; j < m ; j ++ ) a [ i ] [ j ] = Character . getNumericValue ( a1 [ i ] . charAt ( j ) ) ; for ( i = 0 ; i < n ; i ++ ) for ( j = 0 ; j < m ; j ++ ) b [ i ] [ j ] = 0 ; for ( i = 0 ; i < n - 2 ; i ++ ) { for ( j = 1 ; j < m - 1 ; j ++ ) { if ( a [ i ] [ j ] != 0 ) { b [ i + 1 ] [ j ] = a [ i ] [ j ] ; a [ i + 1 ] [ j - 1 ] -= a [ i ] [ j ] ; a [ i + 1 ] [ j + 1 ] -= a [ i ] [ j ] ; a [ i + 2 ] [ j ] -= a [ i ] [ j ] ; a [ i ] [ j ] = 0 ; } } } for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) System . out . print ( b [ i ] [ j ] ) ; System . out . println ( \" \" ) ; } } }", "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 ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ n ] [ m ] ; int [ ] [ ] ret = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = Integer . valueOf ( s . substring ( j , j + 1 ) ) ; } } for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < m - 1 ; j ++ ) { int min = 10 ; min = Math . min ( min , a [ i - 1 ] [ j ] ) ; min = Math . min ( min , a [ i ] [ j - 1 ] ) ; min = Math . min ( min , a [ i + 1 ] [ j ] ) ; min = Math . min ( min , a [ i ] [ j + 1 ] ) ; a [ i - 1 ] [ j ] -= min ; a [ i ] [ j - 1 ] -= min ; a [ i + 1 ] [ j ] -= min ; a [ i ] [ j + 1 ] -= min ; ret [ i ] [ j ] = min ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { System . out . print ( ret [ i ] [ j ] ) ; } System . out . println ( \" \" ) ; } } }" ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE s = eval ( ' list ( map ( int , input ( ) ) ) , ' * n ) NEW_LINE a = eval ( ' [ 0 ] * m , ' * n ) NEW_LINE for i in range ( n - 2 ) : NEW_LINE INDENT for j in range ( 1 , m - 1 ) : NEW_LINE INDENT a [ i + 1 ] [ j ] = s [ i ] [ j ] NEW_LINE for x , y in ( ( i + 1 , j - 1 ) , ( i + 2 , j ) , ( i + 1 , j + 1 ) , ( i , j ) ) : NEW_LINE INDENT s [ x ] [ y ] -= s [ i ] [ j ] NEW_LINE DEDENT DEDENT DEDENT for i in a : NEW_LINE INDENT print ( * i , sep = ' ' ) NEW_LINE DEDENT", "def solve ( N , M , board ) : NEW_LINE INDENT before = [ [ 0 for _ in range ( M ) ] for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( M ) : NEW_LINE INDENT v = board [ i ] [ j ] NEW_LINE if v > 0 : NEW_LINE INDENT before [ i + 1 ] [ j ] = v NEW_LINE board [ i ] [ j ] -= v NEW_LINE board [ i + 2 ] [ j ] -= v NEW_LINE board [ i + 1 ] [ j - 1 ] -= v NEW_LINE board [ i + 1 ] [ j + 1 ] -= v NEW_LINE DEDENT DEDENT DEDENT return before NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE board = [ list ( map ( int , list ( input ( ) ) ) ) for _ in range ( N ) ] NEW_LINE ans = solve ( N , M , board ) NEW_LINE for a in ans : NEW_LINE INDENT print ( * a , sep = \" \" ) NEW_LINE DEDENT DEDENT", "from itertools import product NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE b = [ [ int ( x ) for x in list ( input ( ) ) ] for _ in range ( N ) ] NEW_LINE d = [ 0 , 1 , 0 , - 1 , 0 ] NEW_LINE a = [ [ '0' ] * M for _ in range ( N ) ] NEW_LINE for i , j in product ( range ( N ) [ 1 : - 1 ] , range ( M ) [ 1 : - 1 ] ) : NEW_LINE INDENT m = 10 NEW_LINE for dx , dy in zip ( d [ : - 1 ] , d [ 1 : ] ) : NEW_LINE INDENT x = i + dx NEW_LINE y = j + dy NEW_LINE m = min ( m , b [ x ] [ y ] ) NEW_LINE DEDENT for dx , dy in zip ( d [ : - 1 ] , d [ 1 : ] ) : NEW_LINE INDENT x = i + dx NEW_LINE y = j + dy NEW_LINE b [ x ] [ y ] -= m NEW_LINE DEDENT a [ i ] [ j ] = str ( m ) NEW_LINE DEDENT for x in a : NEW_LINE INDENT print ( ' ' . join ( x ) ) NEW_LINE DEDENT", "def b_amoeba ( N , M , Board ) : NEW_LINE INDENT ans_board = [ [ 0 ] * M for _ in [ None ] * N ] NEW_LINE for row in range ( 1 , N - 1 ) : NEW_LINE INDENT for col in range ( 1 , M - 1 ) : NEW_LINE INDENT v = min ( Board [ row - 1 ] [ col ] , Board [ row ] [ col + 1 ] , Board [ row + 1 ] [ col ] , Board [ row ] [ col - 1 ] ) NEW_LINE ans_board [ row ] [ col ] = v NEW_LINE Board [ row - 1 ] [ col ] -= v NEW_LINE Board [ row ] [ col + 1 ] -= v NEW_LINE Board [ row + 1 ] [ col ] -= v NEW_LINE Board [ row ] [ col - 1 ] -= v NEW_LINE DEDENT DEDENT ans = ' \\n ' . join ( ' ' . join ( map ( str , row ) ) for row in ans_board ) NEW_LINE return ans NEW_LINE DEDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE Board = [ [ int ( i ) for i in input ( ) ] for j in range ( N ) ] NEW_LINE print ( b_amoeba ( N , M , Board ) ) NEW_LINE", "n , m = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE x = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT b , c = input ( ) , [ ] NEW_LINE for i in b : c . append ( int ( i ) ) NEW_LINE x . append ( c ) NEW_LINE DEDENT ans = [ [ 0 for i in range ( m ) ] for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if x [ i ] [ j ] == 0 : continue NEW_LINE ans [ i + 1 ] [ j ] = x [ i ] [ j ] NEW_LINE for k , k2 in [ [ i + 1 , j - 1 ] , [ i + 1 , j + 1 ] , [ i + 2 , j ] , [ i , j ] ] : x [ k ] [ k2 ] -= x [ i ] [ j ] NEW_LINE DEDENT DEDENT for i in ans : NEW_LINE INDENT s = \" \" NEW_LINE for j in i : s += str ( j ) NEW_LINE print ( s ) NEW_LINE DEDENT" ]
atcoder_abc080_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 C = sc . nextInt ( ) ; int [ ] [ ] ar = new int [ C ] [ 100001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int s = sc . nextInt ( ) - 1 ; int t = sc . nextInt ( ) - 1 ; int c = sc . nextInt ( ) - 1 ; for ( int j = s ; j <= t ; j ++ ) { ar [ c ] [ j ] = 1 ; } } int ans = 0 ; for ( int i = 1 ; i < 100001 ; i ++ ) { int max = 0 ; for ( int j = 0 ; j < C ; j ++ ) { max += ar [ j ] [ i ] ; } ans = Math . max ( ans , max ) ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { static int modP = 1000000007 ; static long inf = 1 << 61 ; static int n , c ; static int [ ] S , T , C ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; c = in . nextInt ( ) ; S = new int [ n ] ; T = new int [ n ] ; C = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { S [ i ] = in . nextInt ( ) ; T [ i ] = in . nextInt ( ) ; C [ i ] = in . nextInt ( ) ; } int [ ] memo = new int [ 200005 ] ; int [ ] counts = new int [ 200005 ] ; for ( int j = 1 ; j <= c ; j ++ ) { Arrays . fill ( memo , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( j == C [ i ] ) { int si = S [ i ] ; int ti = T [ i ] ; memo [ 2 * si - 1 ] ++ ; memo [ 2 * ti ] -- ; } } for ( int i = 1 ; i < 200005 ; i ++ ) { memo [ i ] += memo [ i - 1 ] ; } for ( int i = 0 ; i < 200005 ; i ++ ) { if ( memo [ i ] > 0 ) { counts [ i ] ++ ; } } } int ans = Arrays . stream ( counts ) . max ( ) . getAsInt ( ) ; print ( ans ) ; } static void print ( String s ) { System . out . println ( s ) ; } static void print ( int i ) { System . out . println ( i ) ; } static void print ( long i ) { System . out . println ( i ) ; } static void print ( float i ) { System . out . println ( i ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; final int nMax = 100000 ; LinkedList < int [ ] > [ ] dic = new LinkedList [ C + 1 ] ; for ( int i = 0 ; i <= C ; i ++ ) dic [ i ] = new LinkedList < > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; dic [ c ] . add ( new int [ ] { s , t } ) ; } int [ ] res = new int [ nMax + 5 ] ; for ( int i = 1 ; i <= C ; i ++ ) { if ( dic [ i ] . size ( ) == 0 ) continue ; int [ ] cur = new int [ nMax + 5 ] ; while ( dic [ i ] . size ( ) > 0 ) { int [ ] temp = dic [ i ] . remove ( ) ; cur [ temp [ 0 ] ] ++ ; cur [ temp [ 1 ] + 1 ] -- ; } for ( int j = 1 ; j < nMax + 5 ; j ++ ) cur [ j ] = cur [ j - 1 ] + cur [ j ] ; for ( int j = 1 ; j < nMax + 5 ; j ++ ) { if ( cur [ j ] > 0 ) res [ j ] ++ ; } } int ans = 0 ; for ( int j = 1 ; j < nMax + 5 ; j ++ ) ans = Math . max ( ans , res [ j ] ) ; System . out . println ( ans ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "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 C = sc . nextInt ( ) ; int TIME = 100001 ; int [ ] [ ] acc = new int [ TIME ] [ C + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; acc [ s ] [ c ] += 1 ; acc [ t ] [ c ] -= 1 ; } for ( int t = 1 ; t < TIME ; t ++ ) { for ( int c = 1 ; c <= C ; c ++ ) { acc [ t ] [ c ] = acc [ t ] [ c ] + acc [ t - 1 ] [ c ] ; } } for ( int t = 1 ; t < TIME ; t ++ ) { for ( int c = 1 ; c <= C ; c ++ ) { if ( acc [ t ] [ c ] > 0 && acc [ t - 1 ] [ c ] != acc [ t ] [ c ] ) { acc [ t - 1 ] [ c ] += acc [ t ] [ c ] ; } } } int needMaxCnt = 0 ; for ( int t = 1 ; t < TIME ; t ++ ) { int tmpMaxCnt = 0 ; for ( int c = 1 ; c <= C ; c ++ ) { tmpMaxCnt += acc [ t ] [ c ] ; } needMaxCnt = Math . max ( needMaxCnt , tmpMaxCnt ) ; } out . println ( needMaxCnt ) ; } }", "import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int C = in . nextInt ( ) ; Map < Integer , List < int [ ] > > map = new HashMap < > ( ) ; for ( int i = 1 ; i <= C ; i ++ ) { List < int [ ] > list = new ArrayList < > ( ) ; map . put ( i , list ) ; } for ( int i = 0 ; i < n ; i ++ ) { int [ ] tmp = { in . nextInt ( ) , in . nextInt ( ) } ; int c = in . nextInt ( ) ; map . get ( c ) . add ( tmp ) ; } int [ ] time = new int [ 100002 ] ; for ( int i = 1 ; i <= C ; i ++ ) { List < int [ ] > list = map . get ( i ) ; list . sort ( ( st1 , st2 ) -> st1 [ 0 ] - st2 [ 0 ] ) ; int last = 0 ; for ( int [ ] st : list ) { if ( last == st [ 0 ] ) { time [ last + 1 ] ++ ; time [ st [ 1 ] + 1 ] -- ; last = st [ 1 ] ; } else { time [ st [ 0 ] ] ++ ; time [ st [ 1 ] + 1 ] -- ; last = st [ 1 ] ; } } } for ( int i = 1 ; i <= 100001 ; i ++ ) { time [ i ] += time [ i - 1 ] ; } int max = 0 ; for ( int i = 1 ; i <= 100001 ; i ++ ) { max = Math . max ( max , time [ i ] ) ; } System . out . println ( max ) ; in . close ( ) ; } }" ]
[ "n , c = map ( int , input ( ) . split ( ) ) NEW_LINE stc = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE stc . sort ( ) NEW_LINE R = [ [ stc [ 0 ] [ 1 ] , stc [ 0 ] [ 2 ] ] ] NEW_LINE for s , t , c in stc [ 1 : ] : NEW_LINE INDENT for i in range ( len ( R ) ) : NEW_LINE INDENT tr , cr = R [ i ] [ 0 ] , R [ i ] [ 1 ] NEW_LINE if c == cr and tr <= s : NEW_LINE INDENT R [ i ] = [ t , c ] NEW_LINE break NEW_LINE DEDENT if c != cr and tr < s : NEW_LINE INDENT R [ i ] = [ t , c ] NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT R . append ( [ t , c ] ) NEW_LINE DEDENT DEDENT print ( len ( R ) ) NEW_LINE", "from numpy import cumsum NEW_LINE n , c = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE stc = [ [ int ( item ) for item in input ( ) . split ( ) ] for _ in range ( n ) ] NEW_LINE stc . sort ( key = lambda x : ( x [ 2 ] , x [ 0 ] ) ) NEW_LINE timeline = [ 0 ] * ( 10 ** 5 + 1 ) NEW_LINE prev_c = - 1 NEW_LINE for s , t , c in stc : NEW_LINE INDENT if prev_c != c : NEW_LINE INDENT prev_t = - 100 NEW_LINE DEDENT if prev_t != s : NEW_LINE INDENT timeline [ s - 1 ] += 1 NEW_LINE timeline [ t ] += - 1 NEW_LINE DEDENT else : NEW_LINE INDENT timeline [ s ] += 1 NEW_LINE timeline [ t ] += - 1 NEW_LINE DEDENT prev_t = t NEW_LINE prev_c = c NEW_LINE DEDENT print ( max ( cumsum ( timeline ) ) ) NEW_LINE", "def recording ( N : int , C : int , info : list ) -> int : NEW_LINE INDENT _ , max_time , _ = max ( info , key = lambda x : x [ 1 ] ) NEW_LINE max_time = 2 * max_time NEW_LINE recorders = [ [ 0 ] * C for _ in range ( max_time + 1 ) ] NEW_LINE for s , t , ch in info : NEW_LINE INDENT recorders [ 2 * s - 1 ] [ ch - 1 ] += 1 NEW_LINE recorders [ 2 * t ] [ ch - 1 ] -= 1 NEW_LINE DEDENT for t in range ( max_time ) : NEW_LINE INDENT for ch in range ( C ) : NEW_LINE INDENT recorders [ t + 1 ] [ ch ] += recorders [ t ] [ ch ] NEW_LINE DEDENT DEDENT return max ( sum ( used > 0 for used in recorders [ t ] ) for t in range ( max_time + 1 ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = 0 NEW_LINE N , C = map ( int , input ( ) . split ( ) ) NEW_LINE info = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE ans = recording ( N , C , info ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N , C = map ( int , input ( ) . split ( ) ) NEW_LINE dic = [ [ ] for _ in range ( C + 1 ) ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT s , t , c = input ( ) . split ( ) NEW_LINE dic [ int ( c ) ] . append ( [ int ( s ) , int ( t ) ] ) NEW_LINE DEDENT for c in range ( C + 1 ) : NEW_LINE INDENT l = len ( dic [ c ] ) NEW_LINE if l == 1 : NEW_LINE INDENT continue NEW_LINE DEDENT dic [ c ] = sorted ( dic [ c ] ) NEW_LINE i = 0 NEW_LINE while i < l - 1 : NEW_LINE INDENT if i < l - 1 and dic [ c ] [ i ] [ 1 ] == dic [ c ] [ i + 1 ] [ 0 ] : NEW_LINE INDENT dic [ c ] [ i + 1 ] [ 0 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT i += 1 NEW_LINE DEDENT DEDENT DEDENT f = [ 0 for _ in range ( 100002 ) ] NEW_LINE for c in range ( C + 1 ) : NEW_LINE INDENT for t in dic [ c ] : NEW_LINE INDENT f [ t [ 0 ] ] += 1 NEW_LINE f [ t [ 1 ] + 1 ] -= 1 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 1 , 100001 ) : NEW_LINE INDENT f [ i ] += f [ i - 1 ] NEW_LINE if ans < f [ i ] : NEW_LINE INDENT ans = f [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "ri = lambda : int ( input ( ) ) NEW_LINE rl = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE rr = lambda N : [ ri ( ) for _ in range ( N ) ] NEW_LINE YN = lambda b : print ( ' YES ' ) if b else print ( ' NO ' ) NEW_LINE yn = lambda b : print ( ' Yes ' ) if b else print ( ' No ' ) NEW_LINE OE = lambda x : print ( ' Odd ' ) if x % 2 else print ( ' Even ' ) NEW_LINE INF = 10 ** 18 NEW_LINE N , C = rl ( ) NEW_LINE stc = [ rl ( ) for _ in range ( N ) ] NEW_LINE stc . sort ( key = lambda x : ( x [ 2 ] , x [ 0 ] ) ) NEW_LINE nstc = [ ] NEW_LINE for s , t , c in stc : NEW_LINE INDENT if len ( nstc ) != 0 and nstc [ - 1 ] [ 2 ] == c and nstc [ - 1 ] [ 1 ] == s : NEW_LINE INDENT nstc [ - 1 ] [ 1 ] = t NEW_LINE DEDENT else : NEW_LINE INDENT nstc . append ( [ s , t , c ] ) NEW_LINE DEDENT DEDENT n = len ( nstc ) NEW_LINE TT = [ 0 ] * ( 2 * 10 ** 5 + 5 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT TT [ 2 * nstc [ i ] [ 0 ] - 1 ] += 1 NEW_LINE TT [ 2 * nstc [ i ] [ 1 ] ] -= 1 NEW_LINE DEDENT for i in range ( 1 , len ( TT ) ) : NEW_LINE INDENT TT [ i ] += TT [ i - 1 ] NEW_LINE DEDENT print ( max ( TT ) ) NEW_LINE" ]
atcoder_abc037_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 ( ) ; System . out . print ( Math . max ( c / a , c / 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 c = in . nextInt ( ) ; out . println ( c / Math . min ( a , b ) ) ; } } 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 a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( c / Math . min ( a , 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 . 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 ( ) , c = nextInt ( ) ; out . println ( c / min ( a , 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 A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; out . println ( A < B ? C / A : C / B ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }" ]
[ "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if A <= B : NEW_LINE INDENT print ( C // A ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( C // B ) NEW_LINE DEDENT", "def manju ( A : int , B : int , C : int ) -> int : NEW_LINE INDENT max_num = 0 NEW_LINE for numA in range ( C // A + 1 ) : NEW_LINE INDENT numB = ( C - A * numA ) // B NEW_LINE if numB < 0 : NEW_LINE INDENT break NEW_LINE DEDENT max_num = max ( max_num , numA + numB ) NEW_LINE DEDENT return max_num NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE ans = manju ( A , B , C ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "A , B , C = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE a = min ( A , B ) NEW_LINE print ( int ( C / a ) ) NEW_LINE", "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE D = A NEW_LINE count = 0 NEW_LINE if B < A : NEW_LINE INDENT A = B NEW_LINE B = D NEW_LINE DEDENT while True : NEW_LINE INDENT if C >= A : NEW_LINE INDENT C = C - A NEW_LINE count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE", "a , b , c = map ( int , input ( ) . split ( ) ) ; print ( c // min ( a , b ) ) NEW_LINE" ]
atcoder_abc028_C
[ "import java . util . Arrays ; 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 = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int e = scan . nextInt ( ) ; int [ ] num = new int [ 5 ] ; num [ 0 ] = a ; num [ 1 ] = b ; num [ 2 ] = c ; num [ 3 ] = d ; num [ 4 ] = e ; Arrays . sort ( num ) ; int ans = num [ 1 ] + num [ 2 ] + num [ 4 ] ; int ans2 = num [ 4 ] + num [ 3 ] + num [ 0 ] ; System . out . println ( Math . max ( ans2 , 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 int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int [ ] ar = nextIntArray ( 5 ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < ( Math . pow ( 2 , 5 ) ) ; i ++ ) { if ( Integer . bitCount ( i ) != 3 ) continue ; int tempSum = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( ( 1 & i >> j ) == 1 ) { tempSum += ar [ j ] ; } } list . add ( tempSum ) ; } Collections . sort ( list ) ; out . println ( list . get ( list . size ( ) - 3 ) ) ; } }", "import java . util . Comparator ; import java . util . stream . Stream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int a = scanner . nextInt ( ) , b = scanner . nextInt ( ) , c = scanner . nextInt ( ) , d = scanner . nextInt ( ) , e = scanner . nextInt ( ) ; Stream . of ( a + b + c , a + b + d , a + b + e , a + c + d , a + c + e , a + d + e , b + c + d , b + c + e , b + d + e , c + d + e ) . distinct ( ) . sorted ( Comparator . reverseOrder ( ) ) . skip ( 2 ) . findFirst ( ) . ifPresent ( 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 A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int E = sc . nextInt ( ) ; out . println ( Math . max ( A + D + E , B + C + E ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] po = new int [ 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) po [ i ] = sc . nextInt ( ) ; int ans [ ] = new int [ ] { po [ 0 ] + po [ 1 ] + po [ 2 ] , po [ 0 ] + po [ 1 ] + po [ 3 ] , po [ 0 ] + po [ 1 ] + po [ 4 ] , po [ 0 ] + po [ 2 ] + po [ 3 ] , po [ 0 ] + po [ 2 ] + po [ 4 ] , po [ 0 ] + po [ 3 ] + po [ 4 ] , po [ 1 ] + po [ 2 ] + po [ 3 ] , po [ 1 ] + po [ 2 ] + po [ 4 ] , po [ 1 ] + po [ 3 ] + po [ 4 ] , po [ 2 ] + po [ 3 ] + po [ 4 ] } ; Arrays . sort ( ans ) ; System . out . println ( ans [ 7 ] ) ; } }" ]
[ "import itertools NEW_LINE l = list ( map ( int , ( input ( ) . split ( ) ) ) ) NEW_LINE sm = [ ] NEW_LINE for p in itertools . combinations ( l , 3 ) : NEW_LINE INDENT sm . append ( sum ( p ) ) NEW_LINE DEDENT sm . sort ( reverse = True ) NEW_LINE print ( sm [ 2 ] ) NEW_LINE", "ABCDE = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE total_list = [ ] NEW_LINE for i in ABCDE : NEW_LINE INDENT for j in ABCDE : NEW_LINE INDENT if i == j : NEW_LINE INDENT continue NEW_LINE DEDENT for k in ABCDE : NEW_LINE INDENT if j == k or i == k : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT total = i + j + k NEW_LINE if not total in total_list : NEW_LINE INDENT total_list . append ( total ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT total_list . sort ( ) NEW_LINE print ( total_list [ - 3 ] ) NEW_LINE", "from itertools import permutations NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ ] NEW_LINE for x in permutations ( [ 0 , 0 , 1 , 1 , 1 ] ) : NEW_LINE INDENT sum = 0 NEW_LINE for i , y in enumerate ( x ) : NEW_LINE INDENT if y == 1 : NEW_LINE INDENT sum += a [ i ] NEW_LINE DEDENT DEDENT ans . append ( sum ) NEW_LINE DEDENT b = list ( set ( ans ) ) NEW_LINE b . sort ( ) NEW_LINE print ( b [ - 3 ] ) NEW_LINE", "num = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE ans = [ ] NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT for j in range ( i + 1 , 4 ) : NEW_LINE INDENT for k in range ( j + 1 , 5 ) : NEW_LINE INDENT ans . append ( num [ i ] + num [ j ] + num [ k ] ) NEW_LINE DEDENT DEDENT DEDENT ans = sorted ( list ( set ( ans ) ) ) NEW_LINE print ( ans [ - 3 ] ) NEW_LINE", "a , b , c , d , e = map ( int , input ( ) . split ( ) ) NEW_LINE s = a + b + c + d + e NEW_LINE l = [ a , b , c , d , e ] NEW_LINE l1 = [ ] NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT for j in range ( i + 1 , 5 ) : NEW_LINE INDENT l1 . append ( s - l [ i ] - l [ j ] ) NEW_LINE DEDENT DEDENT l1 = sorted ( l1 ) NEW_LINE print ( l1 [ - 3 ] ) NEW_LINE" ]
atcoder_abc023_C
[ "import java . util . Scanner ; public class Main { static int r , c , k , n ; static int [ ] rc , cc ; public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; r = sc . nextInt ( ) ; c = sc . nextInt ( ) ; k = sc . nextInt ( ) ; n = sc . nextInt ( ) ; rc = new int [ n ] ; cc = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { rc [ i ] = sc . nextInt ( ) - 1 ; cc [ i ] = sc . nextInt ( ) - 1 ; } long ans = solve ( ) ; System . out . println ( ans ) ; } static long solve ( ) { int [ ] candyInR = new int [ r + 1 ] ; int [ ] candyInC = new int [ c + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { candyInR [ rc [ i ] ] ++ ; candyInC [ cc [ i ] ] ++ ; } int [ ] countR = new int [ n + 1 ] ; int [ ] countC = new int [ n + 1 ] ; for ( int i = 0 ; i < r ; i ++ ) countR [ candyInR [ i ] ] ++ ; for ( int i = 0 ; i < c ; i ++ ) countC [ candyInC [ i ] ] ++ ; long ans = 0 ; for ( int i = 0 ; i <= k ; i ++ ) ans += countR [ i ] * countC [ k - i ] ; for ( int i = 0 ; i < n ; i ++ ) { int sum = candyInR [ rc [ i ] ] + candyInC [ cc [ i ] ] ; if ( sum == k ) ans -- ; if ( sum == k + 1 ) ans ++ ; } return 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 ( ) , n = scanner . nextInt ( ) ; int [ ] ra = new int [ n ] , ca = new int [ n ] , rSum = new int [ r ] , cSum = new int [ c ] ; for ( int i = 0 ; i < n ; i ++ ) { rSum [ ra [ i ] = scanner . nextInt ( ) - 1 ] ++ ; cSum [ ca [ i ] = scanner . nextInt ( ) - 1 ] ++ ; } long [ ] rb = new long [ n + 1 ] , cb = new long [ n + 1 ] ; for ( int i : rSum ) rb [ i ] ++ ; for ( int i : cSum ) cb [ i ] ++ ; System . out . println ( java . util . stream . IntStream . rangeClosed ( 0 , k ) . mapToLong ( i -> rb [ i ] * cb [ k - i ] ) . sum ( ) + java . util . stream . IntStream . range ( 0 , n ) . map ( i -> rSum [ ra [ i ] ] + cSum [ ca [ i ] ] - k ) . map ( i -> ( i == 0 ? - 1 : i == 1 ? 1 : 0 ) ) . sum ( ) ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] rck = scanner . nextLine ( ) . split ( \" ▁ \" , 3 ) ; int R = Integer . parseInt ( rck [ 0 ] ) ; int C = Integer . parseInt ( rck [ 1 ] ) ; int K = Integer . parseInt ( rck [ 2 ] ) ; int N = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] countPerR = new int [ R + 1 ] ; int [ ] countPerC = new int [ C + 1 ] ; int [ ] Rs = new int [ N ] ; int [ ] Cs = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String [ ] rc = scanner . nextLine ( ) . split ( \" ▁ \" , 2 ) ; int r = Integer . parseInt ( rc [ 0 ] ) ; int c = Integer . parseInt ( rc [ 1 ] ) ; countPerR [ r ] ++ ; countPerC [ c ] ++ ; Rs [ i ] = r ; Cs [ i ] = c ; } long [ ] rPerCount = new long [ N + 1 ] ; for ( int i = 1 ; i <= R ; i ++ ) { rPerCount [ countPerR [ i ] ] ++ ; } long [ ] cPerCount = new long [ N + 1 ] ; for ( int i = 1 ; i <= C ; i ++ ) { cPerCount [ countPerC [ i ] ] ++ ; } long result = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { result += rPerCount [ i ] * cPerCount [ K - i ] ; } for ( int i = 0 ; i < N ; i ++ ) { int r = Rs [ i ] ; int c = Cs [ i ] ; long count = countPerR [ r ] + countPerC [ c ] ; if ( count == K ) { result -- ; } else if ( count == K + 1 ) { result ++ ; } } System . out . println ( result ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int R = scan . nextInt ( ) ; int C = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int N = scan . nextInt ( ) ; int [ ] [ ] p = new int [ N ] [ 2 ] ; int [ ] row = new int [ R + 1 ] ; int [ ] col = new int [ C + 1 ] ; Arrays . fill ( row , 0 ) ; Arrays . fill ( col , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int r = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; p [ i ] [ 0 ] = r ; p [ i ] [ 1 ] = c ; row [ r ] ++ ; col [ c ] ++ ; } scan . close ( ) ; int [ ] row1 = new int [ 100000 + 1 ] ; int [ ] col1 = new int [ 100000 + 1 ] ; Arrays . fill ( row1 , 0 ) ; Arrays . fill ( col1 , 0 ) ; for ( int i = 1 ; i <= R ; i ++ ) { row1 [ row [ i ] ] ++ ; } for ( int i = 1 ; i <= C ; i ++ ) { col1 [ col [ i ] ] ++ ; } long cnt = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { cnt += row1 [ i ] * col1 [ K - i ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( row [ p [ i ] [ 0 ] ] + col [ p [ i ] [ 1 ] ] == K ) { cnt -- ; } else if ( row [ p [ i ] [ 0 ] ] + col [ p [ i ] [ 1 ] ] == K + 1 ) { cnt ++ ; } } System . out . println ( cnt ) ; } }", "import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int r = s . nextInt ( ) , c = s . nextInt ( ) , k = s . nextInt ( ) ; int [ ] cx = new int [ r ] , cy = new int [ c ] , ccx = new int [ k + 1 ] , ccy = new int [ k + 1 ] ; Map < Integer , List < Integer > > p = new HashMap < > ( ) ; for ( int n = s . nextInt ( ) ; n > 0 ; -- n ) { int X = s . nextInt ( ) - 1 , Y = s . nextInt ( ) - 1 ; p . computeIfAbsent ( X , ( i ) -> new ArrayList < > ( ) ) . add ( Y ) ; cx [ X ] ++ ; cy [ Y ] ++ ; } for ( int X : cx ) if ( X < k + 1 ) ccx [ X ] ++ ; for ( int Y : cy ) if ( Y < k + 1 ) ccy [ Y ] ++ ; long res = 0 ; for ( int x = 0 ; x < r ; ++ x ) { int need = k - cx [ x ] ; if ( need < 0 ) continue ; int CY = ccy [ need ] ; if ( p . containsKey ( x ) ) { for ( int y : p . get ( x ) ) { if ( cy [ y ] - 1 == need ) ++ res ; if ( cy [ y ] == need ) -- CY ; } } res += CY ; } System . out . println ( res ) ; } }" ]
[ "r , c , k = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE RC = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( n ) ] NEW_LINE R = [ 0 ] * r NEW_LINE C = [ 0 ] * c NEW_LINE for i in range ( n ) : NEW_LINE INDENT R [ RC [ i ] [ 0 ] - 1 ] += 1 NEW_LINE C [ RC [ i ] [ 1 ] - 1 ] += 1 NEW_LINE DEDENT R2 = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( r ) : NEW_LINE INDENT R2 [ R [ i ] ] += 1 NEW_LINE DEDENT C2 = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( c ) : NEW_LINE INDENT C2 [ C [ i ] ] += 1 NEW_LINE DEDENT cnt = 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT j = k - i NEW_LINE cnt += R2 [ i ] * C2 [ j ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if R [ RC [ i ] [ 0 ] - 1 ] + C [ RC [ i ] [ 1 ] - 1 ] == k : NEW_LINE INDENT cnt -= 1 NEW_LINE DEDENT if R [ RC [ i ] [ 0 ] - 1 ] + C [ RC [ i ] [ 1 ] - 1 ] == k + 1 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE", "import sys NEW_LINE import collections NEW_LINE import itertools NEW_LINE def parse_input ( input_lines ) : NEW_LINE INDENT return tuple ( map ( lambda sl : tuple ( map ( int , sl ) ) , map ( lambda s : s . strip ( ) . split ( ) , input_lines ) ) ) NEW_LINE DEDENT def main ( R , C , K , set_candies ) : NEW_LINE INDENT r_candies = [ 0 ] * R NEW_LINE c_candies = [ 0 ] * C NEW_LINE for i , ( r , c ) in enumerate ( set_candies ) : NEW_LINE INDENT r_candies [ r - 1 ] += 1 NEW_LINE c_candies [ c - 1 ] += 1 NEW_LINE DEDENT r_sums = collections . Counter ( r_candies ) NEW_LINE c_sums = collections . Counter ( c_candies ) NEW_LINE count = 0 NEW_LINE for i in range ( K + 1 ) : NEW_LINE INDENT count += r_sums [ i ] * c_sums [ K - i ] NEW_LINE DEDENT for r , c in set_candies : NEW_LINE INDENT got_candies = r_candies [ r - 1 ] + c_candies [ c - 1 ] NEW_LINE if got_candies == K : NEW_LINE INDENT count -= 1 NEW_LINE DEDENT if got_candies == K + 1 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT ( R , C , K ) , _ , * set_candies = parse_input ( sys . stdin . readlines ( ) ) NEW_LINE print ( main ( R , C , K , set_candies ) ) NEW_LINE DEDENT", "from collections import Counter NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE R , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE X = [ 0 ] * R NEW_LINE Y = [ 0 ] * C NEW_LINE pos = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b = map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) NEW_LINE X [ a ] += 1 NEW_LINE Y [ b ] += 1 NEW_LINE pos . append ( [ a , b ] ) NEW_LINE DEDENT Cx = Counter ( X ) NEW_LINE Cy = Counter ( Y ) NEW_LINE ans = 0 NEW_LINE for i in range ( 0 , K + 1 ) : NEW_LINE INDENT ans += Cx [ i ] * Cy [ K - i ] NEW_LINE DEDENT for x , y in pos : NEW_LINE INDENT if X [ x ] + Y [ y ] == K : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT elif X [ x ] + Y [ y ] == K + 1 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import bisect NEW_LINE from collections import defaultdict NEW_LINE r , c , k = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE cnt_row = [ 0 for i in range ( r ) ] NEW_LINE cnt_col = [ 0 for i in range ( c ) ] NEW_LINE pos_ame = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT pos_row , pos_col = map ( int , input ( ) . split ( ) ) NEW_LINE cnt_row [ pos_row - 1 ] += 1 NEW_LINE cnt_col [ pos_col - 1 ] -= 1 NEW_LINE pos_ame . append ( [ pos_row - 1 , pos_col - 1 ] ) NEW_LINE DEDENT srtd_cnt_row = sorted ( cnt_row ) NEW_LINE srtd_cnt_col = sorted ( cnt_col ) NEW_LINE ans = 0 NEW_LINE left_r = 0 NEW_LINE left_c = bisect . bisect_right ( srtd_cnt_col , - ( k + 1 ) ) NEW_LINE for i in range ( k + 1 ) : NEW_LINE INDENT right_r = bisect . bisect_right ( srtd_cnt_row , i , left_r ) NEW_LINE right_c = bisect . bisect_right ( srtd_cnt_col , - k + i , left_c ) NEW_LINE ans = ans + ( right_r - left_r ) * ( right_c - left_c ) NEW_LINE left_r = right_r NEW_LINE left_c = right_c NEW_LINE DEDENT for i , j in pos_ame : NEW_LINE INDENT if cnt_row [ i ] - cnt_col [ j ] == k : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT elif cnt_row [ i ] - cnt_col [ j ] == k + 1 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT rows , cols , k = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE candies = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT r , c = map ( int , input ( ) . split ( ) ) NEW_LINE candies . append ( ( r - 1 , c - 1 ) ) NEW_LINE DEDENT print ( solve ( rows , cols , k , candies ) ) NEW_LINE DEDENT def solve ( rows , cols , k , candies ) : NEW_LINE INDENT row_c = count ( ( c [ 0 ] for c in candies ) , rows ) NEW_LINE col_c = count ( ( c [ 1 ] for c in candies ) , cols ) NEW_LINE row_cc = count ( row_c . values ( ) , cols + 1 ) NEW_LINE col_cc = count ( col_c . values ( ) , rows + 1 ) NEW_LINE cnt = 0 NEW_LINE for i in range ( k + 1 ) : NEW_LINE INDENT cnt += row_cc . get ( i , 0 ) * col_cc . get ( k - i , 0 ) NEW_LINE DEDENT for r , c in candies : NEW_LINE INDENT x = row_c [ r ] + col_c [ c ] NEW_LINE if x == k : NEW_LINE INDENT cnt -= 1 NEW_LINE DEDENT elif x == k + 1 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT def count ( items , m ) : NEW_LINE INDENT cnt = dict ( ( i , 0 ) for i in range ( m ) ) NEW_LINE for v in items : NEW_LINE INDENT cnt [ v ] = cnt . get ( v , 0 ) + 1 NEW_LINE DEDENT return cnt NEW_LINE DEDENT main ( ) NEW_LINE" ]
atcoder_agc004_B
[ "import java . util . * ; import java . util . stream . * ; public class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; long x = s . nextInt ( ) ; long [ ] [ ] a = new long [ n ] [ n ] ; Arrays . setAll ( a [ 0 ] , i -> s . nextLong ( ) ) ; for ( int j = 0 ; j < n ; ++ j ) { for ( int i = 1 ; i < n ; ++ i ) { a [ i ] [ j ] = Math . min ( a [ i - 1 ] [ j ] , a [ 0 ] [ ( j - i + n ) % n ] ) ; } } System . out . println ( IntStream . range ( 0 , n ) . mapToLong ( i -> i * x + Arrays . stream ( a [ i ] ) . sum ( ) ) . min ( ) . getAsLong ( ) ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . LongStream ; 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 ) ; BColorfulSlimes solver = new BColorfulSlimes ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BColorfulSlimes { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; long x = in . nextLong ( ) ; long [ ] [ ] a = new long [ n ] [ n ] ; a [ 0 ] = LongStream . range ( 0 , n ) . map ( z -> in . nextInt ( ) ) . toArray ( ) ; long ans = LongStream . of ( a [ 0 ] ) . sum ( ) ; for ( int k = 1 ; k < n ; k ++ ) { for ( int i = 0 ; i < n ; i ++ ) { a [ k ] [ i ] = Math . min ( a [ k - 1 ] [ ( i + n - 1 ) % n ] , a [ 0 ] [ i ] ) ; } ans = Math . min ( ans , LongStream . of ( a [ k ] ) . sum ( ) + k * x ) ; } out . println ( ans ) ; } } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { int n ; long x ; long [ ] as ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; x = sc . nextLong ( ) ; as = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextLong ( ) ; } long [ ] [ ] b = new long [ 2 ] [ n ] ; Arrays . fill ( b [ 0 ] , 1L << 50 ) ; int idx = 1 ; long ans = 1L << 50 ; for ( int k = 0 ; k < n ; k ++ ) { long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { b [ idx ] [ i ] = Math . min ( b [ 1 - idx ] [ i ] , as [ ( i + n - k ) % n ] ) ; sum += b [ idx ] [ i ] ; } ans = Math . min ( ans , k * x + sum ) ; idx = 1 - idx ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "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 ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int x = scanner . nextInt ( ) ; int INF = Integer . MAX_VALUE ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } int [ ] b = new int [ n ] ; Arrays . fill ( b , INF ) ; long ans = Long . MAX_VALUE ; for ( int magic = 0 ; magic < n ; magic ++ ) { long s = ( long ) magic * x ; for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = Math . min ( b [ i ] , a [ ( i + n - magic ) % n ] ) ; s += b [ i ] ; } ans = Math . min ( ans , s ) ; } System . out . println ( ans ) ; } }", "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 ( ) ; long x = sc . nextLong ( ) ; long [ ] a = new long [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long [ ] [ ] partmin = new long [ N + 1 ] [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = i ; j <= N + i - 1 ; j ++ ) { if ( i == j ) { partmin [ i ] [ j ] = a [ i ] ; } else { int k = ( j - 1 ) % N + 1 ; if ( k != 1 ) { partmin [ i ] [ k ] = Math . min ( partmin [ i ] [ k - 1 ] , a [ k ] ) ; } else { partmin [ i ] [ k ] = Math . min ( partmin [ i ] [ N ] , a [ 1 ] ) ; } } } } long min = 1000000000 ; min = min * min ; for ( long i = 0 ; i < N ; i ++ ) { long cost = i * x ; for ( int j = 1 ; j <= N ; j ++ ) { cost += partmin [ ( int ) ( N + j - i - 1 ) % N + 1 ] [ j ] ; } min = Math . min ( min , cost ) ; } System . out . println ( min ) ; } }" ]
[ "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE import numpy as np NEW_LINE N , x = inpl ( ) NEW_LINE a = np . array ( inpl ( ) ) NEW_LINE b = np . copy ( a ) NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT c = np . roll ( a , i ) NEW_LINE b = np . minimum ( b , c ) NEW_LINE ans = min ( ans , sum ( b ) + i * x ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE n , x = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE T = A [ : ] NEW_LINE ans = sum ( T ) NEW_LINE for j in range ( 1 , n ) : NEW_LINE INDENT T = [ min ( T [ i ] , A [ i - j ] ) for i in range ( n ) ] NEW_LINE ans = min ( ans , sum ( T ) + x * j ) NEW_LINE 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 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 , x = LI ( ) NEW_LINE A = LI ( ) NEW_LINE min_a , min_i = INF , - 1 NEW_LINE res = 0 NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if a < min_a : NEW_LINE INDENT min_a = a NEW_LINE min_i = i NEW_LINE DEDENT res += a NEW_LINE DEDENT A = A [ min_i : ] + A [ : min_i ] NEW_LINE dp = [ INF ] + A NEW_LINE for k in range ( n - 1 ) : NEW_LINE INDENT tmp = 0 NEW_LINE for i in range ( n ) [ : : - 1 ] : NEW_LINE INDENT if dp [ i + 1 ] > dp [ i ] : NEW_LINE INDENT dp [ i + 1 ] = dp [ i ] NEW_LINE DEDENT tmp += dp [ i + 1 ] NEW_LINE DEDENT res = min ( res , tmp + ( k + 1 ) * x ) NEW_LINE DEDENT return res NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "N , x = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE A = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE ans = sum ( A ) NEW_LINE for k in range ( 1 , N + 1 ) : NEW_LINE INDENT A = [ min ( i , j ) for i , j in zip ( A , A [ 1 : ] + [ A [ 0 ] ] ) ] NEW_LINE ans = min ( ans , x * k + sum ( A ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "N , x = map ( int , input ( ) . split ( ) ) NEW_LINE a_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ex_list = a_list . copy ( ) NEW_LINE ex_list . extend ( a_list ) NEW_LINE ans = float ( \" inf \" ) NEW_LINE cost_list = [ float ( \" inf \" ) for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT cost = 0 NEW_LINE for j in range ( N ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT cost += ex_list [ N + j ] NEW_LINE cost_list [ j ] = ex_list [ N + j ] NEW_LINE DEDENT else : NEW_LINE INDENT tmp = cost_list [ j ] NEW_LINE if tmp > ex_list [ N - i + j ] : NEW_LINE INDENT cost_list [ j ] = ex_list [ N - i + j ] NEW_LINE cost += ex_list [ N - i + j ] NEW_LINE DEDENT else : NEW_LINE INDENT cost += tmp NEW_LINE DEDENT DEDENT DEDENT cost += x * i NEW_LINE ans = min ( ans , cost ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc119_A
[ "import java . text . ParseException ; import java . text . SimpleDateFormat ; import java . util . Date ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( \" yyyy / MM / dd \" ) ; Date date1 = null ; Date date2 = null ; try { date1 = sdf . parse ( S ) ; date2 = sdf . parse ( \"2019/04/30\" ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } if ( date1 . compareTo ( date2 ) == - 1 || date1 . compareTo ( date2 ) == 0 ) { System . out . println ( \" Heisei \" ) ; } else { System . out . println ( \" TBD \" ) ; } } }", "import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String b = scan . next ( ) ; String ans = null ; if ( Integer . parseInt ( b . replaceAll ( \" / \" , \" \" ) ) > 20190430 ) { ans = \" TBD \" ; } else { ans = \" Heisei \" ; } PrintWriter out = new PrintWriter ( System . out ) ; out . println ( ans ) ; out . flush ( ) ; scan . close ( ) ; } }", "import java . time . LocalDate ; import java . time . format . DateTimeFormatter ; import java . time . format . ResolverStyle ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; scanner . close ( ) ; DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( \" yyyy / MM / dd \" ) ; formatter . withResolverStyle ( ResolverStyle . LENIENT ) ; LocalDate tDate = LocalDate . parse ( \"2019/04/30\" , formatter ) ; LocalDate ldt = LocalDate . parse ( S , formatter ) ; if ( ldt . isEqual ( tDate ) || ldt . isBefore ( tDate ) ) { System . out . println ( \" Heisei \" ) ; } else { System . out . println ( \" TBD \" ) ; } } }", "import java . text . ParseException ; import java . text . SimpleDateFormat ; import java . util . Calendar ; import java . util . Date ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws ParseException { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String h = \" Heisei \" ; String t = \" TBD \" ; Calendar c = Calendar . getInstance ( ) ; SimpleDateFormat f = new SimpleDateFormat ( \" yyyy / MM / dd \" ) ; Date d = f . parse ( \"2019/05/01\" ) ; if ( f . parse ( s ) . before ( d ) ) System . out . println ( h ) ; else System . out . println ( t ) ; } }", "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 ) ; TaskAtCoder119 solver = new TaskAtCoder119 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskAtCoder119 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { if ( in . next ( ) . compareTo ( \"2019/04/30\" ) <= 0 ) out . println ( \" Heisei \" ) ; else out . println ( \" TBD \" ) ; } } }" ]
[ "s = int ( input ( ) . replace ( \" / \" , \" \" ) ) NEW_LINE print ( \" Heisei \" if s <= 20190430 else \" TBD \" ) NEW_LINE", "i = input ( ) NEW_LINE x = [ s . strip ( ) for s in i . split ( ' / ' ) ] NEW_LINE if int ( x [ 0 ] ) < 2019 : NEW_LINE INDENT print ( ' Heisei ' ) NEW_LINE DEDENT elif int ( x [ 0 ] ) == 2019 : NEW_LINE INDENT if int ( x [ 1 ] ) < 5 : NEW_LINE INDENT print ( ' Heisei ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' TBD ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' TBD ' ) NEW_LINE DEDENT", "print ( ' Heisei ' if input ( ) <= '2019/04/30' else ' TBD ' ) NEW_LINE", "S = str ( input ( ) ) NEW_LINE def checker ( y , m , d ) : NEW_LINE INDENT if y < 2019 : return ' Heisei ' NEW_LINE if y > 2019 : return ' Heisei ' NEW_LINE if m in [ 1 , 2 , 3 , 4 ] : return ' Heisei ' NEW_LINE return ' TBD ' NEW_LINE DEDENT y , m , d = map ( int , S . split ( ' / ' ) ) NEW_LINE print ( checker ( y , m , d ) ) NEW_LINE", "from datetime import datetime as dt NEW_LINE date = input ( ) NEW_LINE new_date = dt . strptime ( date , ' % Y / % m / % d ' ) NEW_LINE if new_date <= dt ( 2019 , 4 , 30 ) : NEW_LINE INDENT print ( ' Heisei ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' TBD ' ) NEW_LINE DEDENT" ]
atcoder_arc024_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int K = in . nextInt ( ) ; String S = in . next ( ) ; HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; String [ ] s = new String [ N - K + 1 ] ; int [ ] arr = new int [ 26 ] ; for ( int i = 0 ; i <= N - K ; i ++ ) { if ( i == 0 ) { for ( int j = 0 ; j <= N ; j ++ ) { arr [ S . charAt ( i ) - ' a ' ] ++ ; } } else { arr [ S . charAt ( i - 1 ) - ' a ' ] -- ; arr [ S . charAt ( i + K - 1 ) - ' a ' ] ++ ; } s [ i ] = Arrays . toString ( arr ) ; if ( map . containsKey ( s [ i ] ) ) { map . put ( s [ i ] , Math . max ( map . get ( s [ i ] ) , i ) ) ; } else { map . put ( s [ i ] , i ) ; } } for ( int i = 0 ; i <= N - K ; i ++ ) { if ( map . get ( s [ i ] ) - i >= K ) { System . out . println ( \" YES \" ) ; return ; } } System . out . println ( \" NO \" ) ; } }", "import java . util . * ; public class Main { private static int N ; private static int K ; private static String S ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; K = scan . nextInt ( ) ; S = scan . next ( ) ; } public static void main ( String args [ ] ) { input ( ) ; HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; String [ ] s = new String [ N - K + 1 ] ; int [ ] arr = new int [ 26 ] ; for ( int i = 0 ; i <= N - K ; i ++ ) { if ( i == 0 ) { for ( int j = 0 ; j < N ; j ++ ) arr [ S . charAt ( j ) - ' a ' ] ++ ; } else { arr [ S . charAt ( i - 1 ) - ' a ' ] -- ; arr [ S . charAt ( i + K - 1 ) - ' a ' ] ++ ; } s [ i ] = Arrays . toString ( arr ) ; if ( map . containsKey ( s [ i ] ) ) map . put ( s [ i ] , Math . max ( map . get ( s [ i ] ) , i ) ) ; else map . put ( s [ i ] , i ) ; } for ( int i = 0 ; i <= N - K ; i ++ ) { if ( map . get ( s [ i ] ) - i >= K ) { System . out . println ( \" YES \" ) ; return ; } } System . out . println ( \" NO \" ) ; } }" ]
[ "n , k = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE s = input ( ) NEW_LINE if n < k * 2 : print ( \" NO \" ) NEW_LINE else : NEW_LINE INDENT x , t = [ ] , [ 0 ] * 26 NEW_LINE for i in range ( k ) : t [ ord ( s [ i ] ) - 97 ] += 1 NEW_LINE x . append ( ( tuple ( t ) , k - 1 ) ) NEW_LINE for i in range ( k , n ) : NEW_LINE INDENT t [ ord ( s [ i - k ] ) - 97 ] -= 1 NEW_LINE t [ ord ( s [ i ] ) - 97 ] += 1 NEW_LINE x . append ( ( tuple ( t ) , i ) ) NEW_LINE DEDENT x , i , f = sorted ( x ) , 0 , 0 NEW_LINE while i < n - k : NEW_LINE INDENT for j in range ( i + 1 , n - k + 1 ) : NEW_LINE INDENT if x [ i ] [ 0 ] != x [ j ] [ 0 ] : NEW_LINE INDENT i = j NEW_LINE break NEW_LINE DEDENT elif x [ j ] [ 1 ] - x [ i ] [ 1 ] >= k : NEW_LINE INDENT f = 1 NEW_LINE break NEW_LINE DEDENT elif j == n - k : i = n - k NEW_LINE DEDENT if f : break NEW_LINE DEDENT if f : print ( \" YES \" ) NEW_LINE else : print ( \" NO \" ) 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 n , k = LI ( ) NEW_LINE s = [ ord ( c ) - 97 for c in S ( ) ] NEW_LINE ts = [ 0 ] * 26 NEW_LINE d = collections . defaultdict ( int ) NEW_LINE for i in range ( k - 1 ) : NEW_LINE INDENT ts [ s [ i ] ] += 1 NEW_LINE DEDENT for i in range ( n - k + 1 ) : NEW_LINE INDENT if i > 0 : NEW_LINE INDENT ts [ s [ i - 1 ] ] -= 1 NEW_LINE DEDENT ts [ s [ i + k - 1 ] ] += 1 NEW_LINE t = tuple ( ts ) NEW_LINE if d [ t ] == 0 : NEW_LINE INDENT d [ t ] = i + 1 NEW_LINE DEDENT elif d [ t ] + k <= i + 1 : NEW_LINE INDENT return ' YES ' NEW_LINE DEDENT DEDENT return ' NO ' NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "def solve ( ) : NEW_LINE INDENT from collections import deque NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ 10 ** ( ( ord ( c ) - 97 ) * 5 ) for c in input ( ) ] NEW_LINE if N // 2 < K : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE exit ( ) NEW_LINE DEDENT substring = set ( ) NEW_LINE dq = deque ( ) NEW_LINE add , append , popleft = substring . add , dq . append , dq . popleft NEW_LINE subtotal = sum ( S [ N - K : ] ) NEW_LINE append ( subtotal ) NEW_LINE for n1 , n2 in zip ( S [ N - K - 1 : N - 2 * K : - 1 ] , S [ : : - 1 ] ) : NEW_LINE INDENT subtotal += n1 - n2 NEW_LINE append ( subtotal ) NEW_LINE DEDENT for n1 , n2 in zip ( S [ N - 2 * K : : - 1 ] , S [ N - K : : - 1 ] ) : NEW_LINE INDENT add ( popleft ( ) ) NEW_LINE subtotal += n1 - n2 NEW_LINE if subtotal in substring : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE exit ( ) NEW_LINE DEDENT append ( subtotal ) NEW_LINE DEDENT print ( \" NO \" ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT", "from collections import defaultdict , Counter NEW_LINE from string import ascii_lowercase NEW_LINE N , K = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE S = input ( ) NEW_LINE counts = [ ] NEW_LINE tmp_counter = Counter ( S [ : K ] ) NEW_LINE def set_count ( tmp_counter , _index ) : NEW_LINE INDENT counts . append ( tuple ( tmp_counter [ s ] for s in ascii_lowercase ) + ( _index , ) ) NEW_LINE DEDENT set_count ( tmp_counter , 0 ) NEW_LINE for i in range ( N - K ) : NEW_LINE INDENT s_exclude = S [ i ] NEW_LINE s_add = S [ i + K ] NEW_LINE tmp_counter [ s_exclude ] -= 1 NEW_LINE tmp_counter [ s_add ] += 1 NEW_LINE set_count ( tmp_counter , i + 1 ) NEW_LINE DEDENT counts . sort ( ) NEW_LINE tmp_count = counts [ 0 ] NEW_LINE for count in ( counts [ 1 : ] ) : NEW_LINE INDENT if tmp_count [ : 26 ] == count [ : 26 ] : NEW_LINE INDENT if count [ 26 ] - tmp_count [ 26 ] >= K : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT tmp_count = count NEW_LINE DEDENT DEDENT print ( \" NO \" ) NEW_LINE", "N , K = map ( int , input ( ) . strip ( ) . split ( ) ) NEW_LINE S = input ( ) . strip ( ) NEW_LINE def ctoi ( c ) : NEW_LINE INDENT return ord ( c ) - ord ( ' a ' ) NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT if K * 2 > N : return False NEW_LINE ctr = [ 0 for i in range ( 26 ) ] NEW_LINE hs = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT ctr [ ctoi ( S [ i ] ) ] += 1 NEW_LINE if i < K - 1 : continue NEW_LINE if i >= K : NEW_LINE INDENT ctr [ ctoi ( S [ i - K ] ) ] -= 1 NEW_LINE DEDENT h = tuple ( ctr ) NEW_LINE st = i - K + 1 NEW_LINE if h in hs : NEW_LINE INDENT if hs [ h ] + K <= st : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT hs [ h ] = st NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT if solve ( ) : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT" ]
atcoder_abc005_B
[ "import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int x1 = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > aaa = new ArrayList < Integer > ( ) ; String answer = null ; for ( int h = 0 ; h < x1 ; h ++ ) { aaa . add ( Integer . parseInt ( sc . next ( ) ) ) ; } Collections . sort ( aaa ) ; System . out . println ( aaa . get ( 0 ) ) ; System . out . flush ( ) ; sc . close ( ) ; } }", "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 ( ) ; int ans = 100 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . min ( ans , sc . nextInt ( ) ) ; } 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 ( ) ; int output = Integer . MAX_VALUE ; int tmp ; for ( int i = 0 ; i < n ; i ++ ) { tmp = sc . nextInt ( ) ; if ( tmp < output ) { output = tmp ; } } System . out . println ( output ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int n ; n = Integer . parseInt ( sc . next ( ) ) ; int [ ] t = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { t [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( t ) ; System . out . println ( t [ 0 ] ) ; } catch ( Exception e ) { System . out . println ( \" out \" ) ; } } }", "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 [ ] time = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { time [ i ] = sc . nextInt ( ) ; } Arrays . sort ( time ) ; System . out . println ( time [ 0 ] ) ; sc . close ( ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE all1 = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT all1 . append ( int ( input ( ) ) ) NEW_LINE DEDENT print ( min ( all1 ) ) NEW_LINE", "_ , * t = map ( int , open ( 0 ) ) ; print ( min ( t ) ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE t = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE t = sorted ( t ) NEW_LINE print ( t [ 0 ] ) NEW_LINE", "import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE e = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE e = np . array ( [ i [ 0 ] for i in e ] ) NEW_LINE print ( e [ e . argmin ( ) ] ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE ans = 100 NEW_LINE for i in range ( n ) : NEW_LINE INDENT temp = int ( input ( ) ) NEW_LINE ans = min ( ans , temp ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc024_A
[ "import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k % 2 == 0 ) { System . out . println ( a - b ) ; } else { System . out . println ( b - a ) ; } } }", "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 ( ) ; long k = in . nextLong ( ) ; int x = k % 2 == 0 ? a - b : b - a ; out . println ( x ) ; } 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 . * ; import java . awt . * ; 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 ( ) ; long K = sc . nextLong ( ) ; if ( K % 2 == 0 ) { System . out . println ( A - B ) ; } else { System . out . println ( B - A ) ; } } }", "import java . util . Scanner ; 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 ( ) ; Long K = sc . nextLong ( ) ; int ans = 0 ; if ( K % 2 == 1 ) { ans = B - A ; } else { ans = A - B ; } System . out . println ( ans ) ; } }", "import java . util . * ; 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 ( ) ; long k = sc . nextLong ( ) ; System . out . println ( k % 2 == 1 ? b - a : a - b ) ; } }" ]
[ "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 , b , c , k = LI ( ) NEW_LINE return b - a if k % 2 else a - b NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "A , B , C , K = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE if ( K % 2 ) : NEW_LINE INDENT print ( B - A ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( A - B ) NEW_LINE DEDENT", "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 a , b , c , k = li ( ) NEW_LINE if k % 2 : NEW_LINE INDENT print ( b - a ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a - b ) NEW_LINE DEDENT", "a , b , c , k = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( a - b ) * ( - 1 ) ** ( k ) ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE A , B , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE ans = ( - 1 ) ** K * ( A - B ) NEW_LINE print ( ans if abs ( ans ) <= 10 ** 18 else ' Unfair ' ) NEW_LINE" ]
atcoder_agc025_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int A = String . valueOf ( N ) . length ( ) ; int B = 10 ; int have = N ; int sum = 0 ; for ( int i = 0 ; i < ( A - 2 ) ; i ++ ) { B *= 10 ; } if ( N % B == 0 ) { sum = 10 ; System . out . println ( sum ) ; System . exit ( 0 ) ; } sum = N / B ; for ( ; ; ) { have = have - ( have / B ) * B ; B /= 10 ; if ( B == 0 ) { break ; } sum += have / B ; } System . out . println ( sum ) ; } }", "import java . io . * ; import java . util . * ; public class Main { static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { try { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } public String next ( ) { if ( st . hasMoreTokens ( ) ) return st . nextToken ( ) ; try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return st . 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 ( ) { String line = \" \" ; if ( st . hasMoreTokens ( ) ) line = st . nextToken ( ) ; else try { return br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } while ( st . hasMoreTokens ( ) ) line += \" ▁ \" + st . nextToken ( ) ; return line ; } } static int mod = 1000000007 ; static long oo = Long . MAX_VALUE ; public static boolean pow10 ( int v ) { while ( v > 1 && v % 10 == 0 ) v /= 10 ; return v == 1 ; } public static int digSum ( int v ) { if ( v < 10 ) return v ; else return ( v % 10 ) + digSum ( v / 10 ) ; } public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; if ( pow10 ( n ) ) pw . println ( 10 ) ; else pw . println ( digSum ( n ) ) ; pw . close ( ) ; } }", "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 ) { String [ ] n = sc . next ( ) . split ( \" \" ) ; int sum = Arrays . stream ( n ) . mapToInt ( Integer :: parseInt ) . sum ( ) ; System . out . println ( sum == 1 ? 10 : sum ) ; } }", "import java . net . StandardSocketOptions ; 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 ; import org . omg . PortableInterceptor . SYSTEM_EXCEPTION ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_200 ( ) . doIt ( ) ; } class Test_200 { void doIt ( ) { int Wa [ ] = new int [ 100001 ] ; Pa_10 ( Wa ) ; int ans = Integer . MAX_VALUE ; int N = sc . nextInt ( ) ; for ( int i = 1 ; i <= N / 2 ; i ++ ) { ans = Math . min ( ans , Wa [ N - i ] + Wa [ i ] ) ; } System . out . println ( ans ) ; } void Pa_10 ( int Wa [ ] ) { for ( int i = 0 ; i <= 100000 ; i ++ ) { Wa [ i ] = i % 10 ; Wa [ i ] = Wa [ i ] + ( ( i / 10 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 100 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 1000 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 10000 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 100000 ) % 10 ) ; } } } }", "import java . io . PrintStream ; import java . util . Scanner ; import java . util . stream . Stream ; public class Main { static void exec ( Scanner in , PrintStream out ) { String N = in . next ( ) ; if ( N . length ( ) == 1 ) { out . println ( N ) ; return ; } if ( N . substring ( 0 , 2 ) . equals ( \"10\" ) ) { int sum = 10 ; if ( N . length ( ) > 2 ) { sum += Stream . of ( N . substring ( 2 ) . split ( \" \" ) ) . mapToInt ( Integer :: valueOf ) . sum ( ) ; } out . println ( sum ) ; } else { int sum = Stream . of ( N . split ( \" \" ) ) . mapToInt ( Integer :: valueOf ) . sum ( ) ; out . println ( sum ) ; } } public static void main ( String [ ] args ) { exec ( new Scanner ( System . in ) , System . out ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE def sum_digit ( n ) : NEW_LINE INDENT s = 0 NEW_LINE while n > 0 : NEW_LINE INDENT s += n % 10 NEW_LINE n //= 10 NEW_LINE DEDENT return s NEW_LINE DEDENT min_sum = 9 * 10 NEW_LINE for x in range ( 1 , N // 2 + 1 ) : NEW_LINE INDENT min_sum = min ( min_sum , sum_digit ( x ) + sum_digit ( N - x ) ) NEW_LINE DEDENT print ( min_sum ) NEW_LINE", "NL = [ int ( x ) for x in str ( input ( ) ) ] NEW_LINE if NL [ 0 ] == 1 and sum ( NL ) == 1 : NEW_LINE INDENT print ( 10 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( sum ( NL ) ) NEW_LINE DEDENT", "import math NEW_LINE n = int ( input ( ) ) NEW_LINE ns = list ( str ( n ) ) NEW_LINE if ( math . log10 ( n ) == float ( len ( ns ) - 1 ) ) : print ( 10 ) NEW_LINE else : print ( sum ( [ int ( ns [ i ] ) for i in range ( len ( ns ) ) ] ) ) NEW_LINE", "import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE ans = np . Inf NEW_LINE for i in range ( 1 , int ( n / 2 + 1 ) ) : NEW_LINE INDENT a = str ( i ) NEW_LINE b = str ( n - i ) NEW_LINE an = 0 NEW_LINE for j in range ( len ( a ) ) : NEW_LINE INDENT an += int ( a [ j ] ) NEW_LINE DEDENT for k in range ( len ( b ) ) : NEW_LINE INDENT an += int ( b [ k ] ) NEW_LINE DEDENT if an < ans : NEW_LINE INDENT ans = an NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE min_ = 100000 NEW_LINE for i in range ( 1 , N // 2 + 1 ) : NEW_LINE INDENT j = N - i NEW_LINE sum_i = 0 NEW_LINE sum_j = 0 NEW_LINE tmp_i = i NEW_LINE tmp_j = j NEW_LINE while tmp_i > 0 : NEW_LINE INDENT sum_i += tmp_i % 10 NEW_LINE tmp_i = tmp_i // 10 NEW_LINE DEDENT while tmp_j > 0 : NEW_LINE INDENT sum_j += tmp_j % 10 NEW_LINE tmp_j = tmp_j // 10 NEW_LINE DEDENT min_ = min ( min_ , sum_i + sum_j ) NEW_LINE DEDENT print ( min_ ) NEW_LINE" ]
atcoder_abc100_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] X = new long [ N ] ; long [ ] Y = new long [ N ] ; long [ ] Z = new long [ N ] ; int [ ] sg = { 1 , - 1 } ; for ( int i = 0 ; i < N ; i ++ ) { X [ i ] = sc . nextLong ( ) ; Y [ i ] = sc . nextLong ( ) ; Z [ i ] = sc . nextLong ( ) ; } long ans = 0 ; long [ ] S = new long [ N ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { long ans2 = 0 ; for ( int l = 0 ; l < N ; l ++ ) { S [ l ] = X [ l ] * sg [ i ] + Y [ l ] * sg [ j ] + Z [ l ] * sg [ k ] ; } Arrays . sort ( S ) ; for ( int l = N - 1 ; l > N - M - 1 ; l -- ) ans2 += S [ l ] ; ans = Math . max ( ans , ans2 ) ; } } } System . out . println ( ans ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = { 1 , 1 , 1 , 1 , - 1 , - 1 , - 1 , - 1 } ; int [ ] b = { 1 , 1 , - 1 , - 1 , 1 , 1 , - 1 , - 1 } ; int [ ] c = { 1 , - 1 , 1 , - 1 , 1 , - 1 , 1 , - 1 } ; long kati = Long . MIN_VALUE ; long tmp = Long . MIN_VALUE ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ N ] ; long [ ] z = new long [ N ] ; long [ ] maxes = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; z [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < 8 ; i ++ ) { tmp = 0 ; for ( int j = 0 ; j < N ; j ++ ) { maxes [ j ] = x [ j ] * a [ i ] + y [ j ] * b [ i ] + z [ j ] * c [ i ] ; } Arrays . sort ( maxes ) ; for ( int k = 0 ; k < M ; k ++ ) { tmp += maxes [ N - 1 - k ] ; } kati = Math . max ( kati , tmp ) ; } System . out . println ( kati ) ; } }", "import java . util . Scanner ; import java . util . Arrays ; import java . util . Comparator ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; Cake [ ] cake = new Cake [ n ] ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long z = sc . nextLong ( ) ; cake [ i ] = new Cake ( x , y , z ) ; } int [ ] xyz = new int [ 3 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { Arrays . fill ( xyz , 1 ) ; int ii = i ; long an = 0 ; int count = 0 ; while ( ii > 0 ) { if ( ( ii & 1 ) == 1 ) { xyz [ count ] *= - 1 ; } ii >>= 1 ; count ++ ; } for ( int j = 0 ; j < n ; j ++ ) { cake [ j ] . x1 = cake [ j ] . x * xyz [ 0 ] ; cake [ j ] . y1 = cake [ j ] . y * xyz [ 1 ] ; cake [ j ] . z1 = cake [ j ] . z * xyz [ 2 ] ; } Arrays . sort ( cake , Comparator . comparing ( Cake :: getSum ) . reversed ( ) ) ; for ( int k = 0 ; k < m ; k ++ ) { an += cake [ k ] . getSum ( ) ; } ans = Math . max ( ans , an ) ; } System . out . println ( ans ) ; } static class Cake { long x ; long y ; long z ; long x1 ; long y1 ; long z1 ; public Cake ( long x , long y , long z ) { this . x = x ; this . y = y ; this . z = z ; } public long getSum ( ) { return this . x1 + this . y1 + this . z1 ; } } }", "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 ( ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ N ] ; long [ ] z = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; z [ i ] = sc . nextLong ( ) ; } long ans = Long . MIN_VALUE ; for ( int i = 0 ; i < 1 << 3 ; i ++ ) { Long [ ] values = new Long [ N ] ; for ( int j = 0 ; j < N ; j ++ ) { values [ j ] = add ( x [ j ] , ( i >> 2 & 1 ) == 1 ) + add ( y [ j ] , ( i >> 1 & 1 ) == 1 ) + add ( z [ j ] , ( i >> 0 & 1 ) == 1 ) ; } Arrays . sort ( values , Collections . reverseOrder ( ) ) ; long ans_tmp = 0 ; for ( int j = 0 ; j < M ; j ++ ) { ans_tmp += values [ j ] ; } ans = Math . max ( ans , ans_tmp ) ; } out . println ( ans ) ; } public static long add ( long a , boolean isMaximumPlus ) { if ( isMaximumPlus ) { return a ; } return - a ; } }", "import java . util . Comparator ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; long [ ] x = new long [ n ] ; long [ ] y = new long [ n ] ; long [ ] z = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { x [ i ] = scanner . nextLong ( ) ; y [ i ] = scanner . nextLong ( ) ; z [ i ] = scanner . nextLong ( ) ; } int [ ] scale = { - 1 , 1 } ; long result = 0 ; for ( int a = 0 ; a < 2 ; ++ a ) { for ( int b = 0 ; b < 2 ; ++ b ) { for ( int c = 0 ; c < 2 ; ++ c ) { PriorityQueue < Long > sum = new PriorityQueue < > ( Comparator . reverseOrder ( ) ) ; long currentSum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { long current = scale [ a ] * x [ i ] + scale [ b ] * y [ i ] + scale [ c ] * z [ i ] ; sum . add ( current ) ; } for ( int i = 0 ; i < m ; ++ i ) { currentSum += sum . poll ( ) ; } result = Math . max ( result , currentSum ) ; } } } System . out . println ( result ) ; } }" ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE info = [ [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE ans = 0 NEW_LINE for oishi in range ( 2 ) : NEW_LINE INDENT for kirei in range ( 2 ) : NEW_LINE INDENT for ninki in range ( 2 ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT info [ i ] [ 0 ] = ( ( - 1 ) ** kirei ) * info [ i ] [ 1 ] + ( ( - 1 ) ** oishi ) * info [ i ] [ 2 ] + ( ( - 1 ) ** ninki ) * info [ i ] [ 3 ] NEW_LINE DEDENT info = sorted ( info , reverse = True ) NEW_LINE ans_kirei = 0 NEW_LINE ans_oishi = 0 NEW_LINE ans_ninki = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT ans_kirei += ( ( - 1 ) ** kirei ) * info [ i ] [ 1 ] NEW_LINE ans_oishi += ( ( - 1 ) ** oishi ) * info [ i ] [ 2 ] NEW_LINE ans_ninki += ( ( - 1 ) ** ninki ) * info [ i ] [ 3 ] NEW_LINE DEDENT ans = max ( ans , ans_kirei + ans_oishi + ans_ninki ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE import itertools NEW_LINE def solve ( N : int , M : int , x : \" List [ int ] \" , y : \" List [ int ] \" , z : \" List [ int ] \" ) : NEW_LINE INDENT coef = [ 1 , - 1 ] NEW_LINE cand = itertools . product ( coef , repeat = 3 ) NEW_LINE sumMax = 0 NEW_LINE for can in cand : NEW_LINE INDENT combined = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT combined . append ( can [ 0 ] * x [ i ] + can [ 1 ] * y [ i ] + can [ 2 ] * z [ i ] ) NEW_LINE DEDENT combined . sort ( ) NEW_LINE s = sum ( combined [ : M ] ) NEW_LINE sumMax = max ( sumMax , abs ( s ) ) NEW_LINE DEDENT print ( sumMax ) 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 M = int ( next ( tokens ) ) NEW_LINE x = [ int ( ) ] * ( N ) NEW_LINE y = [ int ( ) ] * ( N ) NEW_LINE z = [ int ( ) ] * ( N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT x [ i ] = int ( next ( tokens ) ) NEW_LINE y [ i ] = int ( next ( tokens ) ) NEW_LINE z [ i ] = int ( next ( tokens ) ) NEW_LINE DEDENT solve ( N , M , x , y , z ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys , 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 , M = MAP ( ) NEW_LINE xyz = [ LIST ( ) for _ in range ( N ) ] NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , 2 ) : NEW_LINE INDENT for j in range ( 0 , 2 ) : NEW_LINE INDENT for k in range ( 0 , 2 ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT k_x = 1 NEW_LINE DEDENT else : NEW_LINE INDENT k_x = - 1 NEW_LINE DEDENT if j == 0 : NEW_LINE INDENT k_y = 1 NEW_LINE DEDENT else : NEW_LINE INDENT k_y = - 1 NEW_LINE DEDENT if k == 0 : NEW_LINE INDENT k_z = 1 NEW_LINE DEDENT else : NEW_LINE INDENT k_z = - 1 NEW_LINE DEDENT tmp = [ x * k_x + y * k_y + z * k_z for x , y , z in xyz ] NEW_LINE tmp . sort ( reverse = True ) NEW_LINE ans . append ( sum ( tmp [ 0 : M ] ) ) NEW_LINE DEDENT DEDENT DEDENT print ( max ( ans ) ) NEW_LINE", "def main ( ) : NEW_LINE INDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE t = [ [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y , z = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE for j in range ( 8 ) : NEW_LINE INDENT xs = 1 if j % 2 == 0 else - 1 NEW_LINE ys = 1 if ( j // 2 ) % 2 == 0 else - 1 NEW_LINE zs = 1 if ( j // 4 ) % 2 == 0 else - 1 NEW_LINE t [ j ] . append ( xs * x + ys * y + zs * z ) NEW_LINE DEDENT DEDENT res = [ ] NEW_LINE for li in t : NEW_LINE INDENT li . sort ( reverse = True ) NEW_LINE res . append ( sum ( li [ : M ] ) ) NEW_LINE DEDENT print ( max ( res ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "from operator import mul 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 N , M = tuple ( li ( ) ) NEW_LINE Cs = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT n = tuple ( li ( ) ) NEW_LINE Cs . append ( n ) NEW_LINE DEDENT state = [ 0 , 0 , 0 , 0 ] NEW_LINE maximum = 0 NEW_LINE trans = [ ] NEW_LINE for per in range ( 8 ) : NEW_LINE INDENT ops = [ 1 if ( per & 4 ) >> 2 else - 1 , 1 if ( per & 2 ) >> 1 else - 1 , 1 if per & 1 else - 1 ] NEW_LINE trans . clear ( ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT trans . append ( list ( map ( mul , Cs [ i ] , ops ) ) ) NEW_LINE DEDENT trans . sort ( key = lambda x : - sum ( x ) ) NEW_LINE maximum = max ( maximum , sum ( sum ( t ) for t in trans [ : M ] ) ) NEW_LINE DEDENT print ( maximum ) NEW_LINE" ]
atcoder_abc005_D
[ "import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] b = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= n ; j ++ ) { b [ i ] [ j ] = sc . nextInt ( ) ; } for ( int c = 1 ; c <= n ; c ++ ) for ( int r = 1 ; r <= n ; r ++ ) { b [ c ] [ r ] += b [ c - 1 ] [ r ] + b [ c ] [ r - 1 ] - b [ c - 1 ] [ r - 1 ] ; } int [ ] mem = new int [ n * n + 1 ] ; for ( int c1 = 1 ; c1 <= n ; c1 ++ ) for ( int r1 = 1 ; r1 <= n ; r1 ++ ) { for ( int c2 = c1 ; c2 <= n ; c2 ++ ) for ( int r2 = r1 ; r2 <= n ; r2 ++ ) { mem [ ( c2 - c1 + 1 ) * ( r2 - r1 + 1 ) ] = Math . max ( mem [ ( c2 - c1 + 1 ) * ( r2 - r1 + 1 ) ] , b [ c2 ] [ r2 ] + b [ c1 - 1 ] [ r1 - 1 ] - b [ c2 ] [ r1 - 1 ] - b [ c1 - 1 ] [ r2 ] ) ; } } int q = sc . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int max = 0 ; for ( int j = sc . nextInt ( ) ; j > 0 ; j -- ) max = Math . max ( max , mem [ j ] ) ; System . out . println ( max ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . * ; import java . util . stream . IntStream ; public class Main { static int n ; static int [ ] [ ] d ; static int [ ] [ ] cum ; static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; d = new int [ n ] [ n ] ; cum = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { d [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { cum [ i + 1 ] [ j + 1 ] = cum [ i + 1 ] [ j ] + cum [ i ] [ j + 1 ] + d [ i ] [ j ] - cum [ i ] [ j ] ; } } int q = sc . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int p = sc . nextInt ( ) ; int best = 0 ; for ( int j = 0 ; j < p ; j ++ ) { int x = p - j ; int y = p / x ; y = Math . min ( y , n ) ; best = Math . max ( best , f ( x , y ) ) ; } System . out . println ( best ) ; } } static int f ( int x , int y ) { int best = 0 ; for ( int i = 0 ; i < n - x + 1 ; i ++ ) { for ( int j = 0 ; j < n - y + 1 ; j ++ ) { best = Math . max ( best , cum [ i + x ] [ j + y ] - cum [ i + x ] [ j ] - cum [ i ] [ j + y ] + cum [ i ] [ j ] ) ; } } return best ; } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE grid = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT grid . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT S = [ [ 0 ] * ( N + 1 ) for _ in range ( N + 1 ) ] NEW_LINE Q = int ( input ( ) ) NEW_LINE query = [ int ( input ( ) ) for _ in range ( Q ) ] NEW_LINE def solve ( ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT S [ i + 1 ] [ j + 1 ] = S [ i ] [ j + 1 ] + S [ i + 1 ] [ j ] - S [ i ] [ j ] + grid [ i ] [ j ] NEW_LINE DEDENT DEDENT val = [ 0 ] * ( N * N + 1 ) NEW_LINE for x1 in range ( N ) : NEW_LINE INDENT for x2 in range ( x1 + 1 , N + 1 ) : NEW_LINE INDENT for y1 in range ( N ) : NEW_LINE INDENT for y2 in range ( y1 + 1 , N + 1 ) : NEW_LINE INDENT area = ( x2 - x1 ) * ( y2 - y1 ) NEW_LINE s = S [ x2 ] [ y2 ] - S [ x1 ] [ y2 ] - S [ x2 ] [ y1 ] + S [ x1 ] [ y1 ] NEW_LINE val [ area ] = max ( val [ area ] , s ) NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in range ( N ** 2 ) : NEW_LINE INDENT val [ i + 1 ] = max ( val [ i ] , val [ i + 1 ] ) NEW_LINE DEDENT for q in query : NEW_LINE INDENT print ( val [ q ] ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE", "from collections import defaultdict NEW_LINE import math NEW_LINE def LI ( ) : return list ( map ( int , 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 IIR ( n ) : return [ II ( ) for i in range ( n ) ] NEW_LINE def LIR ( n ) : return [ LI ( ) for i in range ( n ) ] NEW_LINE def SR ( n ) : return [ S ( ) for i in range ( n ) ] NEW_LINE mod = 1000000007 NEW_LINE n = II ( ) NEW_LINE d = LIR ( n ) NEW_LINE q = II ( ) NEW_LINE p = IIR ( q ) NEW_LINE d . insert ( 0 , [ 0 for i in range ( n + 1 ) ] ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT d [ i + 1 ] . insert ( 0 , 0 ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT d [ i + 1 ] [ j + 1 ] += d [ i + 1 ] [ j ] + d [ i ] [ j + 1 ] - d [ i ] [ j ] NEW_LINE DEDENT DEDENT ans = [ 0 for i in range ( n ** 2 + 1 ) ] NEW_LINE for a in range ( n + 1 ) : NEW_LINE INDENT for b in range ( n + 1 ) : NEW_LINE INDENT for c in range ( a ) : NEW_LINE INDENT for e in range ( b ) : NEW_LINE INDENT ans [ ( a - c ) * ( b - e ) ] = max ( ans [ ( a - c ) * ( b - e ) ] , d [ a ] [ b ] - d [ c ] [ b ] - d [ a ] [ e ] + d [ c ] [ e ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in p : NEW_LINE INDENT an = 0 NEW_LINE for a in range ( i + 1 ) : NEW_LINE INDENT an = max ( an , ans [ a ] ) NEW_LINE DEDENT print ( an ) NEW_LINE NEW_LINE DEDENT", "import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE D = np . zeros ( ( N + 1 , N + 1 ) , dtype = np . int ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j , value in enumerate ( map ( int , input ( ) . split ( ) ) ) : NEW_LINE INDENT D [ i + 1 , j + 1 ] = value NEW_LINE DEDENT DEDENT np . cumsum ( D [ 1 : , 1 : ] , axis = 0 , out = D [ 1 : , 1 : ] ) NEW_LINE np . cumsum ( D [ 1 : , 1 : ] , axis = 1 , out = D [ 1 : , 1 : ] ) NEW_LINE maxs = np . zeros ( ( N * N + 1 ) , dtype = D . dtype ) NEW_LINE for r in range ( 1 , N + 1 ) : NEW_LINE INDENT for c in range ( 1 , N + 1 ) : NEW_LINE INDENT maxs [ r * c ] = max ( maxs [ r * c ] , max ( D [ i + r , j + c ] - D [ i , j + c ] - D [ i + r , j ] + D [ i , j ] for i in range ( N - r + 1 ) for j in range ( N - c + 1 ) ) ) NEW_LINE DEDENT DEDENT for p in range ( 1 , N * N + 1 ) : NEW_LINE INDENT maxs [ p ] = max ( maxs [ p ] , maxs [ p - 1 ] ) NEW_LINE DEDENT Q = int ( input ( ) ) NEW_LINE for q in range ( Q ) : NEW_LINE INDENT P = int ( input ( ) ) NEW_LINE print ( maxs [ P ] ) NEW_LINE DEDENT", "from itertools import accumulate NEW_LINE from operator import add NEW_LINE def getAccAss ( Ass ) : NEW_LINE INDENT accAss = [ [ 0 ] * ( len ( Ass [ 0 ] ) + 1 ) ] + [ [ 0 ] + As for As in Ass ] NEW_LINE accAss = [ accumulate ( accAs ) for accAs in accAss ] NEW_LINE accAss [ 0 ] = list ( accAss [ 0 ] ) NEW_LINE for x in range ( 1 , len ( accAss ) ) : NEW_LINE INDENT accAss [ x ] = list ( map ( add , accAss [ x ] , accAss [ x - 1 ] ) ) NEW_LINE DEDENT return accAss NEW_LINE DEDENT def getRangeSum2D ( accAss , xFr , xTo , yFr , yTo ) : NEW_LINE INDENT return accAss [ xTo + 1 ] [ yTo + 1 ] - accAss [ xTo + 1 ] [ yFr ] - accAss [ xFr ] [ yTo + 1 ] + accAss [ xFr ] [ yFr ] NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE Dss = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE Q = int ( input ( ) ) NEW_LINE Ps = [ int ( input ( ) ) for _ in range ( Q ) ] NEW_LINE accDss = getAccAss ( Dss ) NEW_LINE sumDs = [ 0 ] * ( N * N + 1 ) NEW_LINE for xFr in range ( N ) : NEW_LINE INDENT for xTo in range ( xFr , N ) : NEW_LINE INDENT for yFr in range ( N ) : NEW_LINE INDENT for yTo in range ( yFr , N ) : NEW_LINE INDENT area = ( xTo - xFr + 1 ) * ( yTo - yFr + 1 ) NEW_LINE sumD = getRangeSum2D ( accDss , xFr , xTo , yFr , yTo ) NEW_LINE if sumD > sumDs [ area ] : NEW_LINE INDENT sumDs [ area ] = sumD NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT sumDs = list ( accumulate ( sumDs , lambda x , y : x if x >= y else y ) ) NEW_LINE for P in Ps : NEW_LINE INDENT print ( sumDs [ P ] ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE d = [ list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE q = int ( input ( ) ) NEW_LINE p = [ int ( input ( ) ) for _ in range ( q ) ] NEW_LINE darea = lambda i , j , ii , jj : r [ i ] [ j ] - r [ ii + 1 ] [ j ] - r [ i ] [ jj + 1 ] + r [ ii + 1 ] [ jj + 1 ] NEW_LINE r = [ [ 0 for _ in range ( n + 1 ) ] for __ in range ( n + 1 ) ] NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT for j in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT r [ i ] [ j ] = d [ i ] [ j ] + r [ i + 1 ] [ j ] + r [ i ] [ j + 1 ] - r [ i + 1 ] [ j + 1 ] NEW_LINE DEDENT DEDENT dmax = [ 0 for _ in range ( n ** 2 + 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT for ii in range ( i , n ) : NEW_LINE INDENT for jj in range ( j , n ) : NEW_LINE INDENT num = ( ii - i + 1 ) * ( jj - j + 1 ) NEW_LINE d = darea ( i , j , ii , jj ) NEW_LINE if dmax [ num ] < d : NEW_LINE INDENT dmax [ num ] = d NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT m = 0 NEW_LINE for i in range ( n ** 2 + 1 ) : NEW_LINE INDENT if m > dmax [ i ] : NEW_LINE INDENT dmax [ i ] = m NEW_LINE DEDENT else : NEW_LINE INDENT m = dmax [ i ] NEW_LINE DEDENT DEDENT for pk in p : NEW_LINE INDENT print ( dmax [ pk ] ) NEW_LINE DEDENT" ]
atcoder_abc109_B
[ "import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = Integer . parseInt ( s . nextLine ( ) ) ; String prevWord = null ; String currWord = null ; Set < String > set = new HashSet < > ( ) ; boolean isValid = true ; for ( int i = 0 ; i < n ; i ++ ) { currWord = s . nextLine ( ) ; if ( set . contains ( currWord ) ) { isValid = false ; } set . add ( currWord ) ; if ( isValid && i != 0 ) { if ( prevWord . charAt ( prevWord . length ( ) - 1 ) != currWord . charAt ( 0 ) ) { isValid = false ; } } prevWord = currWord ; } System . out . println ( isValid ? \" Yes \" : \" No \" ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ; 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 ( ) ) ; List < String > sir = new ArrayList < String > ( ) ; boolean isCorrect = true ; String lastWord = \" \" ; for ( int n = 0 ; n < N ; n ++ ) { String word = br . readLine ( ) ; String [ ] chr = word . split ( \" \" ) ; if ( n == 0 ) lastWord = chr [ chr . length - 1 ] ; else { if ( ! lastWord . equals ( chr [ 0 ] ) ) { isCorrect = false ; break ; } else { if ( sir . contains ( word ) ) { isCorrect = false ; break ; } sir . add ( word ) ; lastWord = chr [ chr . length - 1 ] ; } } sir . add ( word ) ; } if ( isCorrect ) System . out . println ( \" Yes \" ) ; else System . out . println ( \" No \" ) ; } }", "import java . util . Collections ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . Set ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { private static final String YES = \" Yes \" ; private static final String NO = \" No \" ; public static String process ( TestCase testCase ) { final int N = testCase . N ; final List < String > W = testCase . W ; final Set < String > announced = new HashSet < > ( Collections . singletonList ( W . get ( 0 ) ) ) ; return IntStream . range ( 1 , N ) . allMatch ( i -> { final String prev = W . get ( i - 1 ) ; final String curr = W . get ( i ) ; final boolean notAnnounced = ! announced . contains ( curr ) ; final boolean charSatisfied = curr . charAt ( 0 ) == prev . charAt ( prev . length ( ) - 1 ) ; announced . add ( curr ) ; return notAnnounced && charSatisfied ; } ) ? YES : NO ; } 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 ) ; int N = sc . nextInt ( ) ; final List < String > W = IntStream . range ( 0 , N ) . mapToObj ( i -> sc . next ( ) ) . collect ( Collectors . toList ( ) ) ; return new TestCase ( N , W ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final int N ; final List < String > W ; public TestCase ( int N , List < String > W ) { this . N = N ; this . W = W ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Map < String , Integer > po = new HashMap < String , Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean ppp = true ; sc . nextLine ( ) ; String g = sc . nextLine ( ) ; po . put ( g , 0 ) ; String nstr = g . substring ( g . length ( ) - 1 , g . length ( ) ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { String str = sc . nextLine ( ) ; if ( po . containsKey ( str ) ) { ppp = false ; break ; } else { if ( nstr . equals ( str . substring ( 0 , 1 ) ) ) { nstr = str . substring ( str . length ( ) - 1 , str . length ( ) ) ; po . put ( str , 0 ) ; } else { ppp = false ; break ; } } } System . out . println ( ( ppp ) ? \" Yes \" : \" No \" ) ; } }", "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 ( ) ; String [ ] [ ] nArray = new String [ n ] [ ] ; for ( int i = 0 ; i < n ; i ++ ) { String num = sc . next ( ) ; nArray [ i ] = num . split ( \" \" ) ; } boolean judge = true ; out : for ( int i = 1 ; i < n ; i ++ ) { for ( int k = 0 ; k < i ; k ++ ) { if ( Arrays . equals ( nArray [ i ] , nArray [ k ] ) ) { judge = false ; break out ; } } } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( nArray [ i ] [ nArray [ i ] . length - 1 ] . equals ( nArray [ i + 1 ] [ 0 ] ) ) { } else { judge = false ; break ; } } if ( judge ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE W = [ input ( ) for i in range ( N ) ] NEW_LINE flag = True NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if W [ i ] [ len ( W [ i ] ) - 1 ] != W [ i + 1 ] [ 0 ] : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if i != j : NEW_LINE INDENT if W [ i ] == W [ j ] : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "_ , * l = open ( 0 ) ; print ( ' YNeos ' [ any ( a [ - 2 ] != b [ 0 ] * l . count ( a ) for a , b in zip ( l , l [ 1 : ] ) ) : : 2 ] ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE said = set ( ) NEW_LINE first = input ( ) NEW_LINE said . add ( first ) NEW_LINE last = first [ - 1 ] NEW_LINE is_shiritori = True NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT word = input ( ) NEW_LINE if word in said or word [ 0 ] != last : NEW_LINE INDENT is_shiritori = False NEW_LINE DEDENT said . add ( word ) NEW_LINE last = word [ - 1 ] NEW_LINE DEDENT if is_shiritori : 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", "from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE w_list = [ input ( ) for _ in range ( N ) ] NEW_LINE cnt = Counter ( w_list ) . most_common ( 1 ) [ 0 ] [ 1 ] NEW_LINE if cnt > 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( 0 , N - 1 ) : NEW_LINE INDENT if w_list [ i ] [ - 1 ] != w_list [ i + 1 ] [ 0 ] : NEW_LINE INDENT print ( ' No ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT DEDENT", "N = int ( input ( ) ) NEW_LINE before = [ ] NEW_LINE answer = ' Yes ' NEW_LINE for i in range ( N ) : NEW_LINE INDENT s = input ( ) NEW_LINE if s in before : NEW_LINE INDENT answer = ' No ' NEW_LINE DEDENT if len ( before ) > 0 : NEW_LINE INDENT if before [ - 1 ] [ - 1 ] != s [ 0 ] : NEW_LINE INDENT answer = ' No ' NEW_LINE DEDENT DEDENT before . append ( s ) NEW_LINE DEDENT print ( answer ) NEW_LINE" ]
atcoder_abc069_B
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; System . out . println ( a . charAt ( 0 ) + \" \" + ( a . length ( ) - 2 ) + \" \" + a . charAt ( a . length ( ) - 1 ) ) ; } }", "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 ) { String s = in . next ( ) ; out . printf ( \" % s % d % s \\n \" , s . charAt ( 0 ) , s . length ( ) - 2 , s . charAt ( s . length ( ) - 1 ) ) ; } 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 ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; System . out . println ( word . charAt ( 0 ) + String . valueOf ( word . length ( ) - 2 ) + word . charAt ( word . length ( ) - 1 ) ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int len = str . length ( ) ; int midLen = len - 2 ; System . out . print ( str . substring ( 0 , 1 ) + midLen + str . substring ( len - 1 , len ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . nextLine ( ) ; int size = s . length ( ) ; char a = s . charAt ( 0 ) ; char z = s . charAt ( size - 1 ) ; System . out . print ( a ) ; System . out . print ( size - 2 ) ; System . out . print ( z ) ; scan . close ( ) ; } }" ]
[ "s = input ( ) NEW_LINE print ( s [ 0 ] + str ( len ( s ) - 2 ) + s [ len ( s ) - 1 ] ) 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 s = ns ( ) NEW_LINE print ( s [ 0 ] + str ( len ( s ) - 2 ) + s [ - 1 ] ) NEW_LINE", "S = input ( ) NEW_LINE S0 = S [ 0 ] NEW_LINE S1 = str ( len ( S ) - 2 ) NEW_LINE S2 = S [ - 1 ] NEW_LINE print ( S0 + S1 + S2 ) NEW_LINE", "s1 , * s2 , s3 = map ( str , input ( ) ) NEW_LINE print ( s1 + str ( len ( s2 ) ) + s3 ) NEW_LINE", "s = input ( ) NEW_LINE print ( \" { } { } { } \" . format ( s [ 0 ] , len ( s ) - 2 , s [ - 1 ] ) ) NEW_LINE" ]
atcoder_arc095_A
[ "import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { List < Integer > list = new ArrayList < > ( ) ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } List < Integer > sortedList = new ArrayList < > ( list ) ; Collections . sort ( sortedList ) ; int median = sortedList . get ( N / 2 ) ; int medianMinus = sortedList . get ( N / 2 - 1 ) ; for ( int i : list ) { if ( i >= median ) { System . out . println ( medianMinus ) ; } else { System . out . println ( median ) ; } } } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . 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 ) { int n = in . nextInt ( ) ; int [ ] a = in . nextIntArray ( n ) ; int [ ] b = a . clone ( ) ; Arrays . sort ( b ) ; int mid = b [ ( b . length - 1 ) / 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] <= mid ) { out . println ( b [ ( b . length + 1 ) / 2 ] ) ; } else { out . println ( mid ) ; } } } } 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 int [ ] nextIntArray ( int n ) { int [ ] res = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { res [ i ] = nextInt ( ) ; } return res ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( \" \" ) ; } } }", "import static java . lang . System . * ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int [ ] num = new int [ n ] ; int [ ] num_org = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) num [ i ] = num_org [ i ] = sc . nextInt ( ) ; Arrays . sort ( num ) ; int mid_s = num [ n / 2 - 1 ] ; int mid_l = num [ n / 2 ] ; for ( int i : num_org ) { if ( i <= mid_s ) out . println ( mid_l ) ; else out . println ( mid_s ) ; } return ; } }", "import java . io . BufferedInputStream ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveB ( ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { } } private void solveA ( ) { try ( Scanner sc = new Scanner ( new BufferedInputStream ( System . in , 8096 ) ) ; ) { List < Integer > list = new ArrayList < > ( ) ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } List < Integer > sortedList = new ArrayList < > ( list ) ; Collections . sort ( sortedList ) ; int median = sortedList . get ( N / 2 ) ; int medianMinus = sortedList . get ( N / 2 - 1 ) ; for ( int i : list ) { if ( i >= median ) { System . out . println ( medianMinus ) ; } else { System . out . println ( median ) ; } } } } }", "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; String temp ; String [ ] buf ; temp = reader . readLine ( ) ; int N = Integer . parseInt ( temp . split ( \" ▁ \" ) [ 0 ] ) ; int [ ] a = new int [ N ] , sorted = new int [ N ] ; temp = reader . readLine ( ) ; buf = temp . split ( \" ▁ \" ) ; for ( int i = 0 ; i < N ; i ++ ) { int cur = Integer . parseInt ( buf [ i ] ) ; a [ i ] = cur ; sorted [ i ] = cur ; } Arrays . sort ( sorted ) ; int smaller = sorted [ N / 2 - 1 ] , bigger = sorted [ N / 2 ] ; PrintWriter out = new PrintWriter ( System . out ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] <= smaller ) ans = bigger ; else ans = smaller ; out . println ( ans ) ; } out . flush ( ) ; } }" ]
[ "from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE X = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Y = sorted ( X ) NEW_LINE a = Y [ N // 2 ] NEW_LINE b = Y [ N // 2 - 1 ] NEW_LINE for i in X : NEW_LINE INDENT if i <= b : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( b ) NEW_LINE DEDENT DEDENT", "def solve ( N , Xs ) : NEW_LINE INDENT sorted_Xs = sorted ( Xs ) NEW_LINE left = sorted_Xs [ N // 2 - 1 ] NEW_LINE right = sorted_Xs [ N // 2 ] NEW_LINE ans = [ ] NEW_LINE for x in Xs : NEW_LINE INDENT if x <= left : NEW_LINE INDENT ans . append ( right ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( left ) NEW_LINE DEDENT DEDENT return \" \\n \" . join ( str ( i ) for i in ans ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE Xs = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) NEW_LINE print ( solve ( N , Xs ) ) NEW_LINE DEDENT", "import bisect NEW_LINE N = int ( input ( ) ) NEW_LINE X = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE X2 = sorted ( X ) NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT idx = bisect . bisect_left ( X2 , X [ i ] ) NEW_LINE if idx < N // 2 : NEW_LINE INDENT print ( X2 [ N // 2 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( X2 [ N // 2 - 1 ] ) NEW_LINE DEDENT DEDENT", "n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE d = 0 NEW_LINE l = [ ] NEW_LINE a = sorted ( enumerate ( a ) , key = lambda x : x [ 1 ] ) NEW_LINE b = a [ n // 2 ] [ 1 ] NEW_LINE c = a [ n // 2 - 1 ] [ 1 ] NEW_LINE for ( k , v ) in a : NEW_LINE INDENT d += 1 NEW_LINE if d < n // 2 + 1 : NEW_LINE INDENT l . append ( ( k , b ) ) NEW_LINE DEDENT else : NEW_LINE INDENT l . append ( ( k , c ) ) NEW_LINE DEDENT DEDENT for ( k , v ) in sorted ( l , key = lambda x : x [ 0 ] ) : NEW_LINE INDENT print ( v ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE xs = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ds = sorted ( xs ) NEW_LINE m = n // 2 - 1 NEW_LINE bs = [ ds [ m ] if xs [ i ] > ds [ m ] else ds [ m + 1 ] for i in range ( n ) ] NEW_LINE print ( \" \\n \" . join ( map ( str , bs ) ) ) NEW_LINE" ]
atcoder_arc019_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 . replace ( \" O \" , \"0\" ) . replaceAll ( \" D \" , \"0\" ) . replaceAll ( \" I \" , \"1\" ) . replaceAll ( \" Z \" , \"2\" ) . replaceAll ( \" S \" , \"5\" ) . replaceAll ( \" B \" , \"8\" ) ) ; } }", "import java . util . * ; public class Main { private static String s ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; s = scan . next ( ) ; } public static void main ( String args [ ] ) { input ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { switch ( s . charAt ( i ) ) { case ' O ' : s = s . replace ( ' O ' , '0' ) ; break ; case ' D ' : s = s . replace ( ' D ' , '0' ) ; break ; case ' I ' : s = s . replace ( ' I ' , '1' ) ; break ; case ' Z ' : s = s . replace ( ' Z ' , '2' ) ; break ; case ' S ' : s = s . replace ( ' S ' , '5' ) ; break ; case ' B ' : s = s . replace ( ' B ' , '8' ) ; break ; default : break ; } } System . out . println ( s ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; HashMap < Character , Integer > map = new HashMap < > ( ) ; map . put ( ' O ' , 0 ) ; map . put ( ' D ' , 0 ) ; map . put ( ' I ' , 1 ) ; map . put ( ' Z ' , 2 ) ; map . put ( ' S ' , 5 ) ; map . put ( ' B ' , 8 ) ; String str = in . next ( ) ; for ( char c : str . toCharArray ( ) ) { System . out . print ( map . containsKey ( c ) ? map . get ( c ) . toString ( ) : c ) ; } System . out . println ( ) ; } }", "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 ( ) ; char [ ] c = new char [ S . length ( ) ] ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { c [ i ] = S . charAt ( i ) ; if ( c [ i ] == ' O ' ) { System . out . print ( '0' ) ; } else if ( c [ i ] == ' D ' ) { System . out . print ( '0' ) ; } else if ( c [ i ] == ' I ' ) { System . out . print ( '1' ) ; } else if ( c [ i ] == ' Z ' ) { System . out . print ( '2' ) ; } else if ( c [ i ] == ' S ' ) { System . out . print ( '5' ) ; } else if ( c [ i ] == ' B ' ) { System . out . print ( '8' ) ; } else { System . out . print ( c [ i ] ) ; } } System . out . println ( ) ; } }", "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 ( ) ; String [ ] b = { \" O \" , \" D \" , \" I \" , \" Z \" , \" S \" , \" B \" } ; String [ ] a = { \"0\" , \"0\" , \"1\" , \"2\" , \"5\" , \"8\" } ; for ( int i = 0 ; i < b . length ; i ++ ) { s = s . replaceAll ( b [ i ] , a [ i ] ) ; } out . println ( s ) ; } }" ]
[ "print ( str ( input ( ) ) . translate ( str . maketrans ( { ' O ' : '0' , ' D ' : '0' , ' I ' : '1' , ' Z ' : '2' , ' S ' : '5' , ' B ' : '8' } ) ) ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE d = dict ( ) NEW_LINE d [ ' O ' ] = '0' NEW_LINE d [ ' D ' ] = '0' NEW_LINE d [ ' I ' ] = '1' NEW_LINE d [ ' Z ' ] = '2' NEW_LINE d [ ' S ' ] = '5' NEW_LINE d [ ' B ' ] = '8' NEW_LINE s = input ( ) NEW_LINE ans = ' ' NEW_LINE for c in s [ : - 1 ] : NEW_LINE INDENT if ord ( '0' ) <= ord ( c ) <= ord ( '9' ) : NEW_LINE INDENT ans += c NEW_LINE DEDENT else : NEW_LINE INDENT ans += d [ c ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "S = str ( input ( ) ) NEW_LINE S = list ( S ) NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i ] == \" O \" or S [ i ] == \" D \" : NEW_LINE INDENT S [ i ] = '0' NEW_LINE DEDENT elif S [ i ] == \" I \" : NEW_LINE INDENT S [ i ] = '1' NEW_LINE DEDENT elif S [ i ] == \" Z \" : NEW_LINE INDENT S [ i ] = '2' NEW_LINE DEDENT elif S [ i ] == \" S \" : NEW_LINE INDENT S [ i ] = '5' NEW_LINE DEDENT elif S [ i ] == \" B \" : NEW_LINE INDENT S [ i ] = '8' NEW_LINE DEDENT DEDENT ans = \" \" NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT ans += S [ i ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT chars = { \" O \" : \"0\" , \" D \" : \"0\" , \" I \" : \"1\" , \" Z \" : \"2\" , \" S \" : \"5\" , \" B \" : \"8\" } NEW_LINE s = input ( ) NEW_LINE for k , v in chars . items ( ) : NEW_LINE INDENT s = s . replace ( k , v ) NEW_LINE DEDENT print ( s ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def ans ( ) : NEW_LINE INDENT S = input ( ) NEW_LINE res = \" \" NEW_LINE for s in S : NEW_LINE INDENT if ( s == \" O \" or s == \" D \" ) : NEW_LINE INDENT res += \"0\" NEW_LINE DEDENT elif ( s == \" I \" ) : NEW_LINE INDENT res += \"1\" NEW_LINE DEDENT elif ( s == \" Z \" ) : NEW_LINE INDENT res += \"2\" NEW_LINE DEDENT elif ( s == \" S \" ) : NEW_LINE INDENT res += \"5\" NEW_LINE DEDENT elif ( s == \" B \" ) : NEW_LINE INDENT res += \"8\" NEW_LINE DEDENT else : NEW_LINE INDENT res += s NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE DEDENT ans ( ) NEW_LINE" ]
atcoder_abc090_B
[ "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 cnt = 0 ; for ( int i = a ; i <= b ; i ++ ) { int fi = i / 10000 ; int on = i % 10 ; int fo = i / 1000 % 10 ; int tw = i % 100 / 10 ; if ( fi == on && fo == tw ) { cnt ++ ; } } System . out . println ( cnt ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int s = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = s ; i <= e ; i ++ ) { int rev = getRev ( i ) ; if ( i == rev ) { cnt ++ ; } } System . out . println ( cnt ) ; } public static int getRev ( int i ) { int ic = 0 ; while ( i > 0 ) { ic = ic * 10 + i % 10 ; i /= 10 ; } return ic ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; String strA = reader . next ( ) ; int [ ] A = new int [ 5 ] ; String strB = reader . next ( ) ; int [ ] B = new int [ 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) { A [ i ] = Character . getNumericValue ( strA . charAt ( i ) ) ; B [ i ] = Character . getNumericValue ( strB . charAt ( i ) ) ; } int ans = 0 ; int [ ] C = new int [ 5 ] ; C [ 0 ] = B [ 0 ] - A [ 0 ] ; if ( C [ 0 ] == 0 ) { C [ 1 ] = B [ 1 ] - A [ 1 ] - 1 ; } else { C [ 1 ] = 10 ; } if ( C [ 1 ] == 0 ) { C [ 2 ] = B [ 2 ] - A [ 2 ] - 1 ; } else { C [ 2 ] = 10 ; } ans = C [ 0 ] * C [ 1 ] * C [ 2 ] ; int intA = Integer . parseInt ( strA ) ; int below = 0 ; for ( int i = A [ 0 ] * 10000 ; i < intA ; i ++ ) { int n1 = i / 10000 ; int n2 = i % 10000 / 1000 ; int n4 = i % 100 / 10 ; int n5 = i % 10 ; if ( n1 == n5 && n2 == n4 ) { below ++ ; } } int intB = Integer . parseInt ( strB ) ; int above = 0 ; for ( int i = B [ 0 ] * 10000 ; i <= intB ; i ++ ) { int n1 = i / 10000 ; int n2 = i % 10000 / 1000 ; int n4 = i % 100 / 10 ; int n5 = i % 10 ; if ( n1 == n5 && n2 == n4 ) { above ++ ; } } System . out . println ( ans - below + above ) ; reader . close ( ) ; } }", "import java . io . * ; import java . util . * ; import java . util . stream . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] input = Arrays . stream ( stdin . readLine ( ) . split ( \" ▁ \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; long ans = IntStream . rangeClosed ( input [ 0 ] , input [ 1 ] ) . mapToObj ( String :: valueOf ) . filter ( s -> s . equals ( ( new StringBuilder ( s ) ) . reverse ( ) . toString ( ) ) ) . count ( ) ; System . out . println ( ans ) ; } }", "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 ( ) ) ; int count = 0 ; for ( int i = a ; i <= b ; i ++ ) { if ( isBlandrome ( i ) ) count ++ ; } System . out . println ( count ) ; } public static boolean isBlandrome ( int n ) { int copy = n ; int newN = 0 ; while ( n > 9 ) { newN = newN * 10 + ( n % 10 ) ; n /= 10 ; } if ( n > 0 ) { newN = newN * 10 + ( n % 10 ) ; } return newN == copy ; } }" ]
[ "def p ( a , b ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( a , b + 1 ) : NEW_LINE INDENT si = str ( i ) NEW_LINE if si [ 0 ] == si [ - 1 ] and si [ 1 ] == si [ - 2 ] : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( p ( n , m ) ) NEW_LINE", "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE lists = list ( range ( A , B + 1 ) ) NEW_LINE str_lists = list ( str ( lists [ 0 ] ) ) NEW_LINE kaibun_lists = [ ] NEW_LINE for i in range ( len ( lists ) ) : NEW_LINE INDENT for j in range ( len ( list ( str ( lists [ i ] ) ) ) ) : NEW_LINE INDENT kaibun = str ( lists [ i ] ) [ : : - 1 ] NEW_LINE DEDENT if lists [ i ] == int ( kaibun ) : NEW_LINE INDENT kaibun_lists . append ( int ( kaibun ) ) NEW_LINE DEDENT DEDENT print ( len ( kaibun_lists ) ) NEW_LINE", "def check ( s ) : NEW_LINE INDENT s = str ( s ) NEW_LINE if s == s [ : : - 1 ] : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT cnt = 0 NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( a , b + 1 ) : NEW_LINE INDENT if check ( i ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE", "a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE num = [ ] NEW_LINE for n in range ( a , b + 1 ) : NEW_LINE INDENT num . append ( str ( n ) ) NEW_LINE DEDENT count = 0 NEW_LINE for i in range ( len ( num ) ) : NEW_LINE INDENT hantei = 0 NEW_LINE for j in range ( len ( num [ i ] ) // 2 ) : NEW_LINE INDENT if num [ i ] [ j ] == num [ i ] [ - ( j + 1 ) ] : NEW_LINE INDENT hantei += 1 NEW_LINE DEDENT DEDENT if hantei == len ( num [ i ] ) // 2 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( a , b + 1 ) : NEW_LINE INDENT tmp = str ( i ) NEW_LINE if tmp [ 0 ] == tmp [ - 1 ] and tmp [ 1 ] == tmp [ - 2 ] : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc032_B
[ "import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int k = sc . nextInt ( ) ; Set < String > set = new TreeSet < > ( ) ; for ( int i = 0 ; i + k <= s . length ( ) ; i ++ ) { set . add ( s . substring ( i , i + k ) ) ; } System . out . println ( set . size ( ) ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { new Main ( ) . main ( ) ; } public void main ( ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; int k = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] memory = new String [ s . length ( ) ] ; int memorySize = 0 ; for ( int i = 0 ; i <= s . length ( ) - k ; i ++ ) { String sub = s . substring ( i , i + k ) ; if ( ! this . includes ( memory , memorySize , sub ) ) { memory [ memorySize ] = sub ; memorySize ++ ; } } System . out . println ( memorySize ) ; } private boolean includes ( String [ ] arr , int n , String s ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] . equals ( s ) ) { return true ; } } return false ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int k = sc . nextInt ( ) ; if ( s . length ( ) < k ) { System . out . println ( 0 ) ; return ; } String [ ] words = new String [ s . length ( ) - k + 1 ] ; for ( int i = 0 ; i < words . length ; i ++ ) { words [ i ] = s . substring ( i , i + k ) ; } Arrays . sort ( words ) ; int output = words . length ; for ( int i = 1 ; i < words . length ; i ++ ) { if ( words [ i - 1 ] . equals ( words [ i ] ) ) output -- ; } System . out . println ( output ) ; } }", "import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int len = sc . nextInt ( ) ; List l = new ArrayList < String > ( ) ; for ( int i = 0 ; i + len <= s . length ( ) ; i ++ ) { if ( l . contains ( s . substring ( i , i + len ) ) ) { } else { l . add ( s . substring ( i , i + len ) ) ; } } System . out . println ( l . size ( ) ) ; sc . close ( ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . Scanner ; import java . util . ArrayList ; import java . util . List ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int k = scan . nextInt ( ) ; int ans ; if ( k > s . length ( ) ) { ans = 0 ; } else { List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i <= s . length ( ) - k ; i ++ ) { String t = s . substring ( i , i + k ) ; if ( ! list . contains ( t ) ) { list . add ( t ) ; } } ans = list . size ( ) ; } System . out . println ( ans ) ; } }" ]
[ "s = input ( ) NEW_LINE k = int ( input ( ) ) NEW_LINE plist = [ ] NEW_LINE for i in range ( len ( s ) - k + 1 ) : NEW_LINE INDENT tmp = s [ i : i + k ] NEW_LINE if tmp not in plist : NEW_LINE INDENT plist . append ( tmp ) NEW_LINE DEDENT DEDENT print ( len ( plist ) ) 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 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 S = input ( ) NEW_LINE K = getInt ( ) NEW_LINE d . dmp ( ( S , K ) , ' S , K ' ) NEW_LINE dic = set ( [ ] ) NEW_LINE for i in range ( len ( S ) - K + 1 ) : NEW_LINE INDENT if S [ i : i + K ] not in dic : NEW_LINE INDENT dic . add ( S [ i : i + K ] ) NEW_LINE DEDENT DEDENT d . dmp ( ( dic ) , ' dic ' ) NEW_LINE return len ( dic ) NEW_LINE DEDENT ans = prob ( ) NEW_LINE print ( ans ) NEW_LINE", "def password ( s : str , k : int ) -> int : NEW_LINE INDENT t = set ( ) NEW_LINE for i in range ( len ( s ) - k + 1 ) : NEW_LINE INDENT t . add ( s [ i : i + k ] ) NEW_LINE DEDENT return len ( t ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT s = input ( ) NEW_LINE k = int ( input ( ) ) NEW_LINE ans = password ( s , k ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "s , k = open ( 0 ) ; k = int ( k ) ; print ( len ( { s [ t : t + k ] for t in range ( len ( s ) - k ) } ) ) NEW_LINE", "s = input ( ) NEW_LINE k = int ( input ( ) ) NEW_LINE dict = { } NEW_LINE for l in range ( len ( s ) ) : NEW_LINE INDENT for r in range ( l + 1 , len ( s ) + 1 ) : NEW_LINE INDENT if ( r - l != k ) : NEW_LINE INDENT continue NEW_LINE DEDENT dict [ s [ l : r ] ] = 1 NEW_LINE DEDENT DEDENT ans = len ( dict ) NEW_LINE print ( ans ) NEW_LINE" ]
atcoder_arc068_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextLong ( ) ; long ans = x / 11 ; ans += ans ; if ( x % 11 > 6 ) { ans += 2 ; } else if ( x % 11 > 0 ) { ans ++ ; } System . out . println ( ans ) ; } }", "import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; class Main { public static void main ( String args [ ] ) throws IOException { @ SuppressWarnings ( \" resource \" ) Scanner cin = new Scanner ( System . in ) ; ArrayList < String > inLines = new ArrayList < String > ( ) ; for ( ; cin . hasNext ( ) ; ) { inLines . add ( cin . nextLine ( ) ) ; } Solver solver = new Solver ( ) ; solver . solve ( inLines ) ; } } class Solver { public void solve ( ArrayList < String > inLines ) { long x = Long . parseLong ( inLines . get ( 0 ) ) ; long ans = ( x / 11 ) * 2 ; if ( x % 11 != 0 ) { if ( x % 11 <= 6 ) ans += 1 ; else ans += 2 ; } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { long x ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; x = sc . nextLong ( ) ; solve ( ) ; } void solve ( ) { long remainder = x % 11 ; long ans = x / 11 * 2 ; if ( remainder > 6 ) { ans += 2 ; } else if ( remainder > 0 ) { ans ++ ; } System . out . println ( 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 ; } } }", "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 long nextLong ( ) { return Long . parseLong ( 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 ) { long n = nextLong ( ) ; if ( n % 11 == 0 ) { System . out . println ( n / 11 * 2 ) ; } else if ( n % 11 <= 6 ) { System . out . println ( n / 11 * 2 + 1 ) ; } else { System . out . println ( n / 11 * 2 + 2 ) ; } } }", "import java . io . * ; public class Main { static final int N = 10000 ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long x = Long . parseLong ( br . readLine ( ) ) ; long sum = x / 11 ; long temp = x % 11 ; if ( temp != 0 ) { System . out . println ( ( temp > 6 ) ? sum * 2 + 2 : sum * 2 + 1 ) ; } else { System . out . println ( sum * 2 ) ; } } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE from functools import partial , reduce NEW_LINE from operator import mul NEW_LINE prod = partial ( reduce , mul ) 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 x = II ( ) NEW_LINE ans = x // ( 6 + 5 ) * 2 NEW_LINE x %= ( 6 + 5 ) NEW_LINE if 0 < x <= 6 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT elif 6 < x <= 11 : NEW_LINE INDENT ans += 2 NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "x = int ( input ( ) ) NEW_LINE print ( ( x // 11 ) * 2 + ( 0 if x % 11 == 0 else ( 1 if x % 11 < 7 else 2 ) ) ) 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 N1097 = 10 ** 9 + 7 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 N = getInt ( ) NEW_LINE dmp ( N ) NEW_LINE count = N // ( 5 + 6 ) * 2 NEW_LINE rem = N % ( 5 + 6 ) NEW_LINE if rem > 6 : NEW_LINE INDENT count += 2 NEW_LINE DEDENT elif rem > 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT return count NEW_LINE DEDENT debug = False NEW_LINE ans = probC ( ) NEW_LINE print ( ans ) NEW_LINE NEW_LINE", "x = int ( input ( ) ) NEW_LINE count = 0 NEW_LINE q , mod = divmod ( x , 11 ) NEW_LINE count += q * 2 NEW_LINE if mod > 0 : NEW_LINE INDENT if ( mod <= 6 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT count += 2 NEW_LINE DEDENT DEDENT print ( count ) 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 x = ni ( ) NEW_LINE if x % 11 == 0 : NEW_LINE INDENT print ( x // 11 * 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT if x % 11 <= 6 : NEW_LINE INDENT print ( x // 11 * 2 + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( x // 11 * 2 + 2 ) NEW_LINE DEDENT DEDENT" ]
atcoder_arc093_A
[ "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 ( ) ; ArrayList < Integer > ai = new ArrayList < > ( ) ; int sum = 0 ; int prev = 0 ; ai . add ( 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int tmp = sc . nextInt ( ) ; ai . add ( tmp ) ; sum += Math . abs ( tmp - prev ) ; prev = tmp ; } sum += Math . abs ( prev ) ; ai . add ( 0 ) ; for ( int i = 1 ; i <= N ; i ++ ) { int a1 = Math . abs ( ai . get ( i - 1 ) - ai . get ( i ) ) ; int a2 = Math . abs ( ai . get ( i ) - ai . get ( i + 1 ) ) ; int a3 = Math . abs ( ai . get ( i + 1 ) - ai . get ( i - 1 ) ) ; System . out . println ( sum - ( a1 + a2 - a3 ) ) ; } } }", "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 long nextLong ( ) { return Long . parseLong ( 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 ( ) ; int [ ] ar = new int [ n + 2 ] ; for ( int i = 1 ; i < n + 1 ; i ++ ) { ar [ i ] = nextInt ( ) ; } long sum = 0 ; for ( int i = 1 ; i < n + 2 ; i ++ ) { sum += Math . abs ( ar [ i ] - ar [ i - 1 ] ) ; } for ( int i = 1 ; i < n + 1 ; i ++ ) { System . out . println ( sum + Math . abs ( ar [ i + 1 ] - ar [ i - 1 ] ) - ( Math . abs ( ar [ i + 1 ] - ar [ i ] ) + Math . abs ( ar [ i ] - ar [ i - 1 ] ) ) ) ; } } }", "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 ) { int n = in . nextInt ( ) ; int [ ] x = new int [ n + 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i + 1 ] = in . nextInt ( ) ; } long sum = 0 ; for ( int i = 0 ; i < n + 1 ; i ++ ) { sum += Math . abs ( x [ i + 1 ] - x [ i ] ) ; } for ( int i = 1 ; i <= n ; i ++ ) { out . println ( sum - Math . abs ( x [ i + 1 ] - x [ i ] ) - Math . abs ( x [ i ] - x [ i - 1 ] ) + Math . abs ( x [ i + 1 ] - x [ i - 1 ] ) ) ; } } } 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 . * ; public class Main { public static void main ( String [ ] args ) { TravelingPlan ( ) ; } public static void ABC086A ( ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( ( a * b ) % 2 == 0 ) { System . out . println ( \" Even \" ) ; } else { System . out . println ( \" Odd \" ) ; } } public static void ABC081A ( ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; char chr [ ] = str . toCharArray ( ) ; int count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( chr [ i ] == '1' ) count ++ ; } System . out . println ( count ) ; } public static void TravelingPlan ( ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int [ ] A = new int [ N + 2 ] ; for ( int i = 1 ; i < N + 1 ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } A [ 0 ] = 0 ; A [ N + 1 ] = 0 ; int ans = 0 ; for ( int i = 1 ; i < N + 2 ; i ++ ) { ans += Math . abs ( A [ i ] - A [ i - 1 ] ) ; } for ( int i = 1 ; i < N + 1 ; i ++ ) { System . out . println ( ans - Math . abs ( A [ i ] - A [ i - 1 ] ) - Math . abs ( A [ i + 1 ] - A [ i ] ) + Math . abs ( A [ i + 1 ] - A [ i - 1 ] ) ) ; } } }", "import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; N = scanner . nextInt ( ) ; long total = 0 ; int [ ] map = new int [ N + 5 ] ; int old = 0 ; int old2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int a = scanner . nextInt ( ) ; total += Math . abs ( a - old ) ; if ( i != 0 ) { if ( Math . abs ( a - old ) + Math . abs ( old - old2 ) == Math . abs ( old2 - a ) ) { map [ i - 1 ] = 0 ; } else { map [ i - 1 ] = Math . abs ( a - old ) + Math . abs ( old - old2 ) - Math . abs ( old2 - a ) ; } } old2 = old ; old = a ; } total += Math . abs ( old ) ; if ( Math . abs ( 0 - old ) + Math . abs ( old - old2 ) == Math . abs ( old2 - 0 ) ) { map [ N - 1 ] = 0 ; } else { map [ N - 1 ] = Math . abs ( 0 - old ) + Math . abs ( old - old2 ) - Math . abs ( old2 - 0 ) ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . println ( total - map [ i ] ) ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) + [ 0 ] NEW_LINE c = [ 0 ] * ( N + 2 ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT c [ i + 1 ] = abs ( a [ i ] - a [ i - 1 ] ) NEW_LINE DEDENT c [ - 1 ] = abs ( a [ - 2 ] ) NEW_LINE s = sum ( c ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT print ( s - c [ i + 1 ] - c [ i + 2 ] + abs ( a [ i + 1 ] - a [ i - 1 ] ) ) NEW_LINE DEDENT", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ 0 ] + inpl ( ) + [ 0 ] NEW_LINE sumtr = 0 NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT sumtr += abs ( A [ i + 1 ] - A [ i ] ) NEW_LINE DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( sumtr + abs ( A [ i + 1 ] - A [ i - 1 ] ) - abs ( A [ i ] - A [ i - 1 ] ) - abs ( A [ i + 1 ] - A [ i ] ) ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A . insert ( 0 , 0 ) NEW_LINE A . append ( 0 ) NEW_LINE cost = 0 NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT cost += abs ( A [ i + 1 ] - A [ i ] ) NEW_LINE DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if A [ i - 1 ] <= A [ i ] <= A [ i + 1 ] or A [ i + 1 ] <= A [ i ] <= A [ i - 1 ] : NEW_LINE INDENT sub = 0 NEW_LINE DEDENT elif A [ i - 1 ] <= A [ i + 1 ] <= A [ i ] : NEW_LINE INDENT sub = 2 * ( A [ i ] - A [ i + 1 ] ) NEW_LINE DEDENT elif A [ i ] <= A [ i - 1 ] <= A [ i + 1 ] : NEW_LINE INDENT sub = 2 * ( A [ i - 1 ] - A [ i ] ) NEW_LINE DEDENT elif A [ i + 1 ] <= A [ i - 1 ] <= A [ i ] : NEW_LINE INDENT sub = 2 * ( A [ i ] - A [ i - 1 ] ) NEW_LINE DEDENT elif A [ i ] <= A [ i + 1 ] <= A [ i - 1 ] : NEW_LINE INDENT sub = 2 * ( A [ i + 1 ] - A [ i ] ) NEW_LINE DEDENT print ( cost - sub ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE As = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE As . insert ( 0 , 0 ) NEW_LINE As . append ( 0 ) NEW_LINE total = 0 NEW_LINE costs = [ ] NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT total += abs ( As [ i ] - As [ i - 1 ] ) NEW_LINE x1 = As [ i ] - As [ i - 1 ] NEW_LINE x2 = As [ i + 1 ] - As [ i - 1 ] NEW_LINE if x1 * x2 >= 0 and abs ( x1 ) <= abs ( x2 ) : NEW_LINE INDENT costs . append ( 0 ) NEW_LINE DEDENT elif x1 * x2 >= 0 and abs ( x1 ) > abs ( x2 ) : NEW_LINE INDENT costs . append ( 2 * abs ( x2 - x1 ) ) NEW_LINE DEDENT elif x1 * x2 < 0 : NEW_LINE INDENT costs . append ( 2 * abs ( x1 ) ) NEW_LINE DEDENT DEDENT total += abs ( As [ N + 1 ] - As [ N ] ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT print ( total - costs [ i ] ) NEW_LINE DEDENT", "II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE MIL = lambda : list ( MI ( ) ) NEW_LINE MIS = lambda : input ( ) . split ( ) NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE A = [ 0 ] + MIL ( ) + [ 0 ] NEW_LINE d = [ abs ( A [ i ] - A [ i + 1 ] ) for i in range ( N + 1 ) ] NEW_LINE cost = sum ( d ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( cost - ( d [ i ] + d [ i - 1 ] ) + abs ( A [ i - 1 ] - A [ i + 1 ] ) ) NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc051_D
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { static int N ; static int M ; static Edge [ ] E ; static final int INF = 10000 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; M = sc . nextInt ( ) ; E = new Edge [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { E [ i ] = new Edge ( sc . nextInt ( ) - 1 , sc . nextInt ( ) - 1 , sc . nextInt ( ) ) ; } System . out . println ( solve ( ) ) ; } private static long solve ( ) { int [ ] [ ] dist = new int [ N ] [ N ] ; for ( int [ ] array : dist ) { Arrays . fill ( array , INF ) ; } for ( Edge edge : E ) { dist [ edge . a ] [ edge . b ] = edge . cost ; dist [ edge . b ] [ edge . a ] = edge . cost ; } for ( int k = 0 ; k < N ; k ++ ) { for ( int i = 0 ; i < N ; i ++ ) { if ( dist [ i ] [ k ] == INF ) continue ; for ( int j = 0 ; j < N ; j ++ ) { if ( dist [ k ] [ j ] == INF ) continue ; if ( dist [ i ] [ k ] + dist [ k ] [ j ] < dist [ i ] [ j ] ) { dist [ i ] [ j ] = dist [ i ] [ k ] + dist [ k ] [ j ] ; } } } } int ans = 0 ; for ( Edge edge : E ) { if ( dist [ edge . a ] [ edge . b ] < edge . cost ) ans ++ ; } return ans ; } static class Edge { private final int a ; private final int b ; private final int cost ; public Edge ( int a , int b , int cost ) { this . a = a ; this . b = b ; this . cost = cost ; } } }", "import java . util . Scanner ; 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 [ ] c = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; c [ i ] = sc . nextInt ( ) ; } int [ ] [ ] map = new int [ n + 1 ] [ n + 1 ] ; int inf = 1000000 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { for ( int j = 1 ; j < n + 1 ; j ++ ) { map [ i ] [ j ] = inf ; } } for ( int i = 0 ; i < m ; i ++ ) { map [ a [ i ] ] [ b [ i ] ] = c [ i ] ; map [ b [ i ] ] [ a [ i ] ] = c [ i ] ; } for ( int k = 1 ; k <= n ; k ++ ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { map [ i ] [ j ] = Math . min ( map [ i ] [ j ] , map [ i ] [ k ] + map [ k ] [ j ] ) ; } } } int ans = 0 ; for ( int i = 0 ; i < m ; i ++ ) { if ( map [ a [ i ] ] [ b [ i ] ] != c [ i ] ) { ans ++ ; } } System . out . println ( ans ) ; } } class Pair implements Comparable { int from ; int end ; @ 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 = in . nextInt ( ) ; int m = in . nextInt ( ) ; int [ ] a = new int [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ m ] ; int [ ] [ ] cost = new int [ n ] [ n ] ; int inf = 1 << 29 ; for ( int i = 0 ; i < n ; i ++ ) Arrays . fill ( cost [ i ] , inf ) ; for ( int i = 0 ; i < n ; i ++ ) cost [ i ] [ i ] = 0 ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = in . nextInt ( ) - 1 ; b [ i ] = in . nextInt ( ) - 1 ; c [ i ] = in . nextInt ( ) ; cost [ a [ i ] ] [ b [ i ] ] = c [ i ] ; cost [ b [ i ] ] [ a [ i ] ] = c [ i ] ; } boolean used [ ] = new boolean [ m ] ; for ( int k = 0 ; k < n ; k ++ ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) continue ; cost [ i ] [ j ] = Math . min ( cost [ i ] [ k ] + cost [ k ] [ j ] , cost [ i ] [ j ] ) ; } } } int ans = 0 ; for ( int i = 0 ; i < m ; i ++ ) if ( c [ i ] > cost [ a [ i ] ] [ b [ i ] ] ) ans ++ ; System . out . println ( ans ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; int [ ] [ ] edges = new int [ M ] [ 3 ] ; int [ ] [ ] dist = new int [ N ] [ N ] ; int INF = 100_000_000 ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) dist [ i ] [ j ] = INF ; for ( int i = 0 ; i < M ; i ++ ) { int a = scanner . nextInt ( ) - 1 ; int b = scanner . nextInt ( ) - 1 ; int c = scanner . nextInt ( ) ; edges [ i ] [ 0 ] = a ; edges [ i ] [ 1 ] = b ; edges [ i ] [ 2 ] = c ; dist [ a ] [ b ] = dist [ b ] [ a ] = c ; } for ( int k = 0 ; k < N ; k ++ ) for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( dist [ i ] [ j ] > dist [ i ] [ k ] + dist [ k ] [ j ] ) dist [ i ] [ j ] = dist [ i ] [ k ] + dist [ k ] [ j ] ; int num = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int a = edges [ i ] [ 0 ] ; int b = edges [ i ] [ 1 ] ; int c = edges [ i ] [ 2 ] ; if ( dist [ a ] [ b ] == c ) num ++ ; } System . out . println ( M - num ) ; } }", "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; int inf = Integer . MAX_VALUE / 2 - 10 ; int [ ] [ ] dist = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) Arrays . fill ( dist [ i ] , inf ) ; for ( int i = 0 ; i <= n ; i ++ ) dist [ i ] [ i ] = 0 ; Edge [ ] dic = new Edge [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) ; dic [ i ] = new Edge ( a , b , c ) ; dist [ a ] [ b ] = Math . min ( dist [ a ] [ b ] , c ) ; dist [ b ] [ a ] = Math . min ( dist [ b ] [ a ] , c ) ; } for ( int mid = 1 ; mid <= n ; mid ++ ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) dist [ i ] [ j ] = Math . min ( dist [ i ] [ j ] , dist [ i ] [ mid ] + dist [ mid ] [ j ] ) ; } } int ans = 0 ; for ( Edge e : dic ) { if ( dist [ e . left ] [ e . right ] < e . length ) ans ++ ; } System . out . println ( ans ) ; } static class Edge { int left , right , length ; public Edge ( int l , int r , int len ) { left = l ; right = r ; length = len ; } } }" ]
[ "import heapq NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE abc = [ tuple ( int ( x ) - 1 for x in input ( ) . split ( ) ) for _ in range ( m ) ] NEW_LINE dist = [ [ 9999999 for _ in range ( n ) ] for _ in range ( n ) ] NEW_LINE e = [ dict ( ) for _ in range ( n ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b , c = abc [ i ] [ 0 ] , abc [ i ] [ 1 ] , abc [ i ] [ 2 ] NEW_LINE e [ a ] [ b ] = c + 1 NEW_LINE e [ b ] [ a ] = c + 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT h = [ ] NEW_LINE heapq . heappush ( h , [ 0 , i ] ) NEW_LINE temp = set ( ) NEW_LINE while len ( temp ) < n : NEW_LINE INDENT d , p = heapq . heappop ( h ) NEW_LINE while p in temp : NEW_LINE INDENT d , p = heapq . heappop ( h ) NEW_LINE DEDENT dist [ i ] [ p ] = d NEW_LINE temp . add ( p ) NEW_LINE for x in e [ p ] . keys ( ) : NEW_LINE INDENT heapq . heappush ( h , [ d + e [ p ] [ x ] , x ] ) NEW_LINE DEDENT DEDENT DEDENT ans = m NEW_LINE for a , b , c in abc : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if c + 1 == dist [ a ] [ i ] - dist [ b ] [ i ] : NEW_LINE INDENT ans -= 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "from collections import deque NEW_LINE from operator import itemgetter NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE edge = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( m ) ] NEW_LINE kyori = [ [ float ( \" inf \" ) ] * n for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT kyori [ i ] [ i ] = 0 NEW_LINE DEDENT def dfs ( start , goal ) : NEW_LINE INDENT visited_cost = [ float ( \" inf \" ) ] * n NEW_LINE visited_cost [ start ] = 0 NEW_LINE que = deque ( ) NEW_LINE que . append ( start ) NEW_LINE while que : NEW_LINE INDENT pos = que . pop ( ) NEW_LINE for [ next_pos , cost ] in tree [ pos ] : NEW_LINE INDENT if visited_cost [ next_pos ] > visited_cost [ pos ] + cost : NEW_LINE INDENT visited_cost [ next_pos ] = visited_cost [ pos ] + cost NEW_LINE que . append ( next_pos ) NEW_LINE DEDENT DEDENT DEDENT return visited_cost [ goal ] NEW_LINE DEDENT edge = sorted ( edge , key = itemgetter ( 2 ) ) NEW_LINE tree = [ [ ] for i in range ( n ) ] NEW_LINE ans = m NEW_LINE for [ start , goal , cost ] in edge : NEW_LINE INDENT start -= 1 NEW_LINE goal -= 1 NEW_LINE if cost <= dfs ( start , goal ) : NEW_LINE INDENT tree [ start ] . append ( [ goal , cost ] ) NEW_LINE tree [ goal ] . append ( [ start , cost ] ) NEW_LINE ans -= 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE inf = float ( ' inf ' ) NEW_LINE def warshall_floyd ( dist , n ) : NEW_LINE INDENT for k in range ( n ) : NEW_LINE INDENT 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 elif dist [ i ] [ j ] > dist [ i ] [ k ] + dist [ k ] [ j ] : NEW_LINE INDENT dist [ i ] [ j ] = dist [ i ] [ k ] + dist [ k ] [ j ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE edges = [ ] NEW_LINE ad = [ [ inf ] * N for _ in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE a -= 1 ; b -= 1 NEW_LINE edges . append ( ( a , b , c ) ) NEW_LINE ad [ a ] [ b ] = c NEW_LINE ad [ b ] [ a ] = c NEW_LINE DEDENT warshall_floyd ( ad , N ) NEW_LINE ans = M NEW_LINE for a , b , c in edges : NEW_LINE INDENT if a > b : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT for s in range ( N ) : NEW_LINE INDENT for e in range ( s + 1 , N ) : NEW_LINE INDENT if ad [ s ] [ a ] + c + ad [ b ] [ e ] == ad [ s ] [ e ] : NEW_LINE INDENT ans -= 1 NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def candidates_of_no_shortest_paths ( N : int , M : int , edges : list ) -> int : NEW_LINE INDENT INF = float ( ' inf ' ) NEW_LINE d = [ [ 0 if i == j else INF for i in range ( N ) ] for j in range ( N ) ] NEW_LINE for u , v , c in edges : NEW_LINE INDENT d [ u - 1 ] [ v - 1 ] = d [ v - 1 ] [ u - 1 ] = c NEW_LINE DEDENT for k in range ( N ) : NEW_LINE INDENT for u in range ( N ) : NEW_LINE INDENT for v in range ( N ) : NEW_LINE INDENT if d [ u ] [ v ] > d [ u ] [ k ] + d [ k ] [ v ] : NEW_LINE INDENT d [ u ] [ v ] = d [ u ] [ k ] + d [ k ] [ v ] NEW_LINE DEDENT DEDENT DEDENT DEDENT def used ( edge : tuple ) -> bool : NEW_LINE INDENT u , v , c = edge NEW_LINE for s in range ( N ) : NEW_LINE INDENT if d [ s ] [ u - 1 ] + c == d [ s ] [ v - 1 ] : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT return sum ( not used ( edge ) for edge in edges ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT M = 0 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE edges = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( M ) ] NEW_LINE ans = candidates_of_no_shortest_paths ( N , M , edges ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "from copy import deepcopy NEW_LINE N , M = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) NEW_LINE abc = { } NEW_LINE used = { } NEW_LINE for _ in range ( M ) : NEW_LINE INDENT a , b , c = ( list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) ) NEW_LINE abc [ a , b ] = c NEW_LINE used [ a , b ] = False NEW_LINE DEDENT spth = [ [ float ( \" inf \" ) ] * ( N + 1 ) for _ in range ( N + 1 ) ] NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT spth [ i ] [ i ] = 0 NEW_LINE DEDENT for ab , c in abc . items ( ) : NEW_LINE INDENT spth [ ab [ 0 ] ] [ ab [ 1 ] ] = c NEW_LINE spth [ ab [ 1 ] ] [ ab [ 0 ] ] = c NEW_LINE DEDENT for k in range ( 1 , N + 1 ) : NEW_LINE INDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT for j in range ( 1 , N + 1 ) : NEW_LINE INDENT d = spth [ i ] [ k ] + spth [ k ] [ j ] NEW_LINE if spth [ i ] [ j ] > d : NEW_LINE INDENT spth [ i ] [ j ] = d NEW_LINE DEDENT DEDENT DEDENT DEDENT for ab , c in abc . items ( ) : NEW_LINE INDENT for s in range ( 1 , N + 1 ) : NEW_LINE INDENT if used [ ab ] : break NEW_LINE if spth [ s ] [ ab [ 1 ] ] == spth [ s ] [ ab [ 0 ] ] + c : NEW_LINE INDENT used [ ab ] = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( sum ( not i for i in used . values ( ) ) ) NEW_LINE" ]
atcoder_agc010_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( a % 2 == 1 ) { c ++ ; } } System . out . println ( c % 2 == 0 ? \" YES \" : \" NO \" ) ; } }", "import java . util . Scanner ; import java . util . Arrays ; import java . util . ArrayList ; import java . util . List ; import java . util . Collections ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( isOdd ( ar [ i ] ) == true ) { count ++ ; } } if ( isOdd ( count ) == true ) { System . out . println ( \" NO \" ) ; } else { System . out . println ( \" YES \" ) ; } sc . close ( ) ; } private static boolean isOdd ( int n ) { if ( n % 2 != 0 ) { return true ; } else { return false ; } } }", "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 oddCount = 0 ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( a % 2 == 1 ) { oddCount ++ ; } } System . out . println ( oddCount % 2 == 0 ? \" YES \" : \" NO \" ) ; } }", "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 [ ] cnt = new int [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { cnt [ ( int ) ( sc . nextLong ( ) % 2 ) ] ++ ; } int restOdd = cnt [ 1 ] % 2 ; cnt [ 0 ] += cnt [ 1 ] / 2 ; if ( ( restOdd == 0 && cnt [ 0 ] > 0 ) || ( restOdd == 1 && cnt [ 0 ] == 0 ) ) { out . println ( \" YES \" ) ; } else { out . println ( \" NO \" ) ; } } }", "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 ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] a = new int [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; if ( a [ i ] % 2 == 1 ) { count ++ ; } } if ( count % 2 == 1 ) { System . out . println ( \" NO \" ) ; } else { System . out . println ( \" YES \" ) ; } } }" ]
[ "input ( ) ; print ( ' YNEOS ' [ sum ( map ( lambda x : int ( x ) % 2 > 0 , input ( ) . split ( ) ) ) % 2 > 0 : : 2 ] ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE s = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE evens , odds = 0 , 0 NEW_LINE for i in s : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT evens += 1 NEW_LINE DEDENT else : NEW_LINE INDENT odds += 1 NEW_LINE DEDENT DEDENT if odds % 2 == 0 : NEW_LINE INDENT ok = True NEW_LINE DEDENT else : NEW_LINE INDENT ok = False NEW_LINE DEDENT print ( ' YES ' if ok else ' NO ' ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE oddnum = 0 NEW_LINE for i in A : NEW_LINE INDENT if i % 2 == 1 : NEW_LINE INDENT oddnum += 1 NEW_LINE DEDENT DEDENT print ( \" YES \" if oddnum % 2 == 0 else \" NO \" ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE odds = sum ( [ a % 2 for a in A ] ) NEW_LINE evens = sum ( [ ( a + 1 ) % 2 for a in A ] ) NEW_LINE if len ( A ) == 1 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE exit ( ) NEW_LINE DEDENT if odds % 2 == 0 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( ' NO ' ) NEW_LINE", "n , a = open ( 0 ) ; print ( ' YNEOS ' [ sum ( map ( int , a . split ( ) ) ) % 2 : : 2 ] ) NEW_LINE" ]
atcoder_abc038_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] = scanner . nextInt ( ) ; long count = N ; int l = 0 ; while ( l < N ) { int r = l + 1 ; while ( r < N && a [ r ] > a [ r - 1 ] ) { count += r - l ; r ++ ; } l = r ; } System . out . println ( count ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . lang . reflect . Array ; import java . util . Arrays ; public class Main { private static final int MOD = 1_000_000_007 ; public static void main ( String [ ] args ) { try ( CustomReader in = new CustomReader ( ) ) { new Main ( ) . execute ( in ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } public void execute ( CustomReader in ) throws IOException { final int N = Integer . parseInt ( in . readLine ( ) ) ; int [ ] a = in . readLineAsIntArray ( ) ; long total = 0 ; long subTotal = 1 ; int seq = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( a [ i ] > a [ i - 1 ] ) { seq ++ ; subTotal += seq ; } else { total += subTotal ; subTotal = 1 ; seq = 1 ; } } total += subTotal ; System . out . println ( total ) ; } static class CustomReader extends BufferedReader { private static final int DEFAULT_BUF_SIZE = 2048 ; public CustomReader ( ) throws IOException { super ( new InputStreamReader ( System . in ) , DEFAULT_BUF_SIZE ) ; } public int [ ] readLineAsIntArray ( ) throws IOException { String [ ] strArray = this . readLine ( ) . split ( \" ▁ \" ) ; int [ ] intArray = new int [ strArray . length ] ; for ( int i = 0 , n = strArray . length ; i < n ; i ++ ) { intArray [ i ] = Integer . parseInt ( strArray [ i ] ) ; } return intArray ; } public int [ ] [ ] readAsIntMatrix ( int rows , int columns ) throws IOException { int [ ] [ ] matrix = new int [ rows ] [ columns ] ; for ( int i = 0 ; i < rows ; i ++ ) { String [ ] r = this . readLine ( ) . split ( \" ▁ \" ) ; for ( int j = 0 ; j < columns ; j ++ ) { matrix [ i ] [ j ] = Integer . parseInt ( r [ j ] ) ; } } return matrix ; } } }", "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 ( ) ; int [ ] values = new int [ N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } values [ N ] = 0 ; long ans = 0 ; long count = 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( values [ i ] < values [ i + 1 ] ) { count ++ ; } else { ans += ( count * ( count + 1 ) ) / 2 ; count = 1 ; } } System . out . println ( ans ) ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long total = 0 ; long subtotal = 1 ; int pre = a [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( pre >= a [ i ] ) { total += subtotal ; if ( subtotal > 1 ) { total += subtotal * ( subtotal - 1 ) / 2 ; } subtotal = 1 ; } else { subtotal ++ ; } pre = a [ i ] ; } total += subtotal ; if ( subtotal > 1 ) { total += subtotal * ( subtotal - 1 ) / 2 ; } out . println ( total ) ; } }", "public class Main { private static java . util . Scanner s = new java . util . Scanner ( System . in ) ; static long l = 0 , n = s . nextInt ( ) , b = s . nextInt ( ) ; public static void main ( String [ ] args ) { System . out . println ( java . util . stream . LongStream . range ( 1 , n ) . reduce ( n , ( a , i ) -> a + ( ( b < ( b = s . nextInt ( ) ) ) ? i - l : ( l = i ) * 0 ) ) ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE r = 0 NEW_LINE ans = 0 NEW_LINE for l in range ( n ) : NEW_LINE INDENT while r < n - 1 and a [ r ] < a [ r + 1 ] : NEW_LINE INDENT r += 1 NEW_LINE DEDENT ans += r - l + 1 NEW_LINE if r == l : r += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "from __future__ import print_function NEW_LINE import sys NEW_LINE def eprint ( * args , ** kwargs ) : NEW_LINE INDENT print ( * args , file = sys . stderr , ** kwargs ) NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE array = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE right = 1 NEW_LINE left = 1 NEW_LINE length_s = 0 NEW_LINE ans = 0 NEW_LINE cnt = 0 NEW_LINE temp_x = 0 NEW_LINE while True : NEW_LINE INDENT if right == n + 1 and left == n + 1 : NEW_LINE INDENT cnt += int ( length_s * ( length_s + 1 ) / 2 ) NEW_LINE break NEW_LINE DEDENT if right == n + 1 : NEW_LINE INDENT while left < right : NEW_LINE INDENT left += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if temp_x < array [ right ] : NEW_LINE INDENT temp_x = array [ right ] NEW_LINE right += 1 NEW_LINE length_s = right - left NEW_LINE DEDENT elif right == left : NEW_LINE INDENT cnt += int ( length_s * ( length_s + 1 ) / 2 ) NEW_LINE temp_x = 0 NEW_LINE DEDENT else : NEW_LINE INDENT left += 1 NEW_LINE DEDENT DEDENT DEDENT print ( cnt ) NEW_LINE NEW_LINE", "def simple_incremental ( N : int , A : list ) -> int : NEW_LINE INDENT l , r = 0 , 0 NEW_LINE count = 0 NEW_LINE while r < N : NEW_LINE INDENT while r + 1 < N and A [ r ] < A [ r + 1 ] : NEW_LINE INDENT r = r + 1 NEW_LINE DEDENT count += ( r - l + 1 ) * ( r - l + 2 ) // 2 NEW_LINE l = r = r + 1 NEW_LINE DEDENT return count 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 = simple_incremental ( N , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE Ans = N NEW_LINE suu = input ( ) NEW_LINE ListNum = list ( map ( int , suu . split ( ) ) ) NEW_LINE c = 0 NEW_LINE for i in range ( 0 , len ( ListNum ) , 1 ) : NEW_LINE INDENT try : NEW_LINE INDENT if ListNum [ i ] < ListNum [ i + 1 ] : NEW_LINE INDENT c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT b = c * ( C + 1 ) / 2 NEW_LINE Ans += b NEW_LINE c = 0 NEW_LINE continue NEW_LINE DEDENT DEDENT except : NEW_LINE INDENT b = c * ( c + 1 ) / 2 NEW_LINE Ans += b NEW_LINE c = 0 NEW_LINE if i == len ( ListNum ) - 1 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( int ( Ans ) ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE left = 0 NEW_LINE right = 0 NEW_LINE ans = 0 NEW_LINE tmp = 0 NEW_LINE while right < N : NEW_LINE INDENT right += 1 NEW_LINE if a [ right - 1 ] > tmp : NEW_LINE INDENT tmp = a [ right - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT right -= 1 NEW_LINE ans += ( right - left ) * ( right - left + 1 ) // 2 NEW_LINE left = right NEW_LINE tmp = 0 NEW_LINE DEDENT DEDENT ans += ( right - left ) * ( right - left + 1 ) // 2 NEW_LINE print ( ans ) NEW_LINE" ]
atcoder_arc077_A
[ "import java . util . Deque ; import java . util . Iterator ; import java . util . LinkedList ; import java . util . List ; 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 ( ) ; Deque < String > numDeque = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { numDeque . addFirst ( sc . next ( ) ) ; } else { numDeque . addLast ( sc . next ( ) ) ; } } Iterator < String > i = n % 2 == 0 ? numDeque . descendingIterator ( ) : numDeque . iterator ( ) ; while ( i . hasNext ( ) ) { System . out . print ( \" ▁ \" + i . next ( ) ) ; } } }", "import java . util . Arrays ; import java . util . Collections ; import java . util . LinkedList ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Main { private static String solve ( Scanner scanner ) { int N = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] nums = scanner . nextLine ( ) . split ( \" ▁ \" ) ; LinkedList < String > result = new LinkedList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 1 ) { result . addLast ( nums [ i ] ) ; } else { result . addFirst ( nums [ i ] ) ; } } if ( N % 2 == 0 ) { Collections . reverse ( result ) ; } return result . stream ( ) . collect ( Collectors . joining ( \" ▁ \" ) ) ; } private static final String ex1 = \"4 \\n \" + \"1 ▁ 2 ▁ 3 ▁ 4\" ; private static final String ex2 = \"3 \\n \" + \"1 ▁ 2 ▁ 3\" ; private static final String ex3 = \"1 \\n \" + \"1000000000\" ; private static final String ex4 = \"6 \\n \" + \"0 ▁ 6 ▁ 7 ▁ 6 ▁ 7 ▁ 0\" ; public static void main ( String [ ] args ) { System . out . println ( solve ( new Scanner ( System . in ) ) ) ; } private static int [ ] lineToIntNums ( String line ) { String [ ] strNums = line . split ( \" ▁ \" ) ; int [ ] ret = new int [ strNums . length ] ; for ( int i = 0 ; i < strNums . length ; i ++ ) { ret [ i ] = Integer . parseInt ( strNums [ i ] ) ; } return ret ; } private static long [ ] lineToLongNums ( String line ) { String [ ] strNums = line . split ( \" ▁ \" ) ; long [ ] ret = new long [ strNums . length ] ; for ( int i = 0 ; i < strNums . length ; i ++ ) { ret [ i ] = Long . parseLong ( strNums [ i ] ) ; } return ret ; } }", "import java . util . * ; public class Main { private static int N ; private static ArrayList < Integer > arrayList = new ArrayList < > ( ) ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { arrayList . add ( scan . nextInt ( ) ) ; } } public static void main ( String args [ ] ) { input ( ) ; ArrayList < Integer > b = new ArrayList < > ( ) ; if ( N % 2 == 0 ) { for ( int i = N - 1 ; i >= 0 ; i -= 2 ) b . add ( arrayList . get ( i ) ) ; for ( int i = 0 ; i < N ; i += 2 ) b . add ( arrayList . get ( i ) ) ; } else { for ( int i = N - 1 ; i >= 0 ; i -= 2 ) b . add ( arrayList . get ( i ) ) ; for ( int i = 1 ; i < N ; i += 2 ) b . add ( arrayList . get ( i ) ) ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( b . get ( i ) + \" ▁ \" ) ; } } }", "import java . io . * ; import java . util . Deque ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { InputReader inputReader = new InputReader ( System . in ) ; PrintWriter printWriter = new PrintWriter ( System . out ) ; Deque < Integer > deque = new ArrayDeque < > ( ) ; int n ; n = inputReader . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ( i + 1 ) % 2 == 1 ) { deque . addFirst ( inputReader . nextInt ( ) ) ; } else { deque . addLast ( inputReader . nextInt ( ) ) ; } } if ( n % 2 == 0 ) { for ( Integer i : deque ) { System . out . print ( i . toString ( ) + \" ▁ \" ) ; } } else { for ( int i = 1 ; i <= n ; i ++ ) { System . out . print ( deque . removeLast ( ) . toString ( ) + \" ▁ \" ) ; } } } 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 . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . util . Collection ; import java . io . IOException ; import java . io . BufferedReader ; import java . util . Deque ; import java . util . LinkedList ; 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 ) { int n = in . nextInt ( ) ; boolean end = true ; Deque < Integer > dq = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( end ) { dq . addLast ( in . nextInt ( ) ) ; } else dq . addFirst ( in . nextInt ( ) ) ; end = ! end ; } if ( end ) while ( ! dq . isEmpty ( ) ) out . print ( dq . pollFirst ( ) + \" ▁ \" ) ; else while ( ! dq . isEmpty ( ) ) out . print ( dq . pollLast ( ) + \" ▁ \" ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; 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 ( ) ) ; } } }" ]
[ "from collections import deque NEW_LINE n = int ( input ( ) . strip ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = deque ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT b . append ( a [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT b . appendleft ( a [ i ] ) NEW_LINE DEDENT DEDENT b = list ( b ) NEW_LINE if n % 2 == 1 : NEW_LINE INDENT b = b [ : : - 1 ] NEW_LINE DEDENT print ( ' ▁ ' . join ( map ( str , b ) ) ) NEW_LINE", "INF , MOD = float ( \" inf \" ) , 1e9 + 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 while ( True ) : NEW_LINE INDENT try : NEW_LINE INDENT n = get_int ( ) NEW_LINE a = get_int_list ( ) NEW_LINE print ( * ( a [ : : - 2 ] + a [ 1 : : 2 ] ) if n % 2 else a [ : : - 2 ] + a [ : : 2 ] ) NEW_LINE DEDENT except EOFError : NEW_LINE INDENT exit ( ) NEW_LINE DEDENT DEDENT", "import sys NEW_LINE import collections NEW_LINE import math NEW_LINE n = int ( input ( ) ) NEW_LINE A = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE R = [ 0 ] * n NEW_LINE idx = 0 NEW_LINE for i in range ( n - 1 , - 1 , - 2 ) : NEW_LINE INDENT R [ idx ] = A [ i ] NEW_LINE idx += 1 NEW_LINE DEDENT for i in range ( n % 2 , n , + 2 ) : NEW_LINE INDENT R [ idx ] = A [ i ] NEW_LINE idx += 1 NEW_LINE DEDENT print ( \" ▁ \" . join ( [ str ( i ) for i in R ] ) ) NEW_LINE sys . exit ( 0 ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE n = int ( input ( ) ) NEW_LINE a = inpl ( ) NEW_LINE ans = [ 0 for _ in range ( n ) ] NEW_LINE if n % 2 : NEW_LINE INDENT for i , ai in enumerate ( a ) : NEW_LINE INDENT if i % 2 : NEW_LINE INDENT ans [ n // 2 + ( i + 1 ) // 2 ] = ai NEW_LINE DEDENT else : NEW_LINE INDENT ans [ n // 2 - ( i + 1 ) // 2 ] = ai NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i , ai in enumerate ( a ) : NEW_LINE INDENT if i % 2 : NEW_LINE INDENT ans [ n // 2 - ( i + 1 ) // 2 ] = ai NEW_LINE DEDENT else : NEW_LINE INDENT ans [ n // 2 + ( i + 1 ) // 2 ] = ai NEW_LINE DEDENT DEDENT DEDENT print ( * ans ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE A = input ( ) . split ( ' ▁ ' ) NEW_LINE if n == 1 : NEW_LINE INDENT ans = A [ 0 ] NEW_LINE print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT A_odd = A [ : : 2 ] NEW_LINE A_even = A [ 1 : : 2 ] NEW_LINE if n % 2 == 0 : NEW_LINE INDENT ans = A_even [ : : - 1 ] + A_odd NEW_LINE DEDENT else : NEW_LINE INDENT ans = A_odd [ : : - 1 ] + A_even NEW_LINE DEDENT print ( ' ▁ ' . join ( ans ) ) NEW_LINE DEDENT" ]
atcoder_arc001_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int A = scn . nextInt ( ) ; int B = scn . nextInt ( ) ; int ans = 0 ; int DT = Math . abs ( A - B ) ; ans += DT / 10 ; DT %= 10 ; if ( DT < 4 ) { ans += DT ; } else if ( DT > 7 ) { ans ++ ; ans += 10 - DT ; } else { ans ++ ; ans += Math . abs ( DT - 5 ) ; } System . out . println ( ans ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bias = 100 ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A == B ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } HashSet < Integer > fixed = new HashSet < > ( ) ; int [ ] dic = new int [ ] { 1 , 5 , 10 , - 1 , - 5 , - 10 } ; B = Math . abs ( B - A ) + bias ; int [ ] dist = new int [ 2 * bias + 1 ] ; Arrays . fill ( dist , Integer . MAX_VALUE ) ; dist [ bias ] = 0 ; myComparator mc = new myComparator ( ) ; PriorityQueue < int [ ] > pq = new PriorityQueue < > ( 10 , mc ) ; pq . add ( new int [ ] { bias , 0 } ) ; while ( ! fixed . contains ( B ) ) { int [ ] cur = pq . poll ( ) ; int now = cur [ 0 ] ; if ( fixed . contains ( now ) ) continue ; fixed . add ( now ) ; dist [ now ] = cur [ 1 ] ; for ( int w : dic ) { if ( ! fixed . contains ( now + w ) ) { if ( now + w > 2 * bias || now + w < 0 ) continue ; if ( dist [ now + w ] > dist [ now ] + 1 ) { dist [ now + w ] = dist [ now ] + 1 ; pq . add ( new int [ ] { now + w , dist [ now ] + 1 } ) ; } } } } int ans = dist [ B ] ; System . out . println ( ans ) ; } static class myComparator implements Comparator < int [ ] > { public int compare ( int [ ] a , int [ ] b ) { return a [ 1 ] - b [ 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 count = 0 ; int dif = A - B ; while ( dif != 0 ) { if ( dif >= 8 ) { dif -= 10 ; } else if ( dif >= 4 ) { dif -= 5 ; } else if ( dif >= 1 ) { dif -- ; } else if ( dif <= - 8 ) { dif += 10 ; } else if ( dif <= - 4 ) { dif += 5 ; } else { dif ++ ; } count ++ ; } out . println ( 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 int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int start = sc . nextInt ( ) ; int goal = sc . nextInt ( ) ; int count = 0 ; while ( start != goal ) { if ( start < goal ) { count ++ ; int testA = start + 10 ; int testB = start + 5 ; int testC = start + 1 ; List < Integer > list = Arrays . asList ( testA , testB , testC ) ; start = list . stream ( ) . min ( Comparator . comparing ( ( Integer x ) -> Math . abs ( x - goal ) ) ) . get ( ) ; } else if ( start > goal ) { count ++ ; int testA = start - 10 ; int testB = start - 5 ; int testC = start - 1 ; List < Integer > list = Arrays . asList ( testA , testB , testC ) ; start = list . stream ( ) . min ( Comparator . comparing ( ( Integer x ) -> Math . abs ( x - goal ) ) ) . get ( ) ; } } 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 ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int d = Math . abs ( in . nextInt ( ) - in . nextInt ( ) ) ; int c = 0 ; while ( d > 0 ) { if ( d >= 8 ) { c ++ ; d -= 10 ; d = Math . abs ( d ) ; } else if ( d >= 4 ) { c ++ ; d -= 5 ; d = Math . abs ( d ) ; } else { c += d ; d = 0 ; } } out . println ( c ) ; } } }" ]
[ "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE d = abs ( A - B ) NEW_LINE l = [ 0 , 1 , 2 , 3 , 2 , 1 , 2 , 3 , 3 , 2 ] NEW_LINE c = d // 10 + l [ d % 10 ] NEW_LINE print ( c ) NEW_LINE", "from itertools import product NEW_LINE def check ( Qss ) : NEW_LINE INDENT if max ( map ( sum , Qss ) ) > 1 : NEW_LINE INDENT return False NEW_LINE DEDENT if max ( map ( sum , zip ( * Qss ) ) ) > 1 : NEW_LINE INDENT return False NEW_LINE DEDENT if max ( map ( sum , zip ( * [ [ 0 ] * i + Qs + [ 0 ] * ( 7 - i ) for i , Qs in enumerate ( Qss ) ] ) ) ) > 1 : NEW_LINE INDENT return False NEW_LINE DEDENT if max ( map ( sum , zip ( * [ [ 0 ] * ( 7 - i ) + Qs + [ 0 ] * i for i , Qs in enumerate ( Qss ) ] ) ) ) > 1 : NEW_LINE INDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT css = [ input ( ) for _ in range ( 8 ) ] NEW_LINE Qss = [ [ 1 if c == ' Q ' else 0 for c in cs ] for cs in css ] NEW_LINE rows = [ r for r in range ( 8 ) if sum ( Qss [ r ] ) == 0 ] NEW_LINE for columns in product ( range ( 8 ) , repeat = 5 ) : NEW_LINE INDENT for r , c in zip ( rows , columns ) : NEW_LINE INDENT Qss [ r ] [ c ] = 1 NEW_LINE DEDENT if check ( Qss ) : NEW_LINE INDENT print ( ' \\n ' . join ( [ ' ' . join ( [ ' Q ' if Q else ' . ' for Q in Qs ] ) for Qs in Qss ] ) ) NEW_LINE break NEW_LINE DEDENT for r , c in zip ( rows , columns ) : NEW_LINE INDENT Qss [ r ] [ c ] = 0 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' No ▁ Answer ' ) NEW_LINE DEDENT", "from collections import defaultdict NEW_LINE from heapq import heappush , heappop NEW_LINE import sys NEW_LINE import math NEW_LINE import bisect NEW_LINE import itertools NEW_LINE def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def S ( ) : return list ( sys . stdin . readline ( ) ) NEW_LINE def IR ( n ) : return [ I ( ) for i in range ( n ) ] NEW_LINE def LIR ( n ) : return [ LI ( ) for i in range ( n ) ] NEW_LINE def SR ( n ) : return [ S ( ) for i in range ( n ) ] NEW_LINE def LSR ( n ) : return [ LS ( ) for i in range ( n ) ] NEW_LINE mod = 1000000007 NEW_LINE def A ( ) : NEW_LINE INDENT n = I ( ) NEW_LINE c = S ( ) NEW_LINE minans = float ( \" INF \" ) NEW_LINE maxans = 0 NEW_LINE for i in range ( 1 , 5 ) : NEW_LINE INDENT minans = min ( minans , c . count ( str ( i ) ) ) NEW_LINE maxans = max ( maxans , c . count ( str ( i ) ) ) NEW_LINE DEDENT print ( maxans , minans ) NEW_LINE DEDENT def B ( ) : NEW_LINE INDENT a , b = LI ( ) NEW_LINE ans = 0 NEW_LINE while a != b : NEW_LINE INDENT if a > b : NEW_LINE INDENT a = a ^ b NEW_LINE b = a ^ b NEW_LINE a = a ^ b NEW_LINE DEDENT ab = b - a NEW_LINE if ab >= 8 : NEW_LINE INDENT a += 10 NEW_LINE DEDENT elif ab >= 3 : NEW_LINE INDENT a += 5 NEW_LINE DEDENT else : NEW_LINE INDENT a += 1 NEW_LINE DEDENT ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT B ( ) NEW_LINE DEDENT", "N = 8 NEW_LINE row = [ - 1 ] * N NEW_LINE col = [ - 1 ] * N NEW_LINE dpos = [ - 1 ] * ( 2 * N - 1 ) NEW_LINE dneg = [ - 1 ] * ( 2 * N - 1 ) NEW_LINE def solve ( i ) : NEW_LINE INDENT if i == N : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT print ( ' ' . join ( ' . Q ' [ row [ i ] == j ] for j in range ( N ) ) ) NEW_LINE DEDENT exit ( ) NEW_LINE DEDENT if row [ i ] != - 1 : NEW_LINE INDENT solve ( i + 1 ) NEW_LINE return NEW_LINE DEDENT for j in range ( N ) : NEW_LINE INDENT if 1 in ( col [ j ] , dpos [ i + j ] , dneg [ i - j + N - 1 ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT row [ i ] = j ; col [ j ] = dpos [ i + j ] = dneg [ i - j + N - 1 ] = 1 NEW_LINE solve ( i + 1 ) NEW_LINE row [ i ] = col [ j ] = dpos [ i + j ] = dneg [ i - j + N - 1 ] = - 1 NEW_LINE DEDENT DEDENT for i in range ( N ) : NEW_LINE INDENT r = input ( ) NEW_LINE if ' Q ' in r : NEW_LINE INDENT j = r . index ( ' Q ' ) NEW_LINE if r . count ( ' Q ' ) > 1 or 1 in ( col [ j ] , dpos [ i + j ] , dneg [ i - j + N - 1 ] ) : NEW_LINE INDENT print ( ' No ▁ Answer ' ) NEW_LINE exit ( ) NEW_LINE DEDENT row [ i ] = j ; col [ j ] = dpos [ i + j ] = dneg [ i - j + N - 1 ] = 1 NEW_LINE DEDENT DEDENT solve ( 0 ) NEW_LINE print ( ' No ▁ Answer ' ) NEW_LINE", "A , B = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE result = 0 NEW_LINE if A > B : NEW_LINE INDENT A , B = B , A NEW_LINE DEDENT while A != B : NEW_LINE INDENT if B >= A + 10 : NEW_LINE INDENT A += 10 NEW_LINE DEDENT elif B == A + 9 : NEW_LINE INDENT A -= 1 NEW_LINE DEDENT elif B == A + 8 : NEW_LINE INDENT A -= 1 NEW_LINE DEDENT elif B == A + 7 : NEW_LINE INDENT A += 5 NEW_LINE DEDENT elif B == A + 6 : NEW_LINE INDENT A += 5 NEW_LINE DEDENT elif B == A + 5 : NEW_LINE INDENT A += 5 NEW_LINE DEDENT elif B == A + 4 : NEW_LINE INDENT A -= 1 NEW_LINE DEDENT elif B == A + 3 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif B == A + 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif B == A + 1 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT result += 1 NEW_LINE DEDENT print ( result ) NEW_LINE" ]
atcoder_abc110_A
[ "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 ( ) , c = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( a * 10 + b + c , a + b * 10 + c ) , a + b + c * 10 ) ) ; } }", "import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static String process ( TestCase testCase ) { final int A = testCase . A ; final int B = testCase . B ; final int C = testCase . C ; PriorityQueue < Integer > pq = new PriorityQueue < > ( ( a , b ) -> Integer . compare ( b , a ) ) ; pq . add ( A ) ; pq . add ( B ) ; pq . add ( C ) ; int max = noInspectionGet ( pq ) ; final int smaller = noInspectionGet ( pq ) ; final int smallest = noInspectionGet ( pq ) ; return String . valueOf ( max * 10 + smaller + smallest ) ; } private static int noInspectionGet ( PriorityQueue < Integer > pq ) { return pq . poll ( ) ; } 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 ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; return new TestCase ( A , B , C ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final int A ; final int B ; final int C ; public TestCase ( int A , int B , int C ) { this . A = A ; this . B = B ; this . C = C ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . List ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] abc = br . readLine ( ) . split ( \" ▁ \" ) ; int a = Integer . parseInt ( abc [ 0 ] ) ; int b = Integer . parseInt ( abc [ 1 ] ) ; int c = Integer . parseInt ( abc [ 2 ] ) ; List < Integer > ans = new ArrayList < Integer > ( Arrays . asList ( a , b , c ) ) ; Collections . sort ( ans ) ; int i = ans . get ( 2 ) * 10 + ans . get ( 1 ) ; System . out . println ( i + ans . get ( 0 ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int num [ ] = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) num [ i ] = sc . nextInt ( ) ; Arrays . sort ( num ) ; int ans = num [ 2 ] * 10 + num [ 1 ] + num [ 0 ] ; System . out . println ( ans ) ; } }", "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int answer , temp ; System . out . println ( Math . max ( Math . max ( ( answer = ( temp = 0 ) + scanner . nextInt ( ) ) - temp , ( answer = ( temp = answer ) + scanner . nextInt ( ) ) - temp ) , ( answer = ( temp = answer ) + scanner . nextInt ( ) ) - temp ) * 9 + answer ) ; } }" ]
[ "a , b , c = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( c * 10 + a + b ) NEW_LINE", "a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE num = [ ] NEW_LINE num . append ( a ) NEW_LINE num . append ( b ) NEW_LINE num . append ( c ) NEW_LINE ookii = num . copy ( ) NEW_LINE ooi = max ( ookii ) NEW_LINE num . remove ( max ( num ) ) NEW_LINE print ( ooi * 10 + num [ 0 ] + num [ 1 ] ) NEW_LINE", "l = [ i for i in input ( ) . split ( ) ] NEW_LINE l . sort ( ) NEW_LINE a = int ( l [ - 1 ] + l [ 1 ] ) NEW_LINE print ( a + int ( l [ 0 ] ) ) NEW_LINE", "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if B < C : NEW_LINE INDENT tmp = B NEW_LINE B = C NEW_LINE C = tmp NEW_LINE DEDENT if A < B : NEW_LINE INDENT tmp = A NEW_LINE A = B NEW_LINE B = tmp NEW_LINE DEDENT print ( ( A * 10 ) + B + C ) NEW_LINE", "abc = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sorted_list = sorted ( abc , reverse = True ) NEW_LINE print ( sorted_list [ 0 ] * 10 + sorted_list [ 1 ] + sorted_list [ 2 ] ) NEW_LINE" ]
atcoder_abc099_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 C = sc . nextInt ( ) ; int [ ] [ ] D = new int [ C ] [ C ] ; int [ ] [ ] c = new int [ N ] [ N ] ; for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { D [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { c [ i ] [ j ] = sc . nextInt ( ) - 1 ; } } sc . close ( ) ; int [ ] [ ] g = new int [ C ] [ 3 ] ; for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( c [ j ] [ k ] != i ) { g [ i ] [ ( j + k ) % 3 ] += D [ c [ j ] [ k ] ] [ i ] ; } } } } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { for ( int k = 0 ; k < C ; k ++ ) { if ( i == j || i == k || j == k ) continue ; min = Math . min ( min , g [ i ] [ 0 ] + g [ j ] [ 1 ] + g [ k ] [ 2 ] ) ; } } } System . out . println ( min ) ; } }", "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 C = sc . nextInt ( ) ; int [ ] [ ] D = new int [ C + 1 ] [ C + 1 ] ; int [ ] [ ] c = new int [ N + 1 ] [ N + 1 ] ; int [ ] [ ] table = new int [ 3 ] [ C + 1 ] ; for ( int i = 1 ; i <= C ; i ++ ) { for ( int j = 1 ; j <= C ; j ++ ) { D [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { int col = sc . nextInt ( ) ; table [ ( i + j ) % 3 ] [ col ] ++ ; } } int [ ] [ ] costable = new int [ 3 ] [ C + 1 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = 1 ; j <= C ; j ++ ) for ( int k = 1 ; k <= C ; k ++ ) { costable [ i ] [ k ] += D [ j ] [ k ] * table [ i ] [ j ] ; } } int min = 260000000 ; for ( int i = 1 ; i <= C ; i ++ ) { for ( int j = 1 ; j <= C ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { if ( i != j && j != k && k != i ) { min = Math . min ( min , costable [ 0 ] [ i ] + costable [ 1 ] [ j ] + costable [ 2 ] [ k ] ) ; } } } } System . out . println ( min ) ; } }", "import java . io . File ; import java . io . IOException ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Comparator ; import java . util . Deque ; import java . util . HashMap ; import java . util . List ; import java . util . Scanner ; import java . util . Map . Entry ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int C = in . nextInt ( ) ; int [ ] [ ] D = new int [ C ] [ C ] ; long [ ] [ ] d = new long [ 3 ] [ C ] ; for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) D [ i ] [ j ] = in . nextInt ( ) ; } int [ ] [ ] c = new int [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { c [ i ] [ j ] = in . nextInt ( ) ; for ( int k = 1 ; k <= C ; k ++ ) { d [ ( ( i + j ) % 3 ) ] [ k - 1 ] += D [ c [ i ] [ j ] - 1 ] [ k - 1 ] ; } } } long min = Long . MAX_VALUE ; for ( int i = 1 ; i <= C ; i ++ ) { for ( int j = 1 ; j <= C ; j ++ ) { if ( i == j ) continue ; for ( int k = 1 ; k <= C ; k ++ ) { if ( i == k || j == k ) continue ; long cost = 0 ; cost += d [ 0 ] [ i - 1 ] ; cost += d [ 1 ] [ j - 1 ] ; cost += d [ 2 ] [ k - 1 ] ; min = Math . min ( min , cost ) ; } } } System . out . println ( min ) ; } }", "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 C = sc . nextInt ( ) ; int [ ] [ ] D = new int [ C + 1 ] [ C + 1 ] ; for ( int i = 1 ; i <= C ; i ++ ) { for ( int j = 1 ; j <= C ; j ++ ) { D [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] c = new int [ N + 1 ] [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] colorNums = new int [ C + 1 ] [ 3 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { colorNums [ c [ i ] [ j ] ] [ ( i + j ) % 3 ] ++ ; } } int minDSum = Integer . MAX_VALUE ; for ( int c1 = 1 ; c1 <= C ; c1 ++ ) { for ( int c2 = 1 ; c2 <= C ; c2 ++ ) { if ( c1 == c2 ) { continue ; } for ( int c3 = 1 ; c3 <= C ; c3 ++ ) { if ( c1 == c3 || c2 == c3 ) { continue ; } int tmp = 0 ; for ( int cOrg = 1 ; cOrg <= C ; cOrg ++ ) { tmp += colorNums [ cOrg ] [ 0 ] * D [ cOrg ] [ c1 ] ; tmp += colorNums [ cOrg ] [ 1 ] * D [ cOrg ] [ c2 ] ; tmp += colorNums [ cOrg ] [ 2 ] * D [ cOrg ] [ c3 ] ; } minDSum = Math . min ( minDSum , tmp ) ; } } } out . println ( minDSum ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; final int C = sc . nextInt ( ) ; int [ ] [ ] A = new int [ 3 ] [ C + 1 ] ; int [ ] [ ] D = new int [ C + 1 ] [ C + 1 ] ; int [ ] [ ] B = new int [ 3 ] [ C + 1 ] ; int ans = Integer . MAX_VALUE ; for ( int i = 1 ; i <= C ; i ++ ) for ( int j = 1 ; j <= C ; j ++ ) D [ i ] [ j ] = sc . nextInt ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { int r = ( i + j ) % 3 ; int cij = sc . nextInt ( ) ; A [ r ] [ cij ] ++ ; } } for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = 1 ; j <= C ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { B [ i ] [ j ] += D [ k ] [ j ] * A [ i ] [ k ] ; } } } for ( int i = 1 ; i <= C ; i ++ ) { for ( int j = 1 ; j <= C ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { if ( i != j && i != k && j != k ) { ans = Math . min ( ans , B [ 0 ] [ i ] + B [ 1 ] [ j ] + B [ 2 ] [ k ] ) ; } } } } System . out . println ( ans ) ; } }" ]
[ "N , C = map ( int , input ( ) . split ( ) ) NEW_LINE d = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( C ) ] NEW_LINE c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE c_set = [ [ 0 ] * C for _ in range ( 3 ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT c_set [ ( i + j ) % 3 ] [ c [ i ] [ j ] - 1 ] += 1 NEW_LINE DEDENT DEDENT ans = 1e9 NEW_LINE for c_1 in range ( C ) : NEW_LINE INDENT for c_2 in range ( C ) : NEW_LINE INDENT for c_3 in range ( C ) : NEW_LINE INDENT if c_1 == c_2 or c_1 == c_3 or c_2 == c_3 : NEW_LINE INDENT continue NEW_LINE DEDENT c_list = [ c_1 , c_2 , c_3 ] NEW_LINE k = 0 NEW_LINE for i in range ( C ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT k += d [ i ] [ c_list [ j ] - 1 ] * c_set [ j ] [ i ] NEW_LINE DEDENT DEDENT ans = min ( ans , k ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "n , c = map ( int , input ( ) . split ( ) ) NEW_LINE dmap = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( c ) ] NEW_LINE cmap = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE d1 = { } NEW_LINE d2 = { } NEW_LINE d3 = { } NEW_LINE for i , clist in enumerate ( cmap ) : NEW_LINE INDENT for j , _c in enumerate ( clist ) : NEW_LINE INDENT if ( i + j + 2 ) % 3 == 2 : NEW_LINE INDENT if _c - 1 in d1 : NEW_LINE INDENT d1 [ _c - 1 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT d1 [ _c - 1 ] = 1 NEW_LINE DEDENT DEDENT elif ( i + j + 2 ) % 3 == 0 : NEW_LINE INDENT if _c - 1 in d2 : NEW_LINE INDENT d2 [ _c - 1 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT d2 [ _c - 1 ] = 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if _c - 1 in d3 : NEW_LINE INDENT d3 [ _c - 1 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT d3 [ _c - 1 ] = 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT minc = None NEW_LINE for c1 in range ( c ) : NEW_LINE INDENT for c2 in range ( c ) : NEW_LINE INDENT for c3 in range ( c ) : NEW_LINE INDENT tmp = 0 NEW_LINE if c1 == c2 or c2 == c3 or c3 == c1 : NEW_LINE INDENT continue NEW_LINE DEDENT for _c , cn in d1 . items ( ) : NEW_LINE INDENT tmp += dmap [ _c ] [ c1 ] * cn NEW_LINE DEDENT for _c , cn in d2 . items ( ) : NEW_LINE INDENT tmp += dmap [ _c ] [ c2 ] * cn NEW_LINE DEDENT for _c , cn in d3 . items ( ) : NEW_LINE INDENT tmp += dmap [ _c ] [ c3 ] * cn NEW_LINE DEDENT if minc is None : NEW_LINE INDENT minc = tmp NEW_LINE DEDENT elif minc > tmp : NEW_LINE INDENT minc = tmp NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( minc ) NEW_LINE", "from collections import Counter NEW_LINE from itertools import permutations NEW_LINE N , C = map ( int , input ( ) . split ( ) ) NEW_LINE cost = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( C ) ] NEW_LINE color = [ list ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE mod3 = { 0 : [ ] , 1 : [ ] , 2 : [ ] } NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT m = ( i + j ) % 3 NEW_LINE mod3 [ m ] . append ( color [ i ] [ j ] ) NEW_LINE DEDENT DEDENT cnts = [ Counter ( mod3 [ i ] ) for i in range ( 3 ) ] NEW_LINE cost_mod = [ [ - 1 ] * C for _ in range ( 3 ) ] NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT for to_ in range ( C ) : NEW_LINE INDENT cond = 0 NEW_LINE for from_ in cnts [ i ] . keys ( ) : NEW_LINE INDENT cond += cnts [ i ] [ from_ ] * cost [ from_ ] [ to_ ] NEW_LINE DEDENT cost_mod [ i ] [ to_ ] = cond NEW_LINE DEDENT DEDENT ans = float ( ' inf ' ) NEW_LINE for p in permutations ( range ( C ) , 3 ) : NEW_LINE INDENT cond = 0 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT cond += cost_mod [ i ] [ p [ i ] ] NEW_LINE DEDENT ans = min ( ans , cond ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "n , c = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE ds = [ [ int ( item ) for item in input ( ) . split ( ) ] for _ in range ( c ) ] NEW_LINE cs = [ [ int ( item ) for item in input ( ) . split ( ) ] for _ in range ( n ) ] NEW_LINE counter = [ [ 0 ] * ( c + 1 ) for _ in range ( 3 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT counter [ ( i + j ) % 3 ] [ cs [ i ] [ j ] ] += 1 NEW_LINE DEDENT DEDENT costs = [ [ 0 ] * ( c + 1 ) for _ in range ( 3 ) ] NEW_LINE for i in range ( 1 , c + 1 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT for k , count in enumerate ( counter [ j ] ) : NEW_LINE INDENT if k == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT costs [ j ] [ i ] += ds [ k - 1 ] [ i - 1 ] * count NEW_LINE DEDENT DEDENT DEDENT ans = 500 * 500 * 1000 NEW_LINE for i in range ( c ) : NEW_LINE INDENT for j in range ( c ) : NEW_LINE INDENT for k in range ( c ) : NEW_LINE INDENT if i == j or j == k or k == i : NEW_LINE INDENT continue NEW_LINE DEDENT sol = costs [ 0 ] [ i + 1 ] + costs [ 1 ] [ j + 1 ] + costs [ 2 ] [ k + 1 ] NEW_LINE ans = min ( ans , sol ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "from collections import defaultdict NEW_LINE n , c = map ( int , input ( ) . split ( ) ) NEW_LINE x = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( c ) ] NEW_LINE e = [ [ 0 ] * c for i in range ( 3 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for j in range ( n ) : NEW_LINE INDENT e [ ( i + j + 2 ) % 3 ] [ a [ j ] - 1 ] += 1 NEW_LINE DEDENT DEDENT p = float ( \" inf \" ) NEW_LINE for i in range ( c ) : NEW_LINE INDENT for j in range ( c ) : NEW_LINE INDENT if i != j : NEW_LINE INDENT for h in range ( c ) : NEW_LINE INDENT if i != h and j != h : NEW_LINE INDENT p = min ( p , sum ( [ x [ s ] [ i ] * d for s , d in enumerate ( e [ 0 ] ) ] + [ x [ s ] [ j ] * d for s , d in enumerate ( e [ 1 ] ) ] + [ x [ s ] [ h ] * d for s , d in enumerate ( e [ 2 ] ) ] ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( p ) NEW_LINE" ]
atcoder_abc010_B
[ "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 ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; while ( a % 2 != 1 || a % 3 == 2 ) { a -- ; ans ++ ; } } 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 . 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 n = in . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = in . nextInt ( ) ; while ( tmp % 2 == 0 || tmp % 3 == 2 ) { tmp -- ; count ++ ; } } out . println ( 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 int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "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 h = scanner . nextLine ( ) ; scanner . close ( ) ; String [ ] flowers = new String [ n ] ; flowers = h . split ( \" ▁ \" ) ; int toPluck = 0 ; for ( String flower : flowers ) { int num = Integer . parseInt ( flower ) ; int minus = 0 ; while ( shouldPluck ( num - minus ) ) { toPluck ++ ; minus ++ ; } } System . out . println ( toPluck ) ; } private static boolean shouldPluck ( int num ) { boolean shouldPluck = false ; if ( num % 3 == 2 || num % 2 == 0 ) { shouldPluck = true ; } return shouldPluck ; } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int hana [ ] = new int [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { hana [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { int m = hana [ i ] ; if ( m % 6 == 0 ) count += 3 ; if ( m % 6 == 2 ) count += 1 ; if ( m % 6 == 4 ) count += 1 ; if ( m % 6 == 5 ) count += 2 ; } System . out . println ( count ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int n , ans = 0 ; n = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; if ( a [ i ] == 2 || a [ i ] == 4 || a [ i ] == 8 ) { ans ++ ; } else if ( a [ i ] == 5 ) { ans = ans + 2 ; } else if ( a [ i ] == 6 ) { ans = ans + 3 ; } } System . out . println ( ans ) ; } catch ( Exception e ) { System . out . println ( \" out \" ) ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE c = 0 NEW_LINE for a in A : NEW_LINE INDENT while True : NEW_LINE INDENT if a % 2 != 0 and a % 3 != 2 : NEW_LINE INDENT break NEW_LINE DEDENT a -= 1 NEW_LINE c += 1 NEW_LINE DEDENT DEDENT print ( c ) NEW_LINE", "_ , a = open ( 0 ) ; print ( sum ( int ( '301012' [ int ( i ) % 6 ] ) for i in a . split ( ) ) ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE flowers = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE petals = 0 NEW_LINE for i in flowers : NEW_LINE INDENT if i == 6 : NEW_LINE INDENT petals += 3 NEW_LINE DEDENT elif i == 5 : NEW_LINE INDENT petals += 2 NEW_LINE DEDENT elif i == 8 or i == 4 or i == 2 : NEW_LINE INDENT petals += 1 NEW_LINE DEDENT DEDENT print ( petals ) NEW_LINE", "from statistics import mean , median , variance , stdev NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE def j ( a ) : NEW_LINE INDENT if a == 1 : print ( \" YES \" ) NEW_LINE else : print ( \" NO \" ) 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 n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT while not ( ( a [ i ] % 3 == 0 or a [ i ] % 3 == 1 ) and a [ i ] % 2 ) : NEW_LINE INDENT a [ i ] -= 1 NEW_LINE s += 1 NEW_LINE DEDENT DEDENT print ( s ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE c = [ 0 , 1 , 0 , 1 , 2 , 3 , 0 , 1 , 0 ] NEW_LINE ans = 0 NEW_LINE for b in map ( int , input ( ) . split ( ) ) : NEW_LINE INDENT ans += c [ b - 1 ] NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc077_B
[ "import java . io . PrintWriter ; import java . util . * ; public class Main { static final long MOD = 1000000007 ; static class Comb { int a ; int b ; long pre ; public Comb ( int a ) { this . a = a ; } public long get ( int b ) { if ( b == 0 ) pre = 1 ; else if ( b == 1 ) pre = a ; this . b = b + 1 ; return pre ; } public long getNext ( ) { long ans = ( pre * ( a - b + 1 ) ) % MOD ; ans = ( ans * rev ( b ) ) % MOD ; b ++ ; pre = ans ; return ans ; } long rev ( long a ) { return pow ( a , MOD - 2 ) ; } long pow ( long a , long b ) { long ans = 1 ; while ( b > 0 ) { if ( ( b & 1 ) != 0 ) { ans = ( ans * a ) % MOD ; } a = ( a * a ) % MOD ; b >>= 1 ; } return ans ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; int [ ] ra = new int [ N ] ; int L = 0 ; Arrays . fill ( ra , - 1 ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; if ( ra [ a ] < 0 ) ra [ a ] = i ; else L = ra [ a ] + ( N + 1 - i - 1 ) ; } Comb comb1 = new Comb ( N + 1 ) ; Comb comb2 = new Comb ( L ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) { if ( i == 0 ) pw . println ( ( comb1 . get ( i + 1 ) - comb2 . get ( i ) + MOD ) % MOD ) ; else pw . println ( ( comb1 . getNext ( ) - comb2 . getNext ( ) + MOD ) % MOD ) ; } sc . close ( ) ; pw . close ( ) ; } }" ]
[ "MOD = 10 ** 9 + 7 NEW_LINE def egcd ( a , b ) : NEW_LINE INDENT if a == 0 : NEW_LINE INDENT return ( b , 0 , 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT g , y , x = egcd ( b % a , a ) NEW_LINE return ( g , x - ( b // a ) * y , y ) NEW_LINE DEDENT DEDENT def modinv ( a , m ) : NEW_LINE INDENT g , x , y = egcd ( a , m ) NEW_LINE if g != 1 : NEW_LINE INDENT raise Exception ( ' modular ▁ inverse ▁ does ▁ not ▁ exist ' ) NEW_LINE DEDENT else : NEW_LINE INDENT return x % m NEW_LINE DEDENT DEDENT n = int ( input ( ) ) NEW_LINE L = n + 1 NEW_LINE inv = [ None ] * ( n + 2 ) NEW_LINE for i , a in enumerate ( map ( int , input ( ) . split ( ) ) ) : NEW_LINE INDENT if inv [ a - 1 ] is None : NEW_LINE INDENT inv [ a - 1 ] = i NEW_LINE DEDENT else : NEW_LINE INDENT m = n - i + inv [ a - 1 ] NEW_LINE break NEW_LINE DEDENT DEDENT b = 1 NEW_LINE for i in range ( 2 , m + 1 ) : NEW_LINE INDENT b *= i NEW_LINE b %= MOD NEW_LINE DEDENT a = b NEW_LINE for i in range ( m + 1 , L + 1 ) : NEW_LINE INDENT a *= i NEW_LINE a %= MOD NEW_LINE DEDENT ik = modinv ( a , MOD ) NEW_LINE for i in reversed ( range ( L + 1 ) ) : NEW_LINE INDENT inv [ i ] = ik NEW_LINE ik *= i NEW_LINE ik %= MOD NEW_LINE DEDENT r1 = [ ( a * inv [ k ] * inv [ L - k ] ) % MOD for k in range ( L // 2 + 1 ) ] NEW_LINE r2 = [ ( b * inv [ k ] * inv [ m - k ] ) % MOD for k in range ( m // 2 + 1 ) ] NEW_LINE for k in range ( 1 , m + 2 ) : NEW_LINE INDENT print ( ( r1 [ min ( k , L - k ) ] - r2 [ min ( k - 1 , m - k + 1 ) ] ) % MOD ) NEW_LINE DEDENT for k in range ( m + 2 , n + 2 ) : NEW_LINE INDENT print ( r1 [ min ( k , L - k ) ] % MOD ) NEW_LINE DEDENT", "ai = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ai_ = lambda : [ int ( x ) - 1 for x in input ( ) . split ( ) ] NEW_LINE n = int ( input ( ) ) NEW_LINE a = ai ( ) NEW_LINE dup = sum ( a ) - n * ( n + 1 ) // 2 NEW_LINE ant = a . index ( dup ) NEW_LINE post = a [ : : - 1 ] . index ( dup ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE factorial = [ 1 ] NEW_LINE for i in range ( 1 , n + 2 ) : NEW_LINE INDENT factorial . append ( factorial [ i - 1 ] * i % mod ) NEW_LINE DEDENT inverse = [ 0 ] * ( n + 2 ) NEW_LINE inverse [ n + 2 - 1 ] = pow ( factorial [ n + 2 - 1 ] , mod - 2 , mod ) NEW_LINE for i in range ( n + 2 - 2 , - 1 , - 1 ) : NEW_LINE INDENT inverse [ i ] = inverse [ i + 1 ] * ( i + 1 ) % mod NEW_LINE DEDENT def nCr ( n , r ) : NEW_LINE INDENT if n < r or n == 0 or r == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT return factorial [ n ] * inverse [ r ] * inverse [ n - r ] % mod NEW_LINE DEDENT for k in range ( 1 , n + 2 ) : NEW_LINE INDENT if k == 1 : NEW_LINE INDENT print ( n ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = nCr ( n + 1 , k ) - nCr ( ant + post , k - 1 ) NEW_LINE if ans < 0 : NEW_LINE INDENT ans += mod NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT DEDENT", "MOD = 10 ** 9 + 7 NEW_LINE n = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE fact = { i : None for i in range ( n + 2 ) } NEW_LINE inverse = { i : None for i in range ( 1 , n + 2 ) } NEW_LINE fact_inverse = { i : None for i in range ( n + 2 ) } NEW_LINE fact [ 0 ] = fact [ 1 ] = 1 NEW_LINE fact_inverse [ 0 ] = fact_inverse [ 1 ] = 1 NEW_LINE inverse [ 1 ] = 1 NEW_LINE for i in range ( 2 , n + 2 ) : NEW_LINE INDENT fact [ i ] = i * fact [ i - 1 ] % MOD NEW_LINE inverse [ i ] = - inverse [ MOD % i ] * ( MOD // i ) % MOD NEW_LINE fact_inverse [ i ] = inverse [ i ] * fact_inverse [ i - 1 ] % MOD NEW_LINE DEDENT def combination ( n , r ) : NEW_LINE INDENT if n < r or n < 0 or r < 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return fact [ n ] * ( fact_inverse [ r ] * fact_inverse [ n - r ] % MOD ) % MOD NEW_LINE DEDENT DEDENT dup_num = sum ( A ) - n * ( n + 1 ) // 2 NEW_LINE dup_idx = [ ] NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if a == dup_num : NEW_LINE INDENT dup_idx . append ( i ) NEW_LINE DEDENT DEDENT left , right = dup_idx [ 0 ] , dup_idx [ 1 ] NEW_LINE for k in range ( 1 , n + 2 ) : NEW_LINE INDENT print ( ( combination ( n + 1 , k ) - combination ( n + 1 - ( right - left + 1 ) , k - 1 ) ) % MOD ) NEW_LINE DEDENT", "from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE ctr = Counter ( A ) NEW_LINE doub = ctr . most_common ( ) [ 0 ] [ 0 ] NEW_LINE i1 = A . index ( doub ) NEW_LINE i2 = N - A [ : : - 1 ] . index ( doub ) NEW_LINE l = N - ( i2 - i1 ) NEW_LINE fac = [ 1 , 1 ] + [ 0 ] * N NEW_LINE finv = [ 1 , 1 ] + [ 0 ] * N NEW_LINE inv = [ 0 , 1 ] + [ 0 ] * N NEW_LINE for i in range ( 2 , N + 2 ) : NEW_LINE INDENT fac [ i ] = fac [ i - 1 ] * i % MOD NEW_LINE inv [ i ] = - inv [ MOD % i ] * ( MOD // i ) % MOD NEW_LINE finv [ i ] = finv [ i - 1 ] * inv [ i ] % MOD NEW_LINE DEDENT def ncr ( n , r ) : NEW_LINE INDENT if n < r : return 0 NEW_LINE if n < 0 or r < 0 : return 0 NEW_LINE return fac [ n ] * ( finv [ r ] * finv [ n - r ] % MOD ) % MOD NEW_LINE DEDENT ans = [ ] NEW_LINE for n in range ( 1 , N + 2 ) : NEW_LINE INDENT ans . append ( ncr ( N + 1 , n ) ) NEW_LINE DEDENT for i in range ( l + 1 ) : NEW_LINE INDENT ans [ i ] -= ncr ( l , i ) NEW_LINE ans [ i ] %= MOD NEW_LINE DEDENT print ( * ans , sep = ' \\n ' ) NEW_LINE", "from collections import Counter NEW_LINE mod = 10 ** 9 + 7 NEW_LINE N = 10 ** 5 + 11 NEW_LINE fac , finv , inv = [ 0 ] * N , [ 0 ] * N , [ 0 ] * N NEW_LINE def cmb_init ( ) : NEW_LINE INDENT fac [ 0 ] = fac [ 1 ] = finv [ 0 ] = finv [ 1 ] = inv [ 1 ] = 1 NEW_LINE for i in range ( 2 , N ) : NEW_LINE INDENT fac [ i ] = fac [ i - 1 ] * i % mod NEW_LINE inv [ i ] = mod - inv [ mod % i ] * ( mod // i ) % mod NEW_LINE finv [ i ] = finv [ i - 1 ] * inv [ i ] % mod NEW_LINE DEDENT DEDENT def cmb_mod ( n , k ) : NEW_LINE INDENT if n < k : return 0 NEW_LINE return fac [ n ] * ( finv [ k ] * finv [ n - k ] % mod ) % mod NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ac = Counter ( a ) . most_common ( ) [ 0 ] [ 0 ] NEW_LINE sames = [ i for i , x in enumerate ( a ) if x == ac ] NEW_LINE same_len = sames [ 0 ] + ( n - sames [ 1 ] ) NEW_LINE cmb_init ( ) NEW_LINE print ( n ) NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT nums = cmb_mod ( n + 1 , i + 1 ) - cmb_mod ( same_len , i ) NEW_LINE if nums < 0 : nums += mod NEW_LINE print ( nums ) NEW_LINE DEDENT print ( 1 ) NEW_LINE" ]
atcoder_arc085_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) , M = sc . nextInt ( ) ; int x = 1900 * M + 100 * ( N - M ) ; System . out . println ( ( int ) ( x * Math . pow ( 2 , M ) ) ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n , m ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; solve ( ) ; } void solve ( ) { int ans = n * 100 + 1800 * m ; System . out . println ( ans * pow ( 2 , m ) ) ; } long pow ( long x , int n ) { long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ans * x ; } x = x * x ; 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 ; } } }", "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 ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; long ans = 1900 * m + 100 * ( n - m ) ; for ( int i = 0 ; i < m ; i ++ ) { ans *= 2 ; } 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 int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( \" \" ) ; } } }", "import java . util . * ; import java . lang . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; double c = 1900.0 * M + 100.0 * ( N - M ) ; double p = 1.0 ; double res = 0.0 ; double q = 1.0 ; for ( int i = 0 ; i < M ; i ++ ) p *= 0.5 ; for ( int i = 1 ; i < 3000000 ; i ++ ) { res += i * c * p * q ; q *= 1 - p ; } double eps = 0.0000001 ; int ret = ( int ) Math . floor ( res + eps ) ; System . out . println ( ret ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . run ( ) ; } Scanner sc = new Scanner ( System . in ) ; void run ( ) { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long base = n * 100 + m * 1800 ; System . out . println ( base << m ) ; } }" ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE m = 2 ** M NEW_LINE ans = 0 NEW_LINE i = 1 NEW_LINE while True : NEW_LINE INDENT k = ( ( 1 * ( ( 1 / m ) ) ) * ( ( ( ( m - 1 ) / m ) ** ( i - 1 ) ) ) ) * ( 1900 * M * i + ( N - M ) * 100 * i ) NEW_LINE ans += k NEW_LINE i += 1 NEW_LINE if ( i > 10000 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( int ( ans + 0.5 ) ) NEW_LINE", "def solve ( n , m ) : NEW_LINE INDENT return ( 100 * n + 1800 * m ) * ( 2 ** m ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n , m = input ( ) . split ( ) NEW_LINE n = int ( n ) NEW_LINE m = int ( m ) NEW_LINE print ( solve ( n , m ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N , M = inpl ( ) NEW_LINE print ( 2 ** M * ( 1800 * M + 100 * N ) ) NEW_LINE", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE total_time = M * 1900 + ( N - M ) * 100 NEW_LINE e = 0 NEW_LINE err = 10 ** ( - 3 ) NEW_LINE prev = - 1 NEW_LINE i = 0 NEW_LINE while abs ( prev - e ) > err : NEW_LINE INDENT prev = e NEW_LINE e += ( 1 - ( 1 / 2 ) ** M ) ** i * ( 1 / 2 ) ** M * total_time * ( i + 1 ) NEW_LINE i += 1 NEW_LINE DEDENT def floor ( x , y ) : NEW_LINE INDENT return ( ( - x ) // y ) * ( - 1 ) NEW_LINE DEDENT print ( int ( floor ( e , 1 ) ) ) NEW_LINE", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE E = 0 NEW_LINE i = 1 NEW_LINE a = ( 1900 * ( M ) + 100 * ( N - M ) ) * ( 0.5 ) ** ( M ) NEW_LINE while a > 10e-10 : NEW_LINE INDENT a = ( 1900 * ( M * i ) + 100 * ( N - M ) * i ) * ( ( ( 2 ** M - 1 ) * ( 0.5 ) ** M ) ** ( i - 1 ) ) * ( 0.5 ) ** M NEW_LINE E += a NEW_LINE i += 1 NEW_LINE DEDENT print ( int ( E ) + 1 ) NEW_LINE" ]
atcoder_abc002_C
[ "import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { BigDecimal x1 = new BigDecimal ( Integer . parseInt ( sc . next ( ) ) ) ; BigDecimal y1 = new BigDecimal ( Integer . parseInt ( sc . next ( ) ) ) ; BigDecimal x2 = new BigDecimal ( Integer . parseInt ( sc . next ( ) ) ) ; BigDecimal y2 = new BigDecimal ( Integer . parseInt ( sc . next ( ) ) ) ; BigDecimal x3 = new BigDecimal ( Integer . parseInt ( sc . next ( ) ) ) ; BigDecimal y3 = new BigDecimal ( Integer . parseInt ( sc . next ( ) ) ) ; double c = 0 ; BigDecimal bd = new BigDecimal ( c ) ; BigDecimal two = new BigDecimal ( 2.0 ) ; bd = x1 . multiply ( y2 ) . add ( x2 . multiply ( y3 ) ) . add ( x3 . multiply ( y1 ) ) . subtract ( y1 . multiply ( x2 ) ) . subtract ( y2 . multiply ( x3 ) ) . subtract ( y3 . multiply ( x1 ) ) . divide ( two ) ; bd . setScale ( 3 , BigDecimal . ROUND_HALF_UP ) ; System . out . println ( bd . abs ( ) ) ; System . out . flush ( ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Double x1 = sc . nextDouble ( ) ; Double y1 = sc . nextDouble ( ) ; Double x2 = sc . nextDouble ( ) ; Double y2 = sc . nextDouble ( ) ; Double x3 = sc . nextDouble ( ) ; Double y3 = sc . nextDouble ( ) ; x3 -= x1 ; y3 -= y1 ; x2 -= x1 ; y2 -= y1 ; x1 -= x1 ; y1 -= y1 ; System . out . println ( Math . abs ( ( x3 * y2 ) - x2 * y3 ) / 2 ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 2 ; i >= 0 ; i -- ) { x [ i ] -= x [ 0 ] ; y [ i ] -= y [ 0 ] ; } debug ( x , y ) ; System . out . println ( area ( x [ 1 ] , y [ 1 ] , x [ 2 ] , y [ 2 ] ) ) ; } double area ( int x1 , int y1 , int x2 , int y2 ) { return Math . abs ( 1.0 * x1 * y2 - 1.0 * x2 * y1 ) / 2 ; } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . Scanner ; import static java . lang . Math . abs ; 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 ( ) ; int x3 = sc . nextInt ( ) ; int y3 = sc . nextInt ( ) ; x2 -= x1 ; x3 -= x1 ; y2 -= y1 ; y3 -= y1 ; System . out . println ( MyMath . area_of_triangle ( new Point ( x2 , y2 ) , new Point ( x3 , y3 ) ) ) ; } } class MyMath { static double crossProduct ( Point a , Point b ) { return a . x * b . y - a . y * b . x ; } static double area_of_triangle ( Point a , Point b ) { return abs ( crossProduct ( a , b ) ) / 2.0 ; } } class Point { double x ; double y ; Point ( double x , double y ) { this . x = x ; this . y = y ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] xy = new int [ 3 ] [ 2 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { xy [ i ] [ 0 ] = sc . nextInt ( ) ; xy [ i ] [ 1 ] = sc . nextInt ( ) ; } int xMove = - xy [ 0 ] [ 0 ] ; int yMove = - xy [ 0 ] [ 1 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { xy [ i ] [ 0 ] += xMove ; xy [ i ] [ 1 ] += yMove ; } out . println ( Math . abs ( xy [ 1 ] [ 0 ] * xy [ 2 ] [ 1 ] - xy [ 1 ] [ 1 ] * xy [ 2 ] [ 0 ] ) / 2.0 ) ; } }" ]
[ "x1 , y1 , x2 , y2 , x3 , y3 = map ( int , input ( ) . split ( ) ) NEW_LINE a = x2 - x1 NEW_LINE b = y2 - y1 NEW_LINE c = x3 - x1 NEW_LINE d = y3 - y1 NEW_LINE print ( abs ( a * d - b * c ) / 2 ) NEW_LINE", "from operator import itemgetter NEW_LINE from math import sqrt NEW_LINE x1 , y1 , x2 , y2 , x3 , y3 = map ( int , input ( ) . split ( ) ) NEW_LINE xy = [ ( x1 , y1 ) , ( x2 , y2 ) , ( x3 , y3 ) ] NEW_LINE def edge_len ( x1 , y1 , x2 , y2 ) : NEW_LINE INDENT return sqrt ( ( x1 - x2 ) ** 2 + ( y1 - y2 ) ** 2 ) NEW_LINE DEDENT ls = [ edge_len ( x1 , y1 , x2 , y2 ) , edge_len ( x1 , y1 , x3 , y3 ) , edge_len ( x2 , y2 , x3 , y3 ) ] NEW_LINE s = sum ( ls ) / 2 NEW_LINE print ( sqrt ( s * ( s - ls [ 0 ] ) * ( s - ls [ 1 ] ) * ( s - ls [ 2 ] ) ) ) NEW_LINE", "import math NEW_LINE xa , ya , xb , yb , xc , yc = map ( int , input ( ) . split ( ) ) NEW_LINE a = math . sqrt ( ( xa - xb ) ** 2 + ( ya - yb ) ** 2 ) NEW_LINE b = math . sqrt ( ( xb - xc ) ** 2 + ( yb - yc ) ** 2 ) NEW_LINE c = math . sqrt ( ( xc - xa ) ** 2 + ( yc - ya ) ** 2 ) NEW_LINE s = ( a + b + c ) / 2 NEW_LINE S = math . sqrt ( s * ( s - a ) * ( s - b ) * ( s - c ) ) NEW_LINE print ( str ( S ) + \" \\n \" ) NEW_LINE", "from operator import itemgetter NEW_LINE import numpy as np NEW_LINE from math import atan , cos , sin NEW_LINE x1 , y1 , x2 , y2 , x3 , y3 = map ( int , input ( ) . split ( ) ) NEW_LINE xy = [ ( x1 , y1 ) , ( x2 , y2 ) , ( x3 , y3 ) ] NEW_LINE xy . sort ( key = itemgetter ( 1 ) ) NEW_LINE xy . sort ( key = itemgetter ( 0 ) ) NEW_LINE x1 , y1 = xy [ 0 ] NEW_LINE x2 , y2 = xy [ 1 ] NEW_LINE x3 , y3 = xy [ 2 ] NEW_LINE if x2 - x1 == 0 : NEW_LINE INDENT x2 , x3 = x3 , x2 NEW_LINE y2 , y3 = y3 , y2 NEW_LINE DEDENT theta = atan ( ( y2 - y1 ) / ( x2 - x1 ) ) NEW_LINE def rotate ( x , y , theta , a , b ) : NEW_LINE INDENT rot = np . array ( [ [ cos ( theta ) , - sin ( theta ) ] , [ sin ( theta ) , cos ( theta ) ] ] ) NEW_LINE pos = np . dot ( rot , np . array ( [ [ x - a ] , [ y - b ] ] ) ) NEW_LINE return pos [ 0 ] [ 0 ] + a , pos [ 1 ] [ 0 ] + b NEW_LINE DEDENT x2 , y2 = rotate ( x2 , y2 , - theta , x1 , y1 ) NEW_LINE x3 , y3 = rotate ( x3 , y3 , - theta , x1 , y1 ) NEW_LINE width = x2 - x1 NEW_LINE height = y3 - y1 NEW_LINE print ( abs ( 1 / 2 * width * height ) ) NEW_LINE", "a , b , c , d , e , f = map ( int , input ( ) . split ( ) ) NEW_LINE X1 = c - a NEW_LINE Y1 = d - b NEW_LINE X2 = e - a NEW_LINE Y2 = f - b NEW_LINE S = float ( X1 * Y2 - X2 * Y1 ) / 2 NEW_LINE if S > 0 : NEW_LINE INDENT print ( S ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( float ( - S ) ) NEW_LINE DEDENT" ]
atcoder_abc073_C
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int N = scn . nextInt ( ) ; long [ ] A = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = scn . nextLong ( ) ; } Arrays . sort ( A ) ; int ans = 0 ; int count = 0 ; long buf = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( buf == A [ i ] ) { count ++ ; } else { if ( count % 2 == 1 && count != 0 ) { ans ++ ; } count = 1 ; buf = A [ i ] ; } } if ( count % 2 == 1 ) { ans ++ ; } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashSet ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; int n = Integer . parseInt ( s ) ; HashSet < Integer > set = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s = br . readLine ( ) ; int a = Integer . parseInt ( s ) ; if ( set . contains ( a ) ) set . remove ( a ) ; else set . add ( a ) ; } System . out . println ( set . size ( ) ) ; } }", "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 ) { System . out . println ( IntStream . range ( 0 , scanner . nextInt ( ) ) . boxed ( ) . collect ( Collectors . groupingBy ( i -> scanner . nextInt ( ) , Collectors . reducing ( false , i -> true , ( a , b ) -> a ^ b ) ) ) . values ( ) . stream ( ) . filter ( Boolean :: booleanValue ) . count ( ) ) ; } }", "import java . util . HashMap ; import java . util . HashSet ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; Set < Integer > set = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int m = scan . nextInt ( ) ; if ( set . contains ( m ) ) { if ( mp . containsKey ( m ) ) { int value = mp . get ( m ) ; mp . put ( m , value + 1 ) ; } else { mp . put ( m , 1 ) ; } } set . add ( m ) ; } int count = 0 ; for ( Entry < Integer , Integer > entry : mp . entrySet ( ) ) { Integer key = entry . getKey ( ) ; Integer value = entry . getValue ( ) ; if ( value % 2 == 1 ) { count ++ ; } } System . out . println ( set . size ( ) - count ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashSet ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; HashSet < String > in ; in = new HashSet < > ( ) ; int count = Integer . parseInt ( reader . readLine ( ) ) ; for ( int i = 0 ; i < count ; i ++ ) { String number = reader . readLine ( ) ; if ( in . contains ( number ) ) { in . remove ( number ) ; } else { in . add ( number ) ; } } System . out . println ( in . size ( ) ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE S = set ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT S ^= set ( [ input ( ) ] ) NEW_LINE DEDENT print ( len ( S ) ) 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 pf ( s ) : return print ( s , flush = True ) NEW_LINE N = I ( ) NEW_LINE A = [ I ( ) for i in range ( N ) ] NEW_LINE counts = collections . Counter ( A ) NEW_LINE ans = 0 NEW_LINE for i in counts . values ( ) : NEW_LINE INDENT if i % 2 == 1 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE Ai_to_num = { } NEW_LINE for _ in range ( N ) : NEW_LINE INDENT Ai = input ( ) NEW_LINE if Ai in Ai_to_num . keys ( ) : NEW_LINE INDENT Ai_to_num [ Ai ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT Ai_to_num [ Ai ] = 1 NEW_LINE DEDENT DEDENT ct = 0 NEW_LINE for num_i in Ai_to_num . values ( ) : NEW_LINE INDENT if num_i % 2 : NEW_LINE INDENT ct += 1 NEW_LINE DEDENT DEDENT print ( ct ) NEW_LINE DEDENT main ( ) NEW_LINE", "import itertools NEW_LINE import collections NEW_LINE import bisect NEW_LINE def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE c = collections . Counter ( A ) NEW_LINE ans = 0 NEW_LINE for pair in c . items ( ) : NEW_LINE INDENT if pair [ 1 ] % 2 == 1 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "from collections import Counter NEW_LINE n = int ( input ( ) ) NEW_LINE inputs = [ int ( input ( ) ) for _ in range ( n ) ] NEW_LINE counter = Counter ( inputs ) NEW_LINE answer = 0 NEW_LINE for number , count in counter . items ( ) : NEW_LINE INDENT if count % 2 != 0 : NEW_LINE INDENT answer += 1 NEW_LINE DEDENT DEDENT print ( answer ) NEW_LINE" ]
atcoder_abc019_D
[ "import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = scan . nextInt ( ) ; int max = 0 ; int id = 0 ; int max_ ; for ( int i = 2 ; i <= N ; i ++ ) { out . printf ( \" ? ▁ % d ▁ % d \\n \" , 1 , i ) ; out . flush ( ) ; scan = new Scanner ( System . in ) ; max_ = scan . nextInt ( ) ; if ( max_ > max ) { id = i ; max = max_ ; } } for ( int i = 2 ; i <= N ; i ++ ) { if ( i != id ) { out . printf ( \" ? ▁ % d ▁ % d \\n \" , id , i ) ; out . flush ( ) ; scan = new Scanner ( System . in ) ; max_ = scan . nextInt ( ) ; if ( max_ > max ) { max = max_ ; } } } out . printf ( \" ! ▁ % d \\n \" , max ) ; out . flush ( ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; int max = 0 ; int maxIndex = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { System . out . println ( \" ? ▁ 1 ▁ \" + i ) ; int temp = sc . nextInt ( ) ; if ( max < temp ) { max = temp ; maxIndex = i ; } } int distance = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i == maxIndex ) { continue ; } System . out . printf ( \" ? ▁ % d ▁ % d \\n \" , maxIndex , i ) ; int temp = sc . nextInt ( ) ; if ( distance < temp ) { distance = temp ; } } System . out . println ( \" ! ▁ \" + distance ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . 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 ) ; D solver = new D ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int max = 0 ; int dest = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { out . println ( \" ? ▁ 1 ▁ \" + i ) ; out . flush ( ) ; int dist = in . nextInt ( ) ; if ( max < dist ) { max = dist ; dest = i ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( i == dest ) { continue ; } out . println ( \" ? ▁ \" + dest + \" ▁ \" + i ) ; out . flush ( ) ; max = Math . max ( max , in . nextInt ( ) ) ; } out . println ( \" ! ▁ \" + max ) ; } } }", "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 start = 1 ; int end = 1 ; int maxDis = - 1 ; for ( int j = 0 ; j < 2 ; j ++ ) { start = end ; maxDis = - 1 ; for ( int i = 1 ; i <= N ; i ++ ) { System . out . printf ( \" ? ▁ % d ▁ % d \\n \" , start , i ) ; int dist = sc . nextInt ( ) ; if ( dist > maxDis ) { end = i ; maxDis = dist ; } } } out . println ( \" ! ▁ \" + maxDis ) ; } }", "import java . util . Scanner ; public class Main { static Scanner sc ; public static int getDist ( int a , int b ) { System . out . printf ( \" ? ▁ % d ▁ % d \\n \" , a , b ) ; int dist = sc . nextInt ( ) ; return dist ; } public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int max_dist = - 1 ; int max_node = - 1 ; for ( int i = 2 ; i <= N ; i ++ ) { int dist = getDist ( 1 , i ) ; if ( max_dist < dist ) { max_dist = dist ; max_node = i ; } } int ans = - 1 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i == max_node ) continue ; ans = Math . max ( ans , getDist ( max_node , i ) ) ; } System . out . println ( \" ! ▁ \" + ans ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = 1 NEW_LINE b = 2 NEW_LINE c = 3 NEW_LINE ma = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT print ( \" ? \" , a , i ) NEW_LINE t = int ( input ( ) ) NEW_LINE if t >= ma : NEW_LINE INDENT ma = t NEW_LINE b = i NEW_LINE DEDENT DEDENT ma = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if b == i : NEW_LINE INDENT continue NEW_LINE DEDENT print ( \" ? \" , b , i ) NEW_LINE t = int ( input ( ) ) NEW_LINE if t >= ma : NEW_LINE INDENT ma = t NEW_LINE c = i NEW_LINE DEDENT DEDENT print ( \" ! \" , ma ) NEW_LINE", "def query ( a , b ) : NEW_LINE INDENT print ( \" ? ▁ { } ▁ { } \" . format ( a , b ) ) NEW_LINE return int ( input ( ) ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE v = 1 NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT dist = query ( 1 , i ) NEW_LINE if ans < dist : NEW_LINE INDENT ans = dist NEW_LINE v = i NEW_LINE DEDENT DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if i == v : NEW_LINE INDENT continue NEW_LINE DEDENT ans = max ( ans , query ( v , i ) ) NEW_LINE 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 dist = 0 NEW_LINE far = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT print ( \" ? ▁ 1 ▁ { } \" . format ( i ) , flush = True ) NEW_LINE nex_dist = ni ( ) NEW_LINE if dist < nex_dist : NEW_LINE INDENT dist = nex_dist NEW_LINE far = i NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 1 , n + 1 ) : NEW_LINE INDENT if j == far : NEW_LINE INDENT continue NEW_LINE DEDENT print ( \" ? ▁ { } ▁ { } \" . format ( far , j ) , flush = True ) NEW_LINE nex = ni ( ) NEW_LINE ans = max ( ans , nex ) NEW_LINE DEDENT print ( \" ! ▁ { } \" . format ( ans ) , flush = True ) NEW_LINE", "pointnum = int ( input ( ) ) NEW_LINE points = [ ] NEW_LINE for i in range ( pointnum ) : NEW_LINE INDENT points . append ( i + 1 ) NEW_LINE DEDENT d_list = [ ] NEW_LINE for i in points : NEW_LINE INDENT if i < len ( points ) : NEW_LINE INDENT print ( \" ? ▁ { 0 } ▁ { 1 } \" . format ( points [ 0 ] , points [ i ] ) ) NEW_LINE d_list . append ( int ( input ( ) ) ) NEW_LINE DEDENT DEDENT one_edge = d_list . index ( max ( d_list ) ) + 2 NEW_LINE e_list = [ ] NEW_LINE points . remove ( one_edge ) NEW_LINE for i in points : NEW_LINE INDENT print ( \" ? ▁ { 0 } ▁ { 1 } \" . format ( one_edge , i ) ) NEW_LINE e_list . append ( int ( input ( ) ) ) NEW_LINE DEDENT print ( \" ! ▁ { } \" . format ( ( max ( e_list ) ) ) ) NEW_LINE", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE def fQ ( i : int , i2 : int ) : NEW_LINE INDENT sys . stdout . write ( \" ▁ \" . join ( ( \" ? \" , str ( i ) , str ( i2 ) ) ) ) NEW_LINE sys . stdout . write ( \" \\n \" ) NEW_LINE sys . stdout . flush ( ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE dMax = 0 NEW_LINE iP = 0 NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT fQ ( 1 , i ) NEW_LINE d = int ( input ( ) ) NEW_LINE if dMax < d : NEW_LINE INDENT dMax = d NEW_LINE iP = i NEW_LINE DEDENT DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if i == iP : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT fQ ( iP , i ) NEW_LINE d = int ( input ( ) ) NEW_LINE if dMax < d : NEW_LINE INDENT dMax = d NEW_LINE DEDENT DEDENT DEDENT print ( \" ! \" , dMax ) NEW_LINE" ]
atcoder_abc064_B
[ "import java . util . Arrays ; 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 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( a [ n - 1 ] - a [ 0 ] ) ; sc . close ( ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; ArrayList < Integer > s = new ArrayList < > ( ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { s . add ( Integer . parseInt ( tokenizer . nextToken ( ) ) ) ; } Collections . sort ( s ) ; int sum = 0 ; for ( int i = 1 ; i < n ; i ++ ) { sum += s . get ( i ) - s . get ( i - 1 ) ; } System . out . println ( sum ) ; } }", "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 N = in . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = in . nextInt ( ) ; } Arrays . sort ( a ) ; out . println ( a [ a . length - 1 ] - a [ 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 . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { static Map < String , Integer > map = new TreeMap < > ( ) ; static String ans = \" \" ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int min = 1001 ; int max = - 1 ; for ( int i = 0 ; i < a ; i ++ ) { int b = sc . nextInt ( ) ; min = Math . min ( min , b ) ; max = Math . max ( max , b ) ; } System . out . println ( max - min ) ; } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) ar [ i ] = sc . nextInt ( ) ; Arrays . sort ( ar ) ; int sum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += ar [ i + 1 ] - ar [ i ] ; } System . out . println ( sum ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE l = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( l [ - 1 ] - l [ 0 ] ) 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 n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE a . sort ( ) NEW_LINE print ( a [ - 1 ] - a [ 0 ] ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE zahyou = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE zahyou . sort ( reverse = True ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT ans += zahyou [ i ] - zahyou [ i + 1 ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = sorted ( a ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT ans += a [ i ] - a [ i - 1 ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "_ , t = open ( 0 ) ; * a , = map ( int , t . split ( ) ) ; print ( max ( a ) - min ( a ) ) NEW_LINE" ]
atcoder_arc071_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long mod = 1000000007 ; long [ ] dp = new long [ 2 * n + 2 ] ; dp [ 0 ] = 1 ; dp [ 1 ] = 1 ; long sum = 2 ; for ( int i = 2 ; i < dp . length ; i ++ ) { dp [ i ] = ( sum - dp [ i - 2 ] + mod ) % mod ; sum = ( sum + dp [ i ] ) % mod ; } long res = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { res = ( res + dp [ i ] * ( n - 1 ) % mod * ( n - 1 ) % mod ) % mod ; } res = ( res + dp [ n - 1 ] * ( n - 1 ) % mod ) % mod ; for ( int i = 0 ; i < n - 1 ; i ++ ) { long coef = i + 2 ; if ( i == n - 2 ) coef -- ; res = ( res + dp [ i ] * coef % mod ) % mod ; } res = ( res + dp [ n - 1 ] ) % mod ; System . out . println ( res ) ; } }", "import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } long MODULO = 1_000_000_000 + 7 ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] f = new long [ N + 1 ] ; long [ ] cum = new long [ N + 1 ] ; Arrays . fill ( f , - Integer . MAX_VALUE / 16 ) ; Arrays . fill ( cum , - Integer . MAX_VALUE / 16 ) ; f [ 1 ] = N ; cum [ 1 ] = N ; for ( int i = 2 ; i <= N ; ++ i ) { f [ i ] = f [ i - 1 ] ; f [ i ] = ( f [ i ] + 1L * ( N - 1 ) * ( N - 1 ) % MODULO ) % MODULO ; if ( i > 3 ) { f [ i ] = ( f [ i ] + cum [ i - 3 ] ) % MODULO ; } f [ i ] = ( f [ i ] + Math . min ( 0 , i - 3 ) - ( i - N - 1 ) + 1 ) % MODULO ; cum [ i ] = ( cum [ i - 1 ] + f [ i ] ) % MODULO ; } System . out . println ( f [ N ] ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long MOD = 1000000007 ; long [ ] dp = new long [ N + 1 ] ; dp [ 0 ] = 1 ; dp [ 1 ] = MOD - 1 ; long cur = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cur = ( cur + dp [ i ] ) % MOD ; if ( i == N - 1 ) { dp [ N ] = ( dp [ N ] + cur * N ) % MOD ; } else { dp [ i + 1 ] = ( dp [ i + 1 ] + cur ) % MOD ; dp [ i + 2 ] = ( dp [ i + 2 ] - cur + MOD ) % MOD ; if ( i + 3 <= N ) { dp [ i + 3 ] = ( dp [ i + 3 ] + cur ) % MOD ; dp [ N ] = ( dp [ N ] + cur * ( i + 1 ) ) % MOD ; } else { dp [ N ] = ( dp [ N ] + cur * ( N - 1 ) ) % MOD ; } dp [ N ] = ( dp [ N ] + cur * ( ( ( ( long ) N - 1 ) * ( N - 1 ) ) % MOD ) ) % MOD ; } } System . out . println ( ( cur + dp [ N ] ) % MOD ) ; sc . close ( ) ; } }" ]
[ "from random import * NEW_LINE def readln ( ) : NEW_LINE INDENT _res = list ( map ( int , str ( input ( ) ) . split ( ' ▁ ' ) ) ) NEW_LINE return _res NEW_LINE DEDENT p = 1000000000 + 7 NEW_LINE n = readln ( ) [ 0 ] NEW_LINE f = [ 0 for i in range ( 0 , n + 10 ) ] NEW_LINE f [ 1 ] = n NEW_LINE f [ 2 ] = n * n NEW_LINE s = f [ : ] NEW_LINE s [ 2 ] = f [ 1 ] + f [ 2 ] NEW_LINE for i in range ( 3 , n + 1 ) : NEW_LINE INDENT f [ i ] = f [ i - 1 ] + ( n - 1 ) * ( n - 1 ) NEW_LINE f [ i ] = f [ i ] + s [ i - 3 ] + ( n - i + 2 ) NEW_LINE f [ i ] = f [ i ] % p NEW_LINE s [ i ] = s [ i - 1 ] + f [ i ] NEW_LINE s [ i ] = s [ i ] % p NEW_LINE DEDENT print ( f [ n ] ) NEW_LINE", "import sys NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def solve ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE return NEW_LINE DEDENT dp = [ 0 ] * ( n + 1 ) NEW_LINE dp [ 1 ] = n % mod NEW_LINE dp [ 2 ] = n ** 2 % mod NEW_LINE acc = [ 0 ] * ( n + 1 ) NEW_LINE acc [ 1 ] = dp [ 1 ] % mod NEW_LINE acc [ 2 ] = ( dp [ 1 ] + dp [ 2 ] ) % mod NEW_LINE for k in range ( 3 , n + 1 ) : NEW_LINE INDENT dp [ k ] = ( dp [ k - 1 ] + ( n - 1 ) ** 2 + acc [ k - 3 ] + n - k + 2 ) % mod NEW_LINE acc [ k ] = ( acc [ k - 1 ] + dp [ k ] ) % mod NEW_LINE DEDENT ans = dp [ n ] NEW_LINE print ( ans ) NEW_LINE DEDENT def debug ( x , table ) : NEW_LINE INDENT for name , val in table . items ( ) : NEW_LINE INDENT if x is val : NEW_LINE INDENT print ( ' DEBUG : { } ▁ - > ▁ { } ' . format ( name , val ) , file = sys . stderr ) NEW_LINE return None NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT res_v = [ 0 ] * ( n + 1 ) NEW_LINE res_v_cumsum = [ 0 ] * ( n + 1 ) NEW_LINE res_v [ 0 ] = 0 NEW_LINE res_v [ 1 ] = 1 NEW_LINE res_v [ 2 ] = 1 NEW_LINE res_v_cumsum [ 0 ] = 0 NEW_LINE res_v_cumsum [ 1 ] = 1 NEW_LINE res_v_cumsum [ 2 ] = 2 NEW_LINE M = 1000000007 NEW_LINE for k in range ( 3 , n ) : NEW_LINE INDENT res_v [ k ] = ( 1 + res_v_cumsum [ k - 1 ] - res_v [ k - 2 ] ) % M NEW_LINE res_v_cumsum [ k ] = ( res_v_cumsum [ k - 1 ] + res_v [ k ] ) % M NEW_LINE DEDENT print ( ( ( ( res_v_cumsum [ n - 2 ] * ( ( ( n - 1 ) * ( n - 1 ) ) % M ) ) % M ) + ( ( res_v_cumsum [ n - 1 ] * ( n - 1 ) ) % M ) + n + ( n - 1 ) * ( n - 1 ) % M ) % M ) NEW_LINE DEDENT" ]
atcoder_abc121_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int res = 0 ; int [ ] B = new int [ M ] ; int [ ] A = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { int sum = C ; for ( int n = 0 ; n < M ; n ++ ) { A [ n ] = sc . nextInt ( ) ; } for ( int n = 0 ; n < M ; n ++ ) { sum += A [ n ] * B [ n ] ; } if ( sum > 0 ) { res ++ ; } } System . out . println ( res ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; int tmp [ ] = convertStringToArrayInt ( input ) ; int N = tmp [ 0 ] ; int C = tmp [ 2 ] ; int counter = 0 ; input = sc . nextLine ( ) ; int b [ ] = convertStringToArrayInt ( input ) ; for ( int i = 0 ; i < N ; i ++ ) { input = sc . nextLine ( ) ; int arr [ ] = convertStringToArrayInt ( input ) ; int source = 0 ; for ( int j = 0 ; j < arr . length ; j ++ ) { source = source + ( b [ j ] * arr [ j ] ) ; } if ( source + C > 0 ) { counter ++ ; } } System . out . println ( counter ) ; sc . close ( ) ; } private static int [ ] convertStringToArrayInt ( String input ) { return Arrays . stream ( input . split ( \" ▁ \" ) ) . filter ( s -> ! s . isEmpty ( ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; } }", "import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; scanner . nextLine ( ) ; int b [ ] = new int [ m ] ; IntStream . range ( 0 , m ) . forEach ( i -> b [ i ] = scanner . nextInt ( ) ) ; scanner . nextLine ( ) ; System . out . println ( IntStream . range ( 0 , n ) . filter ( i -> { int sum = IntStream . range ( 0 , m ) . map ( j -> scanner . nextInt ( ) * b [ j ] ) . sum ( ) ; scanner . nextLine ( ) ; return ( sum + c ) > 0 ; } ) . count ( ) ) ; } } }", "import java . util . * ; public class Main { private static int X ( int [ ] a , int [ ] b , int C ) { int num = 0 ; int sum = C ; for ( int i = 0 ; i < a . length ; i ++ ) { sum += a [ i ] * b [ i ] ; } if ( sum > 0 ) num = 1 ; return num ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int [ ] [ ] A = new int [ N ] [ M ] ; int [ ] B = new int [ M ] ; for ( int j = 0 ; j < M ; j ++ ) { B [ j ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } int result = 0 ; int count ; for ( int i = 0 ; i < N ; i ++ ) { result += X ( A [ i ] , B , C ) ; } System . out . println ( result ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int codeNum = sc . nextInt ( ) ; int featNum = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] b = new int [ featNum ] ; int num = 0 ; int num2 = 0 ; int sum = 0 ; int count = 0 ; for ( int i = 0 ; i < featNum ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < codeNum ; i ++ ) { for ( int j = 0 ; j < featNum ; j ++ ) { num = sc . nextInt ( ) ; num2 = b [ j ] * num ; sum += num2 ; } if ( sum + c > 0 ) count ++ ; sum = 0 ; } System . out . println ( count ) ; } }" ]
[ "N , M , C = map ( int , input ( ) . split ( ) ) NEW_LINE B = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE counter = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT s = C NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for j in range ( M ) : NEW_LINE INDENT s += A [ j ] * B [ j ] NEW_LINE DEDENT if s > 0 : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT DEDENT print ( counter ) NEW_LINE", "I = lambda : map ( int , input ( ) . split ( ) ) ; n , m , c = I ( ) ; * b , = I ( ) NEW_LINE print ( sum ( sum ( a * b for a , b in zip ( I ( ) , b ) ) + c > 0 for _ in [ 0 ] * n ) ) NEW_LINE", "n , m , c = map ( int , input ( ) . split ( ) ) NEW_LINE b = map ( int , input ( ) . split ( ) ) NEW_LINE b = [ int ( i ) for i in b ] NEW_LINE kazu = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT goukei = 0 NEW_LINE a = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ int ( i ) for i in a ] NEW_LINE for j in range ( 0 , m ) : NEW_LINE INDENT goukei += a [ j ] * b [ j ] NEW_LINE DEDENT if goukei + c > 0 : NEW_LINE INDENT kazu += 1 NEW_LINE DEDENT DEDENT print ( kazu ) NEW_LINE", "n , m , c = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE cnt = 0 NEW_LINE tot = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT tot += l [ i ] [ j ] * b [ j ] NEW_LINE DEDENT tot = tot + c NEW_LINE if ( tot > 0 ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT tot = 0 NEW_LINE DEDENT print ( cnt ) NEW_LINE", "N , M , C = map ( int , input ( ) . split ( ) ) NEW_LINE deep = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE score = 0 NEW_LINE for n in range ( 1 , N + 1 ) : NEW_LINE INDENT blue = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE linear = 0 NEW_LINE for m in range ( 1 , M + 1 ) : NEW_LINE INDENT linear += deep [ m - 1 ] * blue [ m - 1 ] NEW_LINE DEDENT if linear + C > 0 : NEW_LINE INDENT score += 1 NEW_LINE DEDENT DEDENT print ( score ) NEW_LINE" ]
atcoder_arc018_B
[ "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 ] ; long b [ ] = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextLong ( ) ; b [ i ] = sc . nextLong ( ) ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int k = i ; k < N ; k ++ ) { for ( int j = k ; j < N ; j ++ ) { long s = Math . abs ( ( a [ j ] - a [ i ] ) * ( b [ k ] - b [ i ] ) - ( a [ k ] - a [ i ] ) * ( b [ j ] - b [ i ] ) ) ; if ( s != 0 && s % 2 == 0 ) count ++ ; } } } System . out . println ( count ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] x = new int [ n ] , y = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] s = br . readLine ( ) . split ( \" ▁ \" ) ; x [ i ] = Integer . parseInt ( s [ 0 ] ) ; y [ i ] = Integer . parseInt ( s [ 1 ] ) ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) for ( int k = 0 ; k < j ; k ++ ) { long ax = x [ k ] - x [ i ] ; long ay = y [ k ] - y [ i ] ; long bx = x [ j ] - x [ i ] ; long by = y [ j ] - y [ i ] ; long s2 = Math . abs ( ax * by - ay * bx ) ; if ( s2 > 0 && s2 % 2 == 0 ) { ans ++ ; } } System . out . println ( ans ) ; } }", "import java . awt . Point ; import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; Point [ ] p = new Point [ n ] ; Arrays . setAll ( p , o -> new Point ( s . nextInt ( ) , s . nextInt ( ) ) ) ; int r = 0 ; for ( int i = 0 ; i < n ; ++ i ) { Point a = p [ i ] ; for ( int j = i + 1 ; j < n ; ++ j ) { Point b = p [ j ] ; for ( int k = j + 1 ; k < n ; ++ k ) { Point c = p [ k ] ; if ( Math . atan2 ( a . y - b . y , a . x - b . x ) != Math . atan2 ( a . y - c . y , a . x - c . x ) && ( f ( a , b ) + f ( b , c ) + f ( c , a ) ) % 2 == 0 ) ++ r ; } } } System . out . println ( r ) ; } static long f ( Point a , Point b ) { return Math . abs ( ( long ) ( a . x - b . x ) * ( a . y - b . y ) ) ; } }", "import java . util . * ; public class Main { private static double N ; private static ArrayList < Integer > x = new ArrayList < > ( ) ; private static ArrayList < Integer > y = new ArrayList < > ( ) ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { x . add ( scan . nextInt ( ) ) ; y . add ( scan . nextInt ( ) ) ; } } public static void main ( String args [ ] ) { input ( ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( i != j && j != k && i != k ) { long ax = x . get ( k ) - x . get ( i ) ; long ay = y . get ( k ) - y . get ( i ) ; long bx = x . get ( j ) - x . get ( i ) ; long by = y . get ( j ) - y . get ( i ) ; long area = Math . abs ( ax * by - ay * bx ) ; if ( area > 0 && area % 2 == 0 ) ans ++ ; } } } } System . out . println ( ans / 6 ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE XY = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE ans = 0 NEW_LINE for i in range ( N - 2 ) : NEW_LINE INDENT for j in range ( i + 1 , N - 1 ) : NEW_LINE INDENT for k in range ( j + 1 , N ) : NEW_LINE INDENT x1 , y1 = XY [ i ] NEW_LINE x2 , y2 = XY [ j ] NEW_LINE x3 , y3 = XY [ k ] NEW_LINE area = abs ( ( x2 - x1 ) * ( y3 - y1 ) - ( x3 - x1 ) * ( y2 - y1 ) ) NEW_LINE if area > 0 and area % 2 == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "from itertools import combinations as comb NEW_LINE def tri ( o ) : NEW_LINE INDENT ( x1 , y1 ) , ( x2 , y2 ) , ( x3 , y3 ) = o NEW_LINE return abs ( x1 * y2 + x2 * y3 + x3 * y1 - y1 * x2 - y2 * x3 - y3 * x1 ) NEW_LINE DEDENT l = tuple ( tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( int ( input ( ) ) ) ) NEW_LINE print ( sum ( 1 for s in map ( tri , comb ( l , 3 ) ) if s % 2 == 0 and s ) ) NEW_LINE", "def b_lattice_point_and_integer ( N , Pos ) : NEW_LINE INDENT from itertools import combinations NEW_LINE def surface_2 ( Xa , Ya , Xb , Yb , Xc , Yc ) : NEW_LINE INDENT xb , yb = Xb - Xa , Yb - Ya NEW_LINE xc , yc = Xc - Xa , Yc - Ya NEW_LINE ret = abs ( xb * yc - yb * xc ) NEW_LINE return ret NEW_LINE DEDENT ans = 0 NEW_LINE for i , j , k in combinations ( range ( N ) , 3 ) : NEW_LINE INDENT s = surface_2 ( * ( Pos [ i ] + Pos [ j ] + Pos [ k ] ) ) NEW_LINE if s != 0 and s % 2 == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE Pos = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( N ) ] NEW_LINE print ( b_lattice_point_and_integer ( N , Pos ) ) NEW_LINE", "import itertools NEW_LINE def solve_triangle ( a , b , c ) : NEW_LINE INDENT S = abs ( ( b [ 0 ] - a [ 0 ] ) * ( c [ 1 ] - a [ 1 ] ) - ( c [ 0 ] - a [ 0 ] ) * ( b [ 1 ] - a [ 1 ] ) ) NEW_LINE return ( S % 2 == 0 ) and ( S != 0 ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE lattice = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT lattice . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT cnt = 0 NEW_LINE for triangle in itertools . combinations ( lattice , 3 ) : NEW_LINE INDENT if solve_triangle ( triangle [ 0 ] , triangle [ 1 ] , triangle [ 2 ] ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE", "from math import floor , ceil NEW_LINE N = int ( input ( ) ) NEW_LINE x = [ None ] * N NEW_LINE y = [ None ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT x [ i ] , y [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT for k in range ( j + 1 , N ) : NEW_LINE INDENT x1 = x [ j ] - x [ i ] NEW_LINE y1 = y [ j ] - y [ i ] NEW_LINE x2 = x [ k ] - x [ i ] NEW_LINE y2 = y [ k ] - y [ i ] NEW_LINE s = abs ( x1 * y2 - x2 * y1 ) NEW_LINE if s > 0 and s % 2 == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc079_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s [ ] = sc . next ( ) . split ( \" \" , 0 ) ; int a = Integer . parseInt ( s [ 0 ] ) ; int b = Integer . parseInt ( s [ 1 ] ) ; int c = Integer . parseInt ( s [ 2 ] ) ; int d = Integer . parseInt ( s [ 3 ] ) ; if ( a + b + c + d == 7 ) System . out . println ( a + \" + \" + b + \" + \" + c + \" + \" + d + \" = 7\" ) ; else if ( a + b + c - d == 7 ) System . out . println ( a + \" + \" + b + \" + \" + c + \" - \" + d + \" = 7\" ) ; else if ( a + b - c + d == 7 ) System . out . println ( a + \" + \" + b + \" - \" + c + \" + \" + d + \" = 7\" ) ; else if ( a + b - c - d == 7 ) System . out . println ( a + \" + \" + b + \" - \" + c + \" - \" + d + \" = 7\" ) ; else if ( a - b + c + d == 7 ) System . out . println ( a + \" - \" + b + \" + \" + c + \" + \" + d + \" = 7\" ) ; else if ( a - b + c - d == 7 ) System . out . println ( a + \" - \" + b + \" + \" + c + \" - \" + d + \" = 7\" ) ; else if ( a - b - c + d == 7 ) System . out . println ( a + \" - \" + b + \" - \" + c + \" + \" + d + \" = 7\" ) ; else System . out . println ( a + \" - \" + b + \" - \" + c + \" - \" + d + \" = 7\" ) ; } }", "import java . util . Scanner ; import java . util . StringJoiner ; public class Main { private static void print ( int a , int b , int c , int d , int i , int j , int k ) { StringJoiner sj = new StringJoiner ( \" \" ) ; sj . add ( String . valueOf ( a ) ) ; if ( i == 0 ) { sj . add ( \" + \" ) ; } else { sj . add ( \" - \" ) ; } sj . add ( String . valueOf ( b ) ) ; if ( j == 0 ) { sj . add ( \" + \" ) ; } else { sj . add ( \" - \" ) ; } sj . add ( String . valueOf ( c ) ) ; if ( k == 0 ) { sj . add ( \" + \" ) ; } else { sj . add ( \" - \" ) ; } sj . add ( String . valueOf ( d ) ) ; sj . add ( \" = 7\" ) ; System . out . println ( sj . toString ( ) ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] n = sc . next ( ) . split ( \" \" ) ; int a = Integer . parseInt ( n [ 0 ] ) ; int b = Integer . parseInt ( n [ 1 ] ) ; int c = Integer . parseInt ( n [ 2 ] ) ; int d = Integer . parseInt ( n [ 3 ] ) ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { int sum = 0 ; if ( i == 0 ) { sum = a + b ; } else { sum = a - b ; } if ( j == 0 ) { sum += c ; } else { sum -= c ; } if ( k == 0 ) { sum += d ; } else { sum -= d ; } if ( sum == 7 ) { print ( a , b , c , d , i , j , k ) ; return ; } } } } } }", "import java . util . Scanner ; public class Main { private static String [ ] results = new String [ 3 ] ; private static int [ ] input = new int [ 4 ] ; public static void main ( String args [ ] ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ; for ( int i = 0 ; i < line . length ( ) ; i ++ ) { input [ i ] = Character . getNumericValue ( line . charAt ( i ) ) ; } boolean flg = dfs ( 0 , input [ 0 ] ) ; String A = Integer . toString ( input [ 0 ] ) ; String B = Integer . toString ( input [ 1 ] ) ; String C = Integer . toString ( input [ 2 ] ) ; String D = Integer . toString ( input [ 3 ] ) ; System . out . print ( A + results [ 0 ] + B + results [ 1 ] + C + results [ 2 ] + D + \" = 7\" ) ; scanner . close ( ) ; } public static boolean dfs ( int index , int sum ) { if ( index == 3 && sum == 7 ) { return true ; } else if ( index <= 2 ) { results [ index ] = \" + \" ; if ( dfs ( index + 1 , sum + input [ index + 1 ] ) ) { return true ; } results [ index ] = \" - \" ; if ( dfs ( index + 1 , sum - input [ index + 1 ] ) ) { return true ; } } return false ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { char s [ ] = sc . next ( ) . toCharArray ( ) ; char ans [ ] = new char [ 7 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { ans [ i * 2 ] = s [ i ] ; } for ( int tmp = 0 ; tmp < ( 1 << 3 ) ; tmp ++ ) { for ( int b = 0 ; b < 3 ; b ++ ) { ans [ b * 2 + 1 ] = ( ( ( ( tmp & ( 1 << b ) ) >> b ) == 1 ) ? ' + ' : ' - ' ) ; } if ( check ( ans ) ) { System . out . println ( new String ( ans ) + \" = 7\" ) ; break ; } } } private boolean check ( char str [ ] ) { int ans = str [ 0 ] - '0' ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( str [ i * 2 + 1 ] == ' + ' ) { ans += str [ i * 2 + 2 ] - '0' ; } else { ans -= str [ i * 2 + 2 ] - '0' ; } } return ans == 7 ; } public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { new Main ( ) . main ( sc ) ; } catch ( Exception e ) { throw e ; } } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ABCD = sc . next ( ) ; int [ ] nums = new int [ 4 ] ; for ( int i = 0 ; i < ABCD . length ( ) ; i ++ ) { nums [ i ] = Character . getNumericValue ( ABCD . charAt ( i ) ) ; } int bits = 0 ; for ( int i = 0 ; i < 1 << 3 ; i ++ ) { int tmp = nums [ 0 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( ( i >> j & 1 ) == 1 ) { tmp += nums [ j + 1 ] ; } else { tmp -= nums [ j + 1 ] ; } } if ( tmp == 7 ) { bits = i ; } } StringBuilder str = new StringBuilder ( ) ; str . append ( ABCD . charAt ( 0 ) ) ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( ( bits >> j & 1 ) == 1 ) { str . append ( \" + \" ) ; } else { str . append ( \" - \" ) ; } str . append ( ABCD . charAt ( j + 1 ) ) ; } str . append ( \" = 7\" ) ; out . println ( str . toString ( ) ) ; } }" ]
[ "def dfs ( s , plus , i ) : NEW_LINE INDENT i += 1 NEW_LINE if i == 4 : NEW_LINE INDENT ans = int ( s [ 0 ] ) NEW_LINE for j in range ( 1 , 4 ) : NEW_LINE INDENT ans += int ( s [ j ] ) * plus [ j - 1 ] NEW_LINE DEDENT if ans == 7 : NEW_LINE INDENT ret = s [ 0 ] NEW_LINE for k in range ( 1 , 4 ) : NEW_LINE INDENT if plus [ k - 1 ] == 1 : NEW_LINE INDENT ret += ' + ' NEW_LINE DEDENT else : NEW_LINE INDENT ret += ' - ' NEW_LINE DEDENT ret += s [ k ] NEW_LINE DEDENT ret += ' = 7' NEW_LINE print ( ret ) NEW_LINE exit ( ) NEW_LINE DEDENT return NEW_LINE DEDENT plus [ i - 1 ] = 1 NEW_LINE dfs ( s , plus , i ) NEW_LINE plus [ i - 1 ] = - 1 NEW_LINE dfs ( s , plus , i ) NEW_LINE return NEW_LINE DEDENT dfs ( input ( ) , [ 0 , 0 , 0 ] , 0 ) NEW_LINE", "num = int ( input ( ) ) NEW_LINE a = num // 1000 NEW_LINE b = num % 1000 // 100 NEW_LINE c = num % 100 // 10 NEW_LINE d = num % 10 NEW_LINE if a + b + c + d == 7 : NEW_LINE INDENT print ( a , \" + \" , b , \" + \" , c , \" + \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT elif a + b + c - d == 7 : NEW_LINE INDENT print ( a , \" + \" , b , \" + \" , c , \" - \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT elif a + b - c + d == 7 : NEW_LINE INDENT print ( a , \" + \" , b , \" - \" , c , \" + \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT elif a + b - c - d == 7 : NEW_LINE INDENT print ( a , \" + \" , b , \" - \" , c , \" - \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT elif a - b + c + d == 7 : NEW_LINE INDENT print ( a , \" - \" , b , \" + \" , c , \" + \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT elif a - b + c - d == 7 : NEW_LINE INDENT print ( a , \" - \" , b , \" + \" , c , \" - \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT elif a - b - c + d == 7 : NEW_LINE INDENT print ( a , \" - \" , b , \" - \" , c , \" + \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a , \" - \" , b , \" - \" , c , \" - \" , d , \" = \" , 7 , sep = ' ' ) NEW_LINE DEDENT", "import itertools NEW_LINE num_list = input ( ) NEW_LINE rule = ' + - ' NEW_LINE for ops in itertools . product ( rule , repeat = 3 ) : NEW_LINE INDENT ans = ' { } { } { } { } { } { } { } ' . format ( num_list [ 0 ] , ops [ 0 ] , num_list [ 1 ] , ops [ 1 ] , num_list [ 2 ] , ops [ 2 ] , num_list [ 3 ] ) NEW_LINE res = eval ( ans ) NEW_LINE if res == 7 : NEW_LINE INDENT print ( ' { } = 7' . format ( ans ) ) NEW_LINE break NEW_LINE DEDENT DEDENT", "( lambda o , f , A , B , C , D : any ( f ( ( ' { } ' * 7 ) . format ( A , i , B , j , C , k , D ) ) for i in o for j in o for k in o ) ) ( ' + - ' , lambda s : 7 == eval ( s ) and [ print ( s + ' = 7' ) ] , * input ( ) ) NEW_LINE", "import sys NEW_LINE from sys import stdin NEW_LINE abcd = [ int ( c ) for c in list ( stdin . readline ( ) . rstrip ( ) ) ] NEW_LINE op = [ ' + ' , ' - ' ] NEW_LINE for i in op : NEW_LINE INDENT for j in op : NEW_LINE INDENT for k in op : NEW_LINE INDENT result = abcd [ 0 ] NEW_LINE if i == ' + ' : NEW_LINE INDENT result += abcd [ 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT result -= abcd [ 1 ] NEW_LINE DEDENT if j == ' + ' : NEW_LINE INDENT result += abcd [ 2 ] NEW_LINE DEDENT else : NEW_LINE INDENT result -= abcd [ 2 ] NEW_LINE DEDENT if k == ' + ' : NEW_LINE INDENT result += abcd [ 3 ] NEW_LINE DEDENT else : NEW_LINE INDENT result -= abcd [ 3 ] NEW_LINE DEDENT if result == 7 : NEW_LINE INDENT print ( abcd [ 0 ] , end = ' ' ) NEW_LINE print ( i , end = ' ' ) NEW_LINE print ( abcd [ 1 ] , end = ' ' ) NEW_LINE print ( j , end = ' ' ) NEW_LINE print ( abcd [ 2 ] , end = ' ' ) NEW_LINE print ( k , end = ' ' ) NEW_LINE print ( abcd [ 3 ] , end = ' ' ) NEW_LINE print ( ' = 7' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT" ]
atcoder_arc078_B
[ "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int N = Integer . parseInt ( in . readLine ( ) ) ; Map < Integer , List < Integer > > v = new HashMap < > ( ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) { v . put ( i , new ArrayList < Integer > ( ) ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { Integer [ ] ab = Arrays . stream ( in . readLine ( ) . split ( \" ▁ \" ) ) . map ( Integer :: parseInt ) . toArray ( Integer [ ] :: new ) ; v . get ( ab [ 0 ] ) . add ( ab [ 1 ] ) ; v . get ( ab [ 1 ] ) . add ( ab [ 0 ] ) ; } int [ ] fenecDist = new int [ N + 1 ] ; Arrays . fill ( fenecDist , - 1 ) ; int [ ] snukeDist = new int [ N + 1 ] ; Arrays . fill ( snukeDist , - 1 ) ; dfs ( fenecDist , v , 1 , 0 ) ; dfs ( snukeDist , v , N , 0 ) ; int [ ] fScore = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { if ( fenecDist [ i ] <= snukeDist [ i ] ) { fScore [ i ] = 1 ; } } if ( Arrays . stream ( fScore ) . sum ( ) > N / 2 ) { System . out . println ( \" Fennec \" ) ; } else { System . out . println ( \" Snuke \" ) ; } } public static void dfs ( int [ ] dist , Map < Integer , List < Integer > > v , int start , int depth ) { if ( dist [ start ] > - 1 ) { return ; } dist [ start ] = depth ; for ( int i : v . get ( start ) ) { dfs ( dist , v , i , depth + 1 ) ; } } }", "import java . util . * ; public class Main { static List < Integer > adj [ ] ; public static void addEdge ( int u , int v ) { adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; } static class pair { int i , j ; public pair ( int i , int j ) { this . i = i ; this . j = j ; } } public static String VertexColoring ( int N ) { Queue < pair > q = new LinkedList < > ( ) ; q . offer ( new pair ( 0 , 0 ) ) ; q . offer ( new pair ( N - 1 , 1 ) ) ; int color [ ] = new int [ N ] ; Arrays . fill ( color , - 1 ) ; while ( ! q . isEmpty ( ) ) { pair p = q . poll ( ) ; if ( color [ p . i ] == - 1 ) { color [ p . i ] = p . j ; Iterator < Integer > itr = adj [ p . i ] . iterator ( ) ; while ( itr . hasNext ( ) ) { q . offer ( new pair ( itr . next ( ) , p . j ) ) ; } } } int s [ ] = new int [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { s [ color [ i ] ] ++ ; } return s [ 0 ] > s [ 1 ] ? \" Fennec \" : \" Snuke \" ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int V = sc . nextInt ( ) ; adj = new LinkedList [ V ] ; for ( int i = 0 ; i < V ; i ++ ) { adj [ i ] = new LinkedList < > ( ) ; } for ( int i = 0 ; i < V - 1 ; i ++ ) { int u = sc . nextInt ( ) ; int v = sc . nextInt ( ) ; u -- ; v -- ; addEdge ( u , v ) ; } System . out . println ( VertexColoring ( V ) ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "from scipy . sparse import * NEW_LINE n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE print ( ' FSennunkeec ' [ sum ( g > h for g , h in zip ( * csgraph . dijkstra ( csr_matrix ( ( [ 1 ] * ~ - n , ( a [ : : 2 ] , a [ 1 : : 2 ] ) ) , [ n + 1 ] * 2 ) , 0 , [ 1 , n ] ) ) ) * 2 >= n : : 2 ] ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE nl = { } NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a - 1 in nl : NEW_LINE INDENT nl [ a - 1 ] . append ( b - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT nl [ a - 1 ] = [ b - 1 ] NEW_LINE DEDENT if b - 1 in nl : NEW_LINE INDENT nl [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT nl [ b - 1 ] = [ a - 1 ] NEW_LINE DEDENT DEDENT fenl = [ - 1 for _ in range ( n ) ] NEW_LINE sunl = [ - 1 for _ in range ( n ) ] NEW_LINE fenl [ 0 ] = 1 NEW_LINE sunl [ - 1 ] = 1 NEW_LINE now = [ 0 ] NEW_LINE while now : NEW_LINE INDENT tmp = [ ] NEW_LINE for _n in now : NEW_LINE INDENT for nxt in nl [ _n ] : NEW_LINE INDENT if fenl [ nxt ] == - 1 : NEW_LINE INDENT tmp . append ( nxt ) NEW_LINE fenl [ nxt ] = fenl [ _n ] + 1 NEW_LINE DEDENT DEDENT DEDENT now = tmp NEW_LINE DEDENT now = [ n - 1 ] NEW_LINE while now : NEW_LINE INDENT tmp = [ ] NEW_LINE for _n in now : NEW_LINE INDENT for nxt in nl [ _n ] : NEW_LINE INDENT if sunl [ nxt ] == - 1 : NEW_LINE INDENT tmp . append ( nxt ) NEW_LINE sunl [ nxt ] = sunl [ _n ] + 1 NEW_LINE DEDENT DEDENT DEDENT now = tmp NEW_LINE DEDENT fm , sm = 0 , 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if fenl [ i ] <= sunl [ i ] : NEW_LINE INDENT fm += 1 NEW_LINE DEDENT else : NEW_LINE INDENT sm += 1 NEW_LINE DEDENT DEDENT if fm <= sm : NEW_LINE INDENT print ( ' Snuke ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Fennec ' ) NEW_LINE DEDENT", "from collections import defaultdict as dd NEW_LINE tree = dd ( list ) NEW_LINE def dfs_route ( tree , start , goal ) : NEW_LINE INDENT visited = set ( ) NEW_LINE stack = list ( ) NEW_LINE visited . add ( start ) NEW_LINE stack . append ( start ) NEW_LINE while stack : NEW_LINE INDENT node = stack [ - 1 ] NEW_LINE if node == goal : NEW_LINE INDENT return stack NEW_LINE DEDENT else : NEW_LINE INDENT child = [ x for x in tree [ node ] if x not in visited ] NEW_LINE if child == [ ] : NEW_LINE INDENT stack . pop ( ) NEW_LINE DEDENT else : NEW_LINE INDENT visited . add ( child [ 0 ] ) NEW_LINE stack . append ( child [ 0 ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT n = int ( input ( ) ) NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE tree [ a ] . append ( b ) NEW_LINE tree [ b ] . append ( a ) NEW_LINE DEDENT l = dfs_route ( tree , 1 , n ) NEW_LINE fl = l [ ( len ( l ) - 1 ) // 2 ] NEW_LINE sl = l [ ( len ( l ) + 1 ) // 2 ] NEW_LINE tree [ fl ] . remove ( sl ) NEW_LINE tree [ sl ] . remove ( fl ) NEW_LINE def gr ( tree , start ) : NEW_LINE INDENT island = set ( ) NEW_LINE rest = [ start , ] NEW_LINE while rest : NEW_LINE INDENT node = rest . pop ( ) NEW_LINE island . add ( node ) NEW_LINE for x in tree [ node ] : NEW_LINE INDENT if x not in island : NEW_LINE INDENT rest . append ( x ) NEW_LINE DEDENT DEDENT DEDENT return ( island ) NEW_LINE DEDENT if len ( gr ( tree , 1 ) ) * 2 > n : NEW_LINE INDENT print ( \" Fennec \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Snuke \" ) NEW_LINE DEDENT", "def bfs ( graph , start , n , check ) : NEW_LINE INDENT if check == False : NEW_LINE INDENT arrival = [ 0 for i in range ( n + 1 ) ] NEW_LINE DEDENT else : NEW_LINE INDENT arrival = [ 0 for i in range ( n + 1 ) ] NEW_LINE arrival [ check ] = - 1 NEW_LINE DEDENT q = [ start ] NEW_LINE arrival [ start ] = 1 NEW_LINE while len ( q ) != 0 : NEW_LINE INDENT for i in range ( len ( graph [ q [ 0 ] ] ) ) : NEW_LINE INDENT if arrival [ graph [ q [ 0 ] ] [ i ] ] == 0 : NEW_LINE INDENT q . append ( graph [ q [ 0 ] ] [ i ] ) NEW_LINE arrival [ graph [ q [ 0 ] ] [ i ] ] = arrival [ q [ 0 ] ] + 1 NEW_LINE DEDENT DEDENT q . pop ( 0 ) NEW_LINE DEDENT return arrival NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE graph = dict ( ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT graph [ i ] = [ ] NEW_LINE DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE graph [ a ] . append ( b ) NEW_LINE graph [ b ] . append ( a ) NEW_LINE DEDENT fstart = bfs ( graph , 1 , n , False ) NEW_LINE sstart = bfs ( graph , n , n , False ) NEW_LINE fennec = 0 NEW_LINE snuke = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if abs ( fstart [ i ] - fstart [ 1 ] ) <= abs ( sstart [ i ] - sstart [ n ] ) : NEW_LINE INDENT fennec += 1 NEW_LINE DEDENT else : NEW_LINE INDENT snuke += 1 NEW_LINE DEDENT DEDENT if fennec > snuke : NEW_LINE INDENT print ( \" Fennec \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Snuke \" ) NEW_LINE DEDENT", "from scipy . sparse import * ; f = lambda * z : map ( int , input ( ) . split ( ) ) ; n , = f ( ) ; c = [ 1 ] * ~ - n ; g , h = csgraph . dijkstra ( csr_matrix ( ( c , list ( zip ( * map ( f , c ) ) ) ) , [ n + 1 ] * 2 ) , 0 , [ 1 , n ] ) ; print ( ' FSennunkeec ' [ sum ( g [ i ] > h [ i ] for i in range ( n + 1 ) ) * 2 >= n : : 2 ] ) NEW_LINE" ]
atcoder_arc074_A
[ "import java . util . * ; public class Main { int ni ( ) { return cin . nextInt ( ) ; } long nl ( ) { return cin . nextLong ( ) ; } String line ( ) { return cin . nextLine ( ) ; } void println ( String str ) { System . out . println ( str ) ; } void print ( String str ) { System . out . print ( str ) ; } static final int MOD = 1000000007 ; Scanner cin = new Scanner ( System . in ) ; String output ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { input ( ) ; int res = solve ( ) ; output = res + \" \" ; println ( output ) ; } int H , W ; void input ( ) { H = ni ( ) ; W = ni ( ) ; if ( W > H ) { W = H + W ; H = W - H ; W = W - H ; } } int solve ( ) { if ( H % 3 == 0 || W % 3 == 0 ) { return 0 ; } return Math . min ( cal ( H , W ) , cal ( W , H ) ) ; } int cal ( long h , long w ) { long res = w ; for ( long i = h / 3 ; i <= h / 2 ; i ++ ) { long a [ ] = new long [ 3 ] ; a [ 0 ] = ( i ) * w ; a [ 1 ] = ( h - i ) * ( w / 2 ) ; a [ 2 ] = ( h - i ) * ( w - w / 2 ) ; Arrays . sort ( a ) ; res = Math . min ( res , a [ 2 ] - a [ 0 ] ) ; } return ( int ) res ; } }", "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 ) ; CChocolateBar solver = new CChocolateBar ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class CChocolateBar { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long h = in . nextInt ( ) , w = in . nextInt ( ) ; if ( h * w % 3 == 0 ) { out . println ( 0 ) ; return ; } long ans = Math . min ( h , w ) ; for ( int x = 0 ; x <= w ; x ++ ) { long s1 = ( w - x ) * h ; long s2 = x * ( h / 2 ) ; long s3 = x * ( ( h + 1 ) / 2 ) ; ans = Math . min ( ans , Math . max ( s1 , s3 ) - Math . min ( s1 , s2 ) ) ; } for ( int y = 0 ; y <= h ; y ++ ) { long s1 = w * ( h - y ) ; long s2 = ( w / 2 ) * y ; long s3 = ( ( w + 1 ) / 2 ) * y ; ans = Math . min ( ans , Math . max ( s1 , s3 ) - Math . min ( s1 , s2 ) ) ; } out . println ( ans ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner cin = new Scanner ( System . in ) ; int H = cin . nextInt ( ) ; int W = cin . nextInt ( ) ; cin . close ( ) ; long result = 0L ; if ( W == H ) { result = calcMin ( H , W ) ; } else { result = Math . min ( calcMin ( H , W ) , calcMin ( W , H ) ) ; } System . out . println ( result ) ; } public static long calcMin ( int H , int W ) { long S1 = 0L ; long S2 = 0L ; long S3 = 0L ; long S4 = 0L ; long S5 = 0L ; long Smin = Long . MAX_VALUE ; long tmpS ; for ( long i = 1 ; i < H ; i ++ ) { S1 = i * W ; S2 = ( H - i ) * ( W / 2 ) ; S3 = ( H - i ) * ( W - ( W / 2 ) ) ; tmpS = Math . max ( Math . max ( S1 , S2 ) , S3 ) - Math . min ( Math . min ( S1 , S2 ) , S3 ) ; if ( tmpS < Smin ) { Smin = tmpS ; } if ( i <= H - 2 ) { S4 = W * ( ( H - i ) / 2 ) ; S5 = W * ( H - i - ( ( H - i ) / 2 ) ) ; tmpS = Math . max ( Math . max ( S1 , S4 ) , S5 ) - Math . min ( Math . min ( S1 , S4 ) , S5 ) ; if ( tmpS < Smin ) { Smin = tmpS ; } } } return Smin ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long h = sc . nextInt ( ) ; long w = sc . nextInt ( ) ; long a1 = calc ( h , w ) ; long a2 = calc ( w , h ) ; long ans = a1 > a2 ? a2 : a1 ; System . out . println ( ans ) ; } public static long calc ( long i1 , long i2 ) { long [ ] ss = new long [ 3 ] ; long ans = Long . MAX_VALUE ; long sMax , sMin ; for ( int j = 1 ; j < i1 ; j ++ ) { ss [ 0 ] = j * i2 ; for ( int k = 0 ; k < 2 ; k ++ ) { sMax = Long . MIN_VALUE ; sMin = Long . MAX_VALUE ; if ( k == 0 ) ss [ 1 ] = ( i1 - j ) * ( i2 / 2 ) ; else ss [ 1 ] = ( ( i1 - j ) / 2 ) * i2 ; ss [ 2 ] = ( i1 * i2 ) - ( ss [ 0 ] + ss [ 1 ] ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( sMax < ss [ i ] ) sMax = ss [ i ] ; if ( sMin > ss [ i ] ) sMin = ss [ i ] ; } if ( ans > ( sMax - sMin ) ) ans = sMax - sMin ; } } return 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 ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int h = in . nextInt ( ) , w = in . nextInt ( ) ; if ( h % 3 == 0 || w % 3 == 0 ) { out . println ( 0 ) ; } else { int res = Integer . MAX_VALUE ; if ( h > 2 ) res = Math . min ( res , w ) ; if ( w > 2 ) res = Math . min ( res , h ) ; int tmp = Math . min ( gao ( h , w ) , gao ( w , h ) ) ; out . println ( Math . min ( res , tmp ) ) ; } } private int gao ( int h , int w ) { int base = h / 3 , remain = h % 3 ; int res = Integer . MAX_VALUE ; for ( int i = 0 ; i <= remain ; ++ i ) { int first = w * ( base + i ) , second , third ; if ( w % 2 == 0 ) { second = third = ( h - base - i ) * ( w / 2 ) ; res = Math . min ( res , Math . abs ( first - second ) ) ; } else { second = ( h - base - i ) * ( w / 2 ) ; third = ( h - base - i ) * w - second ; int lower = Math . min ( first , second ) , upper = Math . max ( first , third ) ; res = Math . min ( res , upper - lower ) ; } } return res ; } } }" ]
[ "import sys NEW_LINE import collections NEW_LINE import math NEW_LINE from collections import Counter NEW_LINE from collections import deque NEW_LINE H , W = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE ans = 10 ** 10 NEW_LINE def calc1 ( H , W ) : NEW_LINE INDENT if H % 3 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return W NEW_LINE DEDENT DEDENT def calc2 ( H , W ) : NEW_LINE INDENT ret = 10 ** 10 NEW_LINE for w in range ( 1 , W ) : NEW_LINE INDENT s1 = w * H NEW_LINE h = H // 2 NEW_LINE s2 = h * ( W - w ) NEW_LINE s3 = ( H - h ) * ( W - w ) NEW_LINE maxS = max ( s1 , s2 , s3 ) NEW_LINE minS = min ( s1 , s2 , s3 ) NEW_LINE ret = min ( abs ( maxS - minS ) , ret ) NEW_LINE DEDENT return ret NEW_LINE DEDENT s1 = calc1 ( H , W ) NEW_LINE s2 = calc1 ( W , H ) NEW_LINE s3 = calc2 ( H , W ) NEW_LINE s4 = calc2 ( W , H ) NEW_LINE print ( min ( s1 , s2 , s3 , s4 ) ) NEW_LINE sys . exit ( 0 ) NEW_LINE", "h , w = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if not ( h % 3 ) * ( w % 3 ) : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT def calc_T ( h , w ) : NEW_LINE INDENT bars = [ ] NEW_LINE first_cut = w // 3 + w % 3 - 1 NEW_LINE bars . append ( first_cut * h ) NEW_LINE bars . append ( ( h // 2 ) * ( w - first_cut ) ) NEW_LINE bars . append ( h * w - sum ( bars ) ) NEW_LINE return max ( bars ) - min ( bars ) NEW_LINE DEDENT print ( min ( calc_T ( h , w ) , calc_T ( w , h ) , h , w ) ) NEW_LINE", "from math import ceil NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE ans = float ( \" inf \" ) NEW_LINE for h in range ( 1 , H ) : NEW_LINE INDENT m = min ( h * W , ( H - h ) * ( W // 2 ) , ( H - h ) * ceil ( W / 2 ) ) NEW_LINE M = max ( h * W , ( H - h ) * ( W // 2 ) , ( H - h ) * ceil ( W / 2 ) ) NEW_LINE ans = min ( ans , M - m ) NEW_LINE m = min ( h * W , ( ( H - h ) // 2 ) * ( W ) , ceil ( ( H - h ) / 2 ) * ( W ) ) NEW_LINE M = max ( h * W , ( ( H - h ) // 2 ) * ( W ) , ceil ( ( H - h ) / 2 ) * ( W ) ) NEW_LINE ans = min ( ans , M - m ) NEW_LINE DEDENT for w in range ( 1 , W ) : NEW_LINE INDENT m = min ( w * H , ( W - w ) * ( H // 2 ) , ( W - w ) * ceil ( H / 2 ) ) NEW_LINE M = max ( w * H , ( W - w ) * ( H // 2 ) , ( W - w ) * ceil ( H / 2 ) ) NEW_LINE ans = min ( ans , M - m ) NEW_LINE m = min ( w * H , ( ( W - w ) // 2 ) * H , ceil ( ( W - w ) / 2 ) * H ) NEW_LINE M = max ( w * H , ( ( W - w ) // 2 ) * H , ceil ( ( W - w ) / 2 ) * H ) NEW_LINE ans = min ( ans , M - m ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "H , W = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE ans = float ( \" inf \" ) NEW_LINE for i in range ( 1 , H ) : NEW_LINE INDENT a , b = ( i , W ) NEW_LINE S = W * ( H - i ) NEW_LINE if a % 2 == 0 or b % 2 == 0 : NEW_LINE INDENT ans = min ( ans , abs ( S - a * b // 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if a == 1 and b == 1 : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT Sbig = ( max ( a , b ) + 1 ) * min ( a , b ) // 2 NEW_LINE Ssma = ( max ( a , b ) - 1 ) * min ( a , b ) // 2 NEW_LINE Sdiff = max ( abs ( S - Sbig ) , abs ( S - Ssma ) , abs ( Sbig - Ssma ) ) NEW_LINE ans = min ( ans , Sdiff ) NEW_LINE DEDENT DEDENT DEDENT H , W = ( W , H ) NEW_LINE for i in range ( 1 , H ) : NEW_LINE INDENT a , b = ( i , W ) NEW_LINE S = W * ( H - i ) NEW_LINE if a % 2 == 0 or b % 2 == 0 : NEW_LINE INDENT ans = min ( ans , abs ( S - a * b // 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if a == 1 and b == 1 : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT Sbig = ( max ( a , b ) + 1 ) * min ( a , b ) // 2 NEW_LINE Ssma = ( max ( a , b ) - 1 ) * min ( a , b ) // 2 NEW_LINE Sdiff = max ( abs ( S - Sbig ) , abs ( S - Ssma ) , abs ( Sbig - Ssma ) ) NEW_LINE ans = min ( ans , Sdiff ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE H , W = inpl ( ) NEW_LINE if H % 3 == 0 or W % 3 == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT if H == 2 or W == 2 : NEW_LINE INDENT print ( 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT a = W // 3 NEW_LINE b = W % 3 NEW_LINE c = H // 3 NEW_LINE d = H % 3 NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( b + 1 ) : NEW_LINE INDENT ans = min ( ans , max ( H * ( a + i ) , ( H // 2 + H % 2 ) * ( W - a - i ) , ( H // 2 ) * ( W - a - i ) ) - min ( H * ( a + i ) , ( H // 2 + H % 2 ) * ( W - a - i ) , ( H // 2 ) * ( W - a - i ) ) ) NEW_LINE DEDENT for i in range ( d + 1 ) : NEW_LINE INDENT ans = min ( ans , max ( W * ( c + i ) , ( W // 2 + W % 2 ) * ( H - c - i ) , ( W // 2 ) * ( H - c - i ) ) - min ( W * ( c + i ) , ( W // 2 + W % 2 ) * ( H - c - i ) , ( W // 2 ) * ( H - c - i ) ) ) NEW_LINE DEDENT print ( min ( ans , H , W ) ) NEW_LINE" ]
atcoder_abc001_A
[ "import java . util . Scanner ; public static void main ( String [ ] args ) { private static void q_1 ( ) { }", "import java . io . * ; int h1 = Integer . parseInt ( br . readLine ( ) ) ;", "import java . util . Scanner ; Main main = new Main ( ) ; sc . close ( ) ; int s = sc . nextInt ( ) ;", "import java . io . PrintWriter ; public static void main ( String args [ ] ) { int answer = 0 ; }", "import java . util . Scanner ; Scanner scanner = new Scanner ( System . in ) ; }" ]
[ "h1 = int ( input ( ) ) NEW_LINE h2 = int ( input ( ) ) NEW_LINE print ( h1 - h2 ) NEW_LINE", "print ( int ( input ( ) ) - int ( input ( ) ) ) NEW_LINE", "import sys NEW_LINE h1 = int ( sys . stdin . readline ( ) ) NEW_LINE h2 = int ( sys . stdin . readline ( ) ) NEW_LINE print ( h1 - h2 ) NEW_LINE", "H1 , H2 = [ int ( input ( ) ) for _ in range ( 2 ) ] NEW_LINE print ( H1 - H2 ) NEW_LINE", "a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( \" { } \" . format ( a - b ) ) NEW_LINE" ]
atcoder_abc122_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; if ( line . equals ( \" A \" ) ) { System . out . println ( \" T \" ) ; } else if ( line . equals ( \" T \" ) ) { System . out . println ( \" A \" ) ; } else if ( line . equals ( \" C \" ) ) { System . out . println ( \" G \" ) ; } else if ( line . equals ( \" G \" ) ) { System . out . println ( \" C \" ) ; } } }", "import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s1 = sc . next ( ) ; if ( s1 . equals ( \" A \" ) ) { s1 = \" T \" ; } else if ( s1 . equals ( \" T \" ) ) { s1 = \" A \" ; } if ( s1 . equals ( \" G \" ) ) { s1 = \" C \" ; } else if ( s1 . equals ( \" C \" ) ) { s1 = \" G \" ; } System . out . println ( s1 ) ; System . out . flush ( ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String b = sc . nextLine ( ) ; String str = \" \" ; switch ( b ) { case \" A \" : str = \" T \" ; break ; case \" T \" : str = \" A \" ; break ; case \" C \" : str = \" G \" ; break ; case \" G \" : str = \" C \" ; break ; default : break ; } System . out . println ( str ) ; } }", "import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Main main = new Main ( ) ; main . start ( ) ; } public void start ( ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; if ( str . equals ( \" A \" ) ) System . out . println ( \" T \" ) ; if ( str . equals ( \" T \" ) ) System . out . println ( \" A \" ) ; if ( str . equals ( \" C \" ) ) System . out . println ( \" G \" ) ; if ( str . equals ( \" G \" ) ) System . out . println ( \" C \" ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int x = 0 ; try { x = System . in . read ( ) ; } catch ( IOException e ) { System . err . println ( \" ? ? ? ? ? ? ? ? \" ) ; } System . out . println ( ( char ) x == ' A ' ? \" T \" : ( char ) x == ' T ' ? \" A \" : ( char ) x == ' C ' ? \" G \" : \" C \" ) ; } }" ]
[ "a = str ( input ( ) ) NEW_LINE x = { \" A \" : \" T \" , \" T \" : \" A \" , \" C \" : \" G \" , \" G \" : \" C \" } NEW_LINE print ( x [ a ] ) NEW_LINE", "b = input ( ) NEW_LINE if b == ' A ' : NEW_LINE INDENT output = ' T ' NEW_LINE DEDENT elif b == ' C ' : NEW_LINE INDENT output = ' G ' NEW_LINE DEDENT elif b == ' G ' : NEW_LINE INDENT output = ' C ' NEW_LINE DEDENT elif b == ' T ' : NEW_LINE INDENT output = ' A ' NEW_LINE DEDENT else : NEW_LINE INDENT pass NEW_LINE DEDENT print ( output ) NEW_LINE", "import sys NEW_LINE def i2s ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) . rstrip ( ) NEW_LINE DEDENT def ii2ss ( n ) : NEW_LINE INDENT return [ sys . stdin . readline ( ) for _ in range ( n ) ] NEW_LINE DEDENT def sp2nn ( sp , sep = ' ▁ ' ) : NEW_LINE INDENT return [ int ( s ) for s in sp . split ( sep ) ] NEW_LINE DEDENT def ss2nn ( ss ) : NEW_LINE INDENT return [ int ( s ) for s in list ( ss ) ] NEW_LINE DEDENT def main ( s ) : NEW_LINE INDENT dic = { ' A ' : ' T ' , ' T ' : ' A ' , ' C ' : ' G ' , ' G ' : ' C ' , } NEW_LINE print ( dic [ s ] ) NEW_LINE DEDENT main ( i2s ( ) ) NEW_LINE", "enki = input ( ) NEW_LINE if ( enki == \" A \" ) : NEW_LINE INDENT print ( \" T \" ) NEW_LINE DEDENT elif ( enki == \" T \" ) : NEW_LINE INDENT print ( \" A \" ) NEW_LINE DEDENT elif ( enki == \" G \" ) : NEW_LINE INDENT print ( \" C \" ) NEW_LINE DEDENT elif ( enki == \" C \" ) : NEW_LINE INDENT print ( \" G \" ) NEW_LINE DEDENT", "b = str ( input ( ) ) NEW_LINE if b == ' A ' : NEW_LINE INDENT print ( \" T \" ) NEW_LINE DEDENT elif b == ' C ' : NEW_LINE INDENT print ( ' G ' ) NEW_LINE DEDENT elif b == ' G ' : NEW_LINE INDENT print ( ' C ' ) NEW_LINE DEDENT elif b == ' T ' : NEW_LINE INDENT print ( ' A ' ) NEW_LINE DEDENT" ]
atcoder_arc053_A
[ "import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; System . out . println ( ( h - 1 ) * w + h * ( w - 1 ) ) ; } }", "import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] __ ) { int x = getInt ( ) , y = getInt ( ) ; System . out . println ( ( x - 1 ) * y + x * ( y - 1 ) ) ; } }", "import java . util . Scanner ; public class Main { static Scanner in ; void solve ( ) { int h = in . nextInt ( ) , w = in . nextInt ( ) ; if ( h * w == 1 ) { System . out . println ( 0 ) ; return ; } if ( h == 1 ) { System . out . println ( w - 1 ) ; return ; } if ( w == 1 ) { System . out . println ( h - 1 ) ; return ; } System . out . println ( ( ( h - 1 ) * w + h * ( w - 1 ) ) ) ; } public static void main ( String [ ] args ) { in = new Scanner ( System . in ) ; new Main ( ) . solve ( ) ; } }", "import java . util . * ; public class Main { static int count = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int ans = 0 ; if ( h >= 2 ) { ans += ( h - 1 ) * w ; } if ( w >= 2 ) { ans += ( w - 1 ) * h ; } System . out . println ( ans ) ; } }", "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 ans = 0 ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; ans += 4 * 2 + 3 * ( h - 2 + w - 2 ) * 2 + 4 * ( h - 2 ) * ( w - 2 ) ; ans /= 2 ; System . out . println ( ans ) ; } }" ]
[ "W , H = map ( int , input ( ) . split ( ) ) NEW_LINE res = ( W - 1 ) * H + ( H - 1 ) * W NEW_LINE print ( res ) NEW_LINE", "H , W = map ( int , input ( ) . split ( ) ) NEW_LINE if H == 1 and W == 1 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT elif H == 1 : NEW_LINE INDENT ans = W - 1 NEW_LINE DEDENT elif W == 1 : NEW_LINE INDENT ans = H - 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( H - 1 ) * W + H * ( W - 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT h , w = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 2 * ( h - 1 ) * ( w - 1 ) + h - 1 + w - 1 ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def ma ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE a , b = ma ( ) NEW_LINE print ( ( a - 1 ) * b + a * ( b - 1 ) ) NEW_LINE", "H , W = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( W - 1 ) * H + ( H - 1 ) * W ) NEW_LINE" ]
atcoder_arc053_B
[ "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Printer pr = new Printer ( System . out ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int [ ] cnt = new int [ 26 ] ; for ( char c : s ) { cnt [ c - ' a ' ] ++ ; } int odd = 0 ; for ( int e : cnt ) { if ( e % 2 == 1 ) { odd ++ ; } } if ( odd == 0 ) { pr . println ( s . length ) ; } else { pr . println ( Math . max ( 1 , ( s . length - odd ) / 2 / odd * 2 + 1 ) ) ; } pr . close ( ) ; sc . close ( ) ; } @ SuppressWarnings ( \" unused \" ) private static class Scanner { BufferedReader br ; Iterator < String > it ; Scanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; } String next ( ) throws RuntimeException { try { if ( it == null || ! it . hasNext ( ) ) { it = Arrays . asList ( br . readLine ( ) . split ( \" ▁ \" ) ) . iterator ( ) ; } return it . next ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( ) ; } } int nextInt ( ) throws RuntimeException { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) throws RuntimeException { return Long . parseLong ( next ( ) ) ; } float nextFloat ( ) throws RuntimeException { return Float . parseFloat ( next ( ) ) ; } double nextDouble ( ) throws RuntimeException { return Double . parseDouble ( next ( ) ) ; } void close ( ) { try { br . close ( ) ; } catch ( IOException e ) { } } } private static class Printer extends PrintWriter { Printer ( PrintStream out ) { super ( out ) ; } } }", "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 ) ; String s = sc . next ( ) ; int [ ] alpha = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { alpha [ i ] = 0 ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { alpha [ ( s . charAt ( i ) ) - 97 ] ++ ; } int kisu = 0 ; int use = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( alpha [ i ] % 2 == 1 ) { use += alpha [ i ] - 1 ; kisu ++ ; } else { use += alpha [ i ] ; } } if ( kisu == 0 ) { System . out . println ( ( use ) ) ; } else { System . out . println ( ( 1 + 2 * ( use / ( kisu * 2 ) ) ) ) ; } } 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 ( ) ) ; } } }", "import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; ArrayList < Character > chars = new ArrayList < Character > ( ) ; int one = 0 ; int two = 0 ; int n = 0 ; chars . add ( str . toCharArray ( ) [ 0 ] ) ; for ( char x : str . toCharArray ( ) ) { int count = 0 ; boolean flag = true ; for ( int i = 0 ; i < chars . size ( ) ; i ++ ) { if ( chars . get ( i ) == x ) { flag = false ; } } if ( flag || n == 0 ) { chars . add ( x ) ; for ( char y : str . toCharArray ( ) ) { if ( x == y ) count ++ ; } } two += count / 2 ; one += count % 2 ; n ++ ; } int minLength = two ; if ( one != 0 ) minLength = two / one ; minLength *= 2 ; if ( one > 0 ) minLength += 1 ; System . out . println ( minLength ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] count = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count [ s . charAt ( i ) - ' a ' ] ++ ; } int divnum = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( count [ i ] % 2 != 0 ) { divnum ++ ; count [ i ] -- ; } } int sum = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { sum += count [ i ] ; } if ( divnum == 0 ) { divnum = 1 ; System . out . println ( 2 * ( sum / 2 / divnum ) ) ; return ; } else { System . out . println ( 2 * ( sum / 2 / divnum ) + 1 ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . nextLine ( ) . toCharArray ( ) ; int [ ] d = new int [ 26 ] ; for ( int i = 0 ; i < s . length ; i ++ ) { int c = ( int ) s [ i ] - ( int ) ' a ' ; d [ c ] += 1 ; } int odd = 0 ; int eve = 0 ; for ( int i = 0 ; i < d . length ; i ++ ) { int t = d [ i ] ; if ( t > 0 ) { eve += t / 2 ; odd += t % 2 ; } } if ( odd > 0 ) { System . out . println ( eve / odd * 2 + 1 ) ; } else { System . out . println ( s . length ) ; } } }" ]
[ "S = list ( map ( lambda x : ord ( x ) - ord ( ' a ' ) , list ( input ( ) ) ) ) NEW_LINE c = [ 0 ] * 26 NEW_LINE for s in S : NEW_LINE INDENT c [ s ] += 1 NEW_LINE DEDENT pair = 0 NEW_LINE odd = 0 NEW_LINE for n in c : NEW_LINE INDENT if n % 2 == 1 : NEW_LINE INDENT odd += 1 NEW_LINE DEDENT pair += n // 2 NEW_LINE DEDENT if odd == 0 : NEW_LINE INDENT print ( len ( S ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( pair // odd * 2 + 1 ) NEW_LINE DEDENT", "from collections import Counter NEW_LINE a = Counter ( list ( input ( ) . strip ( ) ) ) NEW_LINE x = 0 NEW_LINE y = 0 NEW_LINE for i , j in a . most_common ( ) : NEW_LINE INDENT x += j // 2 NEW_LINE if j % 2 == 1 : NEW_LINE INDENT y += 1 NEW_LINE DEDENT DEDENT print ( x // y * 2 + 1 if y >= 1 else x * 2 ) NEW_LINE", "s = input ( ) NEW_LINE lis = [ ] NEW_LINE num = [ ] NEW_LINE cou = 0 NEW_LINE even = 0 NEW_LINE for n in range ( len ( s ) ) : NEW_LINE INDENT if s [ n ] in lis : continue NEW_LINE else : NEW_LINE INDENT num . append ( s . count ( s [ n ] ) ) NEW_LINE lis . append ( s [ n ] ) NEW_LINE DEDENT DEDENT for item in num : NEW_LINE INDENT cou += item % 2 NEW_LINE even += item NEW_LINE DEDENT even -= cou NEW_LINE if cou == 0 : NEW_LINE INDENT print ( int ( len ( s ) ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( even / ( 2 * cou ) ) * 2 + 1 ) NEW_LINE DEDENT", "def b_splited_palindrome ( S ) : NEW_LINE INDENT from collections import Counter NEW_LINE num_charactor_appeared = Counter ( S ) NEW_LINE num_appeared_odd_time = len ( [ 1 for v in num_charactor_appeared . values ( ) if v % 2 == 1 ] ) NEW_LINE ans = len ( S ) if num_appeared_odd_time == 0 else 2 * ( ( len ( S ) - num_appeared_odd_time ) // ( 2 * num_appeared_odd_time ) ) + 1 NEW_LINE return ans NEW_LINE DEDENT S = input ( ) NEW_LINE print ( b_splited_palindrome ( S ) ) NEW_LINE", "from collections import defaultdict NEW_LINE S = list ( input ( ) ) NEW_LINE N = len ( S ) NEW_LINE cnt = defaultdict ( int ) NEW_LINE for c in S : NEW_LINE INDENT cnt [ c ] += 1 NEW_LINE DEDENT K = 0 NEW_LINE for value in cnt . values ( ) : NEW_LINE INDENT if value % 2 != 0 : NEW_LINE INDENT K += 1 NEW_LINE DEDENT DEDENT res = 0 NEW_LINE if K == 0 : NEW_LINE INDENT res = N NEW_LINE DEDENT else : NEW_LINE INDENT res = 2 * ( ( N - K ) // ( 2 * K ) ) + 1 NEW_LINE DEDENT print ( res ) NEW_LINE" ]
atcoder_abc102_A
[ "import java . io . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; long num = sc . nextLong ( ) ; if ( num % 2 == 0 && num % num == 0 ) System . out . println ( num ) ; else System . out . println ( num * 2 ) ; } }", "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 ( ) ; out . println ( n % 2 == 0 ? n : n * 2 ) ; } 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 . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numN = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; if ( numN % 2 == 0 ) { System . out . println ( numN ) ; } else { System . out . println ( numN * 2 ) ; } System . out . println ( \" \" ) ; } 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = input . readLine ( ) ; int n = Integer . parseInt ( line ) ; System . out . println ( ( n % 2 == 0 ) ? n : n * 2 ) ; } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n % 2 != 0 ) n *= 2 ; System . out . println ( n ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE if n % 2 == 1 : NEW_LINE INDENT ans = n * 2 NEW_LINE DEDENT else : NEW_LINE INDENT ans = n NEW_LINE DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE print ( N if N % 2 == 0 else N * 2 ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE import fractions as f NEW_LINE g = f . gcd ( 2 , N ) NEW_LINE print ( int ( 2 * N / g ) ) NEW_LINE", "def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE print ( N ) if N % 2 == 0 else print ( N * 2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE c = 1 NEW_LINE while True : NEW_LINE INDENT if ( n * c ) % 2 == 0 : NEW_LINE INDENT print ( n * c ) NEW_LINE break NEW_LINE DEDENT c += 1 NEW_LINE DEDENT" ]
atcoder_abc057_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int m = ( int ) Math . sqrt ( N ) ; int ans = 100 ; for ( int i = m ; i > 0 ; i -- ) { if ( N % i == 0 ) { long A = i ; long B = N / i ; int count = 0 ; while ( A > 0 || B > 0 ) { A /= 10 ; B /= 10 ; count ++ ; } ans = Math . min ( ans , count ) ; break ; } } System . out . println ( ans ) ; } }", "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 divide1 = ( long ) Math . sqrt ( N ) ; while ( N % divide1 != 0 ) { divide1 -- ; } long divide2 = N / divide1 ; int len1 = String . valueOf ( divide1 ) . length ( ) ; int len2 = String . valueOf ( divide2 ) . length ( ) ; out . println ( Math . max ( len1 , len2 ) ) ; } }", "import java . io . PrintStream ; import java . util . Scanner ; import java . util . stream . LongStream ; public class Main { static int F ( long A , long B ) { return Math . max ( Long . toString ( A ) . length ( ) , Long . toString ( B ) . length ( ) ) ; } static void exec ( Scanner in , PrintStream out ) { long N = in . nextLong ( ) ; int min = LongStream . rangeClosed ( 1 , ( long ) Math . sqrt ( N ) ) . filter ( A -> N % A == 0 ) . mapToInt ( A -> F ( A , N / A ) ) . min ( ) . getAsInt ( ) ; out . println ( min ) ; } public static void main ( String [ ] args ) { exec ( new Scanner ( System . in ) , System . out ) ; } }", "import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { long N = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; long rootN = ( long ) Math . sqrt ( N ) ; for ( long i = 1 ; i <= rootN ; i ++ ) { long muti = N / i ; if ( N % i == 0 ) { ans = Math . min ( ans , digit ( muti ) ) ; } } System . out . println ( ans ) ; } private static int digit ( long n ) { return String . valueOf ( n ) . length ( ) ; } }", "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 ) ; long n = sc . nextLong ( ) ; long s = ( long ) sqrt ( n ) + 1 ; int ans = 100 ; for ( long i = 1 ; i <= s ; i ++ ) { if ( n % i == 0 ) ans = min ( F ( i , n / i ) , ans ) ; } out . println ( ans ) ; } static int F ( long A , long B ) { return max ( get ( A ) , get ( B ) ) ; } static int get ( long n ) { int c = 1 ; while ( n / 10 > 0 ) { c ++ ; n /= 10 ; } return c ; } }" ]
[ "def getdigit ( N ) : NEW_LINE INDENT cnt = 0 NEW_LINE while ( N > 0 ) : NEW_LINE INDENT cnt += 1 NEW_LINE N //= 10 NEW_LINE DEDENT return cnt NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE for i in reversed ( range ( 1 , int ( pow ( N , 1 / 2 ) ) + 1 ) ) : NEW_LINE INDENT if ( N % i == 0 ) : NEW_LINE INDENT print ( max ( getdigit ( i ) , getdigit ( N / i ) ) ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT", "import math NEW_LINE n = int ( input ( ) ) NEW_LINE A = [ 0 ] NEW_LINE i = 1 NEW_LINE while i <= math . sqrt ( n ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT A . append ( i ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT B = [ 0 ] NEW_LINE s = [ ] NEW_LINE for i in range ( len ( A ) - 1 ) : NEW_LINE INDENT j = int ( n / A [ i + 1 ] ) NEW_LINE B . append ( j ) NEW_LINE a = len ( str ( A [ i + 1 ] ) ) NEW_LINE b = len ( str ( B [ i + 1 ] ) ) NEW_LINE s . append ( max ( a , b ) ) NEW_LINE DEDENT ans = min ( s ) NEW_LINE print ( ans ) NEW_LINE", "import math NEW_LINE num = int ( input ( ) ) NEW_LINE num_sqrt = int ( math . sqrt ( num ) ) NEW_LINE ans = 11 NEW_LINE for A in range ( 1 , num_sqrt + 1 ) : NEW_LINE INDENT if num % A == 0 : NEW_LINE INDENT B = int ( num / A ) NEW_LINE A , B = str ( A ) , str ( B ) NEW_LINE now_ans = max ( len ( A ) , len ( B ) ) NEW_LINE ans = min ( ans , now_ans ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE def f ( a , b ) : NEW_LINE INDENT return max ( len ( str ( a ) ) , len ( str ( b ) ) ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE n = int ( N ** 0.5 ) NEW_LINE ans = 11 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if N % i == 0 : NEW_LINE INDENT ans = min ( ans , f ( i , N // i ) ) NEW_LINE DEDENT 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 pf_list = [ ] NEW_LINE min_digit = float ( ' inf ' ) NEW_LINE for i in range ( 1 , int ( math . sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT a = len ( str ( int ( i ) ) ) NEW_LINE b = len ( str ( int ( n / i ) ) ) NEW_LINE tmp_list = [ a , b ] NEW_LINE tmp_list = list ( map ( int , tmp_list ) ) NEW_LINE if min_digit > max ( tmp_list ) : NEW_LINE INDENT min_digit = max ( tmp_list ) NEW_LINE DEDENT DEDENT DEDENT print ( min_digit ) NEW_LINE" ]
atcoder_arc028_C
[ "import java . util . * ; public class Main { static int N ; static ArrayList < Integer > [ ] list ; static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; list = new ArrayList [ N ] ; dp = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { list [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 1 ; i < N ; i ++ ) { int x = sc . nextInt ( ) ; list [ x ] . add ( i ) ; } dfs ( 0 ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int ans = N - dp [ i ] ; for ( int item : list [ i ] ) { ans = Math . max ( ans , dp [ item ] ) ; } sb . append ( ans + \" \\n \" ) ; } System . out . print ( sb ) ; } static int dfs ( int now ) { int res = 1 ; for ( int next : list [ now ] ) { res += dfs ( next ) ; } return dp [ now ] = res ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "def solve ( n , p , c ) : NEW_LINE INDENT d = [ 1 ] * n NEW_LINE b = [ 0 ] * n NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if 0 <= p [ i ] : NEW_LINE INDENT d [ p [ i ] ] += d [ i ] NEW_LINE DEDENT if len ( c [ i ] ) : NEW_LINE INDENT m = n - d [ i ] if i != 0 else 0 NEW_LINE for j in c [ i ] : NEW_LINE INDENT m = max ( m , d [ j ] ) NEW_LINE DEDENT b [ i ] = m NEW_LINE DEDENT else : NEW_LINE INDENT b [ i ] = n - 1 NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT print ( b [ i ] ) NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT n = input ( ) NEW_LINE n = int ( n ) NEW_LINE p = [ - 1 ] * n NEW_LINE c = [ [ ] for _ in range ( n ) ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT pi = input ( ) NEW_LINE pi = int ( pi ) NEW_LINE p [ i ] = pi NEW_LINE c [ pi ] . append ( i ) NEW_LINE DEDENT solve ( n , p , c ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 200000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE edges = [ [ ] for _ in [ 0 ] * N ] NEW_LINE for i , v in enumerate ( map ( int , sys . stdin ) , start = 1 ) : NEW_LINE INDENT edges [ i ] . append ( v ) NEW_LINE edges [ v ] . append ( i ) NEW_LINE DEDENT balance = [ 0 ] * N NEW_LINE def rec ( v , prev ) : NEW_LINE INDENT total , max_count = 0 , 0 NEW_LINE for to_v in edges [ v ] : NEW_LINE INDENT if to_v != prev : NEW_LINE INDENT part = rec ( to_v , v ) NEW_LINE total , max_count = total + part , max ( max_count , part ) NEW_LINE DEDENT DEDENT balance [ v ] = max ( max_count , N - 1 - total ) NEW_LINE return total + 1 NEW_LINE DEDENT rec ( 0 , - 1 ) NEW_LINE print ( * balance , sep = \" \\n \" ) NEW_LINE" ]
atcoder_abc036_D
[ "import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { int N ; List < Integer > [ ] rinsetsu ; int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; rinsetsu = new List [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { rinsetsu [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; rinsetsu [ a ] . add ( b ) ; rinsetsu [ b ] . add ( a ) ; } System . out . println ( dfs ( 0 , - 1 ) [ 0 ] ) ; } int [ ] dfs ( int cur , int parent ) { int whole = 1 ; int black = 1 ; for ( int i = 0 ; i < rinsetsu [ cur ] . size ( ) ; i ++ ) { if ( rinsetsu [ cur ] . get ( i ) != parent ) { int [ ] child = dfs ( rinsetsu [ cur ] . get ( i ) , cur ) ; whole = ( int ) ( ( long ) whole * child [ 0 ] % mod ) ; black = ( int ) ( ( long ) black * child [ 1 ] % mod ) ; } } int [ ] ret = new int [ 2 ] ; ret [ 0 ] = ( int ) ( ( ( long ) whole + black ) % mod ) ; ret [ 1 ] = whole ; return ret ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . * ; public class Main { static long mod = 1000000000 + 7 ; static ArrayList < Integer > [ ] map ; static long [ ] white ; static long [ ] black ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; map = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) map [ i ] = new ArrayList < > ( ) ; black = new long [ n + 1 ] ; white = new long [ n + 1 ] ; for ( int i = 1 ; i < n ; i ++ ) { int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; map [ a ] . add ( b ) ; map [ b ] . add ( a ) ; } boolean [ ] vis = new boolean [ n + 1 ] ; long ans = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( vis [ i ] ) continue ; dfs ( i , vis ) ; ans = ans * ( black [ i ] + white [ i ] ) % mod ; } System . out . println ( ans ) ; } static void dfs ( int i , boolean [ ] vis ) { vis [ i ] = true ; black [ i ] = white [ i ] = 1 ; for ( int w : map [ i ] ) { if ( vis [ w ] ) continue ; dfs ( w , vis ) ; white [ i ] = white [ i ] * ( white [ w ] + black [ w ] ) % mod ; black [ i ] = black [ i ] * white [ w ] % mod ; } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { private static final long M = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; Node [ ] nodes = new Node [ N ] ; for ( int i = 0 ; i < N ; i ++ ) nodes [ i ] = new Node ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = scanner . nextInt ( ) - 1 ; int b = scanner . nextInt ( ) - 1 ; nodes [ a ] . neighbors . add ( nodes [ b ] ) ; nodes [ b ] . neighbors . add ( nodes [ a ] ) ; } long [ ] count = dfs ( nodes [ 0 ] ) ; System . out . println ( ( count [ 0 ] + count [ 1 ] ) % M ) ; } private static long [ ] dfs ( Node node ) { node . visited = true ; long [ ] count = new long [ ] { 1 , 1 } ; for ( Node n : node . neighbors ) { if ( ! n . visited ) { long [ ] c = dfs ( n ) ; count [ 0 ] *= ( c [ 0 ] + c [ 1 ] ) % M ; count [ 0 ] %= M ; count [ 1 ] *= c [ 0 ] ; count [ 1 ] %= M ; } } return count ; } private static class Node { final List < Node > neighbors = new ArrayList < > ( ) ; boolean visited ; } }" ]
[ "import sys NEW_LINE from collections import defaultdict as dd NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE d = dd ( list ) NEW_LINE mod = 1000000007 NEW_LINE n = int ( input ( ) ) NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE d [ a ] . append ( b ) NEW_LINE d [ b ] . append ( a ) NEW_LINE DEDENT d = dict ( d ) NEW_LINE f = [ None ] * ( n + 1 ) NEW_LINE g = [ None ] * ( n + 1 ) NEW_LINE def dfs ( p , x ) : NEW_LINE INDENT for i in d [ x ] : NEW_LINE INDENT if i != p : NEW_LINE INDENT dfs ( x , i ) NEW_LINE DEDENT DEDENT f [ x ] , g [ x ] = 1 , 1 NEW_LINE for i in d [ x ] : NEW_LINE INDENT if i != p : NEW_LINE INDENT g [ x ] *= f [ i ] NEW_LINE g [ x ] %= mod NEW_LINE f [ x ] *= g [ i ] NEW_LINE f [ x ] %= mod NEW_LINE DEDENT DEDENT f [ x ] += g [ x ] NEW_LINE f [ x ] %= mod NEW_LINE DEDENT dfs ( - 1 , 1 ) NEW_LINE print ( f [ 1 ] ) NEW_LINE", "from collections import Counter NEW_LINE def cal ( N , bridges ) : NEW_LINE INDENT mod = 10 ** 9 + 7 NEW_LINE bridge_cnt = Counter ( ) NEW_LINE bw_list = [ [ 1 , 1 ] for _ in range ( N + 1 ) ] NEW_LINE con_list = [ [ ] for _ in range ( N + 1 ) ] NEW_LINE for l , r in bridges : NEW_LINE INDENT bridge_cnt [ r ] += 1 NEW_LINE bridge_cnt [ l ] += 1 NEW_LINE con_list [ l ] . append ( r ) NEW_LINE con_list [ r ] . append ( l ) NEW_LINE DEDENT root = bridges [ 0 ] [ 0 ] NEW_LINE def update ( cur , parent ) : NEW_LINE INDENT for child in con_list [ cur ] : NEW_LINE INDENT if child == parent : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT update ( child , cur ) NEW_LINE DEDENT bw_list [ cur ] [ 0 ] = ( bw_list [ cur ] [ 0 ] * bw_list [ child ] [ 1 ] ) NEW_LINE bw_list [ cur ] [ 1 ] = ( bw_list [ cur ] [ 1 ] * ( bw_list [ child ] [ 0 ] + bw_list [ child ] [ 1 ] ) ) NEW_LINE DEDENT DEDENT update ( root , 0 ) NEW_LINE return max ( [ sum ( bw ) for bw in bw_list ] ) % mod NEW_LINE DEDENT import sys NEW_LINE stdin = sys . stdin 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 td = [ tuple ( li ( ) ) for _ in range ( n - 1 ) ] NEW_LINE print ( cal ( n , td ) ) NEW_LINE", "import string NEW_LINE import sys NEW_LINE from collections import defaultdict NEW_LINE from itertools import chain , takewhile NEW_LINE def read ( f , * shape , it = chain . from_iterable ( sys . stdin ) , whitespaces = set ( string . whitespace ) ) : NEW_LINE INDENT def read_word ( ) : NEW_LINE INDENT return f ( \" \" . join ( takewhile ( lambda c : c not in whitespaces , it ) ) . strip ( ) ) NEW_LINE DEDENT if not shape : NEW_LINE INDENT return read_word ( ) NEW_LINE DEDENT elif len ( shape ) == 1 : NEW_LINE INDENT return [ read_word ( ) for _ in range ( shape [ 0 ] ) ] NEW_LINE DEDENT elif len ( shape ) == 2 : NEW_LINE INDENT return [ [ read_word ( ) for _ in range ( shape [ 1 ] ) ] for _ in range ( shape [ 0 ] ) ] NEW_LINE DEDENT DEDENT def arr ( * shape , fill_value = 0 ) : NEW_LINE INDENT if len ( shape ) == 1 : NEW_LINE INDENT return [ fill_value ] * shape [ fill_value ] NEW_LINE DEDENT elif len ( shape ) == 2 : NEW_LINE INDENT return [ [ fill_value ] * shape [ 1 ] for _ in range ( shape [ 0 ] ) ] NEW_LINE DEDENT DEDENT def debug ( ** kwargs ) : NEW_LINE INDENT print ( \" , ▁ \" . join ( \" { } ▁ = ▁ { } \" . format ( k , repr ( v ) ) for k , v in kwargs . items ( ) ) , file = sys . stderr , ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n = read ( int ) NEW_LINE G = defaultdict ( list ) NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b = read ( int , 2 ) NEW_LINE G [ a ] . append ( b ) NEW_LINE G [ b ] . append ( a ) NEW_LINE DEDENT MOD = 1000000000 + 7 NEW_LINE def dfs ( cur , prev ) : NEW_LINE INDENT w , b = 1 , 1 NEW_LINE for node in G [ cur ] : NEW_LINE INDENT if node != prev : NEW_LINE INDENT w_child , b_child = dfs ( node , cur ) NEW_LINE w *= ( w_child + b_child ) % MOD NEW_LINE w %= MOD NEW_LINE b *= w_child NEW_LINE b %= MOD NEW_LINE DEDENT DEDENT return w , b NEW_LINE DEDENT w , b = dfs ( 1 , - 1 ) NEW_LINE print ( ( w + b ) % MOD ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def draw ( N : int , edges : list ) -> int : NEW_LINE INDENT MOD = 10 ** 9 + 7 NEW_LINE memo_f , memo_g = [ 0 ] * N , [ 0 ] * N NEW_LINE graph = [ [ ] for _ in range ( N ) ] NEW_LINE for u , v in edges : NEW_LINE INDENT graph [ u - 1 ] . append ( v - 1 ) NEW_LINE graph [ v - 1 ] . append ( u - 1 ) NEW_LINE DEDENT def f ( parent : int , v : int ) -> int : NEW_LINE INDENT if memo_f [ v ] : NEW_LINE INDENT return memo_f [ v ] NEW_LINE DEDENT memo_f [ v ] = 1 NEW_LINE for child in graph [ v ] : NEW_LINE INDENT if parent == child : NEW_LINE INDENT continue NEW_LINE DEDENT memo_f [ v ] = ( memo_f [ v ] * g ( v , child ) ) % MOD NEW_LINE DEDENT memo_f [ v ] = ( memo_f [ v ] + g ( parent , v ) ) % MOD NEW_LINE return memo_f [ v ] NEW_LINE DEDENT def g ( parent : int , v : int ) -> int : NEW_LINE INDENT if memo_g [ v ] : NEW_LINE INDENT return memo_g [ v ] NEW_LINE DEDENT memo_g [ v ] = 1 NEW_LINE for child in graph [ v ] : NEW_LINE INDENT if parent == child : NEW_LINE INDENT continue NEW_LINE DEDENT memo_g [ v ] = ( memo_g [ v ] * f ( v , child ) ) % MOD NEW_LINE DEDENT return memo_g [ v ] NEW_LINE DEDENT return f ( - 1 , 0 ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE edges = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( N - 1 ) ] NEW_LINE ans = draw ( N , edges ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE BR = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N - 1 ) ] NEW_LINE mod = 10 ** 9 + 7 NEW_LINE BRLIST = [ [ ] for i in range ( N + 1 ) ] NEW_LINE for x , y in BR : NEW_LINE INDENT BRLIST [ x ] . append ( y ) NEW_LINE BRLIST [ y ] . append ( x ) NEW_LINE DEDENT from collections import deque NEW_LINE QUE = deque ( ) NEW_LINE ANS = [ [ 0 , 0 ] for i in range ( N + 1 ) ] NEW_LINE USED = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if len ( BRLIST [ i ] ) == 1 : NEW_LINE INDENT QUE . append ( i ) NEW_LINE DEDENT DEDENT while QUE : NEW_LINE INDENT x = QUE . pop ( ) NEW_LINE if USED [ x ] == 1 : NEW_LINE INDENT continue NEW_LINE DEDENT NOUSES = 0 NEW_LINE for j in BRLIST [ x ] : NEW_LINE INDENT if USED [ j ] == 0 : NEW_LINE INDENT NOUSES += 1 NEW_LINE DEDENT DEDENT if NOUSES >= 2 : NEW_LINE INDENT QUE . appendleft ( x ) NEW_LINE continue NEW_LINE DEDENT W = 1 NEW_LINE B = 1 NEW_LINE for j in BRLIST [ x ] : NEW_LINE INDENT if USED [ j ] != 0 : NEW_LINE INDENT W = W * ( ANS [ j ] [ 0 ] + ANS [ j ] [ 1 ] ) % mod NEW_LINE B = B * ANS [ j ] [ 0 ] % mod NEW_LINE DEDENT else : NEW_LINE INDENT QUE . appendleft ( j ) NEW_LINE DEDENT DEDENT ANS [ x ] = [ W , B ] NEW_LINE USED [ x ] = 1 NEW_LINE DEDENT print ( sum ( ANS [ x ] ) % mod ) NEW_LINE" ]
atcoder_abc007_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String A = sc . next ( ) ; if ( A . equals ( \" a \" ) ) { System . out . println ( - 1 ) ; } else { System . out . println ( \" a \" ) ; } } }", "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 ( ) ; if ( s . equals ( \" a \" ) ) out . println ( - 1 ) ; else out . println ( \" a \" ) ; } } 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 . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String a = scanner . nextLine ( ) ; scanner . close ( ) ; String smaller = \" - 1\" ; if ( a . length ( ) != 1 ) { smaller = a . substring ( 0 , a . length ( ) - 1 ) ; } else { if ( ! a . equals ( \" a \" ) ) { ArrayList < String > alphabets = new ArrayList < String > ( ) ; int alphaSize = ' z ' - ' a ' ; char alpha = ' a ' ; for ( int i = 0 ; i <= alphaSize ; i ++ ) { alphabets . add ( String . valueOf ( alpha ) ) ; alpha ++ ; } int index = alphabets . indexOf ( a ) - 1 ; smaller = alphabets . get ( index ) ; } } System . out . println ( smaller ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try ( CustomReader in = new CustomReader ( ) ) { new Main ( ) . execute ( in ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } public void execute ( CustomReader in ) throws IOException { final char A = ' a ' ; final String S = in . readLine ( ) ; if ( S . length ( ) == 1 && S . charAt ( 0 ) == A ) { System . out . println ( \" - 1\" ) ; } else { System . out . println ( A ) ; } } static class CustomReader extends BufferedReader { private static final int DEFAULT_BUF_SIZE = 2048 ; public CustomReader ( ) throws IOException { super ( new InputStreamReader ( System . in ) , DEFAULT_BUF_SIZE ) ; } public int [ ] readLineAsIntArray ( ) throws IOException { String [ ] strArray = this . readLine ( ) . split ( \" ▁ \" ) ; int [ ] intArray = new int [ strArray . length ] ; for ( int i = 0 , n = strArray . length ; i < n ; i ++ ) { intArray [ i ] = Integer . parseInt ( strArray [ i ] ) ; } return intArray ; } public int [ ] [ ] readAsIntMatrix ( int rows , int columns ) throws IOException { int [ ] [ ] matrix = new int [ rows ] [ columns ] ; for ( int i = 0 ; i < rows ; i ++ ) { String [ ] r = this . readLine ( ) . split ( \" ▁ \" ) ; for ( int j = 0 ; j < columns ; j ++ ) { matrix [ i ] [ j ] = Integer . parseInt ( r [ j ] ) ; } } return matrix ; } } }", "public class Main { public static void main ( String [ ] args ) { System . out . println ( new java . util . Scanner ( System . in ) . next ( ) . equals ( \" a \" ) ? - 1 : \" a \" ) ; } }" ]
[ "a = list ( input ( ) ) NEW_LINE if a [ 0 ] == \" a \" and len ( a ) == 1 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" a \" ) NEW_LINE DEDENT", "print ( ' - 1' if input ( ) == ' a ' else ' a ' ) NEW_LINE", "a = str ( input ( ) ) NEW_LINE if a == \" a \" : NEW_LINE INDENT print ( \" - 1\" ) NEW_LINE DEDENT elif len ( a ) > 1 : NEW_LINE INDENT print ( a [ : len ( a ) - 1 ] ) NEW_LINE DEDENT else : print ( \" a \" ) NEW_LINE", "a = str ( input ( ) ) NEW_LINE if a == ' a ' : NEW_LINE INDENT ans = - 1 NEW_LINE print ( ans ) NEW_LINE DEDENT elif len ( a ) == 1 : NEW_LINE INDENT tmp = ord ( a ) - 1 NEW_LINE ans = chr ( tmp ) NEW_LINE print ( ans ) NEW_LINE DEDENT elif len ( a ) >= 2 : NEW_LINE INDENT ans = a [ : - 1 ] NEW_LINE print ( ans ) NEW_LINE DEDENT", "import sys NEW_LINE s = input ( ) NEW_LINE if s == ' a ' : NEW_LINE INDENT print ( - 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT if s [ 0 ] != ' a ' : NEW_LINE INDENT print ( ' a ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT print ( s [ : 1 ] ) NEW_LINE" ]
atcoder_arc050_B
[ "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 ) ; long r = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long low = 0 , high = min ( r , b ) + 1 , md , s , t ; long c , d , ans = 0 ; for ( int i = 0 ; i < 100 ; i ++ ) { md = ( low + high ) / 2 ; s = ( b - md ) / ( y - 1 ) ; t = ( r - md ) / ( x - 1 ) ; if ( md <= s + t ) { ans = md ; low = md ; } else high = md ; } 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 ; class Main { static long R ; static long B ; static long aka_hon ; static long ao_hon ; static long dekiru_max ; static long min ; static boolean dekiru ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; dekiru = false ; R = sc . nextLong ( ) ; B = sc . nextLong ( ) ; aka_hon = sc . nextLong ( ) ; ao_hon = sc . nextLong ( ) ; dekiru_max = Math . max ( R , B ) ; min = 0 ; long mid = ( min + dekiru_max ) / 2 ; while ( dekiru_max > 1 + min ) { dekiru = false ; mid = ( min + dekiru_max ) / 2 ; dekiru = Solve ( R , B , aka_hon , ao_hon , mid ) ; if ( dekiru == true ) { min = mid ; } else if ( dekiru == false ) { dekiru_max = mid ; } } System . out . println ( ( min + dekiru_max ) / 2 ) ; } static boolean Solve ( long a , long b , long c , long d , long wa ) { long aka = a - wa ; long ao = b - wa ; long po = aka / ( c - 1 ) + ao / ( d - 1 ) ; return aka >= 0 && ao >= 0 && po >= wa ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s = r . readLine ( ) ; String [ ] sl = s . split ( \" [ \\\\ s ] + \" ) ; long R = Long . parseLong ( sl [ 0 ] ) ; long B = Long . parseLong ( sl [ 1 ] ) ; s = r . readLine ( ) ; sl = s . split ( \" [ \\\\ s ] + \" ) ; long x = Long . parseLong ( sl [ 0 ] ) ; long y = Long . parseLong ( sl [ 1 ] ) ; long rl = 0 ; long rr = Math . min ( R , B ) + 1 ; while ( rr - rl >= 2 ) { long rm = ( rl + rr ) / 2 ; if ( ( R - rm ) / ( x - 1 ) + ( B - rm ) / ( y - 1 ) < rm ) { rr = rm ; } else { rl = rm ; } } System . out . println ( rl ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long r = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long ans = binSearch ( r , b , x , y ) ; System . out . println ( ans ) ; } public static long binSearch ( long r , long b , long x , long y ) { long ok = 0 ; long ng = Math . min ( r , b ) + 1 ; while ( Math . abs ( ok - ng ) > 1 ) { long mid = ( ok + ng ) / 2 ; if ( solve ( mid , r , b , x , y ) ) { ok = mid ; } else { ng = mid ; } } return ok ; } public static boolean solve ( long k , long r , long b , long x , long y ) { long rnum = ( r - k ) / ( x - 1 ) ; long bnum = ( b - k ) / ( y - 1 ) ; if ( rnum + bnum >= k ) { return true ; } return false ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; long r = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long Tmax = r + b + 1000L ; long Tmin = 0L ; long T = 0 ; while ( Tmax - Tmin > 1 ) { T = Tmin + ( Tmax - Tmin ) / 2 ; if ( r >= T && b >= T && ( r - T ) / ( x - 1 ) + ( b - T ) / ( y - 1 ) >= T ) { Tmin = T ; } else { Tmax = T ; } } long ans = Tmin ; System . out . println ( ans ) ; } }" ]
[ "R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if R / x < B / y : NEW_LINE INDENT R , B = B , R NEW_LINE x , y = y , x NEW_LINE DEDENT pmin = R // x NEW_LINE if B <= pmin : NEW_LINE INDENT pmin = B NEW_LINE pmax = B NEW_LINE DEDENT else : NEW_LINE INDENT pmax = pmin + ( B - pmin ) // y NEW_LINE point = ( pmax + pmin ) // 2 NEW_LINE DEDENT while pmin < pmax : NEW_LINE INDENT if ( R - point ) // ( x - 1 ) + ( B - point ) // ( y - 1 ) >= point : NEW_LINE INDENT pmin = point NEW_LINE point = ( pmax + point + 1 ) // 2 NEW_LINE DEDENT else : NEW_LINE INDENT pmax = point - 1 NEW_LINE point = ( pmin + point ) // 2 NEW_LINE DEDENT DEDENT print ( pmin ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE def check ( n : int ) -> bool : NEW_LINE INDENT rR = R - n NEW_LINE rB = B - n NEW_LINE if rR < 0 or rB < 0 : NEW_LINE INDENT return False NEW_LINE DEDENT return rR // ( x - 1 ) + rB // ( y - 1 ) >= n NEW_LINE DEDENT lower = 0 NEW_LINE upper = max ( R , B ) NEW_LINE while lower + 1 < upper : NEW_LINE INDENT mid = ( lower + upper ) // 2 NEW_LINE if check ( mid ) : NEW_LINE INDENT lower = mid NEW_LINE DEDENT else : NEW_LINE INDENT upper = mid NEW_LINE DEDENT DEDENT print ( lower ) NEW_LINE", "if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE ans = max ( ans , min ( R // x , B ) ) NEW_LINE ans = max ( ans , min ( R , B // y ) ) ; NEW_LINE if R * y - B >= 0 : NEW_LINE INDENT k = ( R * y - B ) // ( x * y - 1 ) ; NEW_LINE l = min ( R - k * x , ( B - k ) // y ) ; NEW_LINE if l >= 0 : NEW_LINE INDENT ans = max ( ans , k + l ) ; NEW_LINE DEDENT k += 1 NEW_LINE l = min ( R - k * x , ( B - k ) / y ) ; NEW_LINE if l >= 0 : NEW_LINE INDENT ans = max ( ans , k + l ) ; NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT", "def judge ( k ) : NEW_LINE INDENT global R , B , x , y NEW_LINE tr , tb , tx , ty = R - k , B - k , x - 1 , y - 1 NEW_LINE return tr // tx + tb // ty >= k NEW_LINE DEDENT R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE l , r = 0 , min ( R , B ) NEW_LINE nxt , prv = 0 , - 1 NEW_LINE while True : NEW_LINE INDENT nxt = ( l + r ) // 2 NEW_LINE if nxt == prv : NEW_LINE INDENT print ( nxt + 1 if judge ( nxt + 1 ) else nxt ) NEW_LINE break NEW_LINE DEDENT if judge ( nxt ) : NEW_LINE INDENT l = nxt NEW_LINE DEDENT else : NEW_LINE INDENT r = nxt NEW_LINE DEDENT prv = nxt NEW_LINE DEDENT", "def b_bouquet ( R , B , X , Y ) : NEW_LINE INDENT def can_make_bouquet ( k ) : NEW_LINE INDENT if k > R or k > B : NEW_LINE INDENT return False NEW_LINE DEDENT return ( R - k ) // ( X - 1 ) + ( B - k ) // ( Y - 1 ) >= k NEW_LINE DEDENT lower , upper = 0 , R + B NEW_LINE while upper - lower > 1 : NEW_LINE INDENT mid = ( lower + upper ) // 2 NEW_LINE if can_make_bouquet ( mid ) : NEW_LINE INDENT lower = mid NEW_LINE DEDENT else : NEW_LINE INDENT upper = mid NEW_LINE DEDENT DEDENT return lower NEW_LINE DEDENT R , B = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE X , Y = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( b_bouquet ( R , B , X , Y ) ) NEW_LINE" ]
atcoder_abc074_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( ( int ) Math . pow ( sc . nextInt ( ) , 2 ) - sc . nextInt ( ) ) ; } }", "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 A = in . nextInt ( ) ; out . println ( N * N - A ) ; } } 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 . 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 r = Integer . parseInt ( sc . next ( ) ) ; int g = Integer . parseInt ( sc . next ( ) ) ; out . println ( r * r - g ) ; out . flush ( ) ; } }", "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 ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; int a = Integer . parseInt ( input . readLine ( ) ) ; System . out . println ( ( n * n ) - a ) ; } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; System . out . println ( n * n - a ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE print ( N * N - A ) NEW_LINE", "n , a = map ( int , open ( 0 ) ) ; print ( n * n - a ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE Y = N ** 2 - A NEW_LINE print ( Y ) NEW_LINE", "N , A = int ( input ( ) ) , int ( input ( ) ) NEW_LINE print ( N * N - A ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE B = N * N - A NEW_LINE print ( B ) NEW_LINE" ]
atcoder_arc048_A
[ "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 ( ) ; int b = sc . nextInt ( ) ; if ( a < 0 ) a ++ ; if ( b < 0 ) b ++ ; System . out . println ( b - a ) ; } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a < 0 && b > 0 ) { System . out . println ( ( Math . abs ( a ) + b - 1 ) ) ; } else if ( a < 0 && b < 0 ) { System . out . println ( ( Math . abs ( a - b ) ) ) ; } else if ( a > 0 && b > 0 ) { System . out . println ( ( ( b - a ) ) ) ; } } }", "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int f = s . nextInt ( ) , t = s . nextInt ( ) ; if ( f <= 0 && 0 <= t ) t -- ; System . out . println ( t - f ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] $ ) { Scanner c = new Scanner ( System . in ) ; long a = c . nextLong ( ) , b = c . nextLong ( ) ; System . out . println ( a * b < 0 ? b - a - 1 : b - a ) ; } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( A < 0 && B > 0 ) { System . out . println ( B - A - 1 ) ; } else { System . out . println ( B - A ) ; } } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a < 0 : NEW_LINE INDENT a += 1 NEW_LINE DEDENT if b < 0 : NEW_LINE INDENT b += 1 NEW_LINE DEDENT print ( b - a ) NEW_LINE", "def f ( x ) : NEW_LINE INDENT if x < 0 : NEW_LINE INDENT return x + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return x NEW_LINE DEDENT DEDENT A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( f ( B ) - f ( A ) ) NEW_LINE", "A , B = map ( int , input ( ) . split ( \" ▁ \" ) ) NEW_LINE if A > 0 and B > 0 : NEW_LINE INDENT print ( abs ( B - A ) ) NEW_LINE DEDENT elif A < 0 and B < 0 : NEW_LINE INDENT print ( abs ( B - A ) ) NEW_LINE DEDENT elif A < 0 and B > 0 : NEW_LINE INDENT print ( B - A - 1 ) NEW_LINE DEDENT elif A > 0 and B < 0 : NEW_LINE INDENT print ( A - B - 1 ) NEW_LINE DEDENT", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( b - a - 1 if a * b < 0 else b - a ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if A >= 0 : NEW_LINE INDENT ans = B - A NEW_LINE DEDENT elif B <= 0 : NEW_LINE INDENT ans = B - A NEW_LINE DEDENT else : NEW_LINE INDENT ans = B - A - 1 NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc069_C
[ "import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Comparator ; 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 ) ; int n = sc . nextInt ( ) ; long [ ] [ ] a = new long [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] [ 0 ] = sc . nextLong ( ) ; a [ i ] [ 1 ] = i ; } Arrays . sort ( a , new Comparator < long [ ] > ( ) { @ Override public int compare ( long [ ] o1 , long [ ] o2 ) { if ( o1 [ 0 ] != o2 [ 0 ] ) { return - Long . compare ( o1 [ 0 ] , o2 [ 0 ] ) ; } else { return Long . compare ( o1 [ 1 ] , o2 [ 1 ] ) ; } } } ) ; long [ ] cnt = new long [ n ] ; int s = 0 , t = 0 ; while ( true ) { if ( s == n ) break ; while ( t != n && a [ s ] [ 1 ] <= a [ t ] [ 1 ] ) { ++ t ; } cnt [ ( int ) a [ s ] [ 1 ] ] += ( a [ s ] [ 0 ] - ( t == n ? 0 : a [ t ] [ 0 ] ) ) * s ; for ( int i = t - 1 ; i >= s ; -- i ) { cnt [ ( int ) a [ s ] [ 1 ] ] += ( a [ i ] [ 0 ] - ( t == n ? 0 : a [ t ] [ 0 ] ) ) ; } s = t ; } PrintWriter pw = new PrintWriter ( System . out ) ; for ( int i = 0 ; i < cnt . length ; ++ i ) { pw . println ( cnt [ i ] ) ; } pw . close ( ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) a [ i ] = sc . nextLong ( ) ; long [ ] left = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) left [ i ] = Math . max ( left [ i - 1 ] , a [ i ] ) ; PriorityQueue < Long > pq = new PriorityQueue < > ( 10 , Collections . reverseOrder ( ) ) ; long [ ] ans = new long [ n + 1 ] ; long hi = left [ n ] ; long cnt = 0 ; for ( int i = n ; i > 0 ; i -- ) { if ( a [ i ] <= left [ i - 1 ] ) { pq . add ( a [ i ] ) ; continue ; } long lo = left [ i - 1 ] ; cnt ++ ; ans [ i ] += cnt * ( hi - lo ) ; while ( pq . size ( ) > 0 && pq . peek ( ) > lo ) { ans [ i ] += pq . poll ( ) - lo ; cnt ++ ; } hi = lo ; } PrintWriter out = new PrintWriter ( System . out ) ; for ( int i = 1 ; i <= n ; i ++ ) out . println ( ans [ i ] ) ; out . flush ( ) ; } }", "import java . io . PrintWriter ; import java . util . * ; public class Main { static final long MOD = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; ArrayList < Integer > index = new ArrayList < > ( ) ; ArrayList < Integer > value = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( index . size ( ) == 0 || value . get ( value . size ( ) - 1 ) < a [ i ] ) { index . add ( i ) ; value . add ( a [ i ] ) ; } } index . add ( N ) ; value . add ( Integer . MAX_VALUE ) ; long [ ] sum = new long [ index . size ( ) + 1 ] ; Arrays . sort ( a ) ; int p = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( value . get ( p ) <= a [ i ] ) { sum [ p ] += ( ( long ) N - i ) * ( value . get ( p ) - ( p > 0 ? value . get ( p - 1 ) : 0 ) ) ; p ++ ; } sum [ p ] += a [ i ] - ( p > 0 ? value . get ( p - 1 ) : 0 ) ; } long [ ] ans = new long [ N ] ; for ( int i = 0 ; i < index . size ( ) - 1 ; i ++ ) ans [ index . get ( i ) ] = sum [ i ] ; for ( int i = 0 ; i < N ; i ++ ) pw . println ( ans [ i ] ) ; sc . close ( ) ; pw . close ( ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int n = sc . nextInt ( ) ; Pair [ ] p = new Pair [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) p [ i ] = new Pair ( i + 1 , sc . nextLong ( ) ) ; p [ n ] = new Pair ( 0 , 0 ) ; Arrays . sort ( p ) ; long [ ] res = new long [ n + 1 ] ; long cnt = 0 ; int idmin = n + 1 ; for ( int i = 0 ; i < n ; i ++ ) { Pair nowP = p [ i ] ; idmin = Math . min ( idmin , nowP . id ) ; cnt ++ ; while ( nowP . cnt == p [ i + 1 ] . cnt ) { i ++ ; cnt ++ ; } res [ idmin ] += cnt * ( nowP . cnt - p [ i + 1 ] . cnt ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) sb . append ( res [ i ] + \" \\n \" ) ; System . out . print ( sb ) ; } class Pair implements Comparable < Pair > { int id ; long cnt ; public Pair ( int id , long cnt ) { super ( ) ; this . id = id ; this . cnt = cnt ; } @ Override public int compareTo ( Pair arg0 ) { if ( this . cnt == arg0 . cnt ) { return this . id - arg0 . id ; } return - Long . compare ( this . cnt , arg0 . cnt ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner io = new Scanner ( System . in ) ; int N = io . nextInt ( ) ; long [ ] ans = new long [ N ] ; PriorityQueue < Deck > que = new PriorityQueue < > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { que . add ( new Deck ( i , io . nextInt ( ) ) ) ; } que . add ( new Deck ( 0 , 0 ) ) ; Deck nowDeck ; int nowNO = Integer . MAX_VALUE ; int nowNum ; for ( int i = 1 ; i <= N ; i ++ ) { nowDeck = que . poll ( ) ; nowNO = Math . min ( nowNO , nowDeck . NO ) ; ans [ nowNO - 1 ] += ( long ) ( nowDeck . num - que . peek ( ) . num ) * i ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } class Deck implements Comparable < Deck > { int NO ; int num ; public Deck ( int NO , int num ) { this . NO = NO ; this . num = num ; } @ Override public int compareTo ( Deck o ) { return ( o . num - num == 0 ) ? o . NO - NO : o . num - num ; } }" ]
[ "from functools import cmp_to_key NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def group ( a ) : NEW_LINE INDENT d = { } NEW_LINE for i , x in enumerate ( a ) : NEW_LINE INDENT d . setdefault ( x , [ ] ) . append ( i ) NEW_LINE DEDENT return list ( map ( lambda x : [ x [ 0 ] , x [ 1 ] [ 0 ] , len ( x [ 1 ] ) ] , sorted ( d . items ( ) , key = cmp_to_key ( lambda x , y : x [ 0 ] - y [ 0 ] ) , reverse = True ) ) ) NEW_LINE DEDENT ans = [ 0 ] * n NEW_LINE g = group ( a ) NEW_LINE g . append ( [ 0 , 0 , 0 ] ) NEW_LINE for c , n in zip ( g [ : - 1 ] , g [ 1 : ] ) : NEW_LINE INDENT ans [ c [ 1 ] ] += ( c [ 0 ] - n [ 0 ] ) * c [ 2 ] NEW_LINE n [ 1 ] = min ( c [ 1 ] , n [ 1 ] ) NEW_LINE n [ 2 ] += c [ 2 ] NEW_LINE DEDENT [ print ( a ) for a in ans ] 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 II ( ) : return int ( input ( ) ) NEW_LINE def LS ( ) : return input ( ) . split ( ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE a = LI ( ) NEW_LINE b = [ ( a [ i ] , i ) for i in range ( n ) ] NEW_LINE b . sort ( ) NEW_LINE b . reverse ( ) NEW_LINE r = [ 0 ] * n NEW_LINE s = sum ( a ) NEW_LINE t = inf NEW_LINE for i in range ( n ) : NEW_LINE INDENT ai , bi = b [ i ] [ 0 ] , b [ i ] [ 1 ] NEW_LINE if bi == 0 : NEW_LINE INDENT r [ 0 ] += s NEW_LINE break NEW_LINE DEDENT ti = ( ai - b [ i + 1 ] [ 0 ] ) * ( i + 1 ) NEW_LINE if t > bi : NEW_LINE INDENT t = bi NEW_LINE DEDENT r [ t ] += ti NEW_LINE s -= ti NEW_LINE DEDENT return ' \\n ' . join ( map ( str , r ) ) NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "def nibutan ( th , a ) : NEW_LINE INDENT top = len ( th ) NEW_LINE btm = 0 NEW_LINE while top > btm : NEW_LINE INDENT mid = ( top + btm ) // 2 NEW_LINE if th [ mid ] < a <= th [ mid + 1 ] : NEW_LINE INDENT return mid NEW_LINE DEDENT elif a <= th [ mid ] : NEW_LINE INDENT top = mid NEW_LINE DEDENT else : NEW_LINE INDENT btm = mid NEW_LINE DEDENT DEDENT DEDENT N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE th = [ 0 ] NEW_LINE num_th = [ ] NEW_LINE rem = [ ] NEW_LINE max_i = 0 NEW_LINE nonzeros = dict ( ) NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if a > th [ - 1 ] : NEW_LINE INDENT th . append ( a ) NEW_LINE num_th . append ( 1 ) NEW_LINE rem . append ( 0 ) NEW_LINE nonzeros [ i ] = max_i NEW_LINE max_i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT j = nibutan ( th , a ) NEW_LINE if j - 1 >= 0 : NEW_LINE INDENT num_th [ j - 1 ] += 1 NEW_LINE DEDENT rem [ j ] += a - th [ j ] NEW_LINE DEDENT DEDENT for i in range ( len ( num_th ) - 1 , 0 , - 1 ) : NEW_LINE INDENT num_th [ i - 1 ] += num_th [ i ] NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT if i in nonzeros : NEW_LINE INDENT ans = ( th [ nonzeros [ i ] + 1 ] - th [ nonzeros [ i ] ] ) * num_th [ nonzeros [ i ] ] NEW_LINE ans += rem [ nonzeros [ i ] ] NEW_LINE print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT", "from collections import defaultdict , Counter NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE c = Counter ( a ) NEW_LINE values = reversed ( sorted ( set ( a ) ) ) NEW_LINE s = 0 NEW_LINE m = 0 NEW_LINE above = dict ( ) NEW_LINE n_above = dict ( ) NEW_LINE for v in values : NEW_LINE INDENT above [ v ] = s NEW_LINE n_above [ v ] = m NEW_LINE s += c [ v ] * v NEW_LINE m += c [ v ] NEW_LINE DEDENT above [ 0 ] = s NEW_LINE n_above [ 0 ] = m NEW_LINE m = 0 NEW_LINE u = [ 0 ] NEW_LINE for v in a : NEW_LINE INDENT if v > m : NEW_LINE INDENT u . append ( v ) NEW_LINE m = v NEW_LINE DEDENT DEDENT r = defaultdict ( int ) NEW_LINE last = 0 NEW_LINE for j , v in enumerate ( u ) : NEW_LINE INDENT r [ v ] = last - ( above [ v ] - n_above [ v ] * v ) NEW_LINE last = above [ v ] - n_above [ v ] * v NEW_LINE DEDENT m = 0 NEW_LINE for v in a : NEW_LINE INDENT if v > m : NEW_LINE INDENT print ( r [ v ] ) NEW_LINE m = v NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT", "from collections import deque NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE A = inpl ( ) NEW_LINE X = sorted ( [ ( a , i ) for i , a in enumerate ( A , start = 1 ) ] , key = lambda x : [ x [ 0 ] , - x [ 1 ] ] ) NEW_LINE answer = [ 0 ] * ( N + 1 ) NEW_LINE a , i = X . pop ( ) NEW_LINE for c in range ( 1 , N ) : NEW_LINE INDENT b , j = X . pop ( ) NEW_LINE answer [ i ] += ( a - b ) * c NEW_LINE i = min ( i , j ) NEW_LINE a = b NEW_LINE DEDENT answer [ i ] += a * N NEW_LINE print ( * answer [ 1 : ] , sep = \" \\n \" ) NEW_LINE" ]
atcoder_abc085_D
[ "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; int a [ ] = new int [ N ] ; int b [ ] = new int [ N ] ; int max = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; max = Math . max ( a [ i ] , max ) ; } Arrays . sort ( b ) ; int ans = 0 ; int sum = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( max > b [ i ] ) { break ; } sum += b [ i ] ; ans ++ ; if ( sum >= H ) { System . out . println ( ans ) ; return ; } } while ( sum < H ) { sum += max ; ans ++ ; } System . out . println ( ans ) ; } }", "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 ( ) ; long H = sc . nextInt ( ) ; PriorityQueue < Entry > sords = new PriorityQueue < Entry > ( new EntryComparator ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { sords . add ( new Entry ( sc . nextLong ( ) , false ) ) ; sords . add ( new Entry ( sc . nextLong ( ) , true ) ) ; } int cnt = 0 ; long aAttach = - 1l ; while ( H > 0 ) { Entry entry = sords . poll ( ) ; if ( ! entry . isB ) { aAttach = entry . attack ; break ; } H -= entry . attack ; cnt ++ ; } if ( aAttach != - 1 ) { cnt += ( long ) Math . ceil ( ( double ) H / aAttach ) ; } out . println ( cnt ) ; } static class EntryComparator implements Comparator < Entry > { @ Override public int compare ( Entry t1 , Entry t2 ) { if ( t1 . attack < t2 . attack ) { return 1 ; } return - 1 ; } } static class Entry { long attack ; boolean isB ; Entry ( long attack , boolean isB ) { this . attack = attack ; this . isB = isB ; } } }", "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 . Comparator ; 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 M = in . nextInt ( ) ; Integer [ ] a = new Integer [ N ] ; Integer [ ] b = new Integer [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = in . nextInt ( ) ; b [ i ] = in . nextInt ( ) ; } Arrays . sort ( a , Comparator . reverseOrder ( ) ) ; Arrays . sort ( b , Comparator . reverseOrder ( ) ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( b [ i ] <= a [ 0 ] ) { break ; } count ++ ; M -= b [ i ] ; if ( M <= 0 ) { break ; } } while ( M > 0 ) { M -= a [ 0 ] ; count ++ ; } out . println ( 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 int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; String [ ] inputs = input . split ( \" ▁ \" ) ; int count = Integer . valueOf ( inputs [ 0 ] ) ; int score = Integer . valueOf ( inputs [ 1 ] ) ; int [ ] a = new int [ count ] ; int [ ] b = new int [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { String data = sc . nextLine ( ) ; String [ ] datas = data . split ( \" ▁ \" ) ; a [ i ] = Integer . valueOf ( datas [ 0 ] ) ; b [ i ] = Integer . valueOf ( datas [ 1 ] ) ; } int maxA = Integer . MIN_VALUE ; for ( int i = 0 ; i < count ; i ++ ) { if ( a [ i ] > maxA ) { maxA = a [ i ] ; } else if ( a [ i ] == maxA ) { } } int moves = 0 ; Arrays . sort ( b ) ; int [ ] j = new int [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { j [ count - i - 1 ] = b [ i ] ; } b = j ; for ( int i = 0 ; i < count ; i ++ ) { if ( b [ i ] >= maxA ) { moves = moves + 1 ; score = score - b [ i ] ; if ( score <= 0 ) { break ; } } } if ( score > 0 ) { int extraMoves = score / maxA ; if ( score - ( extraMoves * maxA ) > 0 ) moves = moves + extraMoves + 1 ; else moves = moves + extraMoves ; } System . out . println ( moves ) ; } }", "import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; long h = Integer . parseInt ( sc . next ( ) ) ; Long [ ] Throw = new Long [ n ] ; long maxAP = 0 ; long t = 0 ; for ( int i = 0 ; i < n ; i ++ ) { t = Long . parseLong ( sc . next ( ) ) ; Throw [ i ] = Long . parseLong ( sc . next ( ) ) ; if ( t > maxAP ) maxAP = t ; } sc . close ( ) ; Arrays . sort ( Throw , Comparator . reverseOrder ( ) ) ; int cnt = 0 ; while ( cnt < n && 0 < h ) { if ( Throw [ cnt ] <= maxAP ) break ; h -= Throw [ cnt ] ; cnt ++ ; } if ( h > 0 ) { cnt += h / maxAP + 1 ; if ( h % maxAP == 0 ) cnt -- ; } System . out . println ( cnt ) ; } }" ]
[ "import bisect NEW_LINE n , h = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE a_s , b_s = [ ] , [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a , b = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE a_s . append ( a ) NEW_LINE b_s . append ( b ) NEW_LINE DEDENT a_s . sort ( ) NEW_LINE b_s . sort ( ) NEW_LINE throwable = bisect . bisect ( b_s , a_s [ - 1 ] ) NEW_LINE throw_sum = sum ( b_s [ throwable : ] ) NEW_LINE ans = 0 NEW_LINE for item in b_s [ throwable : ] [ : : - 1 ] : NEW_LINE INDENT h -= item NEW_LINE ans += 1 NEW_LINE if h <= 0 : NEW_LINE INDENT print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT ans += h // a_s [ - 1 ] NEW_LINE if h % a_s [ - 1 ] != 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT if ans <= 0 : NEW_LINE INDENT ans = 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import math NEW_LINE n , h = map ( int , input ( ) . split ( ) ) NEW_LINE a = sorted ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] , key = lambda x : x [ 1 ] ) [ : : - 1 ] NEW_LINE r = 0 NEW_LINE d = 0 NEW_LINE p = 0 NEW_LINE k = float ( \" inf \" ) NEW_LINE while p < n : NEW_LINE INDENT r += a [ p ] [ 1 ] NEW_LINE d = max ( d , a [ p ] [ 0 ] ) NEW_LINE k = min ( k , p + 1 + math . ceil ( max ( 0 , ( h - r ) ) / d ) ) NEW_LINE p += 1 NEW_LINE if r >= h : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( k ) NEW_LINE", "from math import ceil NEW_LINE from numpy import cumsum NEW_LINE def solve ( string ) : NEW_LINE INDENT n , h , * ab = map ( int , string . split ( ) ) NEW_LINE max_a = max ( ab [ : : 2 ] ) NEW_LINE cnt = 0 NEW_LINE b = sorted ( [ b for b in ab [ 1 : : 2 ] if b > max_a ] , reverse = True ) NEW_LINE if sum ( b ) < h : NEW_LINE INDENT cnt = len ( b ) + ceil ( ( h - sum ( b ) ) / max_a ) NEW_LINE DEDENT else : NEW_LINE INDENT cnt = ( cumsum ( b ) >= h ) . argmax ( ) + 1 NEW_LINE DEDENT return str ( cnt ) 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 ( n ) ] ) ) ) NEW_LINE DEDENT", "def d_katana_thrower ( N , H , Swords ) : NEW_LINE INDENT import math NEW_LINE swing_damage_max = max ( [ s [ 0 ] for s in Swords ] ) NEW_LINE throw_higher_than_swing = [ s [ 1 ] for s in Swords if s [ 1 ] >= swing_damage_max ] NEW_LINE throw_higher_than_swing . sort ( reverse = True ) NEW_LINE minimum_moving = 0 NEW_LINE for damage in throw_higher_than_swing : NEW_LINE INDENT if H <= 0 : NEW_LINE INDENT H = 0 NEW_LINE break NEW_LINE DEDENT H -= damage NEW_LINE minimum_moving += 1 NEW_LINE DEDENT minimum_moving += math . ceil ( H / swing_damage_max ) NEW_LINE return minimum_moving NEW_LINE DEDENT N , H = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE Swords = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( N ) ] NEW_LINE print ( d_katana_thrower ( N , H , Swords ) ) NEW_LINE", "import sys NEW_LINE import math NEW_LINE stdin = sys . stdin NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE na = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ns = lambda : input ( ) NEW_LINE N , H = na ( ) NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT t = na ( ) NEW_LINE a . append ( t [ 0 ] ) NEW_LINE b . append ( t [ 1 ] ) NEW_LINE DEDENT m_a = max ( a ) NEW_LINE b . sort ( reverse = True ) NEW_LINE sum_b = 0 NEW_LINE b_i = 0 NEW_LINE if ( m_a > b [ - 1 ] ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT sum_b += b [ i ] NEW_LINE if ( b [ i ] <= m_a ) : NEW_LINE INDENT sum_b -= b [ i ] NEW_LINE b_i = i NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT b_i = N NEW_LINE sum_b = sum ( b ) NEW_LINE DEDENT res = 0 NEW_LINE if ( sum_b >= H ) : NEW_LINE INDENT for i in range ( b_i ) : NEW_LINE INDENT res += b [ i ] NEW_LINE if ( res >= H ) : NEW_LINE INDENT print ( i + 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT ct = 0 NEW_LINE H_resi = H - sum_b NEW_LINE ct += math . ceil ( H_resi / m_a ) NEW_LINE print ( ct + b_i ) NEW_LINE DEDENT" ]
atcoder_arc018_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double h = sc . nextDouble ( ) / 100 ; double b = sc . nextDouble ( ) ; System . out . println ( b * h * h ) ; } }", "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 h = in . nextDouble ( ) / 100.0 ; double BMI = in . nextDouble ( ) ; out . println ( BMI * h * h ) ; } } 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 . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double h = scanner . nextDouble ( ) ; double bmi = scanner . nextDouble ( ) ; System . out . println ( h * h * bmi / 10000 ) ; } }", "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 ) ; double he = sc . nextDouble ( ) / 100 ; double BMI = sc . nextDouble ( ) ; pl ( BMI * he * he ) ; } 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 . * ; public class Main { private static double h ; private static double bmi ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; h = scan . nextDouble ( ) ; bmi = scan . nextDouble ( ) ; } public static void main ( String args [ ] ) { input ( ) ; System . out . println ( bmi * Math . pow ( h / 100 , 2 ) ) ; } }" ]
[ "h , b = map ( float , input ( ) . split ( ) ) NEW_LINE print ( h * h * b / 10000 ) NEW_LINE", "print ( eval ( input ( ) . replace ( ' ▁ ' , ' * *2 * ' ) ) / 1e4 ) NEW_LINE", "def main ( ) : NEW_LINE INDENT h , bmi = map ( float , input ( ) . split ( ) ) NEW_LINE print ( h * h * bmi / 10000 ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE H , B = map ( float , input ( ) . split ( ) ) NEW_LINE print ( B * H * H / 10 ** 4 ) NEW_LINE", "print ( ( lambda x , y : y * ( x / 100 ) ** 2 ) ( * map ( float , input ( ) . split ( ) ) ) ) NEW_LINE" ]
atcoder_arc021_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 4 ] [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; if ( i != 0 ) { if ( a [ i ] [ j ] == a [ i - 1 ] [ j ] ) { System . out . println ( \" CONTINUE \" ) ; return ; } } if ( j != 0 ) { if ( a [ i ] [ j ] == a [ i ] [ j - 1 ] ) { System . out . println ( \" CONTINUE \" ) ; return ; } } } } System . out . println ( \" GAMEOVER \" ) ; } }", "import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static IntStream REPS ( int r ) { return IntStream . range ( 0 , r ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INTS ( int l ) { return REPS ( l ) . map ( i -> getInt ( ) ) ; } public static void main ( String [ ] __ ) { int [ ] [ ] in = REPS ( 4 ) . mapToObj ( i -> INTS ( 4 ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { if ( i > 0 && in [ i - 1 ] [ j ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } if ( i < 3 && in [ i + 1 ] [ j ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } if ( j > 0 && in [ i ] [ j - 1 ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } if ( j < 3 && in [ i ] [ j + 1 ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } } } System . out . println ( \" GAMEOVER \" ) ; } private static void hoge ( ) { System . out . println ( \" CONTINUE \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = 4 ; int [ ] [ ] tile = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) tile [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; String res = \" GAMEOVER \" ; for ( int i = 0 ; i < n ; i ++ ) { int t = tile [ i ] [ 0 ] ; for ( int j = 1 ; j < n ; j ++ ) { if ( t == tile [ i ] [ j ] ) res = \" CONTINUE \" ; else t = tile [ i ] [ j ] ; } } for ( int i = 0 ; i < n ; i ++ ) { int t = tile [ 0 ] [ i ] ; for ( int j = 1 ; j < n ; j ++ ) { if ( t == tile [ j ] [ i ] ) res = \" CONTINUE \" ; else t = tile [ j ] [ i ] ; } } System . out . println ( res ) ; } }", "import java . util . * ; import java . awt . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int [ ] dx = { - 1 , 0 , 1 , 0 } ; int [ ] dy = { 0 , - 1 , 0 , 1 } ; int [ ] [ ] A = new int [ 4 ] [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } int c = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { int x = j + dx [ k ] ; int y = i + dy [ k ] ; if ( d ( x , y ) ) { if ( A [ i ] [ j ] == A [ y ] [ x ] ) c ++ ; } } } } out . println ( c == 0 ? \" GAMEOVER \" : \" CONTINUE \" ) ; } static boolean d ( int x , int y ) { return 0 <= x && x < 4 && 0 <= y && y < 4 ; } }", "import java . util . * ; public class Main { private static int a [ ] [ ] = new int [ 4 ] [ 4 ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { a [ i ] [ j ] = scan . nextInt ( ) ; } } } public static void main ( String args [ ] ) { input ( ) ; boolean flag = false ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { if ( j != 3 && a [ i ] [ j ] == a [ i ] [ j + 1 ] ) { flag = true ; break ; } if ( j != 3 && a [ j ] [ i ] == a [ j + 1 ] [ i ] ) { flag = true ; break ; } } } if ( flag ) System . out . println ( \" CONTINUE \" ) ; else System . out . println ( \" GAMEOVER \" ) ; } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE mat = [ [ 0 ] * 4 for _ in range ( 4 ) ] NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for j in range ( 4 ) : NEW_LINE INDENT mat [ i ] [ j ] = l [ j ] NEW_LINE DEDENT DEDENT f = False NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if mat [ i ] [ j ] == mat [ i ] [ j + 1 ] : NEW_LINE INDENT f = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if not f : NEW_LINE INDENT for i in range ( 4 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if mat [ j ] [ i ] == mat [ j + 1 ] [ i ] : NEW_LINE INDENT f = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT if f : NEW_LINE INDENT print ( \" CONTINUE \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" GAMEOVER \" ) NEW_LINE DEDENT", "grid = [ ] NEW_LINE ans = ' GAMEOVER ' NEW_LINE for _ in range ( 4 ) : NEW_LINE INDENT grid . append ( input ( ) . split ( ) ) NEW_LINE DEDENT for i in grid : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if i [ j ] == i [ j + 1 ] : NEW_LINE INDENT ans = ' CONTINUE ' NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT for k in range ( 3 ) : NEW_LINE INDENT for l in range ( 4 ) : NEW_LINE INDENT if grid [ k ] [ l ] == grid [ k + 1 ] [ l ] : NEW_LINE INDENT ans = ' CONTINUE ' NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "def ans ( ) : NEW_LINE INDENT board = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 4 ) ] NEW_LINE pattarn = [ ( 1 , 0 ) , ( - 1 , 0 ) , ( 0 , 1 ) , ( 0 , - 1 ) ] NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT for j in range ( 4 ) : NEW_LINE INDENT for x , y in pattarn : NEW_LINE INDENT try : NEW_LINE INDENT if i + y < 0 or j + x < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT elif board [ i + y ] [ j + x ] == board [ i ] [ j ] : NEW_LINE INDENT return \" CONTINUE \" NEW_LINE DEDENT DEDENT except : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT DEDENT DEDENT return \" GAMEOVER \" NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT print ( ans ( ) ) NEW_LINE DEDENT", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE n = 4 NEW_LINE a = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( 4 ) ] NEW_LINE judge = True NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if i + 1 <= n - 1 : NEW_LINE INDENT if a [ i ] [ j ] == a [ i + 1 ] [ j ] : NEW_LINE INDENT judge = False NEW_LINE DEDENT DEDENT if j + 1 <= n - 1 : NEW_LINE INDENT if a [ i ] [ j ] == a [ i ] [ j + 1 ] : NEW_LINE INDENT judge = False NEW_LINE DEDENT DEDENT DEDENT DEDENT if judge : NEW_LINE INDENT print ( ' GAMEOVER ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' CONTINUE ' ) NEW_LINE DEDENT", "L = [ ] NEW_LINE for h in range ( 4 ) : NEW_LINE INDENT L . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT dxy = [ ( - 1 , 0 ) , ( 1 , 0 ) , ( - 0 , - 1 ) , ( 0 , 1 ) ] NEW_LINE ans = \" GAMEOVER \" NEW_LINE explore = 1 NEW_LINE for y in range ( 4 ) : NEW_LINE INDENT if not explore : NEW_LINE INDENT break NEW_LINE DEDENT for x in range ( 4 ) : NEW_LINE INDENT if not explore : NEW_LINE INDENT break NEW_LINE DEDENT for dy , dx in dxy : NEW_LINE INDENT ny = y + dy NEW_LINE nx = x + dx NEW_LINE if ( ny < 0 ) or ( ny >= 4 ) or ( nx < 0 ) or ( nx >= 4 ) : NEW_LINE INDENT continue NEW_LINE DEDENT if L [ y ] [ x ] == L [ ny ] [ nx ] : NEW_LINE INDENT ans = \" CONTINUE \" NEW_LINE explore = 0 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc042_B
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int N = keyboard . nextInt ( ) ; int L = keyboard . nextInt ( ) ; String [ ] SI = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { SI [ i ] = keyboard . next ( ) ; } Arrays . sort ( SI ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( SI [ i ] ) ; } keyboard . close ( ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . 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 ) ; BIrohaLovesStringsABCEdition solver = new BIrohaLovesStringsABCEdition ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BIrohaLovesStringsABCEdition { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int row = in . nextInt ( ) ; int col = in . nextInt ( ) ; String array [ ] = new String [ row ] ; for ( int i = 0 ; i < row ; i ++ ) { array [ i ] = in . next ( ) ; } Arrays . sort ( array ) ; String temp = \" \" ; for ( int i = 0 ; i < row ; i ++ ) { temp += array [ i ] ; } out . print ( temp ) ; } } 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 . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { String line = null ; List < String > tmpList = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ) { line = sc . nextLine ( ) ; String [ ] tmpArray = line . split ( \" ▁ \" ) ; int letterNum = Integer . parseInt ( tmpArray [ 0 ] ) ; for ( int i = 0 ; i < letterNum ; i ++ ) { tmpList . add ( sc . nextLine ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } tmpList . stream ( ) . sorted ( ) . forEach ( i -> System . out . print ( i ) ) ; } }", "import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashSet ; 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 l = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; sc . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextLine ( ) ) ; } Collections . sort ( list , Comparator . naturalOrder ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; for ( String str : list ) { sb . append ( str ) ; } System . out . println ( sb . toString ( ) ) ; } }", "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 len = sc . nextInt ( ) ; List l = new ArrayList < String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String tmp = sc . next ( ) ; l . add ( tmp ) ; } Collections . sort ( l ) ; for ( int i = 0 ; i < l . size ( ) ; i ++ ) { System . out . print ( l . get ( i ) ) ; if ( i == l . size ( ) - 1 ) { System . out . println ( \" \" ) ; } } sc . close ( ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "N , L = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ input ( ) . rstrip ( ) for _ in range ( N ) ] NEW_LINE print ( ' ' . join ( sorted ( S ) ) ) NEW_LINE", "n , l = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a . append ( input ( ) ) NEW_LINE DEDENT for j in range ( n ) : NEW_LINE INDENT for i in range ( j ) : NEW_LINE INDENT if a [ i ] > a [ j ] : NEW_LINE INDENT b = a [ i ] NEW_LINE a [ i ] = a [ j ] NEW_LINE a [ j ] = b NEW_LINE DEDENT DEDENT DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT a [ 0 ] += a [ i ] NEW_LINE DEDENT print ( a [ 0 ] ) NEW_LINE", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE letters = [ ] NEW_LINE for i in range ( a ) : NEW_LINE INDENT c = input ( ) NEW_LINE letters . append ( c ) NEW_LINE DEDENT letterss = sorted ( letters ) NEW_LINE mojiretsu = ' ' NEW_LINE for x in letterss : NEW_LINE INDENT mojiretsu += x NEW_LINE DEDENT print ( mojiretsu ) NEW_LINE", "Num = [ int ( n ) for n in input ( ) . rstrip ( ) . split ( ) ] NEW_LINE Str = [ input ( ) . rstrip ( ) for _ in range ( Num [ 0 ] ) ] NEW_LINE print ( \" \" . join ( sorted ( Str ) ) ) NEW_LINE", "n , l = map ( int , input ( ) . split ( ) ) NEW_LINE lines = sorted ( [ str ( input ( ) ) for i in range ( n ) ] ) NEW_LINE test = \" \" NEW_LINE for line in lines : NEW_LINE INDENT test += line NEW_LINE DEDENT print ( test ) NEW_LINE" ]
atcoder_abc015_D
[ "import java . util . * ; public class Main { public void main ( Scanner sc ) { int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int limit = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } int dp [ ] [ ] [ ] = new int [ n + 1 ] [ limit + 1 ] [ w + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j <= limit ; j ++ ) { for ( int k = 0 ; k <= w ; k ++ ) { if ( k < a [ i ] ) { dp [ i + 1 ] [ j ] [ k ] = Math . max ( dp [ i ] [ j ] [ k ] , dp [ i + 1 ] [ j ] [ k ] ) ; } else { dp [ i + 1 ] [ j ] [ k ] = Math . max ( Math . max ( dp [ i ] [ j ] [ k ] , dp [ i ] [ j - 1 ] [ k - a [ i ] ] + b [ i ] ) , dp [ i + 1 ] [ j ] [ k ] ) ; } } } } System . out . println ( dp [ n ] [ limit ] [ w ] ) ; } public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { new Main ( ) . main ( sc ) ; } catch ( Exception e ) { throw e ; } } }", "import java . util . * ; public class Main { static long mod = 1000000000 + 7 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int W = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] b = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } int sumB = 0 ; for ( int w : b ) sumB += w ; int [ ] [ ] dp = new int [ K + 1 ] [ sumB + 1 ] ; for ( int i = 0 ; i < K + 1 ; i ++ ) Arrays . fill ( dp [ i ] , Integer . MAX_VALUE / 2 ) ; dp [ 0 ] [ 0 ] = 0 ; for ( int kind = 1 ; kind <= n ; kind ++ ) { for ( int k = K - 1 ; k >= 0 ; k -- ) { for ( int sum = sumB ; sum >= b [ kind ] ; sum -- ) { if ( dp [ k ] [ sum - b [ kind ] ] + a [ kind ] <= W ) dp [ k + 1 ] [ sum ] = Math . min ( dp [ k + 1 ] [ sum ] , dp [ k ] [ sum - b [ kind ] ] + a [ kind ] ) ; } } } int ans = - 1 ; for ( int k = 0 ; k <= K ; k ++ ) { for ( int sum = 0 ; sum <= sumB ; sum ++ ) { if ( dp [ k ] [ sum ] <= W ) ans = Math . max ( sum , ans ) ; } } System . out . println ( ans ) ; } }", "import java . util . * ; import java . io . InputStreamReader ; import java . io . BufferedReader ; import java . util . Arrays ; import java . util . List ; import java . util . ArrayList ; import java . util . ArrayDeque ; import java . util . Deque ; import java . util . Collections ; import java . awt . Point ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int W = Integer . parseInt ( br . readLine ( ) ) ; String [ ] nk = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; int [ ] w = new int [ n + 1 ] ; int [ ] v = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] line = br . readLine ( ) . split ( \" ▁ \" ) ; w [ i + 1 ] = Integer . parseInt ( line [ 0 ] ) ; v [ i + 1 ] = Integer . parseInt ( line [ 1 ] ) ; } int [ ] [ ] [ ] dp = new int [ n + 1 ] [ W + 1 ] [ k + 1 ] ; dp [ 0 ] [ 0 ] [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= W ; j ++ ) { for ( int l = 1 ; l <= k ; l ++ ) { if ( j - w [ i ] >= 0 ) dp [ i ] [ j ] [ l ] = Math . max ( dp [ i - 1 ] [ j - w [ i ] ] [ l - 1 ] + v [ i ] , dp [ i - 1 ] [ j ] [ l ] ) ; else dp [ i ] [ j ] [ l ] = dp [ i - 1 ] [ j ] [ l ] ; } } } System . out . println ( dp [ n ] [ W ] [ k ] ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; 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 ) ; D solver = new D ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D { int n ; int [ ] [ ] [ ] dp ; int [ ] a ; int [ ] b ; public void solve ( int testNumber , Scanner in , PrintWriter out ) { int w = in . nextInt ( ) ; n = in . nextInt ( ) ; int k = in . nextInt ( ) ; dp = new int [ n ] [ n + 1 ] [ w + 1 ] ; a = new int [ n ] ; b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; b [ i ] = in . nextInt ( ) ; for ( int j = 0 ; j <= n ; j ++ ) { Arrays . fill ( dp [ i ] [ j ] , - 1 ) ; } } out . println ( calc ( 0 , w , k ) ) ; } private int calc ( int i , int w , int k ) { if ( i >= n || w <= 0 || k <= 0 ) { return 0 ; } else if ( dp [ i ] [ k ] [ w ] >= 0 ) { return dp [ i ] [ k ] [ w ] ; } int ans = calc ( i + 1 , w , k ) ; if ( w >= a [ i ] ) { ans = Math . max ( ans , calc ( i + 1 , w - a [ i ] , k - 1 ) + b [ i ] ) ; } return dp [ i ] [ k ] [ w ] = ans ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int w = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmp = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( tmp [ 0 ] ) ; int k = Integer . parseInt ( tmp [ 1 ] ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { tmp = br . readLine ( ) . split ( \" ▁ \" ) ; a [ i ] = Integer . parseInt ( tmp [ 0 ] ) ; b [ i ] = Integer . parseInt ( tmp [ 1 ] ) ; } int [ ] [ ] [ ] dp = new int [ n + 1 ] [ w + 1 ] [ k + 1 ] ; for ( int index = 0 ; index < n ; index ++ ) { for ( int width = 0 ; width <= w ; width ++ ) { for ( int num = 0 ; num < k ; num ++ ) { if ( a [ index ] > width ) dp [ index + 1 ] [ width ] [ num + 1 ] = dp [ index ] [ width ] [ num + 1 ] ; else dp [ index + 1 ] [ width ] [ num + 1 ] = Math . max ( dp [ index ] [ width ] [ num + 1 ] , dp [ index ] [ width - a [ index ] ] [ num ] + b [ index ] ) ; } } } System . out . println ( dp [ n ] [ w ] [ k ] ) ; } }" ]
[ "W = int ( input ( ) ) NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE AB = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE dp = [ [ 50001 for _ in range ( 100 * N + 1 ) ] for _ in range ( N + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] = 0 NEW_LINE total = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT a , b = AB [ i ] NEW_LINE for j in range ( i , - 1 , - 1 ) : NEW_LINE INDENT for v in range ( total , - 1 , - 1 ) : NEW_LINE INDENT dp [ j + 1 ] [ v + b ] = min ( dp [ j + 1 ] [ v + b ] , dp [ j ] [ v ] + a ) NEW_LINE DEDENT DEDENT total += b NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( 1 , K + 1 ) : NEW_LINE INDENT for j in range ( 100 * N + 1 ) : NEW_LINE INDENT if dp [ i ] [ j ] <= W : NEW_LINE INDENT ans = max ( ans , j ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE def ? ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE W = int ( input ( ) ) NEW_LINE N , K = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE dp = { 0 : { 0 : 0 } } NEW_LINE INF = float ( \" inf \" ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT w , v = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE if w <= W : NEW_LINE INDENT for k in sorted ( dp . keys ( ) , reverse = True ) : NEW_LINE INDENT if K <= k : NEW_LINE INDENT continue NEW_LINE DEDENT tk = k + 1 NEW_LINE for j in dp [ k ] : NEW_LINE INDENT tv = j + v NEW_LINE tMin = min ( dp . get ( tk , { } ) . get ( tv , INF ) , dp [ k ] [ j ] + w ) NEW_LINE if W < tMin : NEW_LINE INDENT continue NEW_LINE DEDENT if tk in dp : NEW_LINE INDENT dp [ tk ] [ tv ] = tMin NEW_LINE DEDENT else : NEW_LINE INDENT dp [ tk ] = { tv : tMin } NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( max ( max ( ed . keys ( ) ) for ed in dp . values ( ) ) ) NEW_LINE DEDENT ? ( ) NEW_LINE", "import numpy as np NEW_LINE max_w = int ( input ( ) ) NEW_LINE n , max_k = map ( int , input ( ) . split ( ) ) NEW_LINE dp = np . zeros ( ( max_k + 1 , max_w + 1 ) ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT w , val = map ( int , input ( ) . split ( ) ) NEW_LINE if w > max_w : NEW_LINE INDENT continue NEW_LINE DEDENT dp [ 1 : , w : ] = np . maximum ( dp [ : max_k , : max_w + 1 - w ] + val , dp [ 1 : , w : ] ) NEW_LINE DEDENT print ( int ( dp [ max_k , max_w ] ) ) NEW_LINE", "W = int ( input ( ) ) NEW_LINE N , K = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE G = [ 0 ] * N NEW_LINE def calc ( i , max_a , w , k ) : NEW_LINE INDENT if i >= N or k >= K : NEW_LINE INDENT return 0 NEW_LINE DEDENT g_i0 = G [ i ] [ 0 ] NEW_LINE a = calc ( i + 1 , max_a if max_a < g_i0 else g_i0 , w , k ) NEW_LINE w_new = w + g_i0 NEW_LINE if w_new > W or g_i0 > max_a : NEW_LINE INDENT return a NEW_LINE DEDENT b = G [ i ] [ 1 ] + calc ( i + 1 , max_a , w_new , k + 1 ) NEW_LINE return a if a > b else b NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT A , B = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE G [ i ] = ( A , B ) NEW_LINE DEDENT G . sort ( key = lambda x : x [ 1 ] , reverse = True ) NEW_LINE print ( calc ( 0 , 100000 , 0 , 0 ) ) NEW_LINE", "import numpy as np NEW_LINE from itertools import product NEW_LINE W = int ( input ( ) ) NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE wid_val = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for _ in range ( N ) ] NEW_LINE dp = np . zeros ( [ N + 1 , W + 1 , K + 1 ] , dtype = int ) NEW_LINE for i , num in product ( range ( 1 , N + 1 ) , range ( 1 , K + 1 ) ) : NEW_LINE INDENT key = wid_val [ i - 1 ] [ 0 ] NEW_LINE dp [ i , : key , num ] = dp [ i - 1 , : key , num ] NEW_LINE dp [ i , key : , num ] = np . maximum ( dp [ i - 1 , key : , num ] , dp [ i - 1 , : - key , num - 1 ] + wid_val [ i - 1 ] [ 1 ] ) NEW_LINE DEDENT print ( dp [ N ] [ W ] [ K ] ) NEW_LINE" ]
atcoder_arc079_B
[ "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . 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 ) ; TaskD solver = new TaskD ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskD { public void solve ( int testNumber , InputReader in , PrintWriter out ) { long k = in . nextLong ( ) ; long p = k / 50 ; long q = k % 50 ; long [ ] ans = new long [ 50 ] ; Arrays . fill ( ans , 49 + p ) ; for ( int i = 0 ; i < q ; i ++ ) { for ( int j = 0 ; j < 50 ; j ++ ) { if ( j == i ) { ans [ j ] += 50 ; } else { ans [ j ] -- ; } } } out . println ( ans . length ) ; for ( int i = 0 ; i < ans . length ; i ++ ) { if ( i > 0 ) out . print ( \" ▁ \" ) ; out . print ( ans [ i ] ) ; } out . println ( ) ; } } 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 . util . * ; public class Main { private void doit ( ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long k = sc . nextLong ( ) ; long n = 50 ; long base = ( k / n ) + n - 1 ; int x = ( int ) ( k % n ) ; System . out . println ( n ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < x ; i ++ ) { sb . append ( \" ▁ \" ) ; sb . append ( base + n - x + 1 ) ; } for ( int i = 0 ; i < n - x ; i ++ ) { sb . append ( \" ▁ \" ) ; sb . append ( base - x ) ; } System . out . println ( sb . substring ( 1 ) ) ; } } private void debug ( Object ... o ) { System . out . println ( \" debug ▁ = ▁ \" + Arrays . deepToString ( o ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . doit ( ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; long K = sc . nextLong ( ) ; int rest = ( int ) ( K % 50 ) ; long num = K / 50 ; System . out . println ( 50 ) ; long [ ] ans = new long [ 50 ] ; for ( int i = 0 ; i < rest ; i ++ ) { ans [ i ] = num + 50 + 50 - rest ; } for ( int i = rest ; i < 50 ; i ++ ) { ans [ i ] = num + 50 - 1 - rest ; } for ( int i = 0 ; i < 49 ; i ++ ) { System . out . print ( ans [ i ] + \" ▁ \" ) ; } System . out . println ( ans [ 49 ] ) ; out . close ( ) ; } static class Scanner { BufferedReader br ; StringTokenizer st ; Scanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } Scanner ( String fileName ) throws FileNotFoundException { br = new BufferedReader ( new FileReader ( fileName ) ) ; } String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } String nextLine ( ) throws IOException { return br . readLine ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) throws NumberFormatException , IOException { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) throws NumberFormatException , IOException { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static final int MAX_N = 50 ; public static void main ( String [ ] args ) { final long K ; try ( Scanner in = new Scanner ( System . in ) ) { K = in . nextLong ( ) ; } long [ ] xs = new long [ MAX_N ] ; final int N = 50 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i < K % N ) { xs [ i ] = i + ( K / N + 1 ) * ( N + 1 ) - K ; } else { xs [ i ] = i + K / N * ( N + 1 ) - K ; } } System . out . printf ( \" % d \\n \" , N ) ; System . out . printf ( \" % d \" , xs [ 0 ] ) ; for ( int i = 1 ; i < N ; i ++ ) { System . out . printf ( \" ▁ % d \" , xs [ i ] ) ; } System . out . printf ( \" \\n \" ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { long k ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; k = sc . nextLong ( ) ; solve ( ) ; } void solve ( ) { long n = 50 ; long [ ] as = new long [ ( int ) n ] ; long quotient = k / n ; long remainder = k % n ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = 49 + quotient ; } for ( int i = 0 ; i < remainder ; i ++ ) { as [ i ] += n ; for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) { continue ; } as [ j ] -= 1 ; } } System . out . println ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( as [ i ] ) ; if ( i < n - 1 ) { System . out . print ( \" ▁ \" ) ; } else { System . out . println ( ) ; } } } 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 sys NEW_LINE K = int ( input ( ) ) NEW_LINE a = K // 50 NEW_LINE b = K % 50 NEW_LINE if K == 0 : NEW_LINE INDENT print ( 2 ) NEW_LINE print ( 0 , 0 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT Ans = [ 100 + a - b ] * b + [ 49 + a - b ] * ( 50 - b ) NEW_LINE print ( 50 ) NEW_LINE print ( * Ans ) 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 import numpy as np NEW_LINE def solve_d ( k ) : NEW_LINE INDENT if k == 0 : NEW_LINE INDENT return [ 0 ] * 50 NEW_LINE DEDENT if k <= 50 : NEW_LINE INDENT arr = [ ] NEW_LINE for i in range ( k ) : NEW_LINE INDENT arr . append ( 50 - i ) NEW_LINE DEDENT for i in range ( k , 50 ) : NEW_LINE INDENT arr . append ( 0 ) NEW_LINE DEDENT return arr NEW_LINE DEDENT else : NEW_LINE INDENT arr = list ( reversed ( range ( 1 , 51 ) ) ) NEW_LINE base = ( k - 1 ) // 50 NEW_LINE for i in range ( 50 ) : NEW_LINE INDENT arr [ i ] += base - 1 NEW_LINE DEDENT for i in range ( k - base * 50 ) : NEW_LINE INDENT arr [ i ] += 1 NEW_LINE DEDENT return arr NEW_LINE DEDENT DEDENT K = int ( input ( ) ) NEW_LINE print ( 50 ) NEW_LINE print ( * solve_d ( K ) ) NEW_LINE def solve_e ( As ) : NEW_LINE INDENT ans = 0 NEW_LINE N = len ( As ) NEW_LINE As = As [ : ] 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 return ans NEW_LINE NEW_LINE DEDENT", "def counter ( a , n ) : NEW_LINE INDENT big = max ( a ) NEW_LINE check = True NEW_LINE counter = 0 NEW_LINE while big > n - 1 : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if a [ i ] == big and check : NEW_LINE INDENT check = False NEW_LINE a [ i ] -= n NEW_LINE DEDENT else : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT counter += 1 NEW_LINE big = max ( a ) NEW_LINE check = True NEW_LINE DEDENT return counter NEW_LINE DEDENT k = int ( input ( ) ) NEW_LINE n = 50 NEW_LINE print ( n ) NEW_LINE temp = k // 50 NEW_LINE a = [ 49 + temp for i in range ( n ) ] NEW_LINE k = k - 50 * ( k // 50 ) NEW_LINE for i in range ( k ) : NEW_LINE INDENT big = min ( a ) NEW_LINE check = True NEW_LINE for j in range ( n ) : NEW_LINE INDENT if a [ j ] == big and check : NEW_LINE INDENT check = False NEW_LINE a [ j ] += 50 NEW_LINE DEDENT else : NEW_LINE INDENT a [ j ] -= 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT if i != n - 1 : NEW_LINE INDENT print ( a [ i ] , end = \" ▁ \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a [ i ] ) NEW_LINE DEDENT DEDENT", "import numpy as np NEW_LINE k = int ( input ( ) ) NEW_LINE n = 50 NEW_LINE res = np . array ( [ i + k // n for i in range ( 50 ) ] ) NEW_LINE k %= n NEW_LINE for i in range ( k ) : NEW_LINE INDENT res [ i ] += n + 1 NEW_LINE res -= 1 NEW_LINE DEDENT print ( n ) NEW_LINE print ( \" ▁ \" . join ( map ( str , res ) ) ) NEW_LINE", "K = int ( input ( ) ) NEW_LINE N = 50 NEW_LINE def solve ( A , cnt ) : NEW_LINE INDENT res = len ( A ) NEW_LINE for i in range ( cnt ) : NEW_LINE INDENT A [ i ] += ( res + 1 ) NEW_LINE for j in range ( res ) : NEW_LINE INDENT A [ j ] -= 1 NEW_LINE DEDENT DEDENT return A NEW_LINE DEDENT Ans = [ 0 for x in range ( N ) ] NEW_LINE Ans [ 0 ] = 25 + ( K // 50 ) NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT Ans [ i ] = Ans [ i - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT Ans [ i ] = Ans [ i - 1 ] NEW_LINE DEDENT DEDENT Ans = solve ( Ans , K % 50 ) NEW_LINE print ( N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if i == N - 1 : NEW_LINE INDENT print ( Ans [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( Ans [ i ] , end = \" ▁ \" ) NEW_LINE DEDENT DEDENT" ]
atcoder_abc060_A
[ "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 ) ; String A = sc . next ( ) ; String B = sc . next ( ) ; String C = sc . next ( ) ; if ( A . charAt ( A . length ( ) - 1 ) == B . charAt ( 0 ) && B . charAt ( B . length ( ) - 1 ) == C . charAt ( 0 ) ) { out . println ( \" YES \" ) ; } else { out . println ( \" NO \" ) ; } out . flush ( ) ; } }", "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 ( ) ; if ( a . charAt ( a . length ( ) - 1 ) == b . charAt ( 0 ) && b . charAt ( b . length ( ) - 1 ) == c . charAt ( 0 ) ) out . println ( \" YES \" ) ; else out . println ( \" 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 ; } 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 . 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 strA = sc . next ( ) ; String strB = sc . next ( ) ; String strC = sc . next ( ) ; int A = strA . length ( ) ; int B = strB . length ( ) ; int C = strC . length ( ) ; if ( strA . substring ( A - 1 , A ) . equals ( strB . substring ( 0 , 1 ) ) ) { if ( strB . substring ( B - 1 , B ) . equals ( strC . substring ( 0 , 1 ) ) ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } else { System . out . println ( \" NO \" ) ; } } } }", "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 ( ) ; if ( A . charAt ( A . length ( ) - 1 ) == B . charAt ( 0 ) && B . charAt ( B . length ( ) - 1 ) == C . charAt ( 0 ) ) { 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 ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . nextLine ( ) ; String [ ] b = a . split ( \" ▁ \" , 0 ) ; System . out . println ( ( b [ 0 ] . substring ( b [ 0 ] . length ( ) - 1 , b [ 0 ] . length ( ) ) . equals ( b [ 1 ] . substring ( 0 , 1 ) ) && b [ 1 ] . substring ( b [ 1 ] . length ( ) - 1 , b [ 1 ] . length ( ) ) . equals ( b [ 2 ] . substring ( 0 , 1 ) ) ) ? \" YES \" : \" NO \" ) ; } }" ]
[ "A , B , C = input ( ) . split ( ) NEW_LINE if A [ - 1 ] == B [ 0 ] and B [ - 1 ] == C [ 0 ] : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT", "a , b , c = input ( ) . split ( ' ▁ ' ) NEW_LINE print ( ' YES ' if a [ - 1 ] == b [ 0 ] and b [ - 1 ] == c [ 0 ] else ' NO ' ) NEW_LINE", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE A , B , C = map ( str , input ( ) . split ( ) ) NEW_LINE if A [ - 1 ] == B [ 0 ] and B [ - 1 ] == C [ 0 ] : 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 = ( _ for _ in input ( ) . split ( ) ) NEW_LINE if a [ - 1 ] == b [ 0 ] and b [ - 1 ] == c [ 0 ] : 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 = input ( ) . split ( ) NEW_LINE print ( \" YES \" if a [ - 1 ] == b [ 0 ] and b [ - 1 ] == c [ 0 ] else \" NO \" ) NEW_LINE" ]
atcoder_arc045_B
[ "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 [ ] s = new int [ 300002 ] ; int [ ] t = new int [ 300002 ] ; int [ ] x = new int [ 300002 ] ; int [ ] b = new int [ 300002 ] ; for ( int i = 0 ; i < M ; ++ i ) { s [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; int l = s [ i ] - 1 ; int r = t [ i ] - 1 ; b [ l ] ++ ; b [ r + 1 ] -- ; } for ( int i = 0 ; i < N + 1 ; ++ i ) { b [ i + 1 ] += b [ i ] ; } for ( int i = 1 ; i <= N ; i ++ ) { if ( b [ i - 1 ] == 1 ) { x [ i ] = 1 ; } else { x [ i ] = 0 ; } } for ( int i = 1 ; i < N ; i ++ ) { x [ i + 1 ] += x [ i ] ; } ArrayList < Integer > ans = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { if ( x [ t [ i ] ] - x [ s [ i ] - 1 ] == 0 ) { ans . add ( i + 1 ) ; } } System . out . println ( ans . size ( ) ) ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { System . out . println ( ans . get ( i ) ) ; } } }", "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 [ ] arr = new int [ n + 1 ] ; int [ ] arrS = new int [ m + 1 ] ; int [ ] arrT = new int [ m + 1 ] ; for ( int i = 1 ; i <= m ; i ++ ) { arrS [ i ] = sc . nextInt ( ) ; arrT [ i ] = sc . nextInt ( ) ; arr [ arrS [ i ] ] ++ ; if ( arrT [ i ] != n ) { arr [ arrT [ i ] + 1 ] -- ; } } int [ ] arrX = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { arr [ i ] += arr [ i - 1 ] ; arrX [ i ] += arrX [ i - 1 ] ; if ( arr [ i ] < 2 ) { arrX [ i ] ++ ; } } int count = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 1 ; i <= m ; i ++ ) { if ( arrX [ arrT [ i ] ] - arrX [ arrS [ i ] - 1 ] == 0 ) { count ++ ; list . add ( i ) ; } } StringBuilder sb = new StringBuilder ( ) ; sb . append ( count ) . append ( \" \\n \" ) ; for ( int x : list ) { sb . append ( x ) . append ( \" \\n \" ) ; } System . out . print ( sb ) ; } }", "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 [ ] wrc = new int [ n + 1 ] ; int [ ] wrn = new int [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; wrc [ s - 1 ] += 1 ; wrc [ t ] -= 1 ; wrn [ s - 1 ] += i ; wrn [ t ] -= i ; } boolean [ ] brni = new boolean [ m ] ; Arrays . fill ( brni , true ) ; int linecnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { wrc [ i + 1 ] += wrc [ i ] ; wrn [ i + 1 ] += wrn [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( wrc [ i ] == 1 && brni [ wrn [ i ] ] ) { brni [ wrn [ i ] ] = false ; linecnt ++ ; } } System . out . println ( m - linecnt ) ; for ( int i = 0 ; i < m ; i ++ ) { if ( brni [ i ] ) { System . out . println ( i + 1 ) ; } } } }", "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 [ ] s = new int [ 300002 ] ; int [ ] t = new int [ 300002 ] ; int [ ] x = new int [ 300002 ] ; int [ ] b = new int [ 300002 ] ; for ( int i = 0 ; i < M ; ++ i ) { s [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; int l = s [ i ] - 1 ; int r = t [ i ] - 1 ; b [ l ] ++ ; b [ r + 1 ] -- ; } for ( int i = 0 ; i < N + 1 ; ++ i ) { b [ i + 1 ] += b [ i ] ; if ( b [ i ] == 1 ) x [ i + 1 ] = x [ i ] + 1 ; else x [ i + 1 ] = x [ i ] + 0 ; } ArrayList < Integer > ans = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { if ( x [ t [ i ] ] - x [ s [ i ] - 1 ] == 0 ) { ans . add ( i + 1 ) ; } } System . out . println ( ans . size ( ) ) ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { System . out . println ( ans . get ( i ) ) ; } } }" ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE src = [ ] NEW_LINE imos = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT s , t = map ( int , input ( ) . split ( ) ) NEW_LINE src . append ( ( s , t ) ) NEW_LINE imos [ s - 1 ] += 1 NEW_LINE imos [ t ] -= 1 NEW_LINE DEDENT cum = 0 NEW_LINE must = [ 0 ] NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT cum += imos [ i ] NEW_LINE must . append ( must [ - 1 ] + ( 1 if cum == 1 else 0 ) ) NEW_LINE DEDENT ans = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT s , t = src [ i ] NEW_LINE if must [ s - 1 ] == must [ t ] : NEW_LINE INDENT ans . append ( i + 1 ) NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT", "def show ( a ) : NEW_LINE INDENT for i in range ( len ( a ) ) : NEW_LINE INDENT print ( a [ i ] ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT def func ( n , m , a ) : NEW_LINE INDENT table = [ 0 for _ in range ( n + 2 ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT table [ a [ i ] [ 0 ] ] += 1 NEW_LINE table [ a [ i ] [ 1 ] + 1 ] -= 1 NEW_LINE DEDENT for i in range ( 1 , len ( table ) ) : NEW_LINE INDENT table [ i ] += table [ i - 1 ] NEW_LINE DEDENT for i in range ( 1 , len ( table ) ) : NEW_LINE INDENT if table [ i ] != 1 : NEW_LINE INDENT table [ i ] = 0 NEW_LINE DEDENT table [ i ] += table [ i - 1 ] NEW_LINE DEDENT out = [ ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT if table [ a [ i ] [ 0 ] - 1 ] == table [ a [ i ] [ 1 ] ] : NEW_LINE INDENT out . append ( i ) NEW_LINE DEDENT DEDENT print ( len ( out ) ) NEW_LINE for i in range ( len ( out ) ) : NEW_LINE INDENT print ( out [ i ] + 1 ) NEW_LINE DEDENT DEDENT n , m = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = [ [ 0 , 0 , 0 ] for _ in range ( m ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a [ i ] = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE DEDENT func ( n , m , a ) NEW_LINE", "from bisect import bisect , bisect_left NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , M = inpl ( ) NEW_LINE R = [ 0 ] * ( N + 2 ) NEW_LINE Q = [ inpl ( ) for _ in range ( M ) ] NEW_LINE for s , t in Q : NEW_LINE INDENT R [ s ] += 1 NEW_LINE R [ t + 1 ] -= 1 NEW_LINE DEDENT c = 0 NEW_LINE Pf = [ ] NEW_LINE Pe = [ ] NEW_LINE rec = False NEW_LINE f = - 1 NEW_LINE for i , r in enumerate ( R ) : NEW_LINE INDENT c += r NEW_LINE if ( c >= 2 ) : NEW_LINE INDENT if rec : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT rec = True NEW_LINE f = i NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if rec : NEW_LINE INDENT Pf . append ( f ) NEW_LINE Pe . append ( i - 1 ) NEW_LINE rec = False NEW_LINE DEDENT else : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT DEDENT if rec : NEW_LINE INDENT Pf . append ( f ) NEW_LINE Pe . append ( N ) NEW_LINE DEDENT ANS = [ ] NEW_LINE for i , ( s , t ) in enumerate ( Q , start = 1 ) : NEW_LINE INDENT j = bisect ( Pf , s ) NEW_LINE if j : NEW_LINE INDENT e = Pe [ j - 1 ] NEW_LINE if t <= e : NEW_LINE INDENT ANS . append ( i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT print ( len ( ANS ) ) NEW_LINE if len ( ANS ) : NEW_LINE INDENT print ( * ANS , sep = \" \\n \" ) NEW_LINE DEDENT", "from itertools import accumulate NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE R = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( M ) ] NEW_LINE def solve ( ) : NEW_LINE INDENT imos = [ 0 ] * ( N + 2 ) NEW_LINE ans = [ ] NEW_LINE for a , b in R : NEW_LINE INDENT imos [ a ] += 1 NEW_LINE imos [ b + 1 ] -= 1 NEW_LINE DEDENT imos = list ( accumulate ( imos ) ) NEW_LINE for i in range ( N + 2 ) : NEW_LINE INDENT if imos [ i ] != 1 : NEW_LINE INDENT imos [ i ] = 0 NEW_LINE DEDENT DEDENT imos = list ( accumulate ( imos ) ) NEW_LINE for i , t in enumerate ( R ) : NEW_LINE INDENT a = t [ 0 ] NEW_LINE b = t [ 1 ] NEW_LINE if imos [ b ] - imos [ a - 1 ] == 0 : NEW_LINE INDENT ans . append ( i ) NEW_LINE DEDENT DEDENT if ans : NEW_LINE INDENT print ( len ( ans ) ) NEW_LINE print ( \" \\n \" . join ( map ( lambda x : str ( x + 1 ) , ans ) ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE", "n , m = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE s = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( m ) ] NEW_LINE x , y , ans = [ 0 for i in range ( n + 2 ) ] , [ ] , [ ] NEW_LINE for i , j in s : x [ i ] , x [ j + 1 ] = x [ i ] + 1 , x [ j + 1 ] - 1 NEW_LINE for i in range ( 1 , n + 2 ) : NEW_LINE INDENT x [ i ] += x [ i - 1 ] NEW_LINE if x [ i ] == 1 : y . append ( i ) NEW_LINE DEDENT from bisect import bisect NEW_LINE from bisect import bisect_left NEW_LINE for i in range ( m ) : NEW_LINE INDENT if bisect_left ( y , s [ i ] [ 0 ] ) == bisect ( y , s [ i ] [ 1 ] ) : ans . append ( i + 1 ) NEW_LINE DEDENT print ( len ( ans ) ) NEW_LINE for i in ans : print ( i ) NEW_LINE" ]
atcoder_abc020_B
[ "import java . util . * ; public class Main { public static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = \" \" + a + b ; int c = Integer . parseInt ( s ) ; System . out . println ( c * 2 ) ; } }", "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 ( ) ; out . println ( Integer . parseInt ( A + B ) * 2 ) ; } } 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 . 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 ) { out . println ( Integer . parseInt ( in . next ( ) + in . next ( ) ) * 2 ) ; } } 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 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double A = sc . nextInt ( ) ; double B = sc . nextInt ( ) ; double b = B ; int count = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { double c = B % 10 ; B = B / 10 ; if ( c == 0 ) { count ++ ; } else if ( c >= 1 ) { count ++ ; } else { break ; } } double a = Math . pow ( 10 , count ) ; double ans = a * A + b ; System . out . println ( String . format ( \" % .0f \" , ans * 2 ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String A = sc . next ( ) ; String B = sc . next ( ) ; String tmp = A + B ; long sum = Long . parseLong ( tmp ) ; sum *= 2 ; System . out . println ( sum ) ; } }" ]
[ "a , b = input ( ) . split ( ) NEW_LINE print ( int ( a + b ) * 2 ) NEW_LINE", "print ( int ( input ( ) . replace ( \" ▁ \" , \" \" ) ) * 2 ) NEW_LINE", "a , b = map ( str , input ( ) . split ( ) ) NEW_LINE c = a + b NEW_LINE d = int ( c ) * 2 NEW_LINE print ( d ) NEW_LINE", "def solve ( ) : NEW_LINE INDENT a , b = ( input ( ) . split ( ) ) NEW_LINE print ( 2 * int ( a + b ) ) NEW_LINE DEDENT solve ( ) NEW_LINE", "A , B = input ( ) . split ( ) NEW_LINE As = [ i for i in A ] + [ j for j in B ] NEW_LINE print ( int ( \" \" . join ( As ) ) * 2 ) NEW_LINE" ]
atcoder_abc067_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 b = scan . nextInt ( ) ; if ( a % 3 == 0 || b % 3 == 0 || ( a + b ) % 3 == 0 ) { System . out . println ( \" Possible \" ) ; } else { System . out . println ( \" Impossible \" ) ; } } }", "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 ( ) ; out . println ( ( a % 3 == 0 ) || ( b % 3 == 0 ) || ( ( a + b ) % 3 == 0 ) ? \" Possible \" : \" Impossible \" ) ; } 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 ( ) ; if ( A % 3 == 0 || B % 3 == 0 || ( A + B ) % 3 == 0 ) { out . println ( \" Possible \" ) ; } else { out . println ( \" Impossible \" ) ; } } } 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 ) { Main main = new Main ( ) ; Scanner sc = new Scanner ( System . in ) ; main . solve ( sc ) ; sc . close ( ) ; } void solve ( Scanner sc ) { int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A % 3 == 0 ) { System . out . println ( \" Possible \" ) ; } else if ( B % 3 == 0 ) { System . out . println ( \" Possible \" ) ; } else if ( ( A + B ) % 3 == 0 ) { System . out . println ( \" Possible \" ) ; } else { System . out . println ( \" Impossible \" ) ; } } }", "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 ) % 3 == 0 || ( a * b ) % 3 == 0 ? \" Possible \" : \" Impossible \" ) ; } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( \" Possible \" if a % 3 == 0 or b % 3 == 0 or ( a + b ) % 3 == 0 else \" Impossible \" ) NEW_LINE", "[ A , B ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if A % 3 == 0 or B % 3 == 0 or ( A + B ) % 3 == 0 : NEW_LINE INDENT print ( \" Possible \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE DEDENT", "a , b = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE if a % 3 == 0 or b % 3 == 0 or ( a + b ) % 3 == 0 : NEW_LINE INDENT print ( \" Possible \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE DEDENT", "a , b = map ( int , input ( ) . split ( ) ) ; print ( ( ' P ' * ( a % 3 == 0 or b % 3 == 0 or ( a + b ) % 3 == 0 ) or ' Imp ' ) + ' ossible ' ) NEW_LINE", "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( [ \" Possible \" , \" Impossible \" ] [ bool ( A * B * ( A + B ) % 3 ) ] ) NEW_LINE" ]
atcoder_arc039_A
[ "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 res = Math . max ( Math . max ( Math . max ( ( a % 100 + 900 ) - b , a - ( b % 100 + 100 ) ) , Math . max ( ( a / 100 * 100 + a % 10 + 90 - b ) , ( a - ( b / 100 * 100 + b % 10 ) ) ) ) , Math . max ( a / 10 * 10 + 9 - b , ( a - ( b / 10 * 10 ) ) ) ) ; System . out . println ( res ) ; } }", "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 int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static IntStream REPS ( int r ) { return IntStream . range ( 0 , r ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INTS ( int l ) { return REPS ( l ) . map ( i -> getInt ( ) ) ; } public static void main ( String [ ] __ ) { char [ ] a = s . next ( ) . toCharArray ( ) , aa = Arrays . copyOf ( a , a . length ) , b = s . next ( ) . toCharArray ( ) , bb = Arrays . copyOf ( b , b . length ) ; for ( int i = 0 ; i < aa . length ; i ++ ) { if ( aa [ i ] != '9' ) { aa [ i ] = '9' ; break ; } } if ( bb [ 0 ] == '1' ) { for ( int i = 1 ; i < bb . length ; i ++ ) { if ( bb [ i ] != '0' ) { bb [ i ] = '0' ; break ; } } } else { bb [ 0 ] = '1' ; } System . out . println ( Math . max ( miare ( aa ) - miare ( b ) , miare ( a ) - miare ( bb ) ) ) ; } static int miare ( char [ ] c ) { return Integer . parseInt ( String . valueOf ( c ) ) ; } }", "import java . util . Scanner ; class Main { void solve ( ) { Scanner in = new Scanner ( System . in ) ; String [ ] list = in . nextLine ( ) . split ( \" ▁ \" ) ; String a = list [ 0 ] ; String b = list [ 1 ] ; int max = Integer . MIN_VALUE ; int v = Integer . valueOf ( \"9\" + a . charAt ( 1 ) + a . charAt ( 2 ) ) ; max = Math . max ( max , v - Integer . valueOf ( b ) ) ; v = Integer . valueOf ( a . charAt ( 0 ) + \"9\" + a . charAt ( 2 ) ) ; max = Math . max ( max , v - Integer . valueOf ( b ) ) ; v = Integer . valueOf ( \" \" + a . charAt ( 0 ) + a . charAt ( 1 ) + \"9\" ) ; max = Math . max ( max , v - Integer . valueOf ( b ) ) ; v = Integer . valueOf ( \"1\" + b . charAt ( 1 ) + b . charAt ( 2 ) ) ; max = Math . max ( max , Integer . valueOf ( a ) - v ) ; v = Integer . valueOf ( b . charAt ( 0 ) + \"0\" + b . charAt ( 2 ) ) ; max = Math . max ( max , Integer . valueOf ( a ) - v ) ; v = Integer . valueOf ( \" \" + b . charAt ( 0 ) + b . charAt ( 1 ) + \"0\" ) ; max = Math . max ( max , Integer . valueOf ( a ) - v ) ; System . out . println ( max ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String sa = String . valueOf ( a ) ; String sb = String . valueOf ( b ) ; int topa = Integer . parseInt ( sa . substring ( 0 , 1 ) ) ; int topb = Integer . parseInt ( sb . substring ( 0 , 1 ) ) ; int seca = Integer . parseInt ( String . valueOf ( a ) . substring ( 1 , 2 ) ) ; int secb = Integer . parseInt ( String . valueOf ( b ) . substring ( 1 , 2 ) ) ; int a3 = Integer . parseInt ( String . valueOf ( a ) . substring ( 2 , 3 ) ) ; int b3 = Integer . parseInt ( String . valueOf ( b ) . substring ( 2 , 3 ) ) ; long ans = a - b ; for ( int i = 1 ; i <= 9 ; i ++ ) { ans = Math . max ( 100 * i + a % 100 - b , ans ) ; ans = Math . max ( a - 100 * i - b % 100 , ans ) ; } for ( int i = 0 ; i <= 9 ; i ++ ) { ans = Math . max ( ans , 100 * topa + 10 * i + a3 - b ) ; ans = Math . max ( ans , a - 100 * topb - 10 * i - b3 ) ; ans = Math . max ( ans , 100 * topa + 10 * seca + i - b ) ; ans = Math . max ( ans , a - 100 * topb - 10 * secb - i ) ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int a = scanner . nextInt ( ) , b = scanner . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( a - b + Math . max ( 9 - a / 100 , b / 100 - 1 ) * 100 , a - b + Math . max ( 9 - a % 100 / 10 , b % 100 / 10 ) * 10 ) , a - b + Math . max ( 9 - a % 10 , b % 10 ) ) ) ; } }" ]
[ "a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if 9 - int ( a / 100 ) > int ( b / 100 ) - 1 : NEW_LINE INDENT print ( a + 100 * ( 9 - int ( a / 100 ) ) - b ) NEW_LINE DEDENT elif 9 - int ( a / 100 ) < int ( b / 100 ) - 1 : NEW_LINE INDENT print ( a - b + 100 * ( int ( b / 100 ) - 1 ) ) NEW_LINE DEDENT elif int ( a / 100 ) == 9 and int ( b / 100 ) == 1 : NEW_LINE INDENT if int ( a / 10 ) == 99 and int ( b / 10 ) == 10 : NEW_LINE INDENT num = max ( 9 - a % 10 , b % 10 ) NEW_LINE print ( a - b + int ( num ) ) NEW_LINE DEDENT else : NEW_LINE INDENT num2 = max ( 9 - int ( ( a - 900 ) / 10 ) , int ( ( b - 100 ) / 10 ) ) NEW_LINE print ( a - b + int ( num2 * 10 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( a - b + 100 * ( int ( b / 100 ) - 1 ) ) NEW_LINE DEDENT", "A , B = input ( ) . split ( ) NEW_LINE C = A . replace ( A [ 0 ] , '9' , 1 ) NEW_LINE D = A [ : 1 ] + '9' + A [ 2 : ] NEW_LINE E = A [ : 2 ] + '9' NEW_LINE F = B . replace ( B [ 0 ] , '1' , 1 ) NEW_LINE G = B [ : 1 ] + '0' + B [ 2 : ] NEW_LINE H = B [ : 2 ] + '0' NEW_LINE I = [ int ( A ) , int ( C ) , int ( D ) , int ( E ) ] NEW_LINE J = [ int ( B ) , int ( F ) , int ( G ) , int ( H ) ] NEW_LINE ans = - 999 NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT if I [ i ] - int ( B ) >= ans : NEW_LINE INDENT ans = I [ i ] - int ( B ) NEW_LINE DEDENT DEDENT for j in range ( 4 ) : NEW_LINE INDENT if int ( A ) - J [ j ] >= ans : NEW_LINE INDENT ans = int ( A ) - J [ j ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "A , B = input ( ) . split ( ) NEW_LINE a = max ( int ( \"9\" + A [ 1 ] + A [ 2 ] ) , int ( A [ 0 ] + \"9\" + A [ 2 ] ) , int ( A [ 0 ] + A [ 1 ] + \"9\" ) ) NEW_LINE b = min ( int ( \"1\" + B [ 1 ] + B [ 2 ] ) , int ( B [ 0 ] + \"0\" + B [ 2 ] ) , int ( B [ 0 ] + B [ 1 ] + \"0\" ) ) NEW_LINE print ( max ( a - int ( B ) , int ( A ) - b ) ) NEW_LINE", "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE pA = [ int ( c ) for c in list ( str ( A ) ) ] NEW_LINE if pA [ 0 ] == 9 : NEW_LINE INDENT if pA [ 1 ] == 9 : NEW_LINE INDENT if pA [ 2 ] == 9 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT pA [ 2 ] = 9 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT pA [ 1 ] = 9 NEW_LINE DEDENT DEDENT else : pA [ 0 ] = 9 NEW_LINE ppA = pA [ 0 ] * 100 + pA [ 1 ] * 10 + pA [ 2 ] NEW_LINE pB = [ int ( c ) for c in list ( str ( B ) ) ] NEW_LINE if pB [ 0 ] == 1 : NEW_LINE INDENT if pB [ 1 ] > 0 : NEW_LINE INDENT pB [ 1 ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT if pB [ 2 ] > 0 : NEW_LINE INDENT pB [ 2 ] = 0 NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT pB [ 0 ] = 1 NEW_LINE DEDENT ppB = pB [ 0 ] * 100 + pB [ 1 ] * 10 + pB [ 2 ] NEW_LINE print ( max ( A - B , ppA - B , A - ppB ) ) NEW_LINE", "def main ( ) : NEW_LINE INDENT a , b = input ( ) . split ( ) NEW_LINE subs = [ int ( a ) - int ( b ) , int ( \"9\" + a [ 1 ] + a [ 2 ] ) - int ( b ) , int ( a [ 0 ] + \"9\" + a [ 2 ] ) - int ( b ) , int ( a [ 0 ] + a [ 1 ] + \"9\" ) - int ( b ) , int ( a ) - int ( \"1\" + b [ 1 ] + b [ 2 ] ) , int ( a ) - int ( b [ 0 ] + \"0\" + b [ 2 ] ) , int ( a ) - int ( b [ 0 ] + b [ 1 ] + \"0\" ) , ] NEW_LINE print ( max ( subs ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc098_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int max = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { int count = 0 ; for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { if ( s . substring ( 0 , i ) . contains ( String . valueOf ( c ) ) && s . substring ( i ) . contains ( String . valueOf ( c ) ) ) { count ++ ; } } if ( count > max ) { max = count ; } } System . out . println ( max ) ; sc . close ( ) ; } }", "import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; 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 ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { Set < Character > startSet = new HashSet < > ( i ) ; for ( int j = 0 ; j < i ; j ++ ) { startSet . add ( s [ j ] ) ; } Set < Character > endSet = new HashSet < > ( n - i ) ; for ( int j = i ; j < n ; j ++ ) { endSet . add ( s [ j ] ) ; } startSet . retainAll ( endSet ) ; ans = Math . max ( ans , startSet . size ( ) ) ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String po = sc . nextLine ( ) ; po = sc . nextLine ( ) ; int count = 0 ; for ( int i = 1 ; i < po . length ( ) ; i ++ ) { int nm = 0 ; String a = po . substring ( 0 , i ) ; String b = po . substring ( i ) ; Map < String , Integer > m = new HashMap < String , Integer > ( ) ; for ( int j = 0 ; j < a . length ( ) ; j ++ ) { m . put ( a . substring ( j , j + 1 ) , 1 ) ; } for ( int j = 0 ; j < b . length ( ) ; j ++ ) { if ( m . get ( b . substring ( j , j + 1 ) ) != null ) { nm ++ ; m . put ( b . substring ( j , j + 1 ) , null ) ; } } count = Math . max ( count , nm ) ; } System . out . println ( count ) ; } }", "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 ( ) ) ; String S = sc . next ( ) ; int [ ] cntnum = new int [ N ] ; int cnt = 0 ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { int ans = 0 ; String s1 = S . substring ( 0 , i ) ; String s2 = S . substring ( i , N ) ; for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { String d = String . valueOf ( c ) ; if ( s1 . indexOf ( d ) != - 1 && s2 . indexOf ( d ) != - 1 ) { ans ++ ; } } if ( cnt < ans ) { cnt = ans ; } } out . print ( cnt ) ; out . flush ( ) ; } }", "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 ( ) ; String s = sc . next ( ) ; int max = 0 ; int a , j ; ArrayList < Integer > c = new ArrayList < > ( ) ; ArrayList < Integer > cc = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { j = 0 ; a = 0 ; while ( j <= i ) { int b = s . charAt ( j ) ; c . add ( b ) ; j ++ ; } while ( j < N ) { int d = s . charAt ( j ) ; if ( c . contains ( d ) && ! cc . contains ( d ) ) { a ++ ; cc . add ( d ) ; } j ++ ; } if ( a > max ) max = a ; c . clear ( ) ; cc . clear ( ) ; } System . out . println ( max ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE s = str ( input ( ) ) NEW_LINE s1 = ' ' NEW_LINE s2 = ' ' NEW_LINE max = 0 NEW_LINE for i in range ( 1 , n - 1 ) : NEW_LINE INDENT count = { } NEW_LINE s1 = s [ : i ] NEW_LINE s2 = s [ i : ] NEW_LINE for j in range ( len ( s1 ) ) : NEW_LINE INDENT if s2 . count ( s1 [ j ] ) >= 1 : NEW_LINE INDENT count [ s1 [ j ] ] = 1 NEW_LINE DEDENT DEDENT data = list ( count . keys ( ) ) NEW_LINE if len ( data ) > max : NEW_LINE INDENT max = len ( data ) NEW_LINE DEDENT DEDENT print ( max ) NEW_LINE", "_ , a = open ( 0 ) ; print ( max ( len ( set ( a [ : s ] ) & set ( a [ s : ] ) ) for s in range ( 99 ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE def countCommonLetter ( X , Y ) : NEW_LINE INDENT return len ( set ( [ x for x in X if x in Y ] ) ) NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT return max ( [ countCommonLetter ( s [ : i ] , s [ i : ] ) for i in range ( 1 , N ) ] ) NEW_LINE DEDENT print ( solve ( ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , N - 1 ) : NEW_LINE INDENT cnt = 0 NEW_LINE X = s [ : i ] NEW_LINE Y = s [ i : ] NEW_LINE alpX = [ 0 for j in range ( 26 ) ] NEW_LINE alpY = [ 0 for j in range ( 26 ) ] NEW_LINE lenX = i NEW_LINE lenY = N - i NEW_LINE for j in range ( lenX ) : NEW_LINE INDENT alpX [ ord ( X [ j ] ) - 97 ] += 1 NEW_LINE DEDENT for j in range ( lenY ) : NEW_LINE INDENT alpY [ ord ( Y [ j ] ) - 97 ] += 1 NEW_LINE DEDENT for j in range ( 26 ) : NEW_LINE INDENT if alpX [ j ] != 0 and alpY [ j ] != 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT if ans < cnt : NEW_LINE INDENT ans = cnt NEW_LINE DEDENT DEDENT print ( str ( ans ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE import string NEW_LINE abcs = string . ascii_lowercase NEW_LINE ans = 0 NEW_LINE for sakaime in range ( N ) : NEW_LINE INDENT cnt = 0 NEW_LINE left = S [ : sakaime ] NEW_LINE right = S [ sakaime : ] NEW_LINE for alpha in abcs : NEW_LINE INDENT if alpha in left and alpha in right : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT ans = max ( ans , cnt ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc035_A
[ "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 w = in . nextInt ( ) ; int h = in . nextInt ( ) ; out . println ( w / 4 == h / 3 ? \"4:3\" : \"16:9\" ) ; } } 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 . * ; 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 w = nextInt ( ) , h = nextInt ( ) ; out . println ( w * 3 == h * 4 ? \"4:3\" : \"16:9\" ) ; } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { String [ ] line = new Scanner ( System . in ) . nextLine ( ) . split ( \" ▁ \" , 2 ) ; int w = Integer . parseInt ( line [ 0 ] ) ; int h = Integer . parseInt ( line [ 1 ] ) ; if ( w * 3 == h * 4 ) { System . out . println ( \"4:3\" ) ; } else { System . out . println ( \"16:9\" ) ; } } }", "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 * 3 == b * 4 ? \"4:3\" : \"16:9\" ) ; } 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 W = in . nextInt ( ) ; int H = in . nextInt ( ) ; if ( W * 3 == H * 4 ) { out . println ( \"4:3\" ) ; } else { out . println ( \"16:9\" ) ; } } } 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 ( ) ) ; } } }" ]
[ "W , H = map ( int , input ( ) . split ( ) ) NEW_LINE if W / H == 4 / 3 : NEW_LINE INDENT print ( \"4:3\" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \"16:9\" ) NEW_LINE DEDENT", "print ( '146 : : 39' [ eval ( input ( ) . replace ( ' ▁ ' , ' / ' ) ) < 1.7 : : 2 ] ) 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 tv ( H : int , W : int ) -> str : NEW_LINE INDENT g = gcd ( H , W ) NEW_LINE return ' { } : { } ' . format ( H // g , W // g ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT H , W = map ( int , input ( ) . split ( ) ) NEW_LINE ans = tv ( H , W ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "import fractions NEW_LINE a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE x = a // ( fractions . gcd ( a , b ) ) NEW_LINE y = b // ( fractions . gcd ( a , b ) ) NEW_LINE print ( \" { 0 } : {1 } \" . format ( x , y ) ) NEW_LINE", "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE print ( '16:9' if ( x / y ) > 1.6 else '4:3' ) NEW_LINE" ]
atcoder_abc061_D
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; final long INF = - 1_000_000_000_000_000L ; long [ ] dist = new long [ N ] ; for ( int i = 1 ; i < N ; i ++ ) dist [ i ] = INF ; int [ ] [ ] edges = new int [ M ] [ 2 ] ; int [ ] costs = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { edges [ i ] = new int [ ] { scanner . nextInt ( ) - 1 , scanner . nextInt ( ) - 1 } ; costs [ i ] = scanner . nextInt ( ) ; } int [ ] prev = new int [ N ] ; prev [ 0 ] = - 1 ; for ( int i = 0 ; i < 2 * N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { int from = edges [ j ] [ 0 ] ; int to = edges [ j ] [ 1 ] ; int cost = costs [ j ] ; if ( dist [ from ] > INF ) { long newValue = dist [ from ] + cost ; if ( newValue > dist [ to ] ) { dist [ to ] = newValue ; prev [ to ] = from ; } } } } boolean [ ] visited = new boolean [ N ] ; int i = N - 1 ; while ( i != - 1 ) { if ( visited [ i ] ) { System . out . println ( \" inf \" ) ; return ; } visited [ i ] = true ; i = prev [ i ] ; } System . out . println ( dist [ N - 1 ] ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; class Main { static int n ; static int m ; static Edge [ ] e ; static long dis [ ] ; static final long inf = 1000000000000000l ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; e = new Edge [ m ] ; dis = new long [ n ] ; Arrays . fill ( dis , inf ) ; dis [ 0 ] = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; e [ i ] = new Edge ( a - 1 , b - 1 , - c ) ; } sc . close ( ) ; if ( bellmanFord ( ) ) { System . out . print ( \" inf \" ) ; } else { System . out . println ( - dis [ n - 1 ] ) ; } } public static boolean bellmanFord ( ) { for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( dis [ e [ j ] . from ] != inf && dis [ e [ j ] . to ] > dis [ e [ j ] . from ] + e [ j ] . cost ) { dis [ e [ j ] . to ] = dis [ e [ j ] . from ] + e [ j ] . cost ; if ( i == n && e [ j ] . to == n - 1 ) { return true ; } } } } return false ; } } class Edge { int from ; int to ; long cost ; Edge ( int from , int to , long cost ) { this . from = from ; this . to = to ; this . cost = cost ; } }", "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 m = sc . nextInt ( ) ; Edge [ ] edge = new Edge [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; long c = sc . nextLong ( ) ; edge [ i ] = new Edge ( a , b , - c ) ; } long [ ] dist = new long [ n ] ; Arrays . fill ( dist , Long . MAX_VALUE ) ; dist [ 0 ] = 0 ; boolean flag = true ; int cnt = 0 ; long ans = 0 ; while ( flag ) { flag = false ; for ( int i = 0 ; i < m ; i ++ ) { if ( dist [ edge [ i ] . from ] != Long . MAX_VALUE && dist [ edge [ i ] . to ] > dist [ edge [ i ] . from ] + edge [ i ] . cost ) { flag = true ; dist [ edge [ i ] . to ] = dist [ edge [ i ] . from ] + edge [ i ] . cost ; } } if ( cnt == n ) { ans = - dist [ n - 1 ] ; } if ( cnt == 2 * n ) { if ( ans < - dist [ n - 1 ] ) { System . out . println ( \" inf \" ) ; return ; } break ; } cnt ++ ; } System . out . println ( - dist [ n - 1 ] ) ; } static class Edge { int from ; int to ; long cost ; public Edge ( int from , int to , long cost ) { this . from = from ; this . to = to ; this . cost = cost ; } } }", "import java . util . Scanner ; public class Main { static final int MAX = 1000 ; static final long INF = 1000000000000000l ; static final int WHITE = 0 ; static final int GRAY = 1 ; static final int BLACK = 2 ; static int N , M ; static Edge [ ] e ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; M = sc . nextInt ( ) ; e = new Edge [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; e [ i ] = new Edge ( a - 1 , b - 1 , - c ) ; } sc . close ( ) ; if ( bellmanFord ( ) ) { System . out . println ( \" inf \" ) ; } else { System . out . println ( - d [ N - 1 ] ) ; } } static long [ ] d = new long [ MAX ] ; static boolean bellmanFord ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { d [ i ] = INF ; } d [ 0 ] = 0 ; for ( int i = 0 ; i < 2 * N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( d [ e [ j ] . from ] != INF && d [ e [ j ] . to ] > d [ e [ j ] . from ] + e [ j ] . cost ) { d [ e [ j ] . to ] = d [ e [ j ] . from ] + e [ j ] . cost ; if ( i >= N - 1 && e [ j ] . to == N - 1 ) return true ; } } } return false ; } static class Edge { int from , to ; long cost ; public Edge ( int from , int to , long cost ) { this . from = from ; this . to = to ; this . cost = cost ; } } }", "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 ( ) ; int [ ] [ ] edge = new int [ m ] [ 3 ] ; for ( int i = 0 ; i < m ; i ++ ) { edge [ i ] [ 0 ] = sc . nextInt ( ) - 1 ; edge [ i ] [ 1 ] = sc . nextInt ( ) - 1 ; edge [ i ] [ 2 ] = - sc . nextInt ( ) ; } long [ ] d = bellmanFord ( n , edge , 0 ) ; if ( d == null ) System . out . println ( \" inf \" ) ; else System . out . println ( - d [ n - 1 ] ) ; sc . close ( ) ; } public static long [ ] bellmanFord ( int n , int [ ] [ ] edge , int s ) { long d [ ] = new long [ n ] ; Arrays . fill ( d , Long . MAX_VALUE ) ; d [ s ] = 0L ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < edge . length ; j ++ ) { int [ ] e = edge [ j ] ; if ( d [ e [ 0 ] ] != Long . MAX_VALUE && d [ e [ 1 ] ] > d [ e [ 0 ] ] + e [ 2 ] ) { d [ e [ 1 ] ] = d [ e [ 0 ] ] + e [ 2 ] ; if ( i == n - 1 && e [ 1 ] == n - 1 ) { d = null ; break ; } } } } return d ; } }" ]
[ "INF = float ( ' inf ' ) NEW_LINE def solve ( ) : NEW_LINE INDENT lp = [ - INF ] * n NEW_LINE lp [ 0 ] = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for a , b , c in es : NEW_LINE INDENT if lp [ a ] != - INF and lp [ b ] < lp [ a ] + c : NEW_LINE INDENT lp [ b ] = lp [ a ] + c NEW_LINE if i == n - 1 and b == n - 1 : NEW_LINE INDENT return ' inf ' NEW_LINE DEDENT DEDENT DEDENT DEDENT return lp [ n - 1 ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE es = [ ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE a -= 1 NEW_LINE b -= 1 NEW_LINE es . append ( ( a , b , c ) ) NEW_LINE DEDENT print ( solve ( ) ) NEW_LINE DEDENT", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT INF = float ( \" inf \" ) NEW_LINE N , M = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE c = [ ] NEW_LINE d = [ INF ] * N NEW_LINE for i in range ( M ) : NEW_LINE INDENT s1 , s2 , s3 = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE a . append ( s1 ) NEW_LINE b . append ( s2 ) NEW_LINE c . append ( - s3 ) NEW_LINE DEDENT d [ 0 ] = 0 NEW_LINE cnt = [ 0 ] * N NEW_LINE for j in range ( N ) : NEW_LINE INDENT update = False NEW_LINE for i in range ( M ) : NEW_LINE INDENT if math . isinf ( d [ a [ i ] - 1 ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( d [ b [ i ] - 1 ] > d [ a [ i ] - 1 ] + c [ i ] ) : NEW_LINE INDENT d [ b [ i ] - 1 ] = d [ a [ i ] - 1 ] + c [ i ] NEW_LINE cnt [ b [ i ] - 1 ] += 1 NEW_LINE update = True NEW_LINE DEDENT DEDENT if not update : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if cnt [ N - 1 ] < N : NEW_LINE INDENT ans = - d [ N - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' inf ' NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def bellman_ford ( vertex_num : int , edges : list , source : int , sink : int ) -> list : NEW_LINE INDENT distances = [ float ( ' inf ' ) ] * ( vertex_num ) NEW_LINE distances [ source ] = 0 NEW_LINE for _ in range ( vertex_num ) : NEW_LINE INDENT for u , v , c in edges : NEW_LINE INDENT distances [ v ] = min ( distances [ v ] , distances [ u ] + c ) NEW_LINE DEDENT DEDENT for u , v , c in edges : NEW_LINE INDENT if distances [ u ] + c < distances [ v ] : NEW_LINE INDENT distances [ v ] = distances [ u ] + c NEW_LINE if v == sink : NEW_LINE INDENT return [ ] NEW_LINE DEDENT DEDENT DEDENT return distances NEW_LINE DEDENT def score_attack ( N : int , M : int , edges : list ) -> int : NEW_LINE INDENT distances = bellman_ford ( N , [ ( u - 1 , v - 1 , - c ) for u , v , c in edges ] , 0 , N - 1 ) NEW_LINE return - distances [ N - 1 ] if distances else float ( ' inf ' ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT M = 0 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE edges = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( M ) ] NEW_LINE ans = score_attack ( N , M , edges ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 6 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE abc = [ [ int ( j ) for j in input ( ) . split ( ) ] for _ in range ( M ) ] NEW_LINE con = [ [ ] for _ in range ( N + 1 ) ] NEW_LINE inf = float ( \" inf \" ) NEW_LINE allcost = [ - inf ] * ( N + 1 ) NEW_LINE allcost [ 1 ] = 0 NEW_LINE for i in range ( M ) : NEW_LINE INDENT a , b , c = abc [ i ] NEW_LINE con [ a ] . append ( b ) NEW_LINE DEDENT for n in range ( 1 , N ) : NEW_LINE INDENT for edge in range ( M ) : NEW_LINE INDENT a , b , c = abc [ edge ] NEW_LINE if allcost [ b ] < allcost [ a ] + c : NEW_LINE INDENT allcost [ b ] = allcost [ a ] + c NEW_LINE DEDENT DEDENT DEDENT neg = [ False ] * ( N + 1 ) NEW_LINE for edge in range ( M ) : NEW_LINE INDENT a , b , c = abc [ edge ] NEW_LINE if allcost [ a ] + c > allcost [ b ] : NEW_LINE INDENT neg [ b ] = True NEW_LINE DEDENT if neg [ a ] == True : NEW_LINE INDENT neg [ b ] = True NEW_LINE DEDENT DEDENT if neg [ N ] : NEW_LINE INDENT print ( \" inf \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT print ( allcost [ N ] ) NEW_LINE", "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ 0 ] * m NEW_LINE b = [ 0 ] * m NEW_LINE c = [ 0 ] * m NEW_LINE for i in range ( 0 , m ) : NEW_LINE INDENT a [ i ] , b [ i ] , c [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE a [ i ] = a [ i ] - 1 NEW_LINE b [ i ] = b [ i ] - 1 NEW_LINE c [ i ] = - c [ i ] NEW_LINE DEDENT INF = ( n - 1 ) * max ( abs ( min ( c ) ) , abs ( max ( c ) ) ) NEW_LINE dist = [ INF ] * n NEW_LINE dist [ 0 ] = 0 NEW_LINE for j in range ( 0 , n - 1 ) : NEW_LINE INDENT for i in range ( 0 , m ) : NEW_LINE INDENT if dist [ a [ i ] ] == INF : NEW_LINE INDENT continue NEW_LINE DEDENT dist [ b [ i ] ] = min ( dist [ b [ i ] ] , dist [ a [ i ] ] + c [ i ] ) NEW_LINE DEDENT DEDENT ans = - dist [ n - 1 ] NEW_LINE negative = [ False ] * n NEW_LINE for j in range ( 0 , n ) : NEW_LINE INDENT for i in range ( 0 , m ) : NEW_LINE INDENT if dist [ a [ i ] ] == INF : NEW_LINE INDENT continue NEW_LINE DEDENT if negative [ a [ i ] ] : NEW_LINE INDENT negative [ b [ i ] ] = True NEW_LINE DEDENT elif dist [ a [ i ] ] + c [ i ] < dist [ b [ i ] ] : NEW_LINE INDENT dist [ b [ i ] ] = dist [ a [ i ] ] + c [ i ] NEW_LINE negative [ b [ i ] ] = True NEW_LINE DEDENT DEDENT DEDENT if negative [ n - 1 ] : NEW_LINE INDENT print ( \" inf \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ans ) NEW_LINE DEDENT" ]
atcoder_arc071_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] chars = new int [ n ] [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { chars [ i ] [ ( int ) ( s . charAt ( j ) - ' a ' ) ] ++ ; } } String ans = \" \" ; for ( int i = 0 ; i < 26 ; i ++ ) { int min = Integer . MAX_VALUE ; for ( int j = 0 ; j < n ; j ++ ) { min = Math . min ( min , chars [ j ] [ i ] ) ; } for ( int j = 0 ; j < min ; j ++ ) { ans += ( char ) ( i + ' a ' ) ; } } System . out . println ( ans ) ; return ; } }", "import java . util . * ; public class Main { public static int order ( long a ) { int o = 0 ; long d = 1 ; while ( d <= a ) { o ++ ; d *= 10 ; } return o ; } public static int ABCNumber ( char a ) { int num = - 1 ; char [ ] abc = \" abcdefghijklmnopqrstuvwxyz \" . toCharArray ( ) ; for ( int n = 0 ; n < 26 ; n ++ ) { if ( a == abc [ n ] ) num = n ; } return num ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; String [ ] S = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { S [ i ] = sc . next ( ) ; } int [ ] xmin = new int [ 26 ] ; for ( int n = 0 ; n < 26 ; n ++ ) xmin [ n ] = 50 ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] x = new int [ 26 ] ; for ( char a : S [ i ] . toCharArray ( ) ) { x [ ABCNumber ( a ) ] ++ ; } for ( int n = 0 ; n < 26 ; n ++ ) { xmin [ n ] = Math . min ( xmin [ n ] , x [ n ] ) ; } } char [ ] abc = \" abcdefghijklmnopqrstuvwxyz \" . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int n = 0 ; n < 26 ; n ++ ) { for ( int cnt = 0 ; cnt < xmin [ n ] ; cnt ++ ) sb . append ( abc [ n ] ) ; } System . out . println ( sb . toString ( ) ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { int ni ( ) { return cin . nextInt ( ) ; } long nl ( ) { return cin . nextLong ( ) ; } String line ( ) { return cin . nextLine ( ) ; } void println ( String str ) { System . out . println ( str ) ; } void print ( String str ) { System . out . print ( str ) ; } static final int MOD = 1000000007 ; Scanner cin = new Scanner ( System . in ) ; String output ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { input ( ) ; output = solve ( ) ; println ( output ) ; } int N ; String [ ] words ; void input ( ) { N = ni ( ) ; words = new String [ N ] ; line ( ) ; for ( int i = 0 ; i < N ; i ++ ) { words [ i ] = line ( ) ; } } String solve ( ) { int [ ] cnt1 = new int [ 26 ] ; int [ ] cnt2 ; for ( char c : words [ 0 ] . toCharArray ( ) ) { cnt1 [ c - ' a ' ] ++ ; } for ( int i = 1 ; i < N ; i ++ ) { cnt2 = new int [ 26 ] ; for ( char c : words [ i ] . toCharArray ( ) ) { cnt2 [ c - ' a ' ] ++ ; } for ( int j = 0 ; j < 26 ; j ++ ) { if ( cnt1 [ j ] == 0 ) { continue ; } cnt1 [ j ] = Math . min ( cnt1 [ j ] , cnt2 [ j ] ) ; } } StringBuilder res = new StringBuilder ( ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( cnt1 [ i ] == 0 ) { continue ; } for ( int j = 0 ; j < cnt1 [ i ] ; j ++ ) { res . append ( ( char ) ( i + ' a ' ) ) ; } } return res . toString ( ) ; } }", "import java . util . Scanner ; import java . util . Set ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; public final class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int arraySize = Integer . parseInt ( s . nextLine ( ) . trim ( ) ) ; ArrayList < String > words = new ArrayList ( ) ; for ( int i = 0 ; i < arraySize ; i ++ ) { words . add ( s . nextLine ( ) . trim ( ) ) ; } ArrayList < ArrayList < Character > > keeper = new ArrayList ( ) ; for ( int i = 0 ; i < arraySize ; i ++ ) { ArrayList < Character > temp = new ArrayList ( ) ; char [ ] tempArr = words . get ( i ) . toCharArray ( ) ; for ( int x = 0 ; x < tempArr . length ; x ++ ) { temp . add ( tempArr [ x ] ) ; } keeper . add ( temp ) ; } ArrayList < Character > resultWords = new ArrayList ( ) ; for ( char c : keeper . get ( 0 ) ) { boolean shouldAdd = true ; for ( int index = 1 ; index < keeper . size ( ) ; index ++ ) { ArrayList < Character > arr = keeper . get ( index ) ; if ( arr . contains ( c ) ) { arr . remove ( ( Object ) c ) ; } else { shouldAdd = false ; } } if ( shouldAdd ) { resultWords . add ( c ) ; } } String result = \" \" ; while ( ! resultWords . isEmpty ( ) ) { char c = findLeast ( resultWords ) ; result += c ; resultWords . remove ( ( Object ) c ) ; } System . out . println ( result ) ; } public static char findLeast ( ArrayList < Character > chars ) { char result = ' z ' ; for ( char c : chars ) { if ( c < result ) { result = c ; } } return result ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . Scanner ; import java . util . ArrayList ; import java . util . Collections ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int times = Integer . valueOf ( s . nextLine ( ) ) ; ArrayList < String > list = new ArrayList < String > ( ) ; String word = s . nextLine ( ) ; for ( int x = 0 ; x < word . length ( ) ; x ++ ) { list . add ( \" \" + word . charAt ( x ) ) ; } for ( int x = 1 ; x < times ; x ++ ) { ArrayList < String > temp = new ArrayList < String > ( ) ; word = s . nextLine ( ) ; for ( int y = 0 ; y < word . length ( ) ; y ++ ) { String a = \" \" + word . charAt ( y ) ; if ( list . contains ( a ) ) { list . remove ( list . indexOf ( a ) ) ; temp . add ( a ) ; } } list = temp ; } Collections . sort ( list ) ; String build = \" \" ; for ( String thing : list ) build += thing ; System . out . println ( build ) ; } }" ]
[ "l = [ chr ( i ) for i in range ( 97 , 97 + 26 ) ] NEW_LINE s = [ ] NEW_LINE for _ in [ 0 ] * int ( input ( ) ) : NEW_LINE INDENT s . append ( input ( ) ) NEW_LINE DEDENT w = \" \" NEW_LINE for x in l : NEW_LINE INDENT a = [ t . count ( x ) for t in s ] NEW_LINE w += x * min ( a ) NEW_LINE DEDENT print ( w ) NEW_LINE", "def getInt ( ) : return int ( input ( ) ) NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT debug = False NEW_LINE n = getInt ( ) NEW_LINE Str = zeros ( n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT Str [ i ] = [ c for c in input ( ) ] NEW_LINE Str [ i ] . sort ( ) NEW_LINE Str [ i ] = ' ' . join ( Str [ i ] ) NEW_LINE DEDENT db ( ( Str , n ) ) NEW_LINE idx = zeros ( n ) NEW_LINE widx = zeros ( n ) NEW_LINE dub = ' ' NEW_LINE for i in range ( len ( Str [ 0 ] ) ) : NEW_LINE INDENT allFound = True NEW_LINE for j in range ( 1 , n ) : NEW_LINE INDENT widx [ j ] = Str [ j ] . find ( Str [ 0 ] [ i ] , idx [ j ] ) NEW_LINE if widx [ j ] == - 1 : NEW_LINE INDENT allFound = False NEW_LINE DEDENT DEDENT if allFound : NEW_LINE INDENT dub = dub + Str [ 0 ] [ i ] NEW_LINE db ( dub ) NEW_LINE for j in range ( 1 , n ) : NEW_LINE INDENT idx [ j ] = widx [ j ] + 1 NEW_LINE DEDENT DEDENT DEDENT print ( dub ) NEW_LINE", "from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE S = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT s = input ( ) NEW_LINE C = Counter ( s ) NEW_LINE S . append ( C ) NEW_LINE DEDENT dp = [ float ( ' inf ' ) ] * 26 NEW_LINE uni_a = ord ( ' a ' ) NEW_LINE for s in S : NEW_LINE INDENT for i in range ( 26 ) : NEW_LINE INDENT dp [ i ] = min ( dp [ i ] , s [ chr ( uni_a + i ) ] ) NEW_LINE DEDENT DEDENT ans = ' ' NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT ans += chr ( uni_a + i ) * dp [ i ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "n = int ( input ( ) . strip ( ) ) NEW_LINE slis = { ' a ' : 0 , ' b ' : 0 , ' c ' : 0 , ' d ' : 0 , ' e ' : 0 , ' f ' : 0 , ' g ' : 0 , ' h ' : 0 , ' i ' : 0 , ' j ' : 0 , ' k ' : 0 , ' l ' : 0 , ' m ' : 0 , ' n ' : 0 , ' o ' : 0 , ' p ' : 0 , ' q ' : 0 , ' r ' : 0 , ' s ' : 0 , ' t ' : 0 , ' u ' : 0 , ' v ' : 0 , ' w ' : 0 , ' x ' : 0 , ' y ' : 0 , ' z ' : 0 } NEW_LINE tlis = { ' a ' : 0 , ' b ' : 0 , ' c ' : 0 , ' d ' : 0 , ' e ' : 0 , ' f ' : 0 , ' g ' : 0 , ' h ' : 0 , ' i ' : 0 , ' j ' : 0 , ' k ' : 0 , ' l ' : 0 , ' m ' : 0 , ' n ' : 0 , ' o ' : 0 , ' p ' : 0 , ' q ' : 0 , ' r ' : 0 , ' s ' : 0 , ' t ' : 0 , ' u ' : 0 , ' v ' : 0 , ' w ' : 0 , ' x ' : 0 , ' y ' : 0 , ' z ' : 0 } NEW_LINE st = ' ' NEW_LINE S = input ( ) . strip ( ) NEW_LINE for j in range ( len ( S ) ) : NEW_LINE INDENT slis [ S [ j ] ] += 1 NEW_LINE DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT S = input ( ) . strip ( ) NEW_LINE for j in range ( len ( S ) ) : NEW_LINE INDENT tlis [ S [ j ] ] += 1 NEW_LINE DEDENT for j in tlis : NEW_LINE INDENT slis [ j ] = min ( tlis [ j ] , slis [ j ] ) NEW_LINE DEDENT for j in tlis : NEW_LINE INDENT tlis [ j ] = 0 NEW_LINE DEDENT DEDENT stup = [ ] NEW_LINE for i in slis : NEW_LINE INDENT stup . append ( ( i , slis [ i ] ) ) NEW_LINE DEDENT stup . sort ( ) NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT st = st + stup [ i ] [ 0 ] * stup [ i ] [ 1 ] NEW_LINE DEDENT print ( st ) NEW_LINE", "from collections import Counter NEW_LINE from functools import reduce NEW_LINE n = int ( input ( ) ) NEW_LINE ss = [ Counter ( input ( ) ) for _ in range ( n ) ] NEW_LINE s = ' ' NEW_LINE for c in sorted ( reduce ( lambda x , y : x & y , [ { c for c , n in s . items ( ) } for s in ss ] ) ) : NEW_LINE INDENT s += c * min ( s [ c ] for s in ss ) NEW_LINE DEDENT print ( s ) NEW_LINE" ]
atcoder_arc011_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > result = new ArrayList < String > ( ) ; HashMap < Character , Character > map = new HashMap < Character , Character > ( ) ; map . put ( ' b ' , '1' ) ; map . put ( ' c ' , '1' ) ; map . put ( ' d ' , '2' ) ; map . put ( ' w ' , '2' ) ; map . put ( ' t ' , '3' ) ; map . put ( ' j ' , '3' ) ; map . put ( ' f ' , '4' ) ; map . put ( ' q ' , '4' ) ; map . put ( ' l ' , '5' ) ; map . put ( ' v ' , '5' ) ; map . put ( ' s ' , '6' ) ; map . put ( ' x ' , '6' ) ; map . put ( ' p ' , '7' ) ; map . put ( ' m ' , '7' ) ; map . put ( ' h ' , '8' ) ; map . put ( ' k ' , '8' ) ; map . put ( ' n ' , '9' ) ; map . put ( ' g ' , '9' ) ; map . put ( ' z ' , '0' ) ; map . put ( ' r ' , '0' ) ; int N = sc . nextInt ( ) ; char w [ ] [ ] = new char [ N ] [ ] ; for ( int i = 0 ; i < N ; i ++ ) { w [ i ] = sc . next ( ) . toLowerCase ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < w . length ; i ++ ) { StringBuilder sb = new StringBuilder ( ) ; for ( char c : w [ i ] ) { Character num = map . get ( c ) ; if ( num != null ) { sb . append ( num ) ; } } if ( sb . length ( ) > 0 ) { result . add ( sb . toString ( ) ) ; } } System . out . println ( String . join ( \" ▁ \" , result ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; HashMap < Character , Character > map = new HashMap < Character , Character > ( ) ; map . put ( ' b ' , '1' ) ; map . put ( ' c ' , '1' ) ; map . put ( ' d ' , '2' ) ; map . put ( ' w ' , '2' ) ; map . put ( ' t ' , '3' ) ; map . put ( ' j ' , '3' ) ; map . put ( ' f ' , '4' ) ; map . put ( ' q ' , '4' ) ; map . put ( ' l ' , '5' ) ; map . put ( ' v ' , '5' ) ; map . put ( ' s ' , '6' ) ; map . put ( ' x ' , '6' ) ; map . put ( ' p ' , '7' ) ; map . put ( ' m ' , '7' ) ; map . put ( ' h ' , '8' ) ; map . put ( ' k ' , '8' ) ; map . put ( ' n ' , '9' ) ; map . put ( ' g ' , '9' ) ; map . put ( ' z ' , '0' ) ; map . put ( ' r ' , '0' ) ; int N = sc . nextInt ( ) ; List < String > result = new ArrayList < String > ( ) ; char w [ ] [ ] = new char [ N ] [ ] ; for ( int i = 0 ; i < N ; i ++ ) { w [ i ] = sc . next ( ) . toLowerCase ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < w . length ; i ++ ) { StringBuilder sb = new StringBuilder ( ) ; for ( char c : w [ i ] ) { Character num = map . get ( c ) ; if ( num != null ) { sb . append ( num ) ; } } if ( sb . length ( ) > 0 ) { result . add ( sb . toString ( ) ) ; } } System . out . println ( String . join ( \" ▁ \" , result ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > result = new ArrayList < String > ( ) ; HashMap < Character , Integer > map = new HashMap < Character , Integer > ( ) ; map . put ( ' b ' , 1 ) ; map . put ( ' c ' , 1 ) ; map . put ( ' d ' , 2 ) ; map . put ( ' w ' , 2 ) ; map . put ( ' t ' , 3 ) ; map . put ( ' j ' , 3 ) ; map . put ( ' f ' , 4 ) ; map . put ( ' q ' , 4 ) ; map . put ( ' l ' , 5 ) ; map . put ( ' v ' , 5 ) ; map . put ( ' s ' , 6 ) ; map . put ( ' x ' , 6 ) ; map . put ( ' p ' , 7 ) ; map . put ( ' m ' , 7 ) ; map . put ( ' h ' , 8 ) ; map . put ( ' k ' , 8 ) ; map . put ( ' n ' , 9 ) ; map . put ( ' g ' , 9 ) ; map . put ( ' z ' , 0 ) ; map . put ( ' r ' , 0 ) ; int N = sc . nextInt ( ) ; char w [ ] [ ] = new char [ N ] [ ] ; for ( int i = 0 ; i < N ; i ++ ) { w [ i ] = sc . next ( ) . toLowerCase ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < w . length ; i ++ ) { StringBuilder sb = new StringBuilder ( ) ; for ( char c : w [ i ] ) { Integer num = map . get ( c ) ; if ( num != null ) { sb . append ( num ) ; } } if ( sb . length ( ) > 0 ) { result . add ( sb . toString ( ) ) ; } } System . out . println ( String . join ( \" ▁ \" , result ) ) ; } }", "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 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 ( ) ) ; } public static void main ( String [ ] $ ) { System . out . println ( REPS ( getInt ( ) ) . mapToObj ( i -> s . next ( ) ) . map ( o -> o . toLowerCase ( ) . replaceAll ( \" [ ^ b - df - hj - np - tv - xz ] \" , \" \" ) . replaceAll ( \" [ bc ] \" , \"1\" ) . replaceAll ( \" [ dw ] \" , \"2\" ) . replaceAll ( \" [ tj ] \" , \"3\" ) . replaceAll ( \" [ fq ] \" , \"4\" ) . replaceAll ( \" [ lv ] \" , \"5\" ) . replaceAll ( \" [ sx ] \" , \"6\" ) . replaceAll ( \" [ pm ] \" , \"7\" ) . replaceAll ( \" [ hk ] \" , \"8\" ) . replaceAll ( \" [ ng ] \" , \"9\" ) . replaceAll ( \" [ zr ] \" , \"0\" ) ) . filter ( o -> o . length ( ) > 0 ) . collect ( Collectors . joining ( \" ▁ \" ) ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { final int [ ] TABLE = new int [ ] { - 1 , 1 , 1 , 2 , - 1 , 4 , 9 , 8 , - 1 , 3 , 8 , 5 , 7 , 9 , - 1 , 7 , 4 , 0 , 6 , 3 , - 1 , 5 , 2 , 6 , - 1 , 0 } ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( count != 0 ) { sb . append ( \" ▁ \" ) ; } String s = sc . next ( ) . toLowerCase ( ) ; count = 0 ; for ( char c : s . toCharArray ( ) ) { if ( c < ' a ' || c > ' z ' ) { continue ; } int v = TABLE [ c - ' a ' ] ; if ( v == - 1 ) { continue ; } sb . append ( v ) ; count ++ ; } } System . out . println ( sb . toString ( ) . trim ( ) ) ; } }" ]
[ "dicts = { ' b ' : '1' , ' c ' : '1' , ' d ' : '2' , ' w ' : '2' , ' t ' : '3' , ' j ' : '3' , ' f ' : '4' , ' q ' : '4' , ' l ' : '5' , ' v ' : '5' , ' s ' : '6' , ' x ' : '6' , ' p ' : '7' , ' m ' : '7' , ' h ' : '8' , ' k ' : '8' , ' n ' : '9' , ' g ' : '9' , ' z ' : '0' , ' r ' : '0' } NEW_LINE N = int ( input ( ) ) NEW_LINE ans = ' ' NEW_LINE for i , item in enumerate ( input ( ) . split ( ) ) : NEW_LINE INDENT tmp = ' ' NEW_LINE for string in item : NEW_LINE INDENT tmp += dicts . get ( string . lower ( ) , ' ' ) NEW_LINE DEDENT if ans != ' ' and tmp != ' ' : NEW_LINE INDENT ans += ' ▁ ' + tmp NEW_LINE DEDENT else : NEW_LINE INDENT ans += tmp NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import re NEW_LINE n = input ( ) NEW_LINE a = input ( ) . lower ( ) NEW_LINE a = a . replace ( ' b ' , '1' ) NEW_LINE a = a . replace ( ' c ' , '1' ) NEW_LINE a = a . replace ( ' d ' , '2' ) NEW_LINE a = a . replace ( ' w ' , '2' ) NEW_LINE a = a . replace ( ' t ' , '3' ) NEW_LINE a = a . replace ( ' j ' , '3' ) NEW_LINE a = a . replace ( ' f ' , '4' ) NEW_LINE a = a . replace ( ' q ' , '4' ) NEW_LINE a = a . replace ( ' l ' , '5' ) NEW_LINE a = a . replace ( ' v ' , '5' ) NEW_LINE a = a . replace ( ' s ' , '6' ) NEW_LINE a = a . replace ( ' x ' , '6' ) NEW_LINE a = a . replace ( ' p ' , '7' ) NEW_LINE a = a . replace ( ' m ' , '7' ) NEW_LINE a = a . replace ( ' h ' , '8' ) NEW_LINE a = a . replace ( ' k ' , '8' ) NEW_LINE a = a . replace ( ' n ' , '9' ) NEW_LINE a = a . replace ( ' g ' , '9' ) NEW_LINE a = a . replace ( ' z ' , '0' ) NEW_LINE a = a . replace ( ' r ' , '0' ) NEW_LINE a = a . replace ( ' , ' , ' ' ) NEW_LINE a = a . replace ( ' . ' , ' ' ) NEW_LINE a = re . sub ( r \" [ a - z ] \" , \" \" , a ) NEW_LINE a = re . sub ( r \" [ ▁ ] + \" , \" ▁ \" , a ) NEW_LINE a = \" \" if a == \" ▁ \" else a NEW_LINE print ( a . strip ( ) ) NEW_LINE", "a = int ( input ( ) ) NEW_LINE br = input ( ) . split ( \" ▁ \" ) NEW_LINE ar = [ ] NEW_LINE for b in br : NEW_LINE INDENT a = \" \" NEW_LINE for c in list ( b ) : NEW_LINE INDENT if c == \" z \" or c == \" r \" or c == \" Z \" or c == \" R \" : NEW_LINE INDENT a = a + \"0\" NEW_LINE DEDENT elif c == \" b \" or c == \" c \" or c == \" B \" or c == \" C \" : NEW_LINE INDENT a = a + \"1\" NEW_LINE DEDENT elif c == \" t \" or c == \" j \" or c == \" T \" or c == \" J \" : NEW_LINE INDENT a = a + \"3\" NEW_LINE DEDENT elif c == \" l \" or c == \" v \" or c == \" L \" or c == \" V \" : NEW_LINE INDENT a = a + \"5\" NEW_LINE DEDENT elif c == \" d \" or c == \" w \" or c == \" D \" or c == \" W \" : NEW_LINE INDENT a = a + \"2\" NEW_LINE DEDENT elif c == \" f \" or c == \" q \" or c == \" F \" or c == \" Q \" : NEW_LINE INDENT a = a + \"4\" NEW_LINE DEDENT elif c == \" s \" or c == \" x \" or c == \" S \" or c == \" X \" : NEW_LINE INDENT a = a + \"6\" NEW_LINE DEDENT elif c == \" p \" or c == \" m \" or c == \" P \" or c == \" M \" : NEW_LINE INDENT a = a + \"7\" NEW_LINE DEDENT elif c == \" h \" or c == \" k \" or c == \" H \" or c == \" K \" : NEW_LINE INDENT a = a + \"8\" NEW_LINE DEDENT elif c == \" n \" or c == \" g \" or c == \" N \" or c == \" G \" : NEW_LINE INDENT a = a + \"9\" NEW_LINE DEDENT DEDENT if a != \" \" : NEW_LINE INDENT ar . append ( a ) NEW_LINE DEDENT DEDENT if len ( ar ) == 0 : NEW_LINE INDENT print ( \" \" ) NEW_LINE DEDENT elif len ( ar ) == 1 : NEW_LINE INDENT print ( ar [ 0 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( len ( ar ) - 1 ) : NEW_LINE INDENT print ( ar [ i ] + \" ▁ \" , end = \" \" ) NEW_LINE DEDENT print ( ar [ len ( ar ) - 1 ] ) NEW_LINE DEDENT", "def b_mnemonics ( N , W ) : NEW_LINE INDENT words = W . replace ( ' . ' , ' ' ) . lower ( ) . split ( ) NEW_LINE translation_dict = { ' b ' : '1' , ' c ' : '1' , ' d ' : '2' , ' w ' : '2' , ' t ' : '3' , ' j ' : '3' , ' f ' : '4' , ' q ' : '4' , ' l ' : '5' , ' v ' : '5' , ' s ' : '6' , ' x ' : '6' , ' p ' : '7' , ' m ' : '7' , ' h ' : '8' , ' k ' : '8' , ' n ' : '9' , ' g ' : '9' , ' z ' : '0' , ' r ' : '0' , } NEW_LINE ans = [ ] NEW_LINE for w in words : NEW_LINE INDENT tmp = ' ' NEW_LINE for c in w : NEW_LINE INDENT if c not in translation_dict : NEW_LINE INDENT continue NEW_LINE DEDENT tmp += translation_dict [ c ] NEW_LINE DEDENT if tmp : NEW_LINE INDENT ans . append ( tmp ) NEW_LINE DEDENT DEDENT return ' ▁ ' . join ( ans ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE W = input ( ) NEW_LINE print ( b_mnemonics ( N , W ) ) NEW_LINE", "import re ; input ( ) ; print ( * ' ' . join ( { ' b ' : '1' , ' c ' : '1' , ' d ' : '2' , ' w ' : '2' , ' t ' : '3' , ' j ' : '3' , ' f ' : '4' , ' q ' : '4' , ' l ' : '5' , ' v ' : '5' , ' s ' : '6' , ' x ' : '6' , ' p ' : '7' , ' m ' : '7' , ' h ' : '8' , ' k ' : '8' , ' n ' : '9' , ' g ' : '9' , ' z ' : '0' , ' r ' : '0' , ' ▁ ' : ' ▁ ' } [ t ] for t in re . sub ( ' [ aiueoy . , ] ' , ' ' , input ( ) . lower ( ) ) ) . split ( ) ) NEW_LINE" ]
atcoder_abc095_A
[ "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char c [ ] = s . toCharArray ( ) ; int ans = 700 ; for ( int i = 0 ; i < c . length ; i ++ ) { if ( c [ i ] == ' o ' ) { ans += 100 ; } } System . out . println ( ans ) ; sc . close ( ) ; } }", "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 count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( S . charAt ( i ) == ' o ' ) count ++ ; } System . out . println ( 700 + count * 100 ) ; } }", "import java . util . * ; 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 sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int money = 700 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == ' o ' ) { money += 100 ; } } System . out . println ( money ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; String order = sc . next ( ) ; int price = 700 ; if ( \" o \" . equals ( order . subSequence ( 0 , 1 ) ) ) price += 100 ; if ( \" o \" . equals ( order . subSequence ( 1 , 2 ) ) ) price += 100 ; if ( \" o \" . equals ( order . subSequence ( 2 , 3 ) ) ) price += 100 ; System . out . println ( price ) ; } }", "import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; int price = 700 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == ' o ' ) price += 100 ; } out . println ( price ) ; } }" ]
[ "n = input ( ) NEW_LINE print ( 700 + 100 * n . count ( \" o \" ) ) NEW_LINE", "S = input ( ) NEW_LINE count = 0 NEW_LINE if ( S [ 0 ] == \" o \" ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if ( S [ 1 ] == \" o \" ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if ( S [ 2 ] == \" o \" ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT print ( 700 + 100 * count ) NEW_LINE", "print ( int ( input ( ) . count ( \" o \" ) ) * 100 + 700 ) NEW_LINE", "s = input ( ) NEW_LINE sum = 700 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT if s [ i ] == ' o ' : NEW_LINE INDENT sum += 100 NEW_LINE DEDENT DEDENT print ( sum ) NEW_LINE", "s = input ( ) NEW_LINE toppings = s . count ( \" o \" ) NEW_LINE print ( 700 + toppings * 100 ) NEW_LINE" ]
atcoder_abc063_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( i ) == s . charAt ( j ) && i != j ) { System . out . println ( \" no \" ) ; return ; } } } System . out . println ( \" yes \" ) ; } }", "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 ( ) ; char [ ] array = S . toCharArray ( ) ; Arrays . sort ( array ) ; String ans = \" yes \" ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( array [ i ] == array [ i - 1 ] ) { ans = \" no \" ; break ; } } 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 char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] str = s . split ( \" \" ) ; List < String > listA = Arrays . asList ( str ) ; List < String > listB = new ArrayList < String > ( new HashSet < > ( listA ) ) ; if ( listA . size ( ) == listB . size ( ) ) { 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 ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int [ ] count = new int [ 26 ] ; for ( char cc : in . next ( ) . toCharArray ( ) ) { if ( count [ cc - ' a ' ] ++ > 0 ) { out . println ( \" no \" ) ; return ; } } out . println ( \" yes \" ) ; } } 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 . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int [ ] ch = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) ch [ i ] = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { int num = S . charAt ( i ) - ' a ' ; ch [ num ] ++ ; } boolean state = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( ch [ i ] > 1 ) { state = false ; break ; } } System . out . println ( state ? \" yes \" : \" no \" ) ; } }" ]
[ "s = input ( ) NEW_LINE S = [ ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT S . append ( s [ i ] ) NEW_LINE DEDENT print ( \" yes \" if len ( set ( S ) ) == len ( s ) else \" no \" ) NEW_LINE", "S = input ( ) NEW_LINE length = len ( S ) NEW_LINE set_length = len ( set ( S ) ) NEW_LINE if length == set_length : NEW_LINE INDENT print ( ' yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' no ' ) NEW_LINE DEDENT", "S = input ( ) ; print ( ' yneos ' [ len ( S ) != len ( set ( list ( S ) ) ) : : 2 ] ) NEW_LINE", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE S = input ( ) . strip ( ) NEW_LINE n = len ( S ) NEW_LINE m = len ( set ( S ) ) NEW_LINE if n == m : 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", "a = input ( ) NEW_LINE b = [ 0 ] * 26 NEW_LINE for c in a : NEW_LINE INDENT b [ ord ( c ) - 97 ] += 1 NEW_LINE DEDENT for i in b : NEW_LINE INDENT if i >= 2 : NEW_LINE INDENT print ( \" no \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( \" yes \" ) NEW_LINE" ]
atcoder_abc086_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 ( ) ; if ( ( a * b % 2 ) == 0 ) System . out . println ( \" Even \" ) ; else System . out . println ( \" Odd \" ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final PrintWriter sysout = new PrintWriter ( System . out , false ) ; private static StringTokenizer buffer ; private static String readLine ( ) { buffer = null ; try { return br . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } private static String read ( ) { if ( buffer == null || ! buffer . hasMoreTokens ( ) ) { buffer = new StringTokenizer ( readLine ( ) ) ; } return buffer . nextToken ( ) ; } private static int readInt ( ) { return Integer . parseInt ( read ( ) ) ; } private static int [ ] readIntArray ( int loop ) { int [ ] result = new int [ loop ] ; for ( int i = 0 ; i < loop ; i ++ ) { result [ i ] = readInt ( ) ; } return result ; } private static int [ ] splitInt ( ) { String [ ] tmp = read ( ) . split ( \" \" ) ; int [ ] result = new int [ tmp . length ] ; for ( int i = 0 , n = tmp . length ; i < n ; i ++ ) { result [ i ] = Integer . parseInt ( tmp [ i ] ) ; } return result ; } private static long readLong ( ) { return Long . parseLong ( read ( ) ) ; } private static double readDouble ( ) { return Double . parseDouble ( read ( ) ) ; } public static void main ( String [ ] args ) { run ( ) ; } private static void run ( ) { int x = readInt ( ) ; int y = readInt ( ) ; if ( ( x * y ) % 2 == 0 ) { System . out . println ( \" Even \" ) ; } else { System . out . println ( \" Odd \" ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( \" ▁ \" ) ; sc . close ( ) ; int a = Integer . parseInt ( line [ 0 ] ) ; int b = Integer . parseInt ( line [ 1 ] ) ; if ( isValid ( a ) && isValid ( b ) ) { if ( isEven ( a , b ) ) { System . out . println ( \" Even \" ) ; } else { System . out . println ( \" Odd \" ) ; } } } private static boolean isEven ( int a , int b ) { if ( ( a * b ) % 2 == 0 ) { return true ; } else { return false ; } } private static boolean isValid ( int num ) { if ( num >= 1 && num <= 10000 ) { return true ; } else { return false ; } } }", "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 ( ) ; sc . close ( ) ; System . out . println ( calc ( a , b ) ) ; } public static String calc ( int a , int b ) { String ans = \" Odd \" ; if ( a * b % 2 == 0 ) { ans = \" Even \" ; } return ans ; } }", "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 ( ) ) ; if ( ( a * b ) % 2 == 0 ) { System . out . println ( \" Even \" ) ; } else { System . out . println ( \" Odd \" ) ; } sc . close ( ) ; } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a * b % 2 == 0 : NEW_LINE INDENT print ( \" Even \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Odd \" ) NEW_LINE DEDENT", "a , b = list ( map ( int , ( input ( ) . split ( ) ) ) ) NEW_LINE print ( \" Even \" ) if ( a * b ) % 2 == 0 else print ( \" Odd \" ) NEW_LINE", "work = input ( ) . split ( \" ▁ \" ) NEW_LINE a = work [ 0 ] NEW_LINE b = work [ 1 ] NEW_LINE c = int ( a ) * int ( b ) NEW_LINE if ( c % 2 == 0 ) : NEW_LINE INDENT print ( \" Even \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Odd \" ) NEW_LINE DEDENT", "def matmul ( a , b ) : NEW_LINE INDENT c = a * b NEW_LINE return c NEW_LINE DEDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE c = matmul ( a , b ) NEW_LINE if c % 2 == 0 : NEW_LINE INDENT print ( \" Even \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Odd \" ) NEW_LINE DEDENT", "a , b = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE ans = a * b NEW_LINE if ans % 2 == 0 : NEW_LINE INDENT print ( ' Even ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Odd ' ) NEW_LINE DEDENT" ]
atcoder_arc023_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int R = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int a [ ] [ ] = new int [ R ] [ C ] ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int max = 0 ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( ( i + j ) <= D && ( i + j ) % 2 == D % 2 ) { max = Math . max ( max , a [ i ] [ j ] ) ; } } } System . out . println ( max ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int h = s . nextInt ( ) , w = s . nextInt ( ) , d = s . nextInt ( ) , r = 0 ; for ( int i = 0 ; i < h ; ++ i ) for ( int j = 0 ; j < w ; ++ j ) r = Math . max ( r , s . nextInt ( ) * ( ( i + j <= d && ( d - i - j ) % 2 == 0 ) ? 1 : 0 ) ) ; System . out . println ( r ) ; } }", "import java . awt . * ; import java . util . * ; public class Main { private static int R ; private static int C ; private static int D ; private static int table [ ] [ ] ; private static boolean flag = true ; private static ArrayList < Integer > even = new ArrayList < > ( ) ; private static ArrayList < Integer > odd = new ArrayList < > ( ) ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; R = scan . nextInt ( ) ; C = scan . nextInt ( ) ; D = scan . nextInt ( ) ; table = new int [ R ] [ C ] ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { table [ i ] [ j ] = scan . nextInt ( ) ; } } } public static void main ( String args [ ] ) { input ( ) ; int max = 0 ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( ( i + j ) <= D && ( i + j ) % 2 == D % 2 ) { max = Math . max ( max , table [ i ] [ j ] ) ; } } } System . out . println ( max ) ; } }", "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 ( \" ▁ \" , 3 ) ; int r = Integer . parseInt ( arr [ 0 ] ) ; int c = Integer . parseInt ( arr [ 1 ] ) ; int d = Integer . parseInt ( arr [ 2 ] ) ; int [ ] [ ] field = new int [ r ] [ c ] ; for ( int i = 0 ; i < r ; i ++ ) { String [ ] line = br . readLine ( ) . split ( \" ▁ \" , c ) ; for ( int j = 0 ; j < c ; j ++ ) { field [ i ] [ j ] = Integer . parseInt ( line [ j ] ) ; } } int max = 0 ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = ( ( d - i ) % 2 == 0 ) ? 0 : 1 ; j < c && j <= d - i ; j += 2 ) { int x = field [ i ] [ j ] ; if ( max < x ) { max = x ; } } } System . out . println ( max ) ; } }", "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 ) ; BX solver = new BX ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BX { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int r = in . ints ( ) , c = in . ints ( ) , d = in . ints ( ) ; int ans = 0 ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { int a = in . ints ( ) ; if ( ( i + j ) % 2 == d % 2 && ( i + j ) <= d ) { ans = Math . max ( ans , a ) ; } } } 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 ( ) ) ; } } }" ]
[ "H , W , T = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( H ) ] NEW_LINE ans = 0 NEW_LINE for i in range ( H ) : NEW_LINE INDENT for j in range ( W ) : NEW_LINE INDENT if ( i + j ) % 2 == T % 2 and ( i + j ) <= T : NEW_LINE INDENT ans = max ( ans , A [ i ] [ j ] ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE R , C , D = inpl ( ) NEW_LINE for i in range ( min ( R , D + 1 ) ) : NEW_LINE INDENT I = inpl ( ) [ ( D + i ) % 2 : D - i + 1 : 2 ] NEW_LINE ans = max ( ans , max ( I + [ 0 ] ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "r , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE li = [ ] NEW_LINE if d % 2 == 0 : NEW_LINE INDENT for i in range ( r ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = a [ : min ( c , max ( 0 , d + 1 - i ) ) : 2 ] NEW_LINE DEDENT else : NEW_LINE INDENT a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = a [ 1 : min ( c , max ( 0 , d + 1 - i ) ) : 2 ] NEW_LINE DEDENT if len ( a ) > 0 : NEW_LINE INDENT li += a NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i in range ( r ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = a [ 1 : min ( c , max ( 0 , d + 1 - i ) ) : 2 ] NEW_LINE DEDENT else : NEW_LINE INDENT a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = a [ : min ( c , max ( 0 , d + 1 - i ) ) : 2 ] NEW_LINE DEDENT if len ( a ) > 0 : NEW_LINE INDENT li += a NEW_LINE DEDENT DEDENT DEDENT print ( max ( li ) ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE R , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE even = ( D % 2 == 0 ) NEW_LINE ans = 0 NEW_LINE for i in range ( R ) : NEW_LINE INDENT l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for j , c in enumerate ( l ) : NEW_LINE INDENT if i + j <= D : NEW_LINE INDENT if even : NEW_LINE INDENT if ( i + j ) % 2 == 0 : NEW_LINE INDENT ans = max ( ans , l [ j ] ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( i + j ) % 2 == 1 : NEW_LINE INDENT ans = max ( ans , l [ j ] ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE H , W , D = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ list ( map ( int , l . split ( ) ) ) for l in sys . stdin ] NEW_LINE ans = max ( max ( row [ to_x % 2 : to_x + 1 : 2 ] ) for to_x , row in zip ( range ( D , - 1 , - 1 ) , a [ : D + 1 ] ) ) NEW_LINE print ( ans ) NEW_LINE" ]
atcoder_abc003_D
[ "import java . util . * ; public class Main { static long mod = 1000000007 ; static long arrayCombi [ ] [ ] = new long [ 1000 ] [ 1000 ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int row = sc . nextInt ( ) ; int column = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int desk = sc . nextInt ( ) ; int rack = sc . nextInt ( ) ; int sum = desk + rack ; long ans = 0 ; for ( int i = 0 ; i < 1 << 4 ; i ++ ) { int tmpX = x ; int tmpY = y ; if ( ( i & 1 << 0 ) != 0 ) { tmpX -- ; } if ( ( i & 1 << 1 ) != 0 ) { tmpX -- ; } if ( ( i & 1 << 2 ) != 0 ) { tmpY -- ; } if ( ( i & 1 << 3 ) != 0 ) { tmpY -- ; } if ( tmpX < 0 || tmpY < 0 ) { continue ; } ans = advMod ( ans + combi ( tmpX * tmpY , sum ) * ( Integer . bitCount ( i ) % 2 == 0 ? 1 : - 1 ) ) ; } ans = advMod ( ans * combi ( sum , desk ) ) ; ans = advMod ( ans * ( row - x + 1 ) * ( column - y + 1 ) ) ; System . out . println ( ( ans + mod ) % mod ) ; } public static long combi ( int n , int r ) { if ( n <= 0 || n < r ) { return 0 ; } r = Math . min ( n - r , r ) ; if ( r == 0 ) { return 1 ; } if ( arrayCombi [ n ] [ r ] > 0 ) { return arrayCombi [ n ] [ r ] ; } arrayCombi [ n ] [ r ] = advMod ( combi ( n - 1 , r - 1 ) + combi ( n - 1 , r ) ) ; return arrayCombi [ n ] [ r ] ; } public static long advMod ( long i ) { return i % mod + ( ( i % mod ) < 0 ? mod : 0 ) ; } }" ]
[ "print ( sum ( f ( x * y , x * y - s ) // f ( s ) * f ( s , L ) // f ( D ) * ( R - X + 1 ) * ( C - Y + 1 ) * ( - 1 ) ** ( a + b % 2 ) for R , C , X , Y , D , L in [ ( int ( x ) for _ in [ 0 ] * 3 for x in input ( ) . split ( ) ) ] for a in [ 0 , 1 , 1 , 2 ] for b in [ 0 , 1 , 1 , 2 ] for x , y , f , s in [ [ X - a , Y - b , lambda x , y = 0 : x > y and x * f ( x - 1 , y ) or 1 , D + L ] ] if min ( x , y ) > 0 and s <= ( x * y ) ) % ( 10 ** 9 + 7 ) ) NEW_LINE", "class BigCombination ( object ) : NEW_LINE INDENT __slots__ = [ \" mod \" , \" factorial \" , \" inverse \" ] NEW_LINE def __init__ ( self , mod : int = 10 ** 9 + 7 , max_n : int = 10 ** 6 ) : NEW_LINE INDENT fac , inv = [ 1 ] , [ ] NEW_LINE fac_append , inv_append = fac . append , inv . append NEW_LINE for i in range ( 1 , max_n + 1 ) : NEW_LINE INDENT fac_append ( fac [ - 1 ] * i % mod ) NEW_LINE DEDENT inv_append ( pow ( fac [ - 1 ] , mod - 2 , mod ) ) NEW_LINE for i in range ( max_n , 0 , - 1 ) : NEW_LINE INDENT inv_append ( inv [ - 1 ] * i % mod ) NEW_LINE DEDENT self . mod , self . factorial , self . inverse = mod , fac , inv [ : : - 1 ] NEW_LINE DEDENT def get_combination ( self , n , r ) : NEW_LINE INDENT return self . factorial [ n ] * self . inverse [ r ] * self . inverse [ n - r ] % self . mod NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT from itertools import product NEW_LINE R , C = map ( int , input ( ) . split ( ) ) NEW_LINE X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE D , L = map ( int , input ( ) . split ( ) ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE comb = BigCombination ( mod , X * Y ) NEW_LINE get_comb = comb . get_combination NEW_LINE square_comb = ( R - X + 1 ) * ( C - Y + 1 ) NEW_LINE ans = 0 NEW_LINE for a in product ( ( 0 , 1 ) , repeat = 4 ) : NEW_LINE INDENT x , y = ( X - sum ( a [ : 2 ] ) ) , ( Y - sum ( a [ 2 : ] ) ) NEW_LINE if min ( x , y ) <= 0 or D + L > x * y : NEW_LINE INDENT continue NEW_LINE DEDENT ans = ( ans + get_comb ( x * y , D + L ) * get_comb ( D + L , D ) * ( - 1 if a . count ( 1 ) % 2 == 1 else 1 ) ) % mod NEW_LINE DEDENT print ( ans * square_comb % mod ) NEW_LINE DEDENT", "import math NEW_LINE R , C = map ( int , input ( ) . strip ( ) . split ( ) ) NEW_LINE X , Y = map ( int , input ( ) . strip ( ) . split ( ) ) NEW_LINE D , L = map ( int , input ( ) . strip ( ) . split ( ) ) NEW_LINE def ct_combi ( n , r ) : NEW_LINE INDENT if n < r : NEW_LINE INDENT x = 0 NEW_LINE DEDENT else : NEW_LINE INDENT x = math . factorial ( n ) // ( math . factorial ( n - r ) * math . factorial ( r ) ) NEW_LINE DEDENT return x NEW_LINE DEDENT a = R - X NEW_LINE b = C - Y NEW_LINE n_1 = 0 NEW_LINE if a and not b : NEW_LINE INDENT n_1 = a + 1 NEW_LINE DEDENT elif b and not a : NEW_LINE INDENT n_1 = b + 1 NEW_LINE DEDENT elif a and b : NEW_LINE INDENT for i in range ( a + 1 ) : NEW_LINE INDENT for j in range ( b + 1 ) : NEW_LINE INDENT n_1 += 1 NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT n_1 = 1 NEW_LINE DEDENT if X * Y != D + L : NEW_LINE INDENT sum_1 = 2 * ct_combi ( X * ( Y - 1 ) , D + L ) + 2 * ct_combi ( ( X - 1 ) * Y , D + L ) NEW_LINE sum_2 = ct_combi ( ( X - 2 ) * Y , D + L ) + ct_combi ( ( Y - 2 ) * X , D + L ) + 4 * ct_combi ( ( X - 1 ) * ( Y - 1 ) , D + L ) NEW_LINE sum_3 = 2 * ct_combi ( ( X - 1 ) * ( Y - 2 ) , D + L ) + 2 * ct_combi ( ( X - 2 ) * ( Y - 1 ) , D + L ) NEW_LINE sum_4 = ct_combi ( ( X - 2 ) * ( Y - 2 ) , D + L ) NEW_LINE sum = ct_combi ( X * Y , D + L ) - sum_1 + sum_2 - sum_3 + sum_4 NEW_LINE n_2 = sum * ct_combi ( D + L , D ) NEW_LINE DEDENT else : NEW_LINE INDENT n_2 = ct_combi ( D + L , D ) NEW_LINE DEDENT print ( n_1 * n_2 % ( 10 ** 9 + 7 ) ) NEW_LINE", "from math import factorial as f NEW_LINE print ( sum ( f ( x * y ) // f ( x * y - D - L ) // f ( D + L ) * f ( D + L ) // f ( D ) // f ( L ) * ( R - X + 1 ) * ( C - Y + 1 ) * ( - 1 ) ** ( dx + dy % 2 ) for R , C , X , Y , D , L in [ ( int ( x ) for _ in [ 0 ] * 3 for x in input ( ) . split ( ) ) ] for x , dx in zip ( [ X , X - 1 , X - 1 , X - 2 ] , [ 0 , 1 , 1 , 2 ] ) for y , dy in zip ( [ Y , Y - 1 , Y - 1 , Y - 2 ] , [ 0 , 1 , 1 , 2 ] ) if min ( x , y ) > 0 and D + L <= ( x * y ) ) % ( 10 ** 9 + 7 ) ) NEW_LINE", "from math import factorial as fact NEW_LINE from functools import lru_cache NEW_LINE div = int ( 1e9 + 7 ) NEW_LINE @ lru_cache ( maxsize = None ) NEW_LINE def iCj ( i , j ) : NEW_LINE INDENT if i < j : NEW_LINE INDENT return ( 0 ) NEW_LINE DEDENT return ( fact ( i ) // ( fact ( j ) * fact ( i - j ) ) ) NEW_LINE DEDENT numdl = lambda n , d , l : iCj ( n , d ) * iCj ( n - d , l ) NEW_LINE def inner ( x , y , d , l ) : NEW_LINE INDENT if x * y == d + l : NEW_LINE INDENT num = iCj ( x * y , d ) NEW_LINE DEDENT else : NEW_LINE INDENT num = numdl ( x * y , d , l ) NEW_LINE num -= numdl ( x * ( y - 1 ) , d , l ) * 2 NEW_LINE num -= numdl ( ( x - 1 ) * y , d , l ) * 2 NEW_LINE num += numdl ( x * ( y - 2 ) , d , l ) NEW_LINE num += numdl ( ( x - 2 ) * y , d , l ) NEW_LINE num += numdl ( ( x - 1 ) * ( y - 1 ) , d , l ) * 4 NEW_LINE num -= numdl ( ( x - 2 ) * ( y - 1 ) , d , l ) * 2 NEW_LINE num -= numdl ( ( x - 1 ) * ( y - 2 ) , d , l ) * 2 NEW_LINE num += numdl ( ( x - 2 ) * ( y - 2 ) , d , l ) NEW_LINE DEDENT return ( num ) NEW_LINE DEDENT r , c = map ( int , input ( ) . rstrip ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . rstrip ( ) . split ( ) ) NEW_LINE d , l = map ( int , input ( ) . rstrip ( ) . split ( ) ) NEW_LINE area = ( r - x + 1 ) * ( c - y + 1 ) NEW_LINE print ( inner ( x , y , d , l ) * area % div ) NEW_LINE" ]
atcoder_abc051_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 sx = sc . nextInt ( ) ; int sy = sc . nextInt ( ) ; int tx = sc . nextInt ( ) ; int ty = sc . nextInt ( ) ; int xd = tx - sx ; int yd = ty - sy ; for ( int y = 0 ; y < yd ; y ++ ) { out . print ( \" U \" ) ; } for ( int x = 0 ; x < xd ; x ++ ) { out . print ( \" R \" ) ; } for ( int y = 0 ; y < yd ; y ++ ) { out . print ( \" D \" ) ; } for ( int x = 0 ; x < xd ; x ++ ) { out . print ( \" L \" ) ; } out . print ( \" L \" ) ; for ( int y = 0 ; y < yd + 1 ; y ++ ) { out . print ( \" U \" ) ; } for ( int x = 0 ; x < xd + 1 ; x ++ ) { out . print ( \" R \" ) ; } out . print ( \" D \" ) ; out . print ( \" R \" ) ; for ( int y = 0 ; y < yd + 1 ; y ++ ) { out . print ( \" D \" ) ; } for ( int x = 0 ; x < xd + 1 ; x ++ ) { out . print ( \" L \" ) ; } out . print ( \" U \" ) ; out . println ( ) ; } }", "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int sx = scanner . nextInt ( ) , sy = scanner . nextInt ( ) , tx = scanner . nextInt ( ) , ty = scanner . nextInt ( ) , dx = tx - sx , dy = ty - sy ; for ( int i = 0 ; i < dy ; i ++ ) System . out . print ( ' U ' ) ; for ( int i = 0 ; i < dx ; i ++ ) System . out . print ( ' R ' ) ; for ( int i = 0 ; i < dy ; i ++ ) System . out . print ( ' D ' ) ; for ( int i = 0 ; i <= dx ; i ++ ) System . out . print ( ' L ' ) ; for ( int i = 0 ; i <= dy ; i ++ ) System . out . print ( ' U ' ) ; for ( int i = 0 ; i <= dx ; i ++ ) System . out . print ( ' R ' ) ; System . out . print ( \" DR \" ) ; for ( int i = 0 ; i <= dy ; i ++ ) System . out . print ( ' D ' ) ; for ( int i = 0 ; i <= dx ; i ++ ) System . out . print ( ' L ' ) ; System . out . print ( ' U ' ) ; } }", "import java . util . LinkedList ; 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 ) { int sx = sc . nextInt ( ) ; int sy = sc . nextInt ( ) ; int tx = sc . nextInt ( ) ; int ty = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int k = 0 ; k < ty - sy ; k ++ ) { sb . append ( \" U \" ) ; } for ( int k = 0 ; k < tx - sx ; k ++ ) { sb . append ( \" R \" ) ; } for ( int k = 0 ; k < ty - sy ; k ++ ) { sb . append ( \" D \" ) ; } for ( int k = 0 ; k < tx - sx ; k ++ ) { sb . append ( \" L \" ) ; } sx -- ; sb . append ( \" L \" ) ; for ( int k = 0 ; k < ty + 1 - sy ; k ++ ) { sb . append ( \" U \" ) ; } for ( int k = 0 ; k < tx - sx ; k ++ ) { sb . append ( \" R \" ) ; } sb . append ( \" D \" ) ; sb . append ( \" R \" ) ; for ( int k = 0 ; k < ty + 1 - sy ; k ++ ) { sb . append ( \" D \" ) ; } for ( int k = 0 ; k < tx - sx ; k ++ ) { sb . append ( \" L \" ) ; } sb . append ( \" U \" ) ; System . out . println ( sb ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int sx = sc . nextInt ( ) ; int sy = sc . nextInt ( ) ; int tx = sc . nextInt ( ) ; int ty = sc . nextInt ( ) ; int gapx = tx - sx ; int gapy = ty - sy ; ArrayList < Character > list = new ArrayList < Character > ( ) ; for ( int i = 0 ; i < gapy ; i ++ ) { list . add ( ' U ' ) ; } for ( int i = 0 ; i < gapx ; i ++ ) { list . add ( ' R ' ) ; } for ( int i = 0 ; i < gapy ; i ++ ) { list . add ( ' D ' ) ; } for ( int i = 0 ; i < gapx ; i ++ ) { list . add ( ' L ' ) ; } list . add ( ' L ' ) ; for ( int i = 0 ; i < gapy + 1 ; i ++ ) { list . add ( ' U ' ) ; } for ( int i = 0 ; i < gapx + 1 ; i ++ ) { list . add ( ' R ' ) ; } list . add ( ' D ' ) ; list . add ( ' R ' ) ; for ( int i = 0 ; i < gapy + 1 ; i ++ ) { list . add ( ' D ' ) ; } for ( int i = 0 ; i < gapx + 1 ; i ++ ) { list . add ( ' L ' ) ; } list . add ( ' U ' ) ; for ( Character route : list ) { System . out . print ( route ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int sx = scanner . nextInt ( ) ; int sy = scanner . nextInt ( ) ; int tx = scanner . nextInt ( ) ; int ty = scanner . nextInt ( ) ; int x = ( ( tx - sx ) >> 31 ) | 1 ; int y = ( ( ty - sy ) >> 31 ) | 1 ; int nx = ( tx - sx ) * x ; int ny = ( ty - sy ) * y ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < ny ; i ++ ) sb . append ( y > 0 ? ' U ' : ' D ' ) ; y *= - 1 ; for ( int i = 0 ; i < nx + 1 ; i ++ ) sb . append ( x > 0 ? ' R ' : ' L ' ) ; x *= - 1 ; for ( int i = 0 ; i < ny + 1 ; i ++ ) sb . append ( y > 0 ? ' U ' : ' D ' ) ; y *= - 1 ; for ( int i = 0 ; i < nx + 1 ; i ++ ) sb . append ( x > 0 ? ' R ' : ' L ' ) ; sb . append ( y > 0 ? ' U ' : ' D ' ) ; sb . append ( x > 0 ? ' R ' : ' L ' ) ; x *= - 1 ; for ( int i = 0 ; i < ny + 1 ; i ++ ) sb . append ( y > 0 ? ' U ' : ' D ' ) ; y *= - 1 ; for ( int i = 0 ; i < nx + 1 ; i ++ ) sb . append ( x > 0 ? ' R ' : ' L ' ) ; x *= - 1 ; for ( int i = 0 ; i < ny + 1 ; i ++ ) sb . append ( y > 0 ? ' U ' : ' D ' ) ; for ( int i = 0 ; i < nx ; i ++ ) sb . append ( x > 0 ? ' R ' : ' L ' ) ; System . out . println ( sb . toString ( ) ) ; } }" ]
[ "sx , sy , tx , ty = map ( int , input ( ) . split ( ) ) NEW_LINE dx = tx - sx NEW_LINE dy = ty - sy NEW_LINE root1 = ' U ' * dy + ' R ' * dx NEW_LINE root2 = ' D ' * dy + ' L ' * dx NEW_LINE root3 = ' L ' + ' U ' * ( dy + 1 ) + ' R ' * ( dx + 1 ) + ' D ' NEW_LINE root4 = ' R ' + ' D ' * ( dy + 1 ) + ' L ' * ( dx + 1 ) + ' U ' NEW_LINE print ( root1 + root2 + root3 + root4 ) 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 sx , sy , tx , ty = nm ( ) NEW_LINE ans = ' ' NEW_LINE ans += ' L ' NEW_LINE ans += ' U ' * ( ty - sy + 1 ) NEW_LINE ans += ' R ' * ( tx - sx + 1 ) NEW_LINE ans += ' D ' NEW_LINE ans += ' L ' * ( tx - sx ) NEW_LINE ans += ' D ' * ( ty - sy ) NEW_LINE ans += ' D ' NEW_LINE ans += ' R ' * ( tx - sx + 1 ) NEW_LINE ans += ' U ' * ( ty - sy + 1 ) NEW_LINE ans += ' L ' NEW_LINE ans += ' D ' * ( ty - sy ) NEW_LINE ans += ' L ' * ( tx - sx ) NEW_LINE print ( ans ) NEW_LINE", "sx , sy , tx , ty = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = ' R ' NEW_LINE x = tx - sx NEW_LINE y = ty - sy NEW_LINE for _ in range ( x - 1 ) : NEW_LINE INDENT ans += ' R ' NEW_LINE DEDENT for _ in range ( y ) : NEW_LINE INDENT ans += ' U ' NEW_LINE DEDENT for _ in range ( x ) : NEW_LINE INDENT ans += ' L ' NEW_LINE DEDENT for _ in range ( y ) : NEW_LINE INDENT ans += ' D ' NEW_LINE DEDENT ans += ' LU ' NEW_LINE for _ in range ( y ) : NEW_LINE INDENT ans += ' U ' NEW_LINE DEDENT for _ in range ( x ) : NEW_LINE INDENT ans += ' R ' NEW_LINE DEDENT ans += ' RD ' NEW_LINE ans += ' RD ' NEW_LINE for _ in range ( y ) : NEW_LINE INDENT ans += ' D ' NEW_LINE DEDENT for _ in range ( x ) : NEW_LINE INDENT ans += ' L ' NEW_LINE DEDENT ans += ' LU ' NEW_LINE print ( ans ) NEW_LINE", "from functools import reduce NEW_LINE def main ( ) : NEW_LINE INDENT sx , sy , tx , ty = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE tx = tx - sx NEW_LINE ty = ty - sy NEW_LINE print ( ' R ' * tx + ' U ' * ty + ' L ' * tx + ' D ' * ty + ' L ' + ' U ' * ( ty + 1 ) + ' R ' * ( tx + 1 ) + ' D ' + ' R ' + ' D ' * ( ty + 1 ) + ' L ' * ( tx + 1 ) + ' U ' ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "lis = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE S = \" \" NEW_LINE x = lis [ 2 ] - lis [ 0 ] NEW_LINE y = lis [ 3 ] - lis [ 1 ] NEW_LINE S += \" U \" * y NEW_LINE S += \" R \" * x NEW_LINE S += \" D \" * y NEW_LINE S += \" L \" * ( x + 1 ) NEW_LINE S += \" U \" * ( y + 1 ) NEW_LINE S += \" R \" * ( x + 1 ) NEW_LINE S += \" D \" NEW_LINE S += \" R \" NEW_LINE S += \" D \" * ( y + 1 ) NEW_LINE S += \" L \" * ( x + 1 ) NEW_LINE S += \" U \" NEW_LINE print ( S ) NEW_LINE" ]
atcoder_abc043_B
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; String s = keyboard . next ( ) ; String [ ] command = new String [ s . length ( ) ] ; String [ ] result = new String [ s . length ( ) ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { command [ i ] = s . substring ( i , i + 1 ) ; } int jj = 0 ; int count = 1 ; for ( int j = s . length ( ) - 1 ; j >= 0 ; j -- ) { if ( command [ j ] . equals ( \" B \" ) ) { while ( j != 0 && command [ j - 1 ] . equals ( \" B \" ) ) { count ++ ; j -- ; } j -= count ; } else { result [ jj ] = command [ j ] ; jj ++ ; } } for ( int k = jj - 1 ; k >= 0 ; k -- ) { System . out . print ( result [ k ] ) ; } keyboard . close ( ) ; } }", "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 ) { StringBuilder sb = new StringBuilder ( ) ; for ( char cc : in . next ( ) . toCharArray ( ) ) { switch ( cc ) { case '0' : sb . append ( '0' ) ; break ; case '1' : sb . append ( '1' ) ; break ; case ' B ' : if ( sb . length ( ) > 0 ) sb . deleteCharAt ( sb . length ( ) - 1 ) ; break ; } } out . println ( sb ) ; } } 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 . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; List l = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < w . length ( ) ; i ++ ) { if ( w . charAt ( i ) == ' B ' ) { if ( l . size ( ) > 0 ) { l . remove ( l . size ( ) - 1 ) ; } } else { l . add ( w . charAt ( i ) ) ; } } for ( int i = 0 ; i < l . size ( ) ; i ++ ) { System . out . print ( l . get ( i ) ) ; } System . out . println ( \" \" ) ; sc . close ( ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String s = sc . next ( ) ; StringBuffer buf = new StringBuffer ( ) ; int l = s . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { switch ( s . charAt ( i ) ) { case ( '1' ) : buf . append ( \"1\" ) ; break ; case ( '0' ) : buf . append ( \"0\" ) ; break ; case ( ' B ' ) : int a = buf . length ( ) ; if ( a != 0 ) { buf . deleteCharAt ( a - 1 ) ; } break ; } } String ans = buf . toString ( ) ; System . out . println ( ans ) ; } 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 scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ; Stack < Character > items = new Stack < > ( ) ; for ( char letter : line . toCharArray ( ) ) { if ( Character . isDigit ( letter ) ) { items . push ( letter ) ; } else if ( letter == ' B ' && ! items . isEmpty ( ) ) { items . pop ( ) ; } } StringBuilder builder = new StringBuilder ( ) ; for ( char letter : items ) { builder . append ( letter ) ; } System . out . println ( builder ) ; } }" ]
[ "s = list ( input ( ) ) NEW_LINE ans = \" \" NEW_LINE for i in range ( 0 , len ( s ) , 1 ) : NEW_LINE INDENT if s [ i ] == \"1\" or s [ i ] == \"0\" : NEW_LINE INDENT ans = ans + s [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT ans = ans [ : - 1 ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "answer = [ ] NEW_LINE for letter in input ( ) : NEW_LINE INDENT if letter == \"1\" : NEW_LINE INDENT answer . append ( \"1\" ) NEW_LINE DEDENT elif letter == \"0\" : NEW_LINE INDENT answer . append ( \"0\" ) NEW_LINE DEDENT elif letter == \" B \" and len ( answer ) > 0 : NEW_LINE INDENT answer . pop ( ) NEW_LINE DEDENT DEDENT print ( \" \" . join ( answer ) ) NEW_LINE", "S = input ( ) NEW_LINE new_S = str ( ) NEW_LINE for ii in list ( S ) : NEW_LINE INDENT if ii == ' B ' : NEW_LINE INDENT new_S = new_S [ : - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT new_S += ii NEW_LINE DEDENT DEDENT print ( new_S ) NEW_LINE", "def unhappy_hacking ( s : str ) -> str : NEW_LINE INDENT display = ' ' NEW_LINE for key in s : NEW_LINE INDENT if key == '0' : NEW_LINE INDENT display += '0' NEW_LINE DEDENT elif key == '1' : NEW_LINE INDENT display += '1' NEW_LINE DEDENT else : NEW_LINE INDENT display = display [ : - 1 ] NEW_LINE DEDENT DEDENT return display NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT s = input ( ) NEW_LINE ans = unhappy_hacking ( s ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "s = input ( ) NEW_LINE s = list ( s ) NEW_LINE l = [ ] NEW_LINE ls = len ( s ) NEW_LINE for i in range ( ls ) : NEW_LINE INDENT if s [ i ] == '1' : NEW_LINE INDENT l . append ( 1 ) NEW_LINE DEDENT elif s [ i ] == '0' : NEW_LINE INDENT l . append ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT if len ( l ) == 0 : NEW_LINE INDENT l = l NEW_LINE DEDENT else : NEW_LINE INDENT l . pop ( ) NEW_LINE DEDENT DEDENT DEDENT ans = \" \" NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT ans = ans + str ( l [ i ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc096_C
[ "import java . util . * ; import static java . lang . System . * ; public class Main { static final int [ ] dx = new int [ ] { 1 , 0 , - 1 , 0 } ; static final int [ ] dy = new int [ ] { 0 , 1 , 0 , - 1 } ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; boolean [ ] [ ] s = new boolean [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { String str = sc . next ( ) ; for ( int j = 0 ; j < W ; j ++ ) { s [ i ] [ j ] = str . charAt ( j ) == ' # ' ? true : false ; } } boolean isOk = true ; loop : for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( s [ i ] [ j ] ) { boolean tmpIsOk = false ; for ( int k = 0 ; k < 4 ; k ++ ) { int ni = i + dx [ k ] ; int nj = j + dy [ k ] ; if ( ni >= 0 && ni < H && nj >= 0 && nj < W && s [ ni ] [ nj ] ) { tmpIsOk = true ; } } if ( ! tmpIsOk ) { isOk = false ; break loop ; } } } } if ( isOk ) { out . println ( \" Yes \" ) ; } else { out . println ( \" No \" ) ; } } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] [ ] S = new String [ H ] [ W ] ; final int height = H ; final int width = W ; int [ ] [ ] number = new int [ H ] [ W ] ; String [ ] tmp = new String [ H ] ; for ( int i = 0 ; i < H ; i ++ ) { tmp [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < H ; i ++ ) { String [ ] str = tmp [ i ] . split ( \" \" ) ; for ( int j = 0 ; j < W ; j ++ ) { S [ i ] [ j ] = str [ j ] ; } } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( S [ i ] [ j ] . equals ( \" # \" ) ) { if ( countMine ( i , j , height , width , S ) == true ) { continue ; } else { System . out . println ( \" No \" ) ; System . exit ( 0 ) ; } } } } System . out . println ( \" Yes \" ) ; sc . close ( ) ; } public static boolean countMine ( int i , int j , int height , int width , String [ ] [ ] S ) { boolean result = false ; if ( i - 1 >= 0 && S [ i - 1 ] [ j ] . equals ( \" # \" ) ) { result = true ; } else if ( i + 1 < height && S [ i + 1 ] [ j ] . equals ( \" # \" ) ) { result = true ; } else if ( j + 1 < width && S [ i ] [ j + 1 ] . equals ( \" # \" ) ) { result = true ; } else if ( j - 1 >= 0 && S [ i ] [ j - 1 ] . equals ( \" # \" ) ) { result = true ; } else { } return result ; } }", "import java . util . Scanner ; public class Main { private static String [ ] [ ] s ; private static boolean hasNeighbor ( int h , int w ) { return ( h != 0 && \" # \" . equals ( s [ h - 1 ] [ w ] ) ) || ( h != s . length - 1 && \" # \" . equals ( s [ h + 1 ] [ w ] ) ) || ( w != 0 && \" # \" . equals ( s [ h ] [ w - 1 ] ) ) || ( w != s [ h ] . length - 1 && \" # \" . equals ( s [ h ] [ w + 1 ] ) ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; s = new String [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { s [ i ] = sc . next ( ) . split ( \" \" ) ; } for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( \" . \" . equals ( s [ i ] [ j ] ) ) { continue ; } if ( ! hasNeighbor ( i , j ) ) { System . out . println ( \" No \" ) ; return ; } } } System . out . println ( \" Yes \" ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) { int h = 0 ; int w = 0 ; char [ ] [ ] square = null ; String [ ] tmp = null ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { tmp = br . readLine ( ) . split ( \" \\\\ s \" ) ; h = Integer . parseInt ( tmp [ 0 ] ) ; w = Integer . parseInt ( tmp [ 1 ] ) ; square = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { square [ i ] = br . readLine ( ) . toCharArray ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } boolean result = true ; parentLoop : for ( int i = 0 ; i < square . length ; i ++ ) { final char [ ] line = square [ i ] ; for ( int j = 0 ; j < line . length ; j ++ ) { if ( line [ j ] == ' # ' ) { if ( 0 <= i - 1 && square [ i - 1 ] [ j ] != ' # ' ) { if ( i + 1 < h && square [ i + 1 ] [ j ] != ' # ' ) { if ( 0 <= j - 1 && square [ i ] [ j - 1 ] != ' # ' ) { if ( j + 1 < w && square [ i ] [ j + 1 ] != ' # ' ) { result = false ; break parentLoop ; } } } } } } } if ( result ) { System . out . print ( \" Yes \" ) ; } else { System . out . print ( \" No \" ) ; } } }", "import java . util . Scanner ; public class Main { static char [ ] [ ] cv ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; sc . nextLine ( ) ; cv = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { String str = sc . nextLine ( ) ; for ( int j = 0 ; j < w ; j ++ ) { cv [ i ] [ j ] = str . charAt ( j ) ; } } boolean flg = true ; boolean up , down , left , right ; for ( int i = 0 ; i < h && flg ; i ++ ) { for ( int j = 0 ; j < w && flg ; j ++ ) { if ( isBlack ( i , j ) ) { up = isBlack ( i - 1 , j ) ; down = isBlack ( i + 1 , j ) ; left = isBlack ( i , j - 1 ) ; right = isBlack ( i , j + 1 ) ; if ( ! ( up || down || left || right ) ) { flg = false ; } } } } if ( flg ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } static boolean isBlack ( int y , int x ) { try { if ( cv [ y ] [ x ] == ' # ' ) { return true ; } else { return false ; } } catch ( ArrayIndexOutOfBoundsException e ) { return false ; } } }" ]
[ "H , W = ( int ( x ) for x in input ( ) . split ( ) ) NEW_LINE s = [ ] NEW_LINE for i in range ( H ) : NEW_LINE INDENT s += [ [ ' . ' ] + list ( input ( ) ) + [ ' . ' ] ] NEW_LINE DEDENT s = [ [ ' . ' for i in range ( W + 2 ) ] ] + s + [ [ ' . ' for i in range ( W + 2 ) ] ] NEW_LINE around = [ [ - 1 , 0 ] , [ 0 , - 1 ] , [ 0 , 1 ] , [ 1 , 0 ] ] NEW_LINE clear = True NEW_LINE for i in range ( 1 , H + 1 ) : NEW_LINE INDENT for j in range ( 1 , W + 1 ) : NEW_LINE INDENT if s [ i ] [ j ] == ' # ' : NEW_LINE INDENT if all ( ( s [ i + k [ 0 ] ] [ j + k [ 1 ] ] == ' . ' for k in around ) ) : NEW_LINE INDENT clear = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT break NEW_LINE DEDENT if clear : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE try : NEW_LINE INDENT H , W = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ list ( input ( ) ) for _ in range ( H ) ] NEW_LINE dir4 = ( ( 0 , 1 ) , ( 0 , - 1 ) , ( 1 , 0 ) , ( - 1 , 0 ) ) NEW_LINE for i in range ( H ) : NEW_LINE INDENT for j in range ( W ) : NEW_LINE INDENT if s [ i ] [ j ] == \" . \" : continue NEW_LINE cnt = 0 NEW_LINE for d in dir4 : NEW_LINE INDENT nx = i + d [ 0 ] NEW_LINE ny = j + d [ 1 ] NEW_LINE if not ( 0 <= nx < H ) : continue NEW_LINE if not ( 0 <= ny < W ) : continue NEW_LINE if s [ nx ] [ ny ] == \" # \" : cnt += 1 NEW_LINE DEDENT if cnt == 0 : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT print ( \" Yes \" ) NEW_LINE DEDENT finally : NEW_LINE INDENT input = None NEW_LINE DEDENT DEDENT import sys ; sys . setrecursionlimit ( 50000 ) NEW_LINE if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def count ( i , j ) : NEW_LINE INDENT count = 0 NEW_LINE if list [ i ] [ j - 1 ] == ' # ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if list [ i ] [ j + 1 ] == ' # ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if list [ i - 1 ] [ j ] == ' # ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if list [ i + 1 ] [ j ] == ' # ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if count >= 1 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT h , w = map ( int , input ( ) . split ( ) ) NEW_LINE s_init = '0' * ( w + 2 ) NEW_LINE flag = True NEW_LINE list = [ ] NEW_LINE list . append ( s_init ) NEW_LINE for i in range ( h ) : NEW_LINE INDENT s = str ( input ( ) ) NEW_LINE list . append ( '0' + s + '0' ) NEW_LINE DEDENT list . append ( s_init ) NEW_LINE for i in range ( 1 , h + 1 ) : NEW_LINE INDENT for j in range ( 1 , w + 1 ) : NEW_LINE INDENT if list [ i ] [ j ] == ' # ' : NEW_LINE INDENT if not ( count ( i , j ) ) : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "h , w = map ( int , input ( ) . split ( ) ) NEW_LINE glid = [ 0 ] * ( h + 2 ) NEW_LINE h_index = [ - 1 , 0 , 0 , 1 ] NEW_LINE w_index = [ 0 , - 1 , 1 , 0 ] NEW_LINE glid [ 0 ] = [ \" . \" ] * ( w + 2 ) NEW_LINE glid [ h + 1 ] = [ \" . \" ] * ( w + 2 ) NEW_LINE for i in range ( h ) : NEW_LINE INDENT temp1 = [ \" . \" ] NEW_LINE temp2 = list ( input ( ) ) NEW_LINE temp1 . extend ( temp2 ) NEW_LINE temp1 . append ( \" . \" ) NEW_LINE glid [ i + 1 ] = temp1 NEW_LINE DEDENT cnt = 0 NEW_LINE for j in range ( h ) : NEW_LINE INDENT for k in range ( w ) : NEW_LINE INDENT if glid [ j + 1 ] [ k + 1 ] == \" # \" and glid [ j ] [ k + 1 ] == \" . \" and glid [ j + 2 ] [ k + 1 ] == \" . \" and glid [ j + 1 ] [ k ] == \" . \" and glid [ j + 1 ] [ k + 2 ] == \" . \" : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT DEDENT if cnt > 0 : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT", "H , W = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ ] NEW_LINE S . append ( list ( ' @ ' * ( W + 2 ) ) ) NEW_LINE for i in range ( H ) : NEW_LINE INDENT s = list ( input ( ) ) NEW_LINE s . insert ( 0 , ' @ ' ) NEW_LINE s . append ( ' @ ' ) NEW_LINE S . append ( s ) NEW_LINE DEDENT S . append ( list ( ' @ ' * ( W + 2 ) ) ) NEW_LINE judge = 1 NEW_LINE count = 0 NEW_LINE vy = [ 0 , 0 , 1 , - 1 ] NEW_LINE vx = [ 1 , - 1 , 0 , 0 ] NEW_LINE for i in range ( H + 2 ) : NEW_LINE INDENT if ( count == 4 ) : break NEW_LINE if ( ( i != 0 ) and ( i != H + 1 ) ) : NEW_LINE INDENT for j in range ( W + 2 ) : NEW_LINE INDENT if ( count == 4 ) : break NEW_LINE if ( ( j != 0 ) and ( j != W + 1 ) ) : NEW_LINE INDENT if ( S [ i ] [ j ] == ' # ' ) : NEW_LINE INDENT count = 0 NEW_LINE for k in range ( 4 ) : NEW_LINE INDENT if ( S [ i + vy [ k ] ] [ j + vx [ k ] ] == ' # ' ) : break NEW_LINE count += 1 NEW_LINE DEDENT if ( count == 4 ) : NEW_LINE INDENT judge = 0 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT if ( judge == 1 ) : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT" ]
atcoder_abc118_B
[ "import java . text . ParseException ; import java . text . SimpleDateFormat ; import java . util . Date ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] data = sc . nextLine ( ) . split ( \" ▁ \" ) ; int N = Integer . parseInt ( data [ 0 ] ) ; int M = Integer . parseInt ( data [ 1 ] ) ; int [ ] food = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { food [ i ] = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { data = sc . nextLine ( ) . split ( \" ▁ \" ) ; int K = Integer . parseInt ( data [ 0 ] ) ; for ( int j = 1 ; j <= K ; j ++ ) { int value = Integer . parseInt ( data [ j ] ) ; food [ -- value ] ++ ; } } int cnt = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( food [ i ] == N ) cnt ++ ; } System . out . println ( cnt ) ; } }", "import java . io . InputStream ; import java . io . PrintStream ; import java . util . BitSet ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; BitSet a = new BitSet ( M ) ; a . flip ( 0 , M ) ; for ( int i = 0 ; i < N ; i ++ ) { int K = sc . nextInt ( ) ; BitSet x = new BitSet ( M ) ; for ( int j = 0 ; j < K ; j ++ ) { x . set ( sc . nextInt ( ) - 1 ) ; } a . and ( x ) ; } out . println ( a . cardinality ( ) ) ; 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 void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; ArrayList < Integer > [ ] list = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { list [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { int S = sc . nextInt ( ) ; for ( int j = 0 ; j < S ; j ++ ) { list [ i ] . add ( sc . nextInt ( ) ) ; } } int counter = 0 ; for ( int i = 0 ; i <= M ; i ++ ) { boolean flag = true ; for ( int j = 0 ; j < N ; j ++ ) { if ( list [ j ] . contains ( i ) ) { } else { flag = false ; } } if ( flag ) { counter ++ ; } } System . out . println ( counter ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; scanner . nextInt ( ) ; scanner . nextLine ( ) ; Set < Integer > commonSet = new HashSet < > ( ) ; IntStream . range ( 0 , n ) . forEach ( i -> { int number = scanner . nextInt ( ) ; Set < Integer > set = new HashSet < > ( ) ; IntStream . range ( 0 , number ) . forEach ( j -> set . add ( scanner . nextInt ( ) ) ) ; scanner . nextLine ( ) ; if ( 0 == i ) { commonSet . addAll ( set ) ; } else { Set < Integer > removeSet = new HashSet < > ( ) ; for ( Integer integer : commonSet ) { if ( ! set . contains ( integer ) ) { removeSet . add ( integer ) ; } } commonSet . removeAll ( removeSet ) ; } } ) ; System . out . println ( commonSet . size ( ) ) ; } } }", "import java . util . Arrays ; import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int answers = sc . nextInt ( ) ; int kinds = sc . nextInt ( ) ; int [ ] likeCounts = new int [ kinds + 1 ] ; Arrays . fill ( likeCounts , 0 ) ; for ( int i = 0 ; i < answers ; i ++ ) { int ansCount = sc . nextInt ( ) ; for ( int j = 0 ; j < ansCount ; j ++ ) { likeCounts [ sc . nextInt ( ) ] ++ ; } } System . out . println ( IntStream . of ( likeCounts ) . filter ( i -> i == answers ) . count ( ) ) ; } }" ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE KA = [ ] NEW_LINE a = [ ] NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT KA = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = KA [ 1 : ] NEW_LINE a += A NEW_LINE DEDENT for j in range ( 1 , M + 1 ) : NEW_LINE INDENT if a . count ( j ) == N : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import functools NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ set ( map ( int , input ( ) . split ( ) [ 1 : ] ) ) for _ in range ( N ) ] NEW_LINE print ( len ( functools . reduce ( set . intersection , A ) ) ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n , m = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE ans = [ 0 for i in range ( m + 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT k , * a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE for j in range ( k ) : NEW_LINE INDENT ans [ a [ j ] ] += 1 NEW_LINE DEDENT DEDENT print ( ans . count ( n ) ) NEW_LINE DEDENT main ( ) NEW_LINE", "N , M = [ int ( s ) for s in input ( ) . split ( ' ▁ ' ) ] NEW_LINE vote = [ 0 ] * M NEW_LINE for _ in range ( N ) : NEW_LINE INDENT answer = [ int ( s ) for s in input ( ) . split ( ' ▁ ' ) ] [ 1 : ] NEW_LINE for a in answer : NEW_LINE INDENT vote [ a - 1 ] += 1 NEW_LINE DEDENT DEDENT vote_all = 0 NEW_LINE for v in vote : NEW_LINE INDENT if v == N : NEW_LINE INDENT vote_all += 1 NEW_LINE DEDENT DEDENT print ( vote_all ) NEW_LINE", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE K = [ 0 ] * N NEW_LINE A = [ [ 0 for j in range ( M ) ] for i in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT inpt = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE K [ i ] = inpt [ 0 ] NEW_LINE for j in range ( 1 , K [ i ] + 1 , 1 ) : NEW_LINE INDENT A [ i ] [ j - 1 ] = inpt [ j ] NEW_LINE DEDENT DEDENT count = 0 NEW_LINE for j in range ( 1 , M + 1 , 1 ) : NEW_LINE INDENT likecount = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for k in range ( K [ i ] ) : NEW_LINE INDENT if A [ i ] [ k ] == j : NEW_LINE INDENT likecount += 1 NEW_LINE DEDENT DEDENT DEDENT if likecount == N : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE" ]
atcoder_arc088_B
[ "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 input = br . readLine ( ) ; int n = input . length ( ) ; int ts = n ; for ( int i = 1 ; i < n ; i ++ ) { if ( input . charAt ( i - 1 ) != input . charAt ( i ) ) { ts = Math . min ( Math . max ( i , n - i ) , ts ) ; } } System . out . println ( ts ) ; } }", "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 ) ; TaskD solver = new TaskD ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskD { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . nextString ( ) ; int n = s . length ( ) ; int ans = n ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + 1 ) ) { ans = Math . min ( ans , Math . max ( i + 1 , n - 1 - i ) ) ; } } 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 InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( \" \" ) ; } } }", "import java . util . * ; import java . io . * ; public class Main { public static int centerLength ( String s ) { int N = s . length ( ) ; if ( N % 2 == 0 ) { if ( s . charAt ( N / 2 ) != s . charAt ( N / 2 - 1 ) ) return 0 ; char center = s . charAt ( N / 2 ) ; int length = 2 ; int left = N / 2 - 2 , right = N / 2 + 1 ; while ( left >= 0 && s . charAt ( left ) == center && s . charAt ( right ) == center ) { left -- ; right ++ ; length += 2 ; } return length ; } else { char center = s . charAt ( N / 2 ) ; int left = N / 2 - 1 , right = N / 2 + 1 ; int length = 1 ; while ( left >= 0 && s . charAt ( left ) == center && s . charAt ( right ) == center ) { left -- ; right ++ ; length += 2 ; } return length ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int N = S . length ( ) ; System . out . println ( N - ( N - centerLength ( S ) ) / 2 ) ; } }", "import java . io . FileNotFoundException ; import java . util . Arrays ; import java . util . Scanner ; class Main { final long MOD = 1_000_000_000 + 7 ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int n = S . length ( ) ; int ans = n / 2 ; int left = n - ans - 1 ; int right = ans ; char c = S . charAt ( left ) ; while ( left >= 0 && S . charAt ( left ) == S . charAt ( right ) && S . charAt ( left ) == c ) { -- left ; ++ right ; ++ ans ; } System . out . println ( ans ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } public static void main ( String [ ] args ) throws FileNotFoundException { new Main ( ) . run ( ) ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { String s = sc . next ( ) ; int len = s . length ( ) ; int ans = len ; int index = 0 ; while ( true ) { int next ; char c = s . charAt ( index ) ; if ( c == '0' ) { next = s . indexOf ( '1' , index + 1 ) ; } else { next = s . indexOf ( '0' , index + 1 ) ; } if ( next == - 1 ) { break ; } ans = Math . min ( ans , Math . max ( next , len - next ) ) ; index = next ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }" ]
[ "def main ( ) : NEW_LINE INDENT s = input ( ) NEW_LINE n = len ( s ) NEW_LINE chs = changes ( s , n ) NEW_LINE res = n NEW_LINE for c in chs : NEW_LINE INDENT di = max ( c , n - c ) NEW_LINE res = min ( res , di ) NEW_LINE DEDENT print ( res ) NEW_LINE DEDENT def changes ( s , n ) : NEW_LINE INDENT res = [ ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if s [ i - 1 ] != s [ i ] : NEW_LINE INDENT res . append ( i ) NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT main ( ) NEW_LINE", "s = list ( input ( ) ) NEW_LINE s = list ( map ( int , s ) ) NEW_LINE length = len ( s ) NEW_LINE i = 0 NEW_LINE while i < len ( s ) - 1 : NEW_LINE INDENT if s [ i ] != s [ i + 1 ] : NEW_LINE INDENT length = min ( length , max ( i + 1 , len ( s ) - i - 1 ) ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print ( length ) NEW_LINE", "S = list ( input ( ) ) NEW_LINE K = ( len ( S ) + 1 ) // 2 NEW_LINE if len ( S ) % 2 == 0 : NEW_LINE INDENT mark = S [ len ( S ) // 2 ] NEW_LINE if mark != S [ len ( S ) // 2 - 1 ] : NEW_LINE INDENT print ( K ) NEW_LINE exit ( ) NEW_LINE DEDENT count = 1 NEW_LINE while ( 0 < len ( S ) - K - count ) : NEW_LINE INDENT if mark != S [ len ( S ) // 2 - 1 - count ] or mark != S [ len ( S ) // 2 + count ] : NEW_LINE INDENT print ( K + count ) NEW_LINE exit ( ) NEW_LINE DEDENT count += 1 NEW_LINE DEDENT print ( K + count ) NEW_LINE DEDENT else : NEW_LINE INDENT mark = S [ len ( S ) // 2 ] NEW_LINE count = 0 NEW_LINE while ( 0 < len ( S ) - K - count ) : NEW_LINE INDENT if mark != S [ len ( S ) // 2 - 1 - count ] or mark != S [ len ( S ) // 2 + 1 + count ] : NEW_LINE INDENT print ( K + count ) NEW_LINE exit ( ) NEW_LINE DEDENT count += 1 NEW_LINE DEDENT print ( K + count ) NEW_LINE DEDENT", "import sys NEW_LINE S = [ 1 if i == '1' else 0 for i in input ( ) ] NEW_LINE l = len ( S ) NEW_LINE if l % 2 == 1 : NEW_LINE INDENT t = l // 2 NEW_LINE a = S [ t ] NEW_LINE for i in range ( 1 , t + 1 ) : NEW_LINE INDENT if S [ t - i ] != a or S [ t + i ] != a : NEW_LINE INDENT print ( t + i ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT print ( l ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT if l % 2 == 0 : NEW_LINE INDENT t = l // 2 NEW_LINE a = S [ t - 1 ] NEW_LINE b = S [ t ] NEW_LINE if a != b : NEW_LINE INDENT print ( t ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT for i in range ( 1 , t ) : NEW_LINE INDENT if S [ t - 1 - i ] != a or S [ t + i ] != a : NEW_LINE INDENT print ( t + i ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT print ( l ) NEW_LINE sys . exit ( ) 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 S = input ( ) NEW_LINE size = len ( S ) NEW_LINE if len ( S ) % 2 == 0 : NEW_LINE INDENT ans = size // 2 NEW_LINE base = S [ size // 2 ] NEW_LINE for i in range ( size // 2 ) : NEW_LINE INDENT if S [ size // 2 - 1 - i ] == S [ size // 2 + i ] == base : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = size // 2 + 1 NEW_LINE base = S [ size // 2 ] NEW_LINE for i in range ( size // 2 ) : NEW_LINE INDENT if S [ size // 2 - 1 - i ] == S [ size // 2 + 1 + i ] == base : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT" ]
atcoder_arc016_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 ans ; if ( m == 1 ) { ans = 2 ; } else { ans = 1 ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { private static int n ; private static int m ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; m = scan . nextInt ( ) ; } public static void main ( String args [ ] ) { input ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i != m ) { System . out . println ( i ) ; break ; } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > ans = new ArrayList < Integer > ( ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i == M ) { continue ; } ans . add ( i ) ; } System . out . println ( ans . get ( 0 ) ) ; } }", "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 ( ) ; int m = sc . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i != m ) { out . println ( i ) ; exit ( 0 ) ; } } } }", "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) , m = s . nextInt ( ) ; System . out . println ( m % n + 1 ) ; } }" ]
[ "print ( ( input ( ) [ 2 ] < '2' ) + 1 ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if i != m : NEW_LINE INDENT print ( i ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE if M >= 2 : NEW_LINE INDENT print ( M - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 ) NEW_LINE DEDENT", "def ans ( ) : NEW_LINE INDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( i != M ) : NEW_LINE INDENT print ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT ans ( ) NEW_LINE", "print ( \"12\" [ int ( input ( ) [ - 1 ] ) < 2 ] ) NEW_LINE" ]
atcoder_abc098_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 ( Math . max ( a + b , a - b ) , a * b ) ) ; } }", "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 ; try { scanner = new Scanner ( System . in ) ; numA = scanner . nextInt ( ) ; numB = scanner . nextInt ( ) ; System . out . println ( Math . max ( numA + numB , Math . max ( numA - numB , numA * numB ) ) ) ; } 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 . 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 ans = Math . max ( A + B , A * B ) ; ans = Math . max ( ans , A - B ) ; 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 . * ; 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 add = A + B ; int sub = A - B ; int mul = A * B ; int max = 0 ; if ( add >= sub && add >= mul ) max = add ; if ( sub >= add && sub >= mul ) max = sub ; if ( mul >= add && mul >= sub ) max = mul ; System . out . println ( max ) ; } }", "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 ) ; ABC098_A solver = new ABC098_A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC098_A { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int ans = Math . max ( Math . max ( a + b , a - b ) , a * b ) ; out . print ( ans ) ; } } }" ]
[ "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE a = A + B NEW_LINE if A * B > a : NEW_LINE INDENT a = A * B NEW_LINE DEDENT if A - B > a : NEW_LINE INDENT a = A - B NEW_LINE DEDENT print ( a ) NEW_LINE", "i = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = i [ 0 ] NEW_LINE B = i [ 1 ] NEW_LINE a = 0 NEW_LINE s = 0 NEW_LINE m = 0 NEW_LINE def add ( a , b ) : NEW_LINE INDENT return a + b NEW_LINE DEDENT def sub ( a , b ) : NEW_LINE INDENT return a - b NEW_LINE DEDENT def mul ( a , b ) : NEW_LINE INDENT return a * b NEW_LINE DEDENT a = add ( A , B ) NEW_LINE s = sub ( A , B ) NEW_LINE m = mul ( A , B ) NEW_LINE print ( max ( a , s , m ) ) NEW_LINE", "s = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE l = [ s [ 0 ] + s [ 1 ] , s [ 0 ] - s [ 1 ] , s [ 0 ] * s [ 1 ] ] NEW_LINE print ( max ( l ) ) NEW_LINE", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE x = a + b NEW_LINE y = a - b NEW_LINE z = a * b NEW_LINE if y <= x and z <= x : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT elif x <= y and z <= y : NEW_LINE INDENT print ( y ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( z ) NEW_LINE DEDENT", "a , b = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE print ( max ( a + b , a - b , a * b ) ) NEW_LINE" ]
atcoder_agc007_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; double d1 = sc . nextInt ( ) ; double x = sc . nextInt ( ) ; double ans = 0 ; for ( ; N > 0 ; N -- ) { ans += d1 + ( N - 0.5 ) * x ; d1 = ( ( 2 * N + 2 ) * d1 + 5 * x ) / ( 2 * N ) ; x = ( ( double ) N + 2 ) / N * x ; } System . out . println ( ans ) ; sc . close ( ) ; } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . concurrent . SynchronousQueue ; 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 d = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; double [ ] F = new double [ 200001 ] ; double [ ] G = new double [ 200001 ] ; { Arrays . fill ( F , - 1 ) ; Arrays . fill ( G , - 1 ) ; } F [ 1 ] = 0.5 ; G [ 1 ] = 1 ; for ( int i = 2 ; i <= 200000 ; ++ i ) { F [ i ] = ( 1 + 2. / i ) * F [ i - 1 ] + 5. / ( 2 * i ) * G [ i - 1 ] + 1. / ( 2 * i ) * i * ( 2 * i - 1 ) ; G [ i ] = ( 1 + 1d / i ) * G [ i - 1 ] + 1 ; } System . out . println ( String . format ( \" % .20f \" , F [ n ] * x + d * G [ n ] ) ) ; } public static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { MathContext mc = new MathContext ( 25 , RoundingMode . HALF_DOWN ) ; Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int a = in . nextInt ( ) ; int x = in . nextInt ( ) ; BigDecimal L = new BigDecimal ( 1 ) ; BigDecimal ans = new BigDecimal ( 2 * x ) ; for ( int i = 2 ; i <= n ; ++ i ) { BigDecimal t = new BigDecimal ( i ) ; L = L . add ( BigDecimal . ONE . divide ( BigDecimal . valueOf ( i ) , mc ) ) ; t = L . add ( BigDecimal . valueOf ( i ) ) ; t = t . multiply ( BigDecimal . valueOf ( x ) ) ; BigDecimal t2 = ans . multiply ( BigDecimal . valueOf ( 2 ) ) . divide ( BigDecimal . valueOf ( i ) , mc ) ; ans = ans . add ( t ) . add ( t2 ) ; } L = L . add ( BigDecimal . ONE . divide ( BigDecimal . valueOf ( n + 1 ) , mc ) ) ; L = L . subtract ( BigDecimal . ONE ) ; L = L . multiply ( BigDecimal . valueOf ( n + 1 ) ) . multiply ( BigDecimal . valueOf ( 2 * a - 3 * x ) ) ; L = L . divide ( BigDecimal . valueOf ( 2 ) , mc ) ; ans = ans . add ( L ) ; System . out . print ( ans ) ; } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . concurrent . SynchronousQueue ; 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 d = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; double [ ] F = new double [ 200001 ] ; double [ ] G = new double [ 200001 ] ; { Arrays . fill ( F , - 1 ) ; Arrays . fill ( G , - 1 ) ; } F [ 1 ] = 0.5 ; G [ 1 ] = 1 ; for ( int i = 2 ; i <= 200000 ; ++ i ) { F [ i ] = ( 1 + 2. / i ) * F [ i - 1 ] + 5. / ( 2 * i ) * G [ i - 1 ] + 1. / ( 2 * i ) * i * ( 2 * i - 1 ) ; G [ i ] = ( 1 + 1. / i ) * G [ i - 1 ] + 1 ; } System . out . println ( String . format ( \" % .20f \" , F [ n ] * x + d * G [ n ] ) ) ; } public static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . math . BigDecimal ; import java . text . DecimalFormat ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double N = scan . nextDouble ( ) ; double d = scan . nextDouble ( ) ; double x = scan . nextDouble ( ) ; BigDecimal ans = new BigDecimal ( \"0.0\" ) ; while ( N > 0.5 ) { BigDecimal adnum = BigDecimal . valueOf ( d + x * ( N - 0.5 ) ) ; ans = ans . add ( adnum ) ; d = ( N + 1.0 ) * d / N + ( 5.0 * x ) / ( 2.0 * N ) ; x = ( 1.0 + ( 2.0 / N ) ) * x ; -- N ; } DecimalFormat format = new DecimalFormat ( \" # . # \" ) ; format . setMinimumFractionDigits ( 20 ) ; System . out . println ( format . format ( ans ) ) ; } }" ]
[ "def solve ( n , d , x ) : NEW_LINE INDENT ans = 0 NEW_LINE while n : NEW_LINE INDENT ans += d + ( 2 * n - 1 ) * x / 2 NEW_LINE d = ( ( n + 1 ) * d + 5 * x / 2 ) / n NEW_LINE x *= ( n + 2 ) / n NEW_LINE n -= 1 NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( ' { : . 10f } ' . format ( solve ( * map ( float , input ( ) . split ( ) ) ) ) ) NEW_LINE" ]
atcoder_abc029_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int output = 0 ; for ( int i = 0 ; i < 12 ; i ++ ) { if ( sc . next ( ) . contains ( \" r \" ) ) { output ++ ; } } System . out . println ( output ) ; } }", "import java . util . InputMismatchException ; import java . util . Scanner ; public class Main { public static void find ( String [ ] str1 , int n ) { int i = 0 ; int j = 0 ; int count = 0 ; while ( i < n ) { for ( j = 0 ; j < str1 [ i ] . length ( ) ; j ++ ) { if ( str1 [ i ] . substring ( j , j + 1 ) . equals ( \" r \" ) ) { count = count + 1 ; break ; } } i ++ ; } System . out . println ( count ) ; } public static void input ( ) { Scanner sc = null ; try { sc = new Scanner ( System . in ) ; int i = 0 ; String str ; String [ ] str1 = new String [ 12 ] ; while ( i < 12 ) { str = sc . next ( ) ; str1 [ i ] = str ; i ++ ; } find ( str1 , 12 ) ; } catch ( InputMismatchException e ) { } finally { } } public static void main ( String [ ] args ) { input ( ) ; } }", "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 ) { int count = 0 ; for ( int i = 0 ; i < 12 ; i ++ ) if ( in . next ( ) . contains ( \" r \" ) ) count ++ ; out . println ( count ) ; } } 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 . * ; import static java . lang . System . in ; import static java . lang . System . out ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int counter = 0 ; for ( int i = 0 ; i < 12 ; i ++ ) { String str = sc . nextLine ( ) ; if ( str . contains ( \" r \" ) ) counter ++ ; } out . println ( counter ) ; } }", "import java . util . Scanner ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] str = new String [ 12 ] ; for ( int i = 0 ; i < 12 ; i ++ ) { str [ i ] = sc . next ( ) ; } int ans = 0 ; for ( int i = 0 ; i < 12 ; i ++ ) { for ( int j = 0 ; j < str [ i ] . length ( ) ; j ++ ) { if ( str [ i ] . charAt ( j ) == ' r ' ) { ans ++ ; break ; } } } System . out . println ( ans ) ; } }" ]
[ "c = 0 NEW_LINE for i in range ( 12 ) : NEW_LINE INDENT if ' r ' in input ( ) : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT print ( c ) NEW_LINE", "def oyster ( S : list ) -> int : NEW_LINE INDENT return sum ( ' r ' in s for s in S ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT S = [ input ( ) for _ in range ( 12 ) ] NEW_LINE ans = oyster ( S ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "def start_process ( ) : NEW_LINE INDENT X , Y , Z , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( 12 ) : NEW_LINE INDENT a = list ( input ( ) ) NEW_LINE if ' r ' in a : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "print ( sum ( [ ' r ' in input ( ) . strip ( ) for _ in range ( 12 ) ] ) ) NEW_LINE", "import sys NEW_LINE a = 0 NEW_LINE for i in sys . stdin : NEW_LINE INDENT if \" r \" in i : NEW_LINE INDENT a += 1 NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE" ]
atcoder_arc040_B
[ "import java . util . * ; public class Main { static boolean masu [ ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; String S = sc . next ( ) ; int lastindex = - 1 ; masu = new boolean [ N ] ; int last = 0 ; for ( int i = 0 ; i < N ; i ++ ) { masu [ i ] = S . charAt ( i ) == ' o ' ; if ( ! masu [ i ] ) { last = i + 1 ; } } int ans = 0 ; int idx = 1 ; while ( true ) { if ( check ( ) ) break ; if ( last - idx < R ) { ans ++ ; break ; } else if ( masu [ idx - 1 ] ) { ans ++ ; idx ++ ; } else { ans ++ ; for ( int i = idx ; i < idx + R ; i ++ ) { masu [ i - 1 ] = true ; } } } System . out . println ( ans ) ; } static boolean check ( ) { for ( int i = 0 ; i < masu . length ; i ++ ) { if ( ! masu [ i ] ) return false ; } return true ; } }" ]
[ "N , R = map ( int , input ( ) . split ( \" ▁ \" ) ) NEW_LINE S = list ( input ( ) ) NEW_LINE while ( S ) and S [ - 1 ] == \" o \" : NEW_LINE INDENT S . pop ( ) NEW_LINE N -= 1 NEW_LINE DEDENT p = 0 NEW_LINE cost = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] != \" . \" : NEW_LINE INDENT continue NEW_LINE DEDENT S [ i : i + R ] = [ \" o \" ] * R NEW_LINE p = i NEW_LINE cost += 1 NEW_LINE DEDENT cost += min ( max ( 0 , N - R ) , p ) NEW_LINE print ( cost ) NEW_LINE", "def b_paint_line ( N , R , S ) : NEW_LINE INDENT try : NEW_LINE INDENT ans = max ( S . rindex ( ' . ' ) - R + 1 , 0 ) NEW_LINE DEDENT except ValueError : NEW_LINE INDENT return 0 NEW_LINE DEDENT s = list ( S ) NEW_LINE while s . count ( ' . ' ) != 0 : NEW_LINE INDENT ans += 1 NEW_LINE idx = s . index ( ' . ' ) NEW_LINE for j in range ( idx , idx + R ) : NEW_LINE INDENT if j >= N : NEW_LINE INDENT break NEW_LINE DEDENT s [ j ] = ' o ' NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N , R = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE S = input ( ) NEW_LINE print ( b_paint_line ( N , R , S ) ) NEW_LINE", "def check ( d ) : NEW_LINE INDENT l = 0 NEW_LINE for i in d : NEW_LINE INDENT if i == \" o \" : NEW_LINE INDENT l += 1 NEW_LINE DEDENT DEDENT if l == len ( d ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT n , r = map ( int , input ( ) . split ( ) ) NEW_LINE s = list ( input ( ) ) NEW_LINE ans = 0 NEW_LINE p = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if s [ i ] == \" . \" : NEW_LINE INDENT p = i NEW_LINE DEDENT DEDENT i = 0 NEW_LINE j = 0 NEW_LINE for _ in range ( n ) : NEW_LINE INDENT if s [ j ] == \" o \" : NEW_LINE INDENT j += 1 NEW_LINE DEDENT DEDENT if j == n : NEW_LINE INDENT print ( 0 ) NEW_LINE quit ( ) NEW_LINE DEDENT while i < n : NEW_LINE INDENT if s [ i ] == \" o \" and i < p - r + 1 : NEW_LINE INDENT i += 1 NEW_LINE ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT for j in range ( i , min ( i + r , n ) ) : NEW_LINE INDENT s [ j ] = \" o \" NEW_LINE DEDENT ans += 1 NEW_LINE DEDENT if check ( s ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE L = input ( ) [ : - 1 ] NEW_LINE ans = 0 NEW_LINE i = len ( L ) - 1 NEW_LINE first = True NEW_LINE while i >= 0 : NEW_LINE INDENT if L [ i ] == \" o \" : NEW_LINE INDENT i -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT if first : NEW_LINE INDENT ans += 1 NEW_LINE i -= M NEW_LINE if i >= 0 : NEW_LINE INDENT ans += i + 1 NEW_LINE DEDENT first = False NEW_LINE DEDENT else : NEW_LINE INDENT ans += 1 NEW_LINE i -= M NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "N , R = map ( int , input ( ) . split ( ) ) NEW_LINE inputs = list ( input ( ) ) NEW_LINE remain = inputs . count ( ' . ' ) NEW_LINE ans = 0 NEW_LINE for i in range ( N - R + 1 ) : NEW_LINE INDENT not_painted = inputs [ i : i + R ] . count ( ' . ' ) NEW_LINE if remain == 0 : NEW_LINE INDENT break NEW_LINE DEDENT if remain == not_painted : NEW_LINE INDENT ans += 1 NEW_LINE break NEW_LINE DEDENT if inputs [ i ] == ' . ' : NEW_LINE INDENT for j in range ( i , i + R ) : NEW_LINE INDENT inputs [ j ] = ' o ' NEW_LINE DEDENT remain -= not_painted NEW_LINE ans += 1 NEW_LINE DEDENT ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc027_C
[ "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 ) ; long [ ] a = new long [ 61 ] ; for ( int i = 0 ; i < 61 ; i ++ ) { a [ i ] = power ( 2 , i ) ; } long n = sc . nextLong ( ) ; int exponent = 0 ; while ( n / a [ exponent ] > 0 ) exponent ++ ; exponent -- ; int count = 0 ; long t = 1 ; while ( t <= n ) { if ( exponent % 2 == 1 ) { if ( count % 2 == 0 ) t = right ( t ) ; else t = left ( t ) ; } else { if ( count % 2 == 0 ) t = left ( t ) ; else t = right ( t ) ; } count ++ ; } String [ ] ans = { \" Aoki \" , \" Takahashi \" } ; out . println ( ans [ ( count + 1 ) % 2 ] ) ; } static long power ( long x , int n ) { if ( n == 0 ) return 1 ; if ( n % 2 == 0 ) { long e = power ( x , n / 2 ) ; return ( e * e ) ; } long e = ( x * power ( x , n - 1 ) ) ; return e ; } static long right ( long a ) { return a * 2 ; } static long left ( long a ) { return a * 2 + 1 ; } }", "import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; @ SuppressWarnings ( \" unchecked \" ) public class Main { static final String Takahashi = \" Takahashi \" ; static final String Aoki = \" Aoki \" ; static long N ; static boolean odd ; static boolean f ( ) { boolean turn = true ; long num = 1 ; while ( num <= N ) { if ( turn ) { if ( odd ) num = 2 * num + 1 ; else num = 2 * num ; } else { if ( odd ) num = 2 * num ; else num = 2 * num + 1 ; } turn = ! turn ; } boolean flg = true ; if ( ! turn ) flg = false ; return flg ; } public static void main ( String [ ] args ) throws IOException { final String s ; try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { s = reader . readLine ( ) ; } PrintWriter out = new PrintWriter ( System . out ) ; N = Long . parseLong ( s ) ; long depth = 0 ; for ( long i = N ; 0 < i ; i /= 2 ) depth ++ ; odd = depth % 2 == 1 ; if ( f ( ) ) out . println ( Takahashi ) ; else out . println ( Aoki ) ; out . flush ( ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { long n ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextLong ( ) ; solve ( ) ; } void solve ( ) { int depth = 0 ; for ( long k = n ; k > 0 ; k /= 2 ) { depth ++ ; } long x = 1 ; int turn = 0 ; boolean even = depth % 2 == 0 ; while ( x <= n ) { if ( turn == 0 ) { if ( even ) { x *= 2 ; } else { x = 2 * x + 1 ; } } else { if ( even ) { x = 2 * x + 1 ; } else { x *= 2 ; } } turn = ( turn + 1 ) % 2 ; } if ( turn == 0 ) { System . out . println ( \" Takahashi \" ) ; } else { System . out . println ( \" Aoki \" ) ; } } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int depth = 0 ; for ( long n = N ; n > 0 ; n /= 2 ) { depth ++ ; } if ( depth % 2 == 1 ) { long x = 1 ; while ( true ) { if ( x * 2 > N ) { System . out . println ( \" Aoki \" ) ; return ; } x = x * 2 + 1 ; if ( x * 2 > N ) { System . out . println ( \" Takahashi \" ) ; return ; } x *= 2 ; } } else { long x = 1 ; while ( true ) { if ( x * 2 > N ) { System . out . println ( \" Aoki \" ) ; return ; } x *= 2 ; if ( x * 2 > N ) { System . out . println ( \" Takahashi \" ) ; return ; } x = x * 2 + 1 ; } } } }", "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { long n = scanner . nextLong ( ) , x = 1 ; int depth = Long . numberOfTrailingZeros ( Long . highestOneBit ( n ) ) & 1 ; boolean turn = false ; while ( n >= x ) x = x * 2 + ( ( turn = ! turn ) ? 1 - depth : depth ) ; System . out . println ( turn ? \" Aoki \" : \" Takahashi \" ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE row = 0 NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT if 2 ** i <= n <= 2 ** ( i + 1 ) - 1 : NEW_LINE INDENT row = i NEW_LINE break NEW_LINE DEDENT DEDENT def seki ( k , n ) : NEW_LINE INDENT for _ in range ( n ) : NEW_LINE INDENT k = 4 * k + 2 NEW_LINE DEDENT return k NEW_LINE DEDENT k = 0 NEW_LINE if row % 2 != 0 : NEW_LINE INDENT k = 2 NEW_LINE cri = seki ( k , row // 2 ) NEW_LINE if n < cri : NEW_LINE INDENT print ( \" Aoki \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Takahashi \" ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT k = 1 NEW_LINE cri = seki ( k , row // 2 ) NEW_LINE if n < cri : NEW_LINE INDENT print ( \" Takahashi \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Aoki \" ) NEW_LINE DEDENT DEDENT", "def baibai_chance ( N : int ) -> str : NEW_LINE INDENT depth = 0 NEW_LINE n = N NEW_LINE while 1 < n : NEW_LINE INDENT depth += 1 NEW_LINE n >>= 1 NEW_LINE DEDENT def m2 ( x ) : return x << 1 NEW_LINE def m2p1 ( x ) : return ( x << 1 ) + 1 NEW_LINE if depth % 2 == 0 : NEW_LINE INDENT Tst , Ast = m2p1 , m2 NEW_LINE DEDENT else : NEW_LINE INDENT Tst , Ast = m2 , m2p1 NEW_LINE DEDENT x = 1 NEW_LINE while True : NEW_LINE INDENT x = Tst ( x ) NEW_LINE if N < x : NEW_LINE INDENT return \" Aoki \" NEW_LINE DEDENT x = Ast ( x ) NEW_LINE if N < x : NEW_LINE INDENT return ' Takahashi ' NEW_LINE DEDENT DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = baibai_chance ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "N = bin ( int ( input ( ) ) ) [ 2 : ] NEW_LINE ret = [ ' Aoki ' , ' Takahashi ' ] NEW_LINE point = 0 NEW_LINE for i in range ( 1 , len ( N ) ) : NEW_LINE INDENT if N [ i ] == '0' : NEW_LINE INDENT if i % 2 != ( len ( N ) - 1 ) % 2 : NEW_LINE INDENT print ( ret [ i % 2 ] ) NEW_LINE break NEW_LINE DEDENT DEDENT if N [ i ] == '1' : NEW_LINE INDENT if i % 2 == ( len ( N ) - 1 ) % 2 : NEW_LINE INDENT print ( ret [ i % 2 ] ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ret [ ( len ( N ) - 1 ) % 2 ] ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE depth = len ( bin ( N ) ) - 2 NEW_LINE def func ( ) : NEW_LINE INDENT x = 1 NEW_LINE for d in range ( 80 ) : NEW_LINE INDENT if d % 2 == depth % 2 : NEW_LINE INDENT x = 2 * x NEW_LINE DEDENT elif d % 2 != depth % 2 : NEW_LINE INDENT x = 2 * x + 1 NEW_LINE DEDENT if x > N : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return d NEW_LINE DEDENT d = func ( ) NEW_LINE ans = [ \" Aoki \" , \" Takahashi \" ] NEW_LINE index = d % 2 NEW_LINE print ( ans [ index ] ) NEW_LINE", "from math import log2 NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE def left ( x ) : NEW_LINE INDENT return 2 * x NEW_LINE DEDENT def right ( x ) : NEW_LINE INDENT return 2 * x + 1 NEW_LINE DEDENT def floor ( x ) : NEW_LINE INDENT return x // 1 NEW_LINE DEDENT def depth ( x ) : NEW_LINE INDENT return floor ( log2 ( x ) ) + 1 NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE turn = True NEW_LINE d = depth ( n ) NEW_LINE if d % 2 == 0 : NEW_LINE INDENT taka = ( lambda x : left ( x ) ) NEW_LINE aoki = ( lambda x : right ( x ) ) NEW_LINE DEDENT else : NEW_LINE INDENT aoki = ( lambda x : left ( x ) ) NEW_LINE taka = ( lambda x : right ( x ) ) NEW_LINE DEDENT x = 1 NEW_LINE while x <= n : NEW_LINE INDENT if turn : NEW_LINE INDENT x = taka ( x ) NEW_LINE DEDENT else : NEW_LINE INDENT x = aoki ( x ) NEW_LINE DEDENT turn = not turn NEW_LINE DEDENT if turn : NEW_LINE INDENT print ( \" Takahashi \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Aoki \" ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE" ]
atcoder_abc007_C
[ "import java . awt . Point ; import java . util . ArrayDeque ; import java . util . Queue ; import java . util . Scanner ; public class Main { static int INF = 10000 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < Point > que = new ArrayDeque < > ( ) ; int dx [ ] = { 1 , 0 , - 1 , 0 } ; int dy [ ] = { 0 , 1 , 0 , - 1 } ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int sx = sc . nextInt ( ) - 1 ; int sy = sc . nextInt ( ) - 1 ; int gx = sc . nextInt ( ) - 1 ; int gy = sc . nextInt ( ) - 1 ; char f [ ] [ ] = new char [ h ] [ w ] ; int dist [ ] [ ] = new int [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) for ( int j = 0 ; j < w ; j ++ ) dist [ i ] [ j ] = INF ; for ( int i = 0 ; i < h ; i ++ ) { f [ i ] = sc . next ( ) . toCharArray ( ) ; } Point start = new Point ( sx , sy ) ; dist [ sx ] [ sy ] = 0 ; que . add ( start ) ; while ( ! que . isEmpty ( ) ) { Point p = que . poll ( ) ; if ( p . x == gx && p . y == gy ) break ; for ( int i = 0 ; i < 4 ; i ++ ) { int nx = p . x + dx [ i ] ; int ny = p . y + dy [ i ] ; if ( f [ nx ] [ ny ] == ' . ' && dist [ nx ] [ ny ] == INF ) { que . add ( new Point ( nx , ny ) ) ; dist [ nx ] [ ny ] = dist [ p . x ] [ p . y ] + 1 ; } } } System . out . println ( dist [ gx ] [ gy ] ) ; } }", "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 H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int sy = sc . nextInt ( ) - 1 , sx = sc . nextInt ( ) - 1 , gy = sc . nextInt ( ) - 1 , gx = sc . nextInt ( ) - 1 ; int [ ] dx = { - 1 , 0 , 1 , 0 } ; int [ ] dy = { 0 , 1 , 0 , - 1 } ; char [ ] [ ] c = new char [ W ] [ H ] ; int [ ] [ ] step = new int [ W ] [ H ] ; for ( int i = 0 ; i < H ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < W ; j ++ ) { c [ j ] [ i ] = s . charAt ( j ) ; step [ j ] [ i ] = 100000 ; } } Deque < Point > stack = new ArrayDeque < > ( ) ; step [ sx ] [ sy ] = 0 ; stack . addFirst ( new Point ( sx , sy ) ) ; while ( stack . size ( ) > 0 ) { Point p = stack . pollFirst ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { int x = p . x + dx [ i ] ; int y = p . y + dy [ i ] ; if ( 0 <= x && x < W && 0 <= y && y < H && c [ x ] [ y ] == ' . ' ) { if ( step [ x ] [ y ] > step [ p . x ] [ p . y ] + 1 ) { stack . addFirst ( new Point ( x , y ) ) ; step [ x ] [ y ] = step [ p . x ] [ p . y ] + 1 ; } } } } out . println ( step [ gx ] [ gy ] ) ; } }", "import java . awt . * ; import java . util . * ; import java . util . stream . IntStream ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int r = scanner . nextInt ( ) , c = scanner . nextInt ( ) ; Point start = new Point ( scanner . nextInt ( ) - 1 , scanner . nextInt ( ) - 1 ) ; Point goal = new Point ( scanner . nextInt ( ) - 1 , scanner . nextInt ( ) - 1 ) ; int [ ] [ ] a = IntStream . range ( 0 , r ) . mapToObj ( j -> scanner . next ( ) . chars ( ) . map ( ch -> ch == ' # ' ? - 1 : 0 ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; Queue < Point > queue = new ArrayDeque < > ( ) ; a [ start . x ] [ start . y ] ++ ; queue . add ( start ) ; while ( ! queue . isEmpty ( ) ) { Point point = queue . poll ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { try { int x1 = ( new int [ ] { - 1 , 1 , 0 , 0 } ) [ i ] , y1 = ( new int [ ] { 0 , 0 , - 1 , 1 } ) [ i ] ; if ( a [ point . x + x1 ] [ point . y + y1 ] > a [ point . x ] [ point . y ] + 1 || a [ point . x + x1 ] [ point . y + y1 ] == 0 ) { a [ point . x + x1 ] [ point . y + y1 ] = a [ point . x ] [ point . y ] + 1 ; queue . add ( new Point ( point . x + x1 , point . y + y1 ) ) ; } } catch ( ArrayIndexOutOfBoundsException e ) { } } } System . out . println ( a [ goal . x ] [ goal . y ] - 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 R = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int sy = sc . nextInt ( ) - 1 ; int sx = sc . nextInt ( ) - 1 ; int gy = sc . nextInt ( ) - 1 ; int gx = sc . nextInt ( ) - 1 ; String [ ] [ ] c = new String [ R ] [ C ] ; for ( int i = 0 ; i < R ; i ++ ) { c [ i ] = sc . next ( ) . split ( \" \" ) ; } Queue < Point > points = new ArrayDeque < Point > ( ) ; points . add ( new Point ( sy , sx , 0 ) ) ; c [ sy ] [ sx ] = \" ! \" ; out . println ( bfs ( c , points , new Point ( gy , gx , - 1 ) ) ) ; } public static int bfs ( String [ ] [ ] cource , Queue < Point > points , Point goal ) { Point point = points . poll ( ) ; int count = point . count ; if ( point . x == goal . x && point . y == goal . y ) { return count ; } int [ ] [ ] move = { { - 1 , 0 } , { 1 , 0 } , { 0 , - 1 } , { 0 , 1 } } ; count ++ ; for ( int i = 0 ; i < move . length ; i ++ ) { Point nextPoint = new Point ( point . y + move [ i ] [ 0 ] , point . x + move [ i ] [ 1 ] , count ) ; if ( cource [ nextPoint . y ] [ nextPoint . x ] . equals ( \" . \" ) ) { cource [ nextPoint . y ] [ nextPoint . x ] = \" ! \" ; points . add ( nextPoint ) ; } } return bfs ( cource , points , goal ) ; } } class Point { int y ; int x ; int count ; Point ( int y , int x , int count ) { this . y = y ; this . x = x ; this . count = count ; } }", "import java . awt . Point ; import java . util . ArrayDeque ; import java . util . Queue ; import java . util . Scanner ; public class Main { static int INF = 10000 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < Point > que = new ArrayDeque < > ( ) ; int dx [ ] = { 1 , 0 , - 1 , 0 } ; int dy [ ] = { 0 , 1 , 0 , - 1 } ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int sx = sc . nextInt ( ) - 1 ; int sy = sc . nextInt ( ) - 1 ; int gx = sc . nextInt ( ) - 1 ; int gy = sc . nextInt ( ) - 1 ; int dist [ ] [ ] = new int [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) for ( int j = 0 ; j < w ; j ++ ) dist [ i ] [ j ] = INF ; char f [ ] [ ] = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { f [ i ] = sc . next ( ) . toCharArray ( ) ; } dist [ sx ] [ sy ] = 0 ; que . add ( new Point ( sx , sy ) ) ; while ( ! que . isEmpty ( ) ) { Point p = que . poll ( ) ; if ( p . x == gx && p . y == gy ) break ; for ( int i = 0 ; i < 4 ; i ++ ) { int nx = p . x + dx [ i ] ; int ny = p . y + dy [ i ] ; if ( f [ nx ] [ ny ] == ' . ' && dist [ nx ] [ ny ] == INF ) { que . add ( new Point ( nx , ny ) ) ; dist [ nx ] [ ny ] = dist [ p . x ] [ p . y ] + 1 ; } } } System . out . println ( dist [ gx ] [ gy ] ) ; } }" ]
[ "from queue import Queue NEW_LINE h , w = map ( int , input ( ) . split ( ) ) NEW_LINE sy , sx = map ( int , input ( ) . split ( ) ) NEW_LINE sy -= 1 NEW_LINE sx -= 1 NEW_LINE gy , gx = map ( int , input ( ) . split ( ) ) NEW_LINE gy -= 1 NEW_LINE gx -= 1 NEW_LINE map = [ [ 0 ] for _ in range ( h ) ] NEW_LINE for i in range ( h ) : NEW_LINE INDENT map [ i ] = list ( input ( ) ) NEW_LINE DEDENT que = Queue ( ) NEW_LINE que . put ( [ sx , sy ] ) NEW_LINE checked = [ [ - 1 ] * w for _ in range ( h ) ] NEW_LINE checked [ sy ] [ sx ] = 0 NEW_LINE ans = 0 NEW_LINE def bfs ( ) : NEW_LINE INDENT global que , checked , ans NEW_LINE while not que . empty ( ) : NEW_LINE INDENT xy = que . get ( ) NEW_LINE if xy [ 0 ] == gx and xy [ 1 ] == gy : NEW_LINE INDENT ans = checked [ xy [ 1 ] ] [ xy [ 0 ] ] NEW_LINE DEDENT for i in range ( - 1 , 2 ) : NEW_LINE INDENT for j in range ( - 1 , 2 ) : NEW_LINE INDENT if i == j or i == - j : NEW_LINE INDENT continue NEW_LINE DEDENT if 0 <= xy [ 0 ] + i < w and 0 <= xy [ 1 ] + j < h : NEW_LINE INDENT if map [ xy [ 1 ] + j ] [ xy [ 0 ] + i ] == \" . \" and checked [ xy [ 1 ] + j ] [ xy [ 0 ] + i ] == - 1 : NEW_LINE INDENT checked [ xy [ 1 ] + j ] [ xy [ 0 ] + i ] = checked [ xy [ 1 ] ] [ xy [ 0 ] ] + 1 NEW_LINE que . put ( [ xy [ 0 ] + i , xy [ 1 ] + j ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT bfs ( ) NEW_LINE print ( ans ) NEW_LINE", "from collections import deque NEW_LINE R , C = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE sy , sx = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE gy , gx = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE maze = [ list ( input ( ) ) for _ in range ( R ) ] NEW_LINE distance_from_start = [ [ - 1 ] * C for _ in range ( R ) ] NEW_LINE move = [ [ 1 , 0 ] , [ - 1 , 0 ] , [ 0 , 1 ] , [ 0 , - 1 ] ] NEW_LINE que = deque ( ) NEW_LINE que . append ( ( sx , sy ) ) NEW_LINE distance_from_start [ sy - 1 ] [ sx - 1 ] = 0 NEW_LINE def minimum_distance ( ) : NEW_LINE INDENT while len ( que ) != 0 : NEW_LINE INDENT x , y = que . popleft ( ) NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT next_x = x + move [ i ] [ 0 ] NEW_LINE next_y = y + move [ i ] [ 1 ] NEW_LINE if next_x <= 0 or next_x > C or next_y <= 0 or next_y > R or distance_from_start [ next_y - 1 ] [ next_x - 1 ] != - 1 or maze [ next_y - 1 ] [ next_x - 1 ] == \" # \" : NEW_LINE INDENT continue NEW_LINE DEDENT distance_from_start [ next_y - 1 ] [ next_x - 1 ] = distance_from_start [ y - 1 ] [ x - 1 ] + 1 NEW_LINE que . append ( ( next_x , next_y ) ) NEW_LINE DEDENT DEDENT DEDENT minimum_distance ( ) NEW_LINE print ( distance_from_start [ gy - 1 ] [ gx - 1 ] ) NEW_LINE", "from collections import deque NEW_LINE r , c = map ( int , input ( ) . split ( ) ) NEW_LINE root = [ [ None for __ in range ( c ) ] for __ in range ( r ) ] NEW_LINE sx , sy = map ( int , input ( ) . split ( ) ) NEW_LINE gx , gy = map ( int , input ( ) . split ( ) ) NEW_LINE sy -= 1 NEW_LINE sx -= 1 NEW_LINE gy -= 1 NEW_LINE gx -= 1 NEW_LINE m = [ list ( input ( ) ) for __ in range ( r ) ] NEW_LINE root [ sx ] [ sy ] = 0 NEW_LINE celx = deque ( ) NEW_LINE cely = deque ( ) NEW_LINE x = sx NEW_LINE y = sy NEW_LINE while root [ gx ] [ gy ] == None : NEW_LINE INDENT if x != 0 and m [ x - 1 ] [ y ] != ' # ' and root [ x - 1 ] [ y ] == None : NEW_LINE INDENT root [ x - 1 ] [ y ] = root [ x ] [ y ] + 1 NEW_LINE celx . append ( x - 1 ) NEW_LINE cely . append ( y ) NEW_LINE DEDENT if x != r - 1 and m [ x + 1 ] [ y ] != ' # ' and root [ x + 1 ] [ y ] == None : NEW_LINE INDENT root [ x + 1 ] [ y ] = root [ x ] [ y ] + 1 NEW_LINE celx . append ( x + 1 ) NEW_LINE cely . append ( y ) NEW_LINE DEDENT if y != 0 and m [ x ] [ y - 1 ] != ' # ' and root [ x ] [ y - 1 ] == None : NEW_LINE INDENT root [ x ] [ y - 1 ] = root [ x ] [ y ] + 1 NEW_LINE celx . append ( x ) NEW_LINE cely . append ( y - 1 ) NEW_LINE DEDENT if y != c - 1 and m [ x ] [ y + 1 ] != ' # ' and root [ x ] [ y + 1 ] == None : NEW_LINE INDENT root [ x ] [ y + 1 ] = root [ x ] [ y ] + 1 NEW_LINE celx . append ( x ) NEW_LINE cely . append ( y + 1 ) NEW_LINE DEDENT x = celx . popleft ( ) NEW_LINE y = cely . popleft ( ) NEW_LINE DEDENT print ( root [ gx ] [ gy ] ) NEW_LINE", "from collections import deque NEW_LINE def bfs ( maze , visited , sy , sx , gy , gx ) : NEW_LINE INDENT queue = deque ( [ [ sy , sx ] ] ) NEW_LINE visited [ sy ] [ sx ] = 0 NEW_LINE while queue : NEW_LINE INDENT y , x = queue . popleft ( ) NEW_LINE if [ y , x ] == [ gy , gx ] : NEW_LINE INDENT return visited [ y ] [ x ] NEW_LINE DEDENT for j , k in ( [ 1 , 0 ] , [ - 1 , 0 ] , [ 0 , 1 ] , [ 0 , - 1 ] ) : NEW_LINE INDENT new_y , new_x = y + j , x + k NEW_LINE if maze [ new_y ] [ new_x ] == \" . \" and visited [ new_y ] [ new_x ] == - 1 : NEW_LINE INDENT visited [ new_y ] [ new_x ] = visited [ y ] [ x ] + 1 NEW_LINE queue . append ( [ new_y , new_x ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT R , C = map ( int , input ( ) . split ( ) ) NEW_LINE sy , sx = map ( int , input ( ) . split ( ) ) NEW_LINE gy , gx = map ( int , input ( ) . split ( ) ) NEW_LINE sy , sx , gy , gx = sy - 1 , sx - 1 , gy - 1 , gx - 1 NEW_LINE maze = [ input ( ) for i in range ( R ) ] NEW_LINE visited = [ [ - 1 ] * C for j in range ( R ) ] NEW_LINE print ( bfs ( maze , visited , sy , sx , gy , gx ) ) NEW_LINE DEDENT", "from collections import deque NEW_LINE R , C = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sy , sx = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE gy , gx = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE _d = { ' # ' : 1 , ' . ' : 0 } NEW_LINE _map = [ [ _d [ x ] for x in input ( ) ] for _ in range ( R ) ] NEW_LINE moves = [ ( 0 , 1 ) , ( 1 , 0 ) , ( 0 , - 1 ) , ( - 1 , 0 ) ] NEW_LINE dq = deque ( [ ( sy , sx , 0 ) ] ) NEW_LINE visited = set ( [ ( sy , sx ) ] ) NEW_LINE while dq : NEW_LINE INDENT y , x , dist = dq . popleft ( ) NEW_LINE for m in moves : NEW_LINE INDENT next_y = y + m [ 0 ] NEW_LINE next_x = x + m [ 1 ] NEW_LINE if next_y == gy and next_x == gx : NEW_LINE INDENT print ( dist + 1 ) NEW_LINE break NEW_LINE DEDENT if ( next_y , next_x ) not in visited : NEW_LINE INDENT if _map [ next_y - 1 ] [ next_x - 1 ] == 0 : NEW_LINE INDENT dq . append ( ( next_y , next_x , dist + 1 ) ) NEW_LINE visited . add ( ( next_y , next_x ) ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT break NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Something ▁ wrong ' ) NEW_LINE DEDENT" ]
atcoder_abc102_B
[ "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 min = 1000000000 ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; b [ i ] = a ; if ( max < b [ i ] ) { max = b [ i ] ; } if ( b [ i ] < min ) { min = b [ i ] ; } } System . out . println ( Math . abs ( max - min ) ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . PriorityQueue ; import java . util . Queue ; public class Main { public static void main ( String args [ ] ) throws Exception { Input input = new Input ( ) ; final Data l = input . readLine ( ) ; final int n = l . col [ 0 ] ; Queue < Integer > q = input . getColQueue ( ) ; input . close ( ) ; int min = q . poll ( ) ; int max = min ; while ( ! q . isEmpty ( ) ) { max = q . poll ( ) ; } System . out . println ( max - min ) ; } 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 < Integer > getColQueue ( ) throws Exception { Data d = readLine ( ) ; PriorityQueue < Integer > q ; q = new PriorityQueue < > ( ( a , b ) -> a - b ) ; 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 ] ) ; } } } }", "import java . io . PrintStream ; import java . util . IntSummaryStatistics ; import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static void exec ( Scanner in , PrintStream out ) { int N = in . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i += 1 ) { A [ i ] = in . nextInt ( ) ; } IntSummaryStatistics s = IntStream . of ( A ) . summaryStatistics ( ) ; out . println ( s . getMax ( ) - s . getMin ( ) ) ; } public static void main ( String [ ] args ) { exec ( new Scanner ( System . in ) , System . out ) ; } }", "import java . io . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; stdin . readLine ( ) ; int [ ] nums = Arrays . stream ( stdin . readLine ( ) . split ( \" ▁ \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; Arrays . sort ( nums ) ; System . out . println ( nums [ nums . length - 1 ] - nums [ 0 ] ) ; } }", "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 = Integer . parseInt ( sc . next ( ) ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Long . parseLong ( sc . next ( ) ) ; } Arrays . sort ( a ) ; System . out . println ( a [ a . length - 1 ] - a [ 0 ] ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( max ( A ) - min ( A ) ) NEW_LINE", "import itertools NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE X = 0 NEW_LINE for v in itertools . combinations ( A , 2 ) : NEW_LINE INDENT if abs ( v [ 0 ] - v [ 1 ] ) > X : NEW_LINE INDENT X = abs ( v [ 0 ] - v [ 1 ] ) NEW_LINE DEDENT DEDENT print ( X ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE minval = 10 ** 10 NEW_LINE maxval = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] > maxval : NEW_LINE INDENT maxval = a [ i ] NEW_LINE DEDENT if a [ i ] < minval : NEW_LINE INDENT minval = a [ i ] NEW_LINE DEDENT DEDENT print ( abs ( maxval - minval ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT ans = max ( A [ j ] - A [ i ] , ans ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE print ( abs ( a [ n - 1 ] - a [ 0 ] ) if len ( a ) >= 2 else 0 ) NEW_LINE" ]
atcoder_abc030_C
[ "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 ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ m ] ; Pair [ ] pairs = new Pair [ n + m ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; Pair ps = new Pair ( ) ; ps . start = a [ i ] ; ps . goal = a [ i ] + x ; ps . dir = 1 ; pairs [ i ] = ps ; } for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . nextInt ( ) ; Pair ps = new Pair ( ) ; ps . start = b [ i ] ; ps . goal = b [ i ] + y ; ps . dir = - 1 ; pairs [ i + n ] = ps ; } Arrays . sort ( pairs ) ; int count = 0 ; int t = 0 ; int nowdir = 1 ; for ( int i = 0 ; i < n + m ; i ++ ) { int start = pairs [ i ] . start ; int goal = pairs [ i ] . goal ; int dir = pairs [ i ] . dir ; if ( t <= start && nowdir == dir ) { count ++ ; t = goal ; nowdir *= - 1 ; } } System . out . println ( count / 2 ) ; } } class Pair implements Comparable { int start ; int goal ; int dir ; @ Override public int compareTo ( Object other ) { Pair otherpair = ( Pair ) other ; return goal - otherpair . goal ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , x = sc . nextInt ( ) , y = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) b [ i ] = sc . nextInt ( ) ; solve ( n , m , a , b , x , y ) ; } static int t = 0 , ans = 0 , i = 0 , j = 0 ; static void calc1 ( int n , int m , int [ ] a , int [ ] b , int x , int y ) { boolean f = true ; while ( i < n && j < m ) { if ( f ) { calc2 ( n , a , x , f ) ; f = false ; } else { calc2 ( m , b , y , f ) ; f = true ; } } } static void calc2 ( int n , int [ ] a , int x , boolean f ) { int k = f ? i : j ; if ( t <= a [ k ] ) { t = a [ k ] + x ; k ++ ; ans ++ ; } else { while ( k < n && a [ k ] < t ) k ++ ; if ( k < n ) { t = a [ k ] + x ; ans ++ ; } } if ( f ) i = k ; else j = k ; } static void solve ( int n , int m , int [ ] a , int [ ] b , int x , int y ) { calc1 ( n , m , a , b , x , y ) ; out . println ( ans / 2 ) ; } }", "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 = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int [ ] b = new int [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int time = 0 ; while ( true ) { int aIndex = binarySearch ( a , time ) ; if ( aIndex >= N ) { break ; } time = a [ aIndex ] + X ; int bIndex = binarySearch ( b , time ) ; if ( bIndex >= M ) { break ; } time = b [ bIndex ] + Y ; ans ++ ; } out . println ( ans ) ; } public static int binarySearch ( int [ ] arr , int num ) { int result = Arrays . binarySearch ( arr , num ) ; return ( result >= 0 ) ? result : ~ result ; } }", "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 ( ) ; int x = scanner . nextInt ( ) , y = scanner . nextInt ( ) ; int [ ] a = java . util . stream . IntStream . range ( 0 , n ) . map ( i -> scanner . nextInt ( ) ) . toArray ( ) ; int [ ] b = java . util . stream . IntStream . range ( 0 , m ) . map ( i -> scanner . nextInt ( ) ) . toArray ( ) ; int i = 0 , j = 0 , t = 1 , ans = 0 ; loop : while ( i < n && j < m ) { while ( a [ i ] < t ) if ( ++ i == n ) break loop ; t = a [ i ] + x ; while ( b [ j ] < t ) if ( ++ j == m ) break loop ; t = b [ j ] + y ; ans ++ ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long [ ] as = new long [ N ] ; long [ ] bs = new long [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { as [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { bs [ i ] = sc . nextLong ( ) ; } int count = 0 ; int i = 0 ; while ( true ) { if ( i >= as . length ) { break ; } int index = Arrays . binarySearch ( bs , as [ i ] + x ) ; index = ( index >= 0 ) ? index : ~ index ; if ( index >= bs . length ) { break ; } i = Arrays . binarySearch ( as , bs [ index ] + y ) ; i = ( i >= 0 ) ? i : ~ i ; count ++ ; } System . out . println ( count ) ; } }" ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def binarysearch ( x , line ) : NEW_LINE INDENT ng = - 1 NEW_LINE ok = len ( line ) NEW_LINE while abs ( ok - ng ) > 1 : NEW_LINE INDENT mid = ( ok + ng ) // 2 NEW_LINE if line [ mid ] >= x : NEW_LINE INDENT ok = mid NEW_LINE DEDENT else : NEW_LINE INDENT ng = mid NEW_LINE DEDENT DEDENT return ok NEW_LINE DEDENT ans = 0 NEW_LINE time = 0 NEW_LINE flag = True NEW_LINE while 1 : NEW_LINE INDENT if flag : NEW_LINE INDENT xyz = binarysearch ( time , a ) NEW_LINE if xyz == len ( a ) : NEW_LINE INDENT break NEW_LINE DEDENT time = a [ xyz ] + x NEW_LINE flag = False NEW_LINE DEDENT else : NEW_LINE INDENT xyz = binarysearch ( time , b ) NEW_LINE if xyz == len ( b ) : NEW_LINE INDENT break NEW_LINE DEDENT time = b [ xyz ] + y NEW_LINE ans += 1 NEW_LINE flag = True NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import bisect NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE al = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE bl = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a , b = 0 , 0 NEW_LINE t = 0 NEW_LINE ans = 0 NEW_LINE while al [ - 1 ] >= t and bl [ - 1 ] >= t : NEW_LINE INDENT a = bisect . bisect_left ( al , t ) NEW_LINE if a >= N - 1 and al [ - 1 ] < t : NEW_LINE INDENT break NEW_LINE DEDENT t = al [ a ] + X NEW_LINE b = bisect . bisect_left ( bl , t ) NEW_LINE if b >= M - 1 and bl [ - 1 ] < t : NEW_LINE INDENT break NEW_LINE DEDENT ans += 1 NEW_LINE t = bl [ b ] + Y NEW_LINE DEDENT print ( ans ) NEW_LINE", "import bisect NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 + 7 ) NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cache = { } NEW_LINE def f ( t , airport ) : NEW_LINE INDENT key = ( t , airport ) NEW_LINE if key in cache : NEW_LINE INDENT return cache [ key ] NEW_LINE DEDENT val = 0 NEW_LINE if airport : NEW_LINE INDENT u = bisect . bisect_left ( a , t ) NEW_LINE if u < n : NEW_LINE INDENT val = max ( val , f ( a [ u ] + x , not airport ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT u = bisect . bisect_left ( b , t ) NEW_LINE if u < m : NEW_LINE INDENT val = max ( val , f ( b [ u ] + y , not airport ) + 1 ) NEW_LINE DEDENT DEDENT cache [ key ] = val NEW_LINE return val NEW_LINE DEDENT print ( f ( 0 , True ) ) NEW_LINE", "def pilot ( N : int , M : int , X : int , Y : int , A : list , B : list ) -> int : NEW_LINE INDENT ai , bi = 0 , 0 NEW_LINE t = 0 NEW_LINE repeat = 0 NEW_LINE while ai < N and bi < M : NEW_LINE INDENT while ai < N and A [ ai ] < t : NEW_LINE INDENT ai += 1 NEW_LINE DEDENT if N <= ai : NEW_LINE INDENT break NEW_LINE DEDENT t = A [ ai ] + X NEW_LINE ai += 1 NEW_LINE while bi < M and B [ bi ] < t : NEW_LINE INDENT bi += 1 NEW_LINE DEDENT if M <= bi : NEW_LINE INDENT break NEW_LINE DEDENT t = B [ bi ] + Y NEW_LINE bi += 1 NEW_LINE repeat += 1 NEW_LINE DEDENT return repeat NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE B = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = pilot ( N , M , X , Y , A , B ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "import math 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 INF = float ( \" inf \" ) NEW_LINE N , K = s_inpl ( ) NEW_LINE X , Y = s_inpl ( ) NEW_LINE a = inpl ( ) NEW_LINE b = inpl ( ) NEW_LINE t = 0 NEW_LINE ans = 0 NEW_LINE while True : NEW_LINE INDENT next_a = bisect_left ( a , t ) NEW_LINE if next_a == N : NEW_LINE INDENT break NEW_LINE DEDENT t = a [ next_a ] + X NEW_LINE next_b = bisect_left ( b , t ) NEW_LINE if next_b == K : NEW_LINE INDENT break NEW_LINE DEDENT t = b [ next_b ] + Y NEW_LINE ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc009_B
[ "import java . util . * ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = s . nextInt ( ) ; int [ ] branches = new int [ n ] ; int [ ] parent = new int [ n ] ; int [ ] [ ] childlen = new int [ n ] [ ] ; for ( int i = 1 ; i < n ; ++ i ) ++ branches [ parent [ i ] = s . nextInt ( ) - 1 ] ; for ( int i = 0 ; i < n ; ++ i ) childlen [ i ] = new int [ branches [ i ] ] ; loop : for ( int i = 0 ; i < n ; ++ i ) { int I = i ; while ( true ) { if ( branches [ I ] > 0 ) break ; int r = 0 ; { int [ ] c = childlen [ I ] ; Arrays . sort ( c ) ; for ( int j = 0 , e = c . length ; j < e ; ++ j ) r = Math . max ( r , c [ j ] + e - j ) ; } if ( I == 0 ) { System . out . println ( r ) ; break loop ; } I = parent [ I ] ; childlen [ I ] [ -- branches [ I ] ] = r ; } } } }", "import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . Scanner ; public class Main { static ArrayList < Integer > [ ] g ; static int n ; static int [ ] deg ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; g = new ArrayList [ n ] ; deg = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { g [ i ] = new ArrayList < > ( ) ; } for ( int i = 1 ; i < n ; ++ i ) { int a = sc . nextInt ( ) - 1 ; g [ a ] . add ( i ) ; g [ i ] . add ( a ) ; } dfs ( 0 , - 1 ) ; System . out . println ( deg [ 0 ] ) ; } static void dfs ( int cur , int par ) { if ( cur != 0 && g [ cur ] . size ( ) == 1 ) { deg [ cur ] = 0 ; return ; } else if ( g [ cur ] . size ( ) == 0 ) { deg [ cur ] = 0 ; return ; } ArrayList < Integer > v = new ArrayList < > ( ) ; for ( int dst : g [ cur ] ) { if ( dst == par ) continue ; dfs ( dst , cur ) ; v . add ( deg [ dst ] ) ; } Collections . sort ( v , new Comparator < Integer > ( ) { @ Override public int compare ( Integer o1 , Integer o2 ) { return - Integer . compare ( o1 , o2 ) ; } } ) ; int max = 0 ; for ( int i = 0 ; i < v . size ( ) ; ++ i ) { max = Math . max ( max , i + v . get ( i ) ) ; } deg [ cur ] = max + 1 ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . io . * ; import java . util . * ; public class Main { static int dfs ( ArrayList < Integer > list [ ] , int idx , int par ) { int min = 0 ; ArrayList < Integer > node = new ArrayList < > ( ) ; for ( int temp : list [ idx ] ) { if ( temp == par ) continue ; int child = dfs ( list , temp , idx ) ; node . add ( child ) ; } Collections . sort ( node ) ; for ( int temp : node ) { min = Math . max ( temp , min ) + 1 ; } return min ; } public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; ArrayList < Integer > list [ ] = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) list [ i ] = new ArrayList < > ( ) ; for ( int i = 2 ; i <= n ; i ++ ) { int temp = Integer . parseInt ( br . readLine ( ) ) ; list [ i ] . add ( temp ) ; list [ temp ] . add ( i ) ; } System . out . println ( dfs ( list , 1 , - 1 ) ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; ArrayList < Integer > [ ] graph = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { graph [ i ] = new ArrayList < > ( ) ; } for ( int i = 1 ; i < N ; i ++ ) { int a = scanner . nextInt ( ) - 1 ; graph [ a ] . add ( i ) ; } System . out . println ( dfs ( 0 , graph ) - 1 ) ; } private static int dfs ( int v , ArrayList < Integer > [ ] graph ) { if ( graph [ v ] . isEmpty ( ) ) { return 1 ; } int [ ] tmp = new int [ graph [ v ] . size ( ) ] ; for ( int i = 0 ; i < tmp . length ; i ++ ) { int u = graph [ v ] . get ( i ) ; tmp [ i ] = dfs ( u , graph ) ; } Arrays . sort ( tmp ) ; int max = 0 ; for ( int t : tmp ) { if ( t <= max ) max ++ ; else max = t ; } max ++ ; return max ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . * ; public class Main { public static int [ ] dp ; public static ArrayList < Integer > [ ] win ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; win = new ArrayList [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { win [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 1 ; i < n ; i ++ ) { win [ a [ i ] - 1 ] . add ( i ) ; } dp = new int [ n ] ; solve ( 0 ) ; System . out . println ( dp [ 0 ] - 1 ) ; } public static void solve ( int v ) { int size = win [ v ] . size ( ) ; if ( size == 0 ) { dp [ v ] = 1 ; return ; } int [ ] d = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { int t = win [ v ] . get ( i ) ; solve ( t ) ; d [ i ] = dp [ t ] ; } Arrays . sort ( d ) ; int depth = 0 ; for ( int i = 0 ; i < size ; i ++ ) { if ( depth < size - i + d [ i ] ) depth = size - i + d [ i ] ; } dp [ v ] = depth ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 202020 ) NEW_LINE N = int ( input ( ) ) NEW_LINE won = [ [ ] for i in range ( N ) ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT a = int ( input ( ) ) - 1 NEW_LINE won [ a ] . append ( i ) NEW_LINE DEDENT def height ( v ) : NEW_LINE INDENT if not won [ v ] : return 0 NEW_LINE hs = [ height ( op ) for op in won [ v ] ] NEW_LINE ret = 0 NEW_LINE for i , h in enumerate ( sorted ( hs ) ) : NEW_LINE INDENT ret = max ( ret , h + len ( hs ) - i ) NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( height ( 0 ) ) NEW_LINE", "from sys import stdin , setrecursionlimit NEW_LINE setrecursionlimit ( 10 ** 7 ) NEW_LINE def solve ( ) : NEW_LINE INDENT N = int ( stdin . readline ( ) ) NEW_LINE Adj = [ [ ] for i in range ( N ) ] NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT a = int ( stdin . readline ( ) ) - 1 NEW_LINE Adj [ a ] . append ( i + 1 ) NEW_LINE DEDENT ans = dfs ( N , Adj , 0 , - 1 ) NEW_LINE print ( ans ) NEW_LINE DEDENT def dfs ( N , Adj , v , p ) : NEW_LINE INDENT dl = [ ] NEW_LINE for u in Adj [ v ] : NEW_LINE INDENT if u == p : NEW_LINE INDENT continue NEW_LINE DEDENT dl . append ( dfs ( N , Adj , u , v ) ) NEW_LINE DEDENT dl . sort ( reverse = True ) NEW_LINE if not dl : NEW_LINE INDENT return 0 NEW_LINE DEDENT res = max ( dl [ i ] + i + 1 for i in range ( len ( dl ) ) ) NEW_LINE return res NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT", "import sys NEW_LINE from heapq import heapify , heappush , heappop NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE List = [ [ ] for i in range ( N ) ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE List [ a - 1 ] . append ( i ) NEW_LINE DEDENT def f ( x ) : NEW_LINE INDENT if len ( List [ x ] ) == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT L = [ ] NEW_LINE heapify ( L ) NEW_LINE for a in List [ x ] : NEW_LINE INDENT heappush ( L , f ( a ) ) NEW_LINE DEDENT n = len ( L ) NEW_LINE res = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT b = heappop ( L ) NEW_LINE res = max ( res , b + n - i ) NEW_LINE DEDENT return res NEW_LINE DEDENT print ( f ( 0 ) ) NEW_LINE", "from collections import Counter NEW_LINE n = int ( input ( ) ) NEW_LINE xs = [ None ] + [ int ( input ( ) ) - 1 for _ in range ( n - 1 ) ] NEW_LINE count_win = Counter ( xs ) NEW_LINE q = [ i for i in range ( n ) if not i in count_win ] NEW_LINE children = [ [ ] for i in range ( n ) ] NEW_LINE qi = 0 NEW_LINE while not q [ qi ] == 0 : NEW_LINE INDENT i , qi = q [ qi ] , qi + 1 NEW_LINE children [ i ] . sort ( reverse = True ) NEW_LINE children [ i ] = max ( v + w for v , w in enumerate ( [ 0 ] + children [ i ] ) ) NEW_LINE j = xs [ i ] NEW_LINE children [ j ] . append ( children [ i ] ) NEW_LINE if count_win [ j ] <= 1 : NEW_LINE INDENT q . append ( j ) NEW_LINE DEDENT else : NEW_LINE INDENT count_win [ j ] -= 1 NEW_LINE DEDENT DEDENT children [ 0 ] . sort ( reverse = True ) NEW_LINE children [ 0 ] = max ( v + w for v , w in enumerate ( [ 0 ] + children [ 0 ] ) ) NEW_LINE print ( children [ 0 ] ) NEW_LINE", "import sys , math , copy NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE HUGE = 2147483647 NEW_LINE HUGEL = 9223372036854775807 NEW_LINE ABC = \" abcdefghijklmnopqrstuvwxyz \" NEW_LINE class Node : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . children0 = [ ] NEW_LINE self . parent0 = - 1 NEW_LINE self . depth = - 1 NEW_LINE DEDENT def get_depth ( self ) : NEW_LINE INDENT if self . depth == - 1 : NEW_LINE INDENT childdepths = sorted ( [ nodes [ ch0 ] . get_depth ( ) for ch0 in self . children0 ] , reverse = True ) NEW_LINE res = 0 NEW_LINE for i0 , cd in enumerate ( childdepths ) : NEW_LINE INDENT res = max ( res , cd + i0 + 1 ) NEW_LINE DEDENT self . depth = res NEW_LINE DEDENT return self . depth NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT for i0 in range ( 1 , N ) : NEW_LINE INDENT pa1 = int ( input ( ) ) NEW_LINE assert pa1 >= 1 NEW_LINE pa0 = pa1 - 1 NEW_LINE nodes [ i0 ] . parent0 = pa0 NEW_LINE nodes [ pa0 ] . children0 . append ( i0 ) NEW_LINE DEDENT print ( nodes [ 0 ] . get_depth ( ) ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE nodes = [ Node ( ) for i in range ( N ) ] NEW_LINE main ( ) NEW_LINE" ]
atcoder_abc110_D
[ "import java . util . Scanner ; import java . util . Map . Entry ; public class Main { static int MAX_FAC = 510000 ; static int MOD = 1000000007 ; static long [ ] fac = new long [ MAX_FAC ] ; static long [ ] finv = new long [ MAX_FAC ] ; static long [ ] inv = new long [ MAX_FAC ] ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long N = in . nextLong ( ) ; long M = in . nextLong ( ) ; long ans = 1 ; initComb ( ) ; long m = M ; for ( int i = 2 ; i * i <= m ; i ++ ) { if ( m % i == 0 ) { int count = 0 ; while ( m % i == 0 ) { m /= i ; count ++ ; } ans = ( ans * comb ( ( int ) N - 1 + count , count ) ) % MOD ; } } if ( m > 1 ) { ans = ( ans * N ) % MOD ; } System . out . println ( ans ) ; } public static void initComb ( ) { fac [ 0 ] = finv [ 0 ] = inv [ 0 ] = fac [ 1 ] = finv [ 1 ] = inv [ 1 ] = 1 ; for ( int i = 2 ; i < MAX_FAC ; ++ i ) { fac [ i ] = fac [ i - 1 ] * i % MOD ; inv [ i ] = MOD - ( MOD / i ) * inv [ ( int ) ( MOD % i ) ] % MOD ; finv [ i ] = finv [ i - 1 ] * inv [ i ] % MOD ; } } public static long comb ( int n , int k ) { return fac [ n ] * finv [ k ] % MOD * finv [ n - k ] % MOD ; } }", "import java . util . ArrayList ; import java . util . Scanner ; class Main { static final long MOD = 1000000007 ; static long pow = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long M = sc . nextLong ( ) ; ArrayList < Integer > sosu = new ArrayList < Integer > ( ) ; long ans = 1 ; for ( int i = 2 ; i * i <= M ; i ++ ) { if ( M % i == 0 ) { int scount = 0 ; while ( M % i == 0 ) { scount ++ ; M /= i ; } if ( scount != 0 ) { ans *= comb ( scount + N - 1 , scount ) ; ans %= pow ; } } } if ( M != 1 ) { ans *= comb ( 1 + N - 1 , 1 ) ; ans %= pow ; } System . out . println ( ans ) ; } static long comb ( long x , Integer y ) { long ue = 1 ; long sita = 1 ; for ( int i = 0 ; i < y ; i ++ ) { ue *= x - i ; ue %= pow ; sita *= i + 1 ; sita %= pow ; } long ans = ue * modpow ( sita , pow - 2 ) % pow ; return ans ; } static long modpow ( long a , long p ) { if ( p == 0 ) { return 1 ; } if ( p % 2 == 0 ) { long halfp = p / 2 ; long half = modpow ( a , halfp ) ; return half * half % pow ; } else { return a * modpow ( a , p - 1 ) % pow ; } } } 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 . * ; 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 size = 1000000 ; long [ ] fact = new long [ size ] ; long [ ] inv = new long [ size ] ; fact [ 0 ] = 1 ; inv [ 0 ] = 1 ; long mod = 1000000007 ; for ( int i = 1 ; i < size ; i ++ ) { fact [ i ] = ( fact [ i - 1 ] * i ) % mod ; inv [ i ] = power ( fact [ i ] , ( int ) mod - 2 ) % mod ; } int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; if ( m == 1 ) { out . println ( 1 ) ; } else { HashMap < Integer , Integer > map = new HashMap < > ( ) ; int stop = ( int ) sqrt ( m ) + 1 ; for ( int i = 2 ; i <= stop ; i ++ ) { while ( m % i == 0 ) { m /= i ; map . put ( i , map . getOrDefault ( i , 0 ) + 1 ) ; } } if ( m != 1 ) map . put ( m , 1 ) ; long ans = 1 ; for ( int k : map . keySet ( ) ) { ans = ( ans % mod * fact [ n - 1 + map . get ( k ) ] % mod * inv [ n - 1 ] % mod * inv [ map . get ( k ) ] % mod ) % mod ; } out . println ( ans ) ; } } static long power ( long x , int n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans % mod * x % mod ) % mod ; } x = ( x % mod * x % mod ) % mod ; n >>= 1 ; } return ans ; } }", "import java . util . Scanner ; public class Main { static int MOD = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int sq = ( int ) Math . ceil ( Math . sqrt ( M ) ) ; int prime = 0 ; long ans = 1 ; Combination comb = new Combination ( N + sq , MOD ) ; for ( int i = 2 ; i <= sq ; i ++ ) { if ( M % i == 0 ) { prime = 0 ; while ( M % i == 0 ) { prime ++ ; M /= i ; } ans = ( ans * comb . comb ( N - 1 + prime , Math . min ( N - 1 , prime ) ) ) % MOD ; } } if ( M > 1 ) ans = ( ans * N ) % MOD ; System . out . println ( ans ) ; sc . close ( ) ; } } class Combination { long fac [ ] ; long inv [ ] ; int MOD ; Combination ( int size , int mod ) { this . fac = new long [ size + 1 ] ; this . inv = new long [ size + 1 ] ; this . MOD = mod ; this . fac [ 0 ] = 1 ; this . inv [ 0 ] = 1 ; for ( int i = 1 ; i <= size ; i ++ ) { fac [ i ] = ( fac [ i - 1 ] * i ) % MOD ; inv [ i ] = modPow ( fac [ i ] , ( int ) MOD - 2 ) % MOD ; } } long comb ( int n , int r ) { return fac [ n ] * inv [ r ] % MOD * inv [ n - r ] % MOD ; } private long modPow ( long base , int exp ) { long ret = 1 ; while ( exp > 0 ) { if ( ( exp & 1 ) == 1 ) { ret = ret * base % MOD ; } base = base * base % MOD ; exp >>= 1 ; } return ret ; } }", "import java . util . * ; public class Main { static int modAns = ( int ) Math . pow ( 10 , 9 ) + 7 ; static long fac [ ] = new long [ 1000000 ] ; static long finv [ ] = new long [ 1000000 ] ; static long inv [ ] = new long [ 1000000 ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int length = sc . nextInt ( ) ; int multi = sc . nextInt ( ) ; long ans = 1 ; ArrayList < Integer > counts = new ArrayList < Integer > ( ) ; for ( int i = 2 ; i <= multi ; i ++ ) { if ( multi % i == 0 ) { int count = 0 ; while ( multi % i == 0 ) { multi /= i ; count ++ ; } counts . add ( count ) ; } if ( multi == 1 ) { break ; } } COMinit ( ) ; for ( int i = 0 ; i < counts . size ( ) ; i ++ ) { ans *= combi ( counts . get ( i ) + length - 1 , Math . min ( counts . get ( i ) , length - 1 ) ) % modAns ; ans %= modAns ; } System . out . println ( ans ) ; } public static long combi ( int n , int r ) { return fac [ n ] * ( finv [ r ] * finv [ n - r ] % modAns ) % modAns ; } public static void COMinit ( ) { fac [ 0 ] = fac [ 1 ] = 1 ; finv [ 0 ] = finv [ 1 ] = 1 ; inv [ 1 ] = 1 ; for ( int i = 2 ; i < fac . length ; i ++ ) { fac [ i ] = fac [ i - 1 ] * i % modAns ; inv [ i ] = modAns - inv [ modAns % i ] * ( modAns / i ) % modAns ; finv [ i ] = finv [ i - 1 ] * inv [ i ] % modAns ; } } }" ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE def factorization ( N ) : NEW_LINE INDENT prime = primelist ( int ( N ** ( 1 / 2 ) ) + 2 ) NEW_LINE factor = [ 0 for i in range ( int ( N ** ( 1 / 2 ) + 2 ) ) ] NEW_LINE isprime = False NEW_LINE for i in prime : NEW_LINE INDENT while N % i == 0 : NEW_LINE INDENT N = N // i NEW_LINE factor [ i ] += 1 NEW_LINE DEDENT DEDENT if sum ( factor ) == 0 : NEW_LINE INDENT isprime = True NEW_LINE DEDENT if N != 1 : NEW_LINE INDENT factor . append ( 1 ) NEW_LINE DEDENT return factor , isprime NEW_LINE DEDENT def primelist ( N ) : NEW_LINE INDENT prime = [ 2 ] NEW_LINE for i in range ( 3 , N + 1 ) : NEW_LINE INDENT flag = 1 NEW_LINE for j in prime : NEW_LINE INDENT if i % j == 0 : NEW_LINE INDENT flag = 0 NEW_LINE break NEW_LINE DEDENT DEDENT if flag == 1 : NEW_LINE INDENT prime . append ( i ) NEW_LINE DEDENT DEDENT return prime NEW_LINE DEDENT def cmb ( n , r ) : NEW_LINE INDENT if n - r < r : r = n - r NEW_LINE if r == 0 : return 1 NEW_LINE if r == 1 : return n NEW_LINE numerator = [ n - r + k + 1 for k in range ( r ) ] NEW_LINE denominator = [ k + 1 for k in range ( r ) ] NEW_LINE for p in range ( 2 , r + 1 ) : NEW_LINE INDENT pivot = denominator [ p - 1 ] NEW_LINE if pivot > 1 : NEW_LINE INDENT offset = ( n - r ) % p NEW_LINE for k in range ( p - 1 , r , p ) : NEW_LINE INDENT numerator [ k - offset ] /= pivot NEW_LINE denominator [ k ] /= pivot NEW_LINE DEDENT DEDENT DEDENT result = 1 NEW_LINE for k in range ( r ) : NEW_LINE INDENT if numerator [ k ] > 1 : NEW_LINE INDENT result *= int ( numerator [ k ] ) NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT factor = factorization ( M ) [ 0 ] NEW_LINE ans = 1 NEW_LINE for i in factor : NEW_LINE INDENT ans *= cmb ( N + i - 1 , i ) NEW_LINE ans %= 1000000007 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE import math NEW_LINE MOD = 1000000007 NEW_LINE def factorization ( n : int ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT return [ ] NEW_LINE DEDENT factors = None NEW_LINE for i in range ( 2 , math . ceil ( math . sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT factors = [ i ] + factorization ( n // i ) NEW_LINE break NEW_LINE DEDENT DEDENT if factors == None : NEW_LINE INDENT return [ n ] NEW_LINE DEDENT else : NEW_LINE INDENT return factors NEW_LINE DEDENT DEDENT def comb ( i : int , j : int ) : NEW_LINE INDENT if j > i - j : NEW_LINE INDENT return comb ( i , i - j ) NEW_LINE DEDENT mul = 1 NEW_LINE for k in range ( i - j + 1 , i + 1 ) : NEW_LINE INDENT mul *= k NEW_LINE DEDENT for k in range ( 2 , j + 1 ) : NEW_LINE INDENT mul //= k NEW_LINE DEDENT return mul NEW_LINE DEDENT def solve ( N : int , M : int ) : NEW_LINE INDENT factor = factorization ( M ) NEW_LINE factorDict = { } NEW_LINE for f in factor : NEW_LINE INDENT if f not in factorDict : NEW_LINE INDENT factorDict [ f ] = 0 NEW_LINE DEDENT factorDict [ f ] += 1 NEW_LINE DEDENT mul = 1 NEW_LINE for k in factorDict : NEW_LINE INDENT mul = ( mul * comb ( factorDict [ k ] + N - 1 , factorDict [ k ] ) ) % MOD NEW_LINE DEDENT print ( mul ) 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 M = int ( next ( tokens ) ) NEW_LINE solve ( N , M ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "inpl = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE N , M = inpl ( ) NEW_LINE def factorize ( n ) : NEW_LINE INDENT factorize_list = [ ] NEW_LINE i = 2 NEW_LINE while i * i <= n : NEW_LINE INDENT k = 0 NEW_LINE while n % i == 0 : NEW_LINE INDENT n //= i NEW_LINE k += 1 NEW_LINE DEDENT if k > 0 : NEW_LINE INDENT factorize_list . append ( k ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT if n > 1 : NEW_LINE INDENT factorize_list . append ( 1 ) NEW_LINE DEDENT return ( factorize_list ) NEW_LINE DEDENT def H ( n , k ) : NEW_LINE INDENT h = 1 NEW_LINE L = n + k - 1 NEW_LINE k = min ( n - 1 , k ) NEW_LINE for j in range ( k ) : NEW_LINE INDENT h *= L - j NEW_LINE DEDENT for j in range ( k ) : NEW_LINE INDENT h //= j + 1 NEW_LINE DEDENT return h NEW_LINE DEDENT ans = 1 NEW_LINE for k in factorize ( M ) : NEW_LINE INDENT ans *= H ( N , k ) % MOD NEW_LINE ans %= MOD NEW_LINE DEDENT print ( ans ) NEW_LINE", "MOD = 10 ** 9 + 7 NEW_LINE MAX = 10 ** 6 NEW_LINE fac = [ 0 ] * MAX NEW_LINE finv = [ 0 ] * MAX NEW_LINE inv = [ 0 ] * MAX NEW_LINE def comb_init ( ) : NEW_LINE INDENT global fac , finv , inv NEW_LINE fac [ 0 ] = fac [ 1 ] = 1 NEW_LINE finv [ 0 ] = finv [ 1 ] = 1 NEW_LINE inv [ 1 ] = 1 NEW_LINE for i in range ( 2 , MAX ) : NEW_LINE INDENT fac [ i ] = fac [ i - 1 ] * i % MOD NEW_LINE inv [ i ] = MOD - inv [ MOD % i ] * ( MOD // i ) % MOD NEW_LINE finv [ i ] = finv [ i - 1 ] * inv [ i ] % MOD NEW_LINE DEDENT DEDENT def comb ( n : int , r : int ) -> int : NEW_LINE INDENT global fac , finv NEW_LINE if n < r : return 0 NEW_LINE if n < 0 or r < 0 : return 0 NEW_LINE return fac [ n ] * ( finv [ r ] * finv [ n - r ] % MOD ) % MOD NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 1 NEW_LINE comb_init ( ) NEW_LINE i = 2 NEW_LINE nokori = M NEW_LINE while i * i <= nokori : NEW_LINE INDENT if nokori % i == 0 : NEW_LINE INDENT cnt = 0 NEW_LINE while nokori % i == 0 : NEW_LINE INDENT cnt += 1 NEW_LINE nokori //= i NEW_LINE DEDENT ans *= comb ( N + cnt - 1 , N - 1 ) NEW_LINE ans %= MOD NEW_LINE DEDENT i += 1 NEW_LINE DEDENT if nokori != 1 : NEW_LINE INDENT ans *= comb ( N + 1 - 1 , N - 1 ) NEW_LINE ans %= MOD NEW_LINE DEDENT print ( ans ) 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 collections import Counter NEW_LINE from itertools import product NEW_LINE from math import factorial NEW_LINE primes = list ( range ( int ( 10 ** 5 ) + 1 ) ) NEW_LINE primes [ 1 ] = 0 NEW_LINE for i in range ( 2 , int ( len ( primes ) ** 0.5 ) + 1 ) : NEW_LINE INDENT if primes [ i ] : NEW_LINE INDENT for j in range ( 2 * i , len ( primes ) , i ) : NEW_LINE INDENT primes [ j ] = 0 NEW_LINE DEDENT DEDENT DEDENT def main ( ) : NEW_LINE INDENT N , M = LI ( ) NEW_LINE factors = Counter ( ) NEW_LINE for i in range ( int ( M ** 0.5 ) + 1 ) : NEW_LINE INDENT if primes [ i ] : NEW_LINE INDENT while M % i == 0 : NEW_LINE INDENT factors [ i ] += 1 NEW_LINE M //= i NEW_LINE DEDENT DEDENT if M < i : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if M != 1 : NEW_LINE INDENT factors [ M ] += 1 NEW_LINE DEDENT ans = 1 NEW_LINE for k in factors . values ( ) : NEW_LINE INDENT a , b = 1 , 1 NEW_LINE for i in range ( 1 , k + 1 ) : NEW_LINE INDENT a *= N + k - i NEW_LINE b *= i NEW_LINE DEDENT ans = ( ans * ( a // b ) ) % MOD NEW_LINE DEDENT return ans % MOD NEW_LINE DEDENT print ( main ( ) ) NEW_LINE" ]
atcoder_arc014_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char last = '0' ; int loser = 0 ; HashSet < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; if ( i != 0 ) { if ( s . charAt ( 0 ) != last || set . contains ( s ) ) { loser = i ; break ; } } last = s . charAt ( s . length ( ) - 1 ) ; set . add ( s ) ; } if ( loser == 0 ) { System . out . println ( \" DRAW \" ) ; } else if ( loser % 2 == 0 ) { System . out . println ( \" LOSE \" ) ; } else { System . out . println ( \" WIN \" ) ; } } }", "import java . util . HashSet ; import java . util . Scanner ; import java . util . function . LongSupplier ; import java . util . stream . IntStream ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static final long [ ] fal_rnd ( long [ ] ar , LongSupplier sp ) { int l = - 1 , r = ar . length ; while ( l + 1 != r ) ar [ Math . random ( ) < 0.5 ? ++ l : -- r ] = sp . getAsLong ( ) ; return ar ; } static final IntStream REPS ( int v ) { return IntStream . range ( 0 , v ) ; } ; public static void main ( String [ ] __ ) { int r = - 1 , n = s . nextInt ( ) ; String in = s . next ( ) ; HashSet < String > set = new HashSet < > ( 100 ) ; set . add ( in ) ; for ( int i = 1 ; i < n ; i ++ ) { String nin = s . next ( ) ; if ( nin . charAt ( 0 ) != in . charAt ( in . length ( ) - 1 ) || set . contains ( nin ) ) { r = i ; break ; } in = nin ; set . add ( in ) ; } System . out . println ( r == - 1 ? \" DRAW \" : r % 2 == 1 ? \" WIN \" : \" LOSE \" ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; HashSet < String > used = new HashSet < String > ( ) ; int N = sc . nextInt ( ) ; String last = \" \" ; boolean first = false ; boolean second = false ; boolean flag = false ; for ( int i = 0 ; i < N ; i ++ ) { String W = sc . next ( ) ; if ( i % 2 == 0 ) { if ( used . contains ( W ) ) { if ( ! flag ) { second = true ; flag = true ; } } if ( i != 0 && W . charAt ( 0 ) != last . charAt ( last . length ( ) - 1 ) ) { if ( ! flag ) { second = true ; flag = true ; } } used . add ( W ) ; } else { if ( used . contains ( W ) ) { if ( ! flag ) { first = true ; flag = true ; } } if ( i != 0 && W . charAt ( 0 ) != last . charAt ( last . length ( ) - 1 ) ) { if ( ! flag ) { flag = true ; first = true ; } } used . add ( W ) ; } last = W ; } if ( ! flag ) { System . out . println ( \" DRAW \" ) ; return ; } if ( first ) { System . out . println ( \" WIN \" ) ; return ; } else { System . out . println ( \" LOSE \" ) ; return ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; ArrayList < String > word = new ArrayList < String > ( ) ; String preW = sc . next ( ) ; word . add ( preW ) ; int lose = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { String s = sc . next ( ) ; if ( word . contains ( s ) ) { lose = i ; break ; } if ( preW . charAt ( preW . length ( ) - 1 ) != s . charAt ( 0 ) ) { lose = i ; break ; } preW = s ; word . add ( s ) ; } String ans = \" \" ; if ( lose == 0 ) { ans = \" DRAW \" ; } else { if ( lose % 2 == 0 ) { ans = \" WIN \" ; } else { ans = \" LOSE \" ; } } 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 ( ) ; HashSet < String > used = new HashSet < > ( ) ; String a [ ] = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . next ( ) ; } String prev = a [ 0 ] ; used . add ( prev ) ; for ( int i = 1 ; i < N ; i ++ ) { String current = a [ i ] ; if ( prev . charAt ( prev . length ( ) - 1 ) != current . charAt ( 0 ) || used . contains ( current ) ) { System . out . println ( i % 2 == 0 ? \" LOSE \" : \" WIN \" ) ; return ; } used . add ( current ) ; prev = current ; } System . out . println ( \" DRAW \" ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE W = input ( ) NEW_LINE words = set ( [ W ] ) NEW_LINE end = W [ len ( W ) - 1 ] NEW_LINE lose = \" * \" NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT W = input ( ) NEW_LINE if ( ( W in words ) or W [ 0 ] != end ) and lose == \" * \" : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT lose = \" hiragana \" NEW_LINE DEDENT else : NEW_LINE INDENT lose = \" katakana \" NEW_LINE DEDENT DEDENT end = W [ len ( W ) - 1 ] NEW_LINE words . add ( W ) NEW_LINE DEDENT if lose == \" * \" : NEW_LINE INDENT print ( \" DRAW \" ) NEW_LINE DEDENT elif lose == \" katakana \" : NEW_LINE INDENT print ( \" WIN \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" LOSE \" ) NEW_LINE DEDENT", "s = [ ] NEW_LINE k = [ \" LOSE \" , \" WIN \" ] NEW_LINE for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT d = input ( ) NEW_LINE if i == 0 : NEW_LINE INDENT s . append ( d ) NEW_LINE DEDENT elif d in s or s [ - 1 ] [ - 1 ] != d [ 0 ] : NEW_LINE INDENT print ( k [ i % 2 ] ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT s . append ( d ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( \" DRAW \" ) NEW_LINE DEDENT", "a = [ ] ; s = ' DRAW ' NEW_LINE for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT c = input ( ) NEW_LINE if i and ( b [ - 1 ] != c [ 0 ] or c in a ) : s = ' LWOISNE ' [ i % 2 : : 2 ] ; break NEW_LINE b = c ; a += [ c ] NEW_LINE DEDENT print ( s ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE N = int ( input ( ) ) NEW_LINE p = set ( ) NEW_LINE ans = \" DRAW \" NEW_LINE cnt = 1 NEW_LINE prev = input ( ) NEW_LINE p . add ( prev ) NEW_LINE for _ in range ( N - 1 ) : NEW_LINE INDENT cnt += 1 NEW_LINE s = input ( ) NEW_LINE if s [ 0 ] == prev [ - 1 ] : NEW_LINE INDENT if s in p : NEW_LINE INDENT if cnt % 2 == 1 : NEW_LINE INDENT ans = \" LOSE \" NEW_LINE DEDENT else : NEW_LINE INDENT ans = \" WIN \" NEW_LINE DEDENT break NEW_LINE DEDENT else : NEW_LINE INDENT prev = s NEW_LINE p . add ( s ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if cnt % 2 == 1 : NEW_LINE INDENT ans = \" LOSE \" NEW_LINE DEDENT else : NEW_LINE INDENT ans = \" WIN \" NEW_LINE DEDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def b_shiritori ( N , W ) : NEW_LINE INDENT word_said = [ ] NEW_LINE last_word = W [ 0 ] [ 0 ] NEW_LINE ans = ' DRAW ' NEW_LINE for turn , word in enumerate ( W ) : NEW_LINE INDENT if last_word [ - 1 ] != word [ 0 ] or word in word_said : NEW_LINE INDENT ans = ' WIN ' if turn % 2 == 1 else ' LOSE ' NEW_LINE break NEW_LINE DEDENT last_word = word NEW_LINE word_said . append ( word ) NEW_LINE DEDENT return ans NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE W = [ input ( ) for _ in range ( N ) ] NEW_LINE print ( b_shiritori ( N , W ) ) NEW_LINE" ]
atcoder_abc082_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; String [ ] ss = s . split ( \" \" ) ; String [ ] tt = t . split ( \" \" ) ; int x = 0 ; int l = ss . length ; boolean e = true ; Arrays . sort ( ss ) ; Arrays . sort ( tt , Collections . reverseOrder ( ) ) ; if ( ss . length > tt . length ) { l = tt . length ; } for ( int i = 0 ; i < l ; i ++ ) { if ( ss [ i ] . compareTo ( tt [ i ] ) != 0 ) { e = false ; x = i ; break ; } } if ( ss . length < tt . length && e == true ) { System . out . println ( \" Yes \" ) ; } else if ( ss . length >= tt . length && e == true ) { System . out . println ( \" No \" ) ; } else if ( e == false && ss [ x ] . compareTo ( tt [ x ] ) < 0 ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } sc . close ( ) ; } }", "import java . io . PrintStream ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { static void exec ( Scanner in , PrintStream out ) { String s = in . next ( ) ; String t = in . next ( ) ; List < Character > sl = new ArrayList < > ( s . length ( ) ) ; for ( int i = 0 ; i < s . length ( ) ; i += 1 ) { sl . add ( s . charAt ( i ) ) ; } List < Character > tl = new ArrayList < > ( t . length ( ) ) ; for ( int i = 0 ; i < t . length ( ) ; i += 1 ) { tl . add ( t . charAt ( i ) ) ; } sl . sort ( null ) ; tl . sort ( Collections . reverseOrder ( ) ) ; for ( int i = 0 , n = Math . min ( sl . size ( ) , tl . size ( ) ) ; i < n ; i += 1 ) { if ( sl . get ( i ) . charValue ( ) < tl . get ( i ) . charValue ( ) ) { out . println ( \" Yes \" ) ; return ; } if ( sl . get ( i ) . charValue ( ) > tl . get ( i ) . charValue ( ) ) { out . println ( \" No \" ) ; return ; } } out . println ( s . length ( ) < t . length ( ) ? \" Yes \" : \" No \" ) ; } public static void main ( String [ ] args ) { exec ( new Scanner ( System . in ) , System . out ) ; } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; Arrays . sort ( t ) ; String t2 = new StringBuilder ( String . valueOf ( t ) ) . reverse ( ) . toString ( ) ; Arrays . sort ( s ) ; String s2 = String . valueOf ( s ) ; System . out . println ( s2 . compareTo ( t2 ) < 0 ? \" Yes \" : \" No \" ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int N = s . length ( ) ; int M = t . length ( ) ; char [ ] S = new char [ N ] ; char [ ] T = new char [ M ] ; for ( int i = 0 ; i < N ; i ++ ) S [ i ] = s . charAt ( i ) ; for ( int i = 0 ; i < M ; i ++ ) T [ i ] = t . charAt ( i ) ; Arrays . sort ( S ) ; Arrays . sort ( T ) ; int loop = 0 ; if ( N <= M ) { loop = N ; } else { loop = M ; } for ( int i = 0 ; i < loop ; i ++ ) { if ( S [ i ] < T [ ( M - 1 ) - i ] ) { System . out . println ( \" Yes \" ) ; return ; } else if ( S [ i ] > T [ i ] ) { System . out . println ( \" No \" ) ; return ; } else { continue ; } } System . out . println ( N < M ? \" Yes \" : \" No \" ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Comparator ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word1 = stdin . readLine ( ) ; String word2 = stdin . readLine ( ) ; String sorted1 = Arrays . stream ( word1 . split ( \" \" ) ) . sorted ( ) . collect ( Collectors . joining ( ) ) ; String sorted2 = Arrays . stream ( word2 . split ( \" \" ) ) . sorted ( Comparator . reverseOrder ( ) ) . collect ( Collectors . joining ( ) ) ; String answer = sorted2 . compareTo ( sorted1 ) > 0 ? \" Yes \" : \" No \" ; System . out . println ( answer ) ; } }" ]
[ "s = input ( ) NEW_LINE t = input ( ) NEW_LINE s = sorted ( s ) NEW_LINE s = ' ' . join ( s ) NEW_LINE t = sorted ( t , reverse = True ) NEW_LINE t = ' ' . join ( t ) NEW_LINE if s < t : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "s = list ( input ( ) ) NEW_LINE t = list ( input ( ) ) NEW_LINE s = ' ' . join ( sorted ( s ) ) NEW_LINE t = ' ' . join ( sorted ( t , reverse = True ) ) NEW_LINE print ( ' Yes ' if s < t else ' No ' ) NEW_LINE", "def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT s = list ( io ( ) ) NEW_LINE s . sort ( ) NEW_LINE t = list ( io ( ) ) NEW_LINE t . sort ( reverse = True ) NEW_LINE return ' Yes ' if s < t else ' No ' NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE print ( main ( io ) ) NEW_LINE DEDENT", "s = input ( ) . strip ( ) NEW_LINE t = input ( ) . strip ( ) NEW_LINE s = sorted ( s ) NEW_LINE t = sorted ( t , reverse = True ) NEW_LINE sl = \" \" . join ( s ) NEW_LINE tl = \" \" . join ( t ) NEW_LINE if sl < tl : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT", "n = sorted ( list ( input ( ) ) ) NEW_LINE m = sorted ( list ( input ( ) ) ) NEW_LINE m = m [ : : - 1 ] NEW_LINE if m > n : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT" ]
atcoder_arc059_A
[ "import java . util . * ; 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 ( ) ; } Arrays . sort ( a ) ; int start = a [ 0 ] ; int end = a [ a . length - 1 ] ; int sum = Integer . MAX_VALUE ; for ( int i = start ; i <= end ; i ++ ) { int ans = 0 ; for ( int j = 0 ; j < N ; j ++ ) { ans += ( a [ j ] - i ) * ( a [ j ] - i ) ; } sum = Math . min ( sum , ans ) ; } System . out . println ( sum ) ; } }", "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 ( ) ; as = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextInt ( ) ; } solve ( ) ; } void solve ( ) { int min = Integer . MAX_VALUE ; for ( int i = - 100 ; i <= 100 ; i ++ ) { int score = 0 ; for ( int j = 0 ; j < n ; j ++ ) { score += ( i - as [ j ] ) * ( i - as [ j ] ) ; } if ( score < min ) { min = score ; } } System . out . println ( min ) ; } 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 . 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 = Integer . parseInt ( s ) ; s = r . readLine ( ) ; String [ ] sl = s . split ( \" [ \\\\ s ] + \" ) ; int a [ ] = new int [ 1000 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( sl [ i ] ) ; } int c = 99999999 ; for ( int i = - 100 ; i <= 100 ; i ++ ) { int v = 0 ; for ( int j = 0 ; j < n ; j ++ ) { v += ( i - a [ j ] ) * ( i - a [ j ] ) ; } c = Math . min ( c , v ) ; } System . out . println ( c ) ; } }", "import java . util . Scanner ; public class Main { static Scanner in = new Scanner ( System . in ) ; void solve ( ) { int n = in . nextInt ( ) ; int [ ] a = new int [ n ] ; int t = 0 ; boolean f = true ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; if ( i == 0 ) t = a [ i ] ; if ( f && t != a [ i ] ) f = false ; } if ( f ) { System . out . println ( 0 ) ; return ; } int ans = Integer . MAX_VALUE ; for ( int i = - 100 ; i <= 100 ; i ++ ) { int sum = 0 ; for ( int j : a ) { sum += Math . pow ( j - i , 2 ) ; } ans = Math . min ( ans , sum ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } }", "import java . util . * ; import java . lang . * ; import java . io . * ; public class Main { public static int maxOfArray ( int [ ] a ) { int ans = a [ 0 ] ; for ( int i = 1 ; i < a . length ; i ++ ) { if ( a [ i ] > ans ) ans = a [ i ] ; } return ans ; } public static int minOfArray ( int [ ] a ) { int ans = a [ 0 ] ; for ( int i = 1 ; i < a . length ; i ++ ) { if ( a [ i ] < ans ) ans = a [ i ] ; } return ans ; } public static int cost ( int [ ] array , int target ) { int ans = 0 ; for ( int n = 0 ; n < array . length ; n ++ ) ans += ( array [ n ] - target ) * ( array [ n ] - target ) ; return ans ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) a [ n ] = sc . nextInt ( ) ; int min = minOfArray ( a ) ; int max = maxOfArray ( a ) ; int ans = Integer . MAX_VALUE ; for ( int target = min ; target <= max ; target ++ ) { ans = Math . min ( ans , cost ( a , target ) ) ; } System . out . println ( ans ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE m = round ( sum ( a ) / n ) NEW_LINE ans = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT ans += ( a [ i ] - m ) ** 2 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 6 ) NEW_LINE def main ( n ) : NEW_LINE INDENT a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 10 ** 8 NEW_LINE for i in range ( - 100 , 101 , 1 ) : NEW_LINE INDENT temp = 0 NEW_LINE for j in a : NEW_LINE INDENT temp += ( i - j ) ** 2 NEW_LINE DEDENT if ans > temp : NEW_LINE INDENT ans = temp NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT main ( int ( input ( ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE a_s = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE average = sum ( a_s ) NEW_LINE average /= len ( a_s ) * 1.0 NEW_LINE ans = - 1 NEW_LINE for target in range ( int ( average ) , int ( average ) + 2 ) : NEW_LINE INDENT c = sum ( map ( lambda x : ( x - target ) * ( x - target ) , a_s ) ) NEW_LINE if ans < 0 : NEW_LINE INDENT ans = c NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( ans , c ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def compute_score ( s ) : NEW_LINE INDENT return sum ( [ ( a - s ) ** 2 for a in As ] ) NEW_LINE DEDENT N = int ( input ( ) . strip ( ) ) NEW_LINE As = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) NEW_LINE s = sum ( As ) / N NEW_LINE ans = 0 NEW_LINE if ( s % 1 == 0 ) : NEW_LINE INDENT ans = compute_score ( s ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( compute_score ( s // 1 ) , compute_score ( s // 1 + 1 ) ) NEW_LINE DEDENT print ( int ( ans ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE ans = ( 200 ** 2 ) * 100 NEW_LINE for i in range ( - 100 , 101 ) : NEW_LINE INDENT tmp = 0 NEW_LINE for j in range ( N ) : NEW_LINE INDENT tmp += ( A [ j ] - i ) ** 2 NEW_LINE DEDENT ans = min ( ans , tmp ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]