id
stringlengths
13
20
java
sequence
python
sequence
atcoder_abc095_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] m = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { m [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; int sum = 0 ; int min = X ; for ( int i = 0 ; i < N ; i ++ ) { sum += m [ i ] ; cnt ++ ; if ( m [ i ] < min ) min = m [ i ] ; } X -= sum ; while ( X >= min ) { X -= min ; cnt ++ ; } System . out . println ( cnt ) ; sc . close ( ) ; } }", "import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) , x = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int temp = sc . nextInt ( ) ; min = Math . min ( min , temp ) ; x -= temp ; } out . println ( n + ( x / min ) ) ; } }", "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 ) ) ; int left_ingredient = Arrays . stream ( stdin . readLine ( ) . split ( \" ▁ \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) [ 1 ] ; int [ ] need_ingredient = stdin . lines ( ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int min = Arrays . stream ( need_ingredient ) . min ( ) . getAsInt ( ) ; int count = 0 ; for ( int gram : need_ingredient ) { left_ingredient -= gram ; count ++ ; } count += Math . floor ( left_ingredient / min ) ; System . out . println ( count ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int kona = Integer . parseInt ( sc . next ( ) ) ; int dounatu [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { dounatu [ i ] = Integer . parseInt ( sc . next ( ) ) ; kona = kona - dounatu [ i ] ; } Arrays . sort ( dounatu ) ; System . out . print ( N + kona / dounatu [ 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 = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] pow = new int [ n ] ; int total = 0 ; int amari = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { pow [ i ] = sc . nextInt ( ) ; total += pow [ i ] ; } Arrays . sort ( pow ) ; amari = x - total ; if ( amari == 0 ) { ans = n ; } else { ans = ( amari / pow [ 0 ] ) + n ; } System . out . println ( ans ) ; } }" ]
[ "N , X = map ( int , input ( ) . split ( ) ) NEW_LINE m_list = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE ans = 0 NEW_LINE for i in m_list : NEW_LINE INDENT X -= i NEW_LINE ans += 1 NEW_LINE DEDENT ans += X // min ( m_list ) NEW_LINE print ( ans ) NEW_LINE", "N , X = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE m = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE print ( int ( ( X - sum ( m ) ) / min ( m ) ) + N ) NEW_LINE", "N , X = map ( int , input ( ) . split ( ) ) NEW_LINE Z = [ ] NEW_LINE ALL = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT Y = int ( input ( ) ) NEW_LINE ALL += Y NEW_LINE Z . append ( Y ) NEW_LINE DEDENT ANS = ( X - ALL ) // ( min ( Z ) ) NEW_LINE if ANS == 0 : NEW_LINE INDENT print ( len ( Z ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ANS + len ( Z ) ) NEW_LINE DEDENT", "import math NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE M = [ 0 ] * A [ 0 ] NEW_LINE for i in range ( A [ 0 ] ) : NEW_LINE INDENT M [ i ] = int ( input ( ) ) NEW_LINE DEDENT S = math . floor ( ( A [ 1 ] - sum ( M ) ) / min ( M ) ) NEW_LINE print ( S + A [ 0 ] ) NEW_LINE", "N , X = map ( int , input ( ) . split ( ) ) NEW_LINE m = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE count = N NEW_LINE X -= sum ( m ) NEW_LINE while True : NEW_LINE INDENT X -= min ( m ) NEW_LINE if X < 0 : NEW_LINE INDENT break NEW_LINE DEDENT count += 1 NEW_LINE DEDENT print ( count ) NEW_LINE" ]
atcoder_arc025_B
[ "import java . util . * ; public class Main { private static int H ; private static int W ; private static int C [ ] [ ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; H = scan . nextInt ( ) ; W = scan . nextInt ( ) ; C = new int [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { int x = scan . nextInt ( ) ; if ( ( i + j ) % 2 == 0 ) C [ i ] [ j ] = x ; else C [ i ] [ j ] = - x ; } } } public static void main ( String args [ ] ) { input ( ) ; for ( int i = 1 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { C [ i ] [ j ] += C [ i - 1 ] [ j ] ; } } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 1 ; j < W ; j ++ ) { C [ i ] [ j ] += C [ i ] [ j - 1 ] ; } } int ans = 0 ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = i ; j < H ; j ++ ) { for ( int k = 0 ; k < W ; k ++ ) { for ( int l = k ; l < W ; l ++ ) { int tmp = C [ j ] [ l ] ; if ( i > 0 ) tmp -= C [ i - 1 ] [ l ] ; if ( k > 0 ) tmp -= C [ j ] [ k - 1 ] ; if ( i > 0 && k > 0 ) tmp += C [ i - 1 ] [ k - 1 ] ; if ( tmp == 0 ) ans = Math . max ( ans , ( j - i + 1 ) * ( l - k + 1 ) ) ; } } } } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { Scanner sc = new Scanner ( System . in ) ; void solve ( ) { int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int [ ] [ ] C = new int [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { int x = sc . nextInt ( ) ; if ( ( i + j ) % 2 == 0 ) C [ i ] [ j ] = x ; else C [ i ] [ j ] = - x ; } } for ( int i = 1 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { C [ i ] [ j ] += C [ i - 1 ] [ j ] ; } } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 1 ; j < W ; j ++ ) { C [ i ] [ j ] += C [ i ] [ j - 1 ] ; } } int ans = 0 ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = i ; j < H ; j ++ ) { for ( int k = 0 ; k < W ; k ++ ) { for ( int l = k ; l < W ; l ++ ) { int tmp = C [ j ] [ l ] ; if ( i > 0 ) tmp -= C [ i - 1 ] [ l ] ; if ( k > 0 ) tmp -= C [ j ] [ k - 1 ] ; if ( i > 0 && k > 0 ) tmp += C [ i - 1 ] [ k - 1 ] ; if ( tmp == 0 ) { ans = Math . max ( ans , ( j - i + 1 ) * ( l - k + 1 ) ) ; } } } } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; Main main = new Main ( ) ; main . solve ( ) ; } }" ]
[ "def solve ( ) : NEW_LINE INDENT from itertools import product NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * H ] NEW_LINE cumsum = [ [ [ 0 , 0 ] ] * ( W + 1 ) ] + [ [ [ 0 , 0 ] for _ in [ 0 ] * ( W + 1 ) ] for _ in [ 0 ] * H ] NEW_LINE for y , l in enumerate ( a , start = 1 ) : NEW_LINE INDENT cum_b , cum_w = 0 , 0 NEW_LINE for x , ( v , ( up_b , up_w ) ) in enumerate ( zip ( l , cumsum [ y - 1 ] [ 1 : ] ) , start = 1 ) : NEW_LINE INDENT if ( x + y % 2 ) % 2 == 0 : NEW_LINE INDENT cum_b += v NEW_LINE DEDENT else : NEW_LINE INDENT cum_w += v NEW_LINE DEDENT cumsum [ y ] [ x ] = [ up_b + cum_b , up_w + cum_w ] NEW_LINE DEDENT DEDENT result = 0 NEW_LINE for width , height in product ( range ( 1 , W + 1 ) , range ( 1 , H + 1 ) ) : NEW_LINE INDENT if result >= width * height : NEW_LINE INDENT continue NEW_LINE DEDENT for _y , y in zip ( range ( H + 1 ) , range ( height , H + 1 ) ) : NEW_LINE INDENT for ( b1 , w1 ) , ( b2 , w2 ) , ( b3 , w3 ) , ( b4 , w4 ) in zip ( cumsum [ _y ] , cumsum [ _y ] [ width : ] , cumsum [ y ] , cumsum [ y ] [ width : ] ) : NEW_LINE INDENT b = b1 - b2 - b3 + b4 NEW_LINE w = w1 - w2 - w3 + w4 NEW_LINE if b == w : NEW_LINE INDENT result = width * height NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( result ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT" ]
atcoder_abc055_A
[ "import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = 800 * n ; int y = n / 15 * 200 ; System . out . println ( x - y ) ; } }", "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 ( ) ; out . println ( n * 800 - ( n / 15 ) * 200 ) ; } } 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 . 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 ( ) ; out . println ( 800 * N - N / 15 * 200 ) ; } } 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 . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int x = N * 800 ; int y = N / 15 * 200 ; int ans = x - y ; System . out . print ( ans ) ; } }", "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 ( ) ) ; sc . close ( ) ; System . out . println ( ( n * 800 ) - n / 15 * 200 ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE print ( N * 800 - N // 15 * 200 ) NEW_LINE", "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE x = 800 * N NEW_LINE y = 200 * ( N // 15 ) NEW_LINE return x - y NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE count = 0 NEW_LINE morta = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT count += 800 NEW_LINE if ( i + 1 ) % 15 == 0 : NEW_LINE INDENT morta += 200 NEW_LINE DEDENT DEDENT print ( count - morta ) NEW_LINE", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT N = int ( input ( ) . rstrip ( ) ) NEW_LINE print ( N * 800 - ( N // 15 ) * 200 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "x = int ( input ( ) ) NEW_LINE ans1 = 800 * x NEW_LINE z = x // 15 NEW_LINE ans2 = ans1 - ( z * 200 ) NEW_LINE print ( ans2 ) NEW_LINE" ]
atcoder_arc063_B
[ "import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int min [ ] = new int [ N ] ; min [ 0 ] = A [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( A [ i ] < min [ i - 1 ] ) { min [ i ] = A [ i ] ; } else { min [ i ] = min [ i - 1 ] ; } } int max [ ] = new int [ N ] ; max [ N - 1 ] = A [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( A [ i ] > max [ i + 1 ] ) { max [ i ] = A [ i ] ; } else { max [ i ] = max [ i + 1 ] ; } } int maxgap = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( maxgap < max [ i ] - min [ i ] ) { maxgap = max [ i ] - min [ i ] ; } } int prevmax = 0 ; int prevmin = 0 ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( max [ i ] - min [ i ] == maxgap && ( prevmax != max [ i ] || prevmin != min [ i ] ) ) { count ++ ; } prevmax = max [ i ] ; prevmin = min [ i ] ; } System . out . println ( count ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int numTown = input . nextInt ( ) ; input . nextInt ( ) ; int [ ] val = new int [ numTown ] ; for ( int i = 0 ; i < numTown ; i ++ ) { val [ i ] = input . nextInt ( ) ; } int maxdiff = 0 ; int count = 0 ; int [ ] maxright = new int [ numTown ] ; int [ ] minleft = new int [ numTown ] ; maxright [ numTown - 1 ] = val [ numTown - 1 ] ; minleft [ 0 ] = val [ 0 ] ; for ( int i = 1 ; i < numTown ; i ++ ) { minleft [ i ] = Math . min ( minleft [ i - 1 ] , val [ i ] ) ; } for ( int i = numTown - 2 ; i >= 0 ; i -- ) { maxright [ i ] = Math . max ( maxright [ i + 1 ] , val [ i ] ) ; } for ( int i = 0 ; i < numTown ; i ++ ) { if ( maxright [ i ] - minleft [ i ] > maxdiff ) { int mr = maxright [ i ] ; int ml = minleft [ i ] ; maxdiff = maxright [ i ] - minleft [ i ] ; count = 1 ; while ( i < numTown && maxright [ i ] == mr && minleft [ i ] == ml ) { i ++ ; } } else if ( maxright [ i ] - minleft [ i ] == maxdiff ) { count ++ ; int mr = maxright [ i ] ; int ml = minleft [ i ] ; while ( i < numTown && maxright [ i ] == mr && minleft [ i ] == ml ) { i ++ ; } } } System . out . println ( count ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String [ ] sp = line . split ( \" ▁ \" ) ; int n = Integer . parseInt ( sp [ 0 ] ) ; line = br . readLine ( ) ; sp = line . split ( \" ▁ \" ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Long . parseLong ( sp [ i ] ) ; } long min = Integer . MAX_VALUE ; long max = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { min = Math . min ( min , a [ i ] ) ; if ( a [ i ] - min > max ) { max = a [ i ] - min ; count = 1 ; } else if ( a [ i ] - min == max ) { max = a [ i ] - min ; count ++ ; } } System . out . println ( count ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] A = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; A [ 0 ] = Integer . MAX_VALUE ; int max = 0 ; int last_min_i = N ; int max_start_i = N ; int diff_max = 0 ; int cost = 0 ; for ( int i = N ; i >= 0 ; i -- ) { if ( A [ i ] > max ) { if ( diff_max > 0 ) { int cost0 = 0 ; int cost1 = 0 ; for ( int j = i + 1 ; j <= max_start_i ; j ++ ) { if ( A [ j ] == max && j >= last_min_i ) { cost0 ++ ; } else if ( A [ j ] == max - diff_max ) { if ( cost0 > cost1 ) { cost0 = cost1 ; } cost1 ++ ; } } cost += Math . min ( cost0 , cost1 ) ; } max = A [ i ] ; max_start_i = i ; } else if ( A [ i ] == max ) { } else { if ( max - A [ i ] == diff_max ) { last_min_i = i ; } else if ( max - A [ i ] > diff_max ) { diff_max = max - A [ i ] ; last_min_i = i ; cost = 0 ; } } } System . out . println ( cost ) ; } }", "import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long maxDiff = 0 ; long min = Long . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( i != 0 ) { maxDiff = Math . max ( maxDiff , a [ i ] - min ) ; } min = Math . min ( min , a [ i ] ) ; } int ans = 0 ; Map < Long , Long > cnt = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long target = a [ i ] - maxDiff ; if ( cnt . containsKey ( target ) ) { ans += cnt . get ( target ) ; } Long tmpCnt = cnt . get ( a [ i ] ) ; if ( tmpCnt == null ) { tmpCnt = 0L ; } tmpCnt ++ ; cnt . put ( a [ i ] , tmpCnt ) ; } System . out . println ( ans ) ; } } }" ]
[ "n , t = map ( int , input ( ) . split ( ) ) NEW_LINE alist = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE minal = [ alist [ 0 ] ] NEW_LINE maxal = [ alist [ - 1 ] ] NEW_LINE for a in alist [ 1 : ] : NEW_LINE INDENT if minal [ - 1 ] > a : NEW_LINE INDENT minal . append ( a ) NEW_LINE DEDENT else : NEW_LINE INDENT minal . append ( minal [ - 1 ] ) NEW_LINE DEDENT DEDENT for a in alist [ : : - 1 ] [ 1 : ] : NEW_LINE INDENT if maxal [ - 1 ] < a : NEW_LINE INDENT maxal . append ( a ) NEW_LINE DEDENT else : NEW_LINE INDENT maxal . append ( maxal [ - 1 ] ) NEW_LINE DEDENT DEDENT maxal = maxal [ : : - 1 ] NEW_LINE maxda = 0 NEW_LINE ans = 0 NEW_LINE prevmina , prevmaxa = None , None NEW_LINE for mina , maxa in zip ( minal , maxal ) : NEW_LINE INDENT if prevmina == mina and prevmaxa == maxa : NEW_LINE INDENT continue NEW_LINE DEDENT elif maxa - mina == maxda : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT elif maxa - mina > maxda : NEW_LINE INDENT maxda = maxa - mina NEW_LINE ans = 1 NEW_LINE DEDENT prevmina , prevmaxa = mina , maxa NEW_LINE DEDENT print ( ans ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N , T = inpl ( ) NEW_LINE A = inpl ( ) NEW_LINE minA = [ 0 for _ in range ( N ) ] NEW_LINE minA [ 0 ] = A [ 0 ] NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT minA [ i + 1 ] = min ( minA [ i ] , A [ i + 1 ] ) NEW_LINE DEDENT ans = 1 NEW_LINE maxpro = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if A [ i + 1 ] - minA [ i ] == maxpro : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT if A [ i + 1 ] - minA [ i ] > maxpro : NEW_LINE INDENT ans = 1 NEW_LINE maxpro = A [ i + 1 ] - minA [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "n , _ , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE m = d = c = 0 NEW_LINE for t in a [ : : - 1 ] : NEW_LINE INDENT if t > m : NEW_LINE INDENT m = t NEW_LINE DEDENT if m - t > d : NEW_LINE INDENT d = m - t NEW_LINE c = 1 NEW_LINE DEDENT elif m - t == d : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT print ( c ) NEW_LINE", "import sys , collections NEW_LINE from collections import defaultdict NEW_LINE def update_minA ( minA , t ) : NEW_LINE INDENT if minA > t : NEW_LINE INDENT return t NEW_LINE DEDENT return minA NEW_LINE DEDENT def check_range ( y , x , H , W ) : NEW_LINE INDENT return 0 < x and x < W and 0 < y and y < H NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT N , T = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE minA = float ( \" inf \" ) NEW_LINE P = defaultdict ( lambda : 0 ) NEW_LINE for i , v in enumerate ( A ) : NEW_LINE INDENT if i != 0 : NEW_LINE INDENT P [ v - minA ] += 1 NEW_LINE DEDENT minA = update_minA ( minA , v ) NEW_LINE DEDENT print ( P [ max ( P ) ] ) NEW_LINE DEDENT solve ( ) NEW_LINE", "def main ( ) : NEW_LINE INDENT buf = input ( ) NEW_LINE buflist = buf . split ( ) NEW_LINE N = int ( buflist [ 0 ] ) NEW_LINE T = int ( buflist [ 1 ] ) NEW_LINE buf = input ( ) NEW_LINE buflist = buf . split ( ) NEW_LINE A = list ( map ( int , buflist ) ) NEW_LINE min_price = A [ 0 ] NEW_LINE max_price_diff = 0 NEW_LINE max_diff_count = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if A [ i ] < min_price : NEW_LINE INDENT min_price = A [ i ] NEW_LINE DEDENT elif A [ i ] - min_price > max_price_diff : NEW_LINE INDENT max_price_diff = A [ i ] - min_price NEW_LINE max_diff_count = 1 NEW_LINE DEDENT elif A [ i ] - min_price == max_price_diff : NEW_LINE INDENT max_diff_count += 1 NEW_LINE DEDENT DEDENT print ( max_diff_count ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_arc042_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 ( ) ; ArrayDeque < Integer > deque = new ArrayDeque < > ( M ) ; for ( int i = 0 ; i < M ; i ++ ) { deque . addFirst ( sc . nextInt ( ) ) ; } boolean f [ ] = new boolean [ N + 1 ] ; while ( ! deque . isEmpty ( ) ) { int p = deque . poll ( ) ; if ( ! f [ p ] ) { f [ p ] = true ; System . out . println ( p ) ; } } for ( int i = 1 ; i <= N ; i ++ ) { if ( ! f [ i ] ) { System . out . println ( i ) ; } } } }", "import java . util . * ; import java . util . stream . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , m = scanner . nextInt ( ) ; List < Integer > list = IntStream . range ( 0 , m ) . map ( i -> scanner . nextInt ( ) ) . boxed ( ) . collect ( Collectors . toList ( ) ) ; Collections . reverse ( list ) ; Stream . concat ( list . stream ( ) , IntStream . rangeClosed ( 1 , n ) . boxed ( ) ) . distinct ( ) . forEach ( System . out :: println ) ; } }", "import java . util . ArrayDeque ; import java . util . Deque ; 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 ( ) ; boolean [ ] a = new boolean [ n ] ; Deque < Integer > d = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int b = sc . nextInt ( ) ; d . push ( b ) ; } while ( ! d . isEmpty ( ) ) { int c = d . poll ( ) ; if ( ! a [ c - 1 ] ) { a [ c - 1 ] = true ; System . out . println ( c ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( ! a [ i ] ) System . out . println ( i + 1 ) ; } } }", "import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; ArrayDeque < Integer > stack = new ArrayDeque < > ( ) ; for ( int i = n ; i > 0 ; i -- ) { stack . addFirst ( i ) ; } for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; stack . addFirst ( a [ i ] ) ; } int [ ] used = new int [ n + 1 ] ; while ( stack . size ( ) > 0 ) { int ans = stack . pollFirst ( ) ; if ( used [ ans ] == 0 ) { out . println ( ans ) ; used [ ans ] ++ ; } } } }", "import java . util . ArrayDeque ; 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 ( ) ; ArrayDeque < Integer > deque = new ArrayDeque < > ( m ) ; boolean f [ ] = new boolean [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { deque . addFirst ( s . nextInt ( ) ) ; } while ( ! deque . isEmpty ( ) ) { int p = deque . poll ( ) ; if ( ! f [ p ] ) { f [ p ] = true ; System . out . println ( p ) ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( ! f [ i ] ) { System . out . println ( i ) ; } } } }" ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ int ( input ( ) ) for _ in range ( M ) ] NEW_LINE a = a [ : : - 1 ] + [ int ( i ) for i in range ( 1 , N + 1 ) ] NEW_LINE L = set ( ) NEW_LINE for i in a : NEW_LINE INDENT if i not in L : NEW_LINE INDENT print ( i ) NEW_LINE L . add ( i ) NEW_LINE DEDENT 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 l = [ [ v , i ] for i , v in enumerate ( reversed ( range ( N ) ) ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT N += 1 NEW_LINE n = int ( input ( ) ) - 1 NEW_LINE l [ n ] [ 0 ] = N NEW_LINE DEDENT l = sorted ( l , key = lambda x : x [ 0 ] , reverse = True ) NEW_LINE for v , i in l : NEW_LINE INDENT print ( i + 1 ) NEW_LINE DEDENT", "class Node ( object ) : NEW_LINE INDENT def __init__ ( self , value , prev , next ) : NEW_LINE INDENT self . value = value NEW_LINE self . prev = prev NEW_LINE self . next = next NEW_LINE DEDENT DEDENT class Threads ( object ) : NEW_LINE INDENT def __init__ ( self , count ) : NEW_LINE INDENT self . nodes = [ ] NEW_LINE for i in range ( count + 2 ) : NEW_LINE INDENT self . nodes . append ( Node ( i , None , None ) ) NEW_LINE DEDENT for i in range ( count + 1 ) : NEW_LINE INDENT self . nodes [ i ] . next = self . nodes [ i + 1 ] NEW_LINE self . nodes [ i + 1 ] . prev = self . nodes [ i ] NEW_LINE DEDENT DEDENT def move_first ( self , i ) : NEW_LINE INDENT self . nodes [ i ] . prev . next = self . nodes [ i ] . next NEW_LINE self . nodes [ i ] . next . prev = self . nodes [ i ] . prev NEW_LINE self . nodes [ i ] . prev = self . nodes [ 0 ] NEW_LINE self . nodes [ i ] . next = self . nodes [ 0 ] . next NEW_LINE self . nodes [ i ] . prev . next = self . nodes [ i ] NEW_LINE self . nodes [ i ] . next . prev = self . nodes [ i ] NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE threads = Threads ( n ) NEW_LINE for _ in range ( m ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE threads . move_first ( a ) NEW_LINE DEDENT node = threads . nodes [ 0 ] . next NEW_LINE while node != threads . nodes [ - 1 ] : NEW_LINE INDENT print ( node . value ) NEW_LINE node = node . next NEW_LINE DEDENT DEDENT main ( ) NEW_LINE", "def a_bbs ( N , M , A ) : NEW_LINE INDENT written_thread = set ( ) NEW_LINE ans = [ ] NEW_LINE for a in reversed ( A ) : NEW_LINE INDENT if a not in written_thread : NEW_LINE INDENT written_thread . add ( a ) NEW_LINE ans . append ( a ) NEW_LINE DEDENT DEDENT remain_thread = set ( range ( 1 , N + 1 ) ) - written_thread NEW_LINE ans . extend ( sorted ( remain_thread ) ) NEW_LINE ans = ' \\n ' . join ( map ( str , ans ) ) NEW_LINE return ans NEW_LINE DEDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE A = [ int ( input ( ) ) for _ in [ 0 ] * M ] NEW_LINE print ( a_bbs ( N , M , A ) ) NEW_LINE", "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ [ 0 , i + 1 ] for i in range ( n ) ] NEW_LINE for _ in range ( m ) : NEW_LINE INDENT a = int ( input ( ) ) - 1 NEW_LINE A [ a ] [ 0 ] = _ + 1 NEW_LINE DEDENT A . sort ( reverse = True ) NEW_LINE K = [ ] NEW_LINE for j in range ( n ) : NEW_LINE INDENT if A [ j ] [ 0 ] == 0 : NEW_LINE INDENT A = A [ j : : ] NEW_LINE A . sort ( ) NEW_LINE for i in range ( len ( A ) ) : NEW_LINE INDENT K . append ( A [ i ] [ 1 ] ) NEW_LINE DEDENT break NEW_LINE DEDENT else : NEW_LINE INDENT K . append ( A [ j ] [ 1 ] ) NEW_LINE DEDENT DEDENT for i in K : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT" ]
atcoder_agc021_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { char [ ] n = sc . next ( ) . toCharArray ( ) ; boolean f = false ; for ( int i = 1 ; i < n . length ; i ++ ) { if ( n [ i ] != '9' ) { f = true ; break ; } } if ( f ) { int ans = Integer . parseInt ( String . valueOf ( n [ 0 ] ) ) - 1 + 9 * ( n . length - 1 ) ; System . out . println ( ans ) ; } else { int ans = Integer . parseInt ( String . valueOf ( n [ 0 ] ) ) + 9 * ( n . length - 1 ) ; System . out . println ( ans ) ; } } }", "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 ) ; ADigitSum2 solver = new ADigitSum2 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ADigitSum2 { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String n = in . string ( ) ; int ans = 0 ; boolean filled = true ; for ( int i = 1 ; i < n . length ( ) ; i ++ ) { if ( n . charAt ( i ) != '9' ) { filled = false ; } ans += 9 ; } ans += Integer . parseInt ( n . substring ( 0 , 1 ) ) ; if ( ! filled ) { ans -= 1 ; } 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 class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { String n = scanner . next ( ) ; System . out . println ( n . charAt ( 0 ) - 49 + ( n . length ( ) - 1 ) * 9 + ( n . substring ( 1 ) . matches ( \"9 * \" ) ? 1 : 0 ) ) ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N = sc . next ( ) ; int [ ] arr = new int [ N . length ( ) ] ; int max = 0 ; for ( int i = 0 ; i < N . length ( ) ; i ++ ) { arr [ i ] = N . charAt ( i ) - '0' ; max += arr [ i ] ; } for ( int i = 0 ; i < arr . length && arr [ i ] != 0 ; i ++ ) { int tmp = 0 ; for ( int j = 0 ; j < arr . length ; j ++ ) { if ( i == j ) { tmp += arr [ j ] - 1 + ( arr . length - j - 1 ) * 9 ; break ; } else { tmp += arr [ j ] ; } } max = Math . max ( max , tmp ) ; } out . println ( max ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int ans = solve ( N ) ; System . out . println ( ans ) ; } static int help ( long N ) { int ans = 0 ; while ( N > 0 ) { ans += N % 10 ; N = N / 10 ; } return ans ; } static int solve ( long N ) { if ( N < 10 ) return ( int ) N ; String s = String . valueOf ( N ) ; int len = s . length ( ) ; int ans = help ( N ) ; for ( int i = 2 ; i <= len ; i ++ ) { long temp = ( long ) Math . pow ( 10 , i - 1 ) ; long cur = N / temp - 1 ; ans = Math . max ( ans , help ( cur ) + 9 * ( i - 1 ) ) ; } return ans ; } }" ]
[ "N = list ( input ( ) ) NEW_LINE ans1 , ans2 = 0 , 0 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT if ( i == 0 ) : ans1 += int ( N [ i ] ) - 1 NEW_LINE else : ans1 += 9 NEW_LINE ans2 += int ( N [ i ] ) NEW_LINE DEDENT ans = max ( ans1 , ans2 ) NEW_LINE print ( ans ) NEW_LINE", "N = input ( ) NEW_LINE flag = True NEW_LINE if N [ 0 ] == '1' : NEW_LINE INDENT for i in range ( 1 , len ( N ) ) : NEW_LINE INDENT if N [ i ] != '9' : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if not flag : NEW_LINE INDENT print ( 9 * ( len ( N ) - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 1 + 9 * ( len ( N ) - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 1 , len ( N ) ) : NEW_LINE INDENT if N [ i ] != '9' : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if not flag : NEW_LINE INDENT print ( 9 * ( len ( N ) - 1 ) + int ( N [ 0 ] ) - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 9 * ( len ( N ) - 1 ) + int ( N [ 0 ] ) ) NEW_LINE DEDENT DEDENT", "import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE t = int ( np . log10 ( n ) + 1 ) NEW_LINE s = ( n + 1 ) // ( 10 ** ( t - 1 ) ) NEW_LINE print ( 9 * ( t - 1 ) + s - 1 ) NEW_LINE", "s = input ( ) ; print ( max ( int ( s [ 0 ] ) - 1 + 9 * ( len ( s ) - 1 ) , sum ( map ( int , list ( s ) ) ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE bN = N NEW_LINE while bN : NEW_LINE INDENT ans += bN % 10 NEW_LINE bN //= 10 NEW_LINE DEDENT for i in range ( 17 , 0 , - 1 ) : NEW_LINE INDENT p = N // ( 10 ** i ) NEW_LINE if p == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT tmp = 0 NEW_LINE rem = p - 1 NEW_LINE while rem : NEW_LINE INDENT tmp += rem % 10 NEW_LINE rem //= 10 NEW_LINE DEDENT tmp += 9 * i NEW_LINE if tmp > ans : NEW_LINE INDENT ans = tmp NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc096_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A , B , C , K , D , E , max = 0 , ans ; A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; D = Math . max ( A , B ) ; C = sc . nextInt ( ) ; E = Math . max ( D , C ) ; K = sc . nextInt ( ) ; ans = A + B + C - E ; ans += E * Math . pow ( 2.0 , ( double ) K ) ; System . out . println ( ans ) ; sc . close ( ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Arrays ; 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 [ ] valuees = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { valuees [ i ] = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } Arrays . sort ( valuees ) ; int k = Integer . parseInt ( input . readLine ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { valuees [ 2 ] *= 2 ; } System . out . println ( valuees [ 0 ] + valuees [ 1 ] + valuees [ 2 ] ) ; } }", "import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) , k = sc . nextInt ( ) ; int total = a + b + c ; int max = max ( a , b , c ) ; int pow = ( int ) Math . pow ( 2 , k ) ; out . println ( ( total - max ) + max * pow ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int [ ] hako = { A , B , C } ; Arrays . sort ( hako ) ; int max = hako [ 2 ] ; for ( int i = 0 ; i < K ; i ++ ) { max = max * 2 ; } max = max + hako [ 0 ] + hako [ 1 ] ; System . out . print ( max ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int [ ] arr = new int [ 3 ] ; arr [ 0 ] = reader . nextInt ( ) ; arr [ 1 ] = reader . nextInt ( ) ; arr [ 2 ] = reader . nextInt ( ) ; int K = reader . nextInt ( ) ; int ans = 0 ; Arrays . sort ( arr ) ; for ( int i = 0 ; i < K ; i ++ ) { arr [ 2 ] *= 2 ; } for ( int i = 0 ; i < 3 ; i ++ ) { ans += arr [ i ] ; } System . out . print ( ans ) ; reader . close ( ) ; } }" ]
[ "abc_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( k ) : NEW_LINE INDENT abc_list [ abc_list . index ( max ( abc_list ) ) ] = max ( abc_list ) * 2 NEW_LINE DEDENT print ( sum ( abc_list ) ) NEW_LINE", "from collections import Counter NEW_LINE from functools import reduce NEW_LINE import fractions NEW_LINE import math NEW_LINE import statistics NEW_LINE import sys NEW_LINE import time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def IS ( ) : return input ( ) NEW_LINE def P ( x ) : return print ( x ) NEW_LINE def C ( x ) : return Counter ( x ) NEW_LINE def GCD_LIST ( numbers ) : NEW_LINE INDENT return reduce ( fractions . gcd , numbers ) NEW_LINE DEDENT def LCM_LIST ( numbers ) : NEW_LINE INDENT return reduce ( LCM , numbers ) NEW_LINE DEDENT def LCM ( m , n ) : NEW_LINE INDENT return ( m * n // fractions . gcd ( m , n ) ) NEW_LINE DEDENT li = LI ( ) NEW_LINE k = II ( ) NEW_LINE ans = [ ] NEW_LINE def calc ( a , b , c , count ) : NEW_LINE INDENT if count == k : NEW_LINE INDENT val = a + b + c NEW_LINE ans . append ( val ) NEW_LINE count -= 1 NEW_LINE return NEW_LINE DEDENT count += 1 NEW_LINE calc ( a * 2 , b , c , count ) NEW_LINE calc ( a , b * 2 , c , count ) NEW_LINE calc ( a , b , c * 2 , count ) NEW_LINE DEDENT calc ( li [ 0 ] , li [ 1 ] , li [ 2 ] , 0 ) NEW_LINE print ( max ( ans ) ) NEW_LINE NEW_LINE", "A = [ int ( j ) for j in input ( ) . split ( ) ] NEW_LINE K = int ( input ( ) ) NEW_LINE A . sort ( ) NEW_LINE print ( A [ 2 ] * ( ( 2 ** K ) - 1 ) + sum ( A ) ) NEW_LINE", "N = sorted ( list ( map ( int , input ( ) . split ( ) ) ) , reverse = True ) NEW_LINE print ( N [ 0 ] * 2 ** int ( input ( ) ) + N [ 1 ] + N [ 2 ] ) NEW_LINE", "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE arr = [ A , B , C ] NEW_LINE for _ in range ( K ) : NEW_LINE INDENT arr1 = 2 * arr [ 0 ] + arr [ 1 ] + arr [ 2 ] NEW_LINE arr2 = arr [ 0 ] + 2 * arr [ 1 ] + arr [ 2 ] NEW_LINE arr3 = arr [ 0 ] + arr [ 1 ] + 2 * arr [ 2 ] NEW_LINE tmp = [ arr1 , arr2 , arr3 ] NEW_LINE idx = tmp . index ( max ( tmp ) ) NEW_LINE arr [ idx ] *= 2 NEW_LINE DEDENT print ( sum ( arr ) ) NEW_LINE" ]
atcoder_agc012_C
[ "import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Deque ; import java . util . List ; import java . util . Scanner ; class Main { private static int bitcount ( long n ) { int res = 0 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) ++ res ; n /= 2 ; } return res ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long N = scan . nextLong ( ) ; int maxbit = - 1 ; long n = N ; while ( n > 0 ) { n /= 2 ; ++ maxbit ; } Deque < Integer > first = new ArrayDeque < > ( ) ; List < Integer > second = new ArrayList < > ( ) ; for ( int i = maxbit ; i > 0 ; -- i ) { first . addLast ( i ) ; second . add ( i ) ; } Deque < Integer > useNumber = new ArrayDeque < > ( ) ; for ( int i = bitcount ( N ) - 1 ; i > 0 ; -- i ) { useNumber . addLast ( maxbit + i ) ; first . addFirst ( maxbit + i ) ; } for ( int i = maxbit - 1 ; i >= 0 ; -- i ) { if ( ( ( N >> i ) & 1 ) == 1 ) { int inn = useNumber . removeFirst ( ) ; second . add ( second . indexOf ( i + 1 ) + 1 , inn ) ; } } List < Integer > ans = new ArrayList < > ( ) ; ans . add ( 100 ) ; while ( ! first . isEmpty ( ) ) { ans . add ( first . removeFirst ( ) ) ; } for ( int i : second ) ans . add ( i ) ; ans . add ( 100 ) ; System . out . println ( ans . size ( ) ) ; for ( int i : ans ) System . out . print ( i + \" ▁ \" ) ; System . out . println ( ) ; } }", "import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; ++ N ; ArrayDeque < Integer > deque = new ArrayDeque < > ( ) ; int curVal = 1 ; ArrayList < Integer > lis = new ArrayList < > ( ) ; while ( N > 0 ) { if ( N % 2 == 0 ) { lis . add ( 0 ) ; } else { lis . add ( 1 ) ; } N /= 2 ; } for ( int i = lis . size ( ) - 2 ; i >= 0 ; -- i ) { deque . addLast ( curVal ) ; if ( lis . get ( i ) == 1 ) { ++ curVal ; deque . addFirst ( curVal ) ; } ++ curVal ; } -- curVal ; System . out . println ( curVal * 2 ) ; for ( int i = 0 ; i < curVal ; ++ i ) { System . out . print ( deque . pollFirst ( ) + \" ▁ \" ) ; } for ( int i = 1 ; i <= curVal ; ++ i ) { System . out . print ( i + ( i == curVal ? \" \\n \" : \" ▁ \" ) ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . util . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; ArrayList < Integer > res = new ArrayList < Integer > ( ) ; int k ; for ( k = 40 ; k >= 0 ; k -- ) { if ( n >= ( 1L << k ) - 1 ) break ; } for ( int i = 1 ; i <= k ; i ++ ) res . add ( i ) ; n -= ( 1L << k ) - 1 ; for ( int i = k - 1 ; i >= 0 ; i -- ) { if ( n < ( 1L << i ) ) continue ; k ++ ; res . add ( i , k ) ; n -= 1L << i ; } System . out . println ( 2 * res . size ( ) ) ; for ( int x : res ) System . out . print ( x + \" ▁ \" ) ; for ( int i = 1 ; i <= res . size ( ) ; i ++ ) System . out . print ( i + \" ▁ \" ) ; System . out . println ( ) ; } }", "import java . util . ArrayList ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { long N = sc . nextLong ( ) ; ArrayList < Integer > first = new ArrayList < > ( ) ; ArrayList < Integer > second = new ArrayList < > ( ) ; for ( int i = 1 ; ( 1L << i ) - 1 <= N ; i ++ ) { first . add ( i ) ; second . add ( i ) ; } N -= ( 1L << first . size ( ) ) - 1 ; while ( N > 0 ) { int a = first . size ( ) + 1 ; first . add ( a ) ; for ( int i = 0 ; ; i ++ ) { if ( ( 1L << ( i + 1 ) ) > N ) { second . add ( i , a ) ; N -= ( 1L << ( i ) ) ; break ; } } } System . out . println ( first . size ( ) * 2 ) ; for ( int i = 0 ; i < first . size ( ) ; i ++ ) { System . out . print ( first . get ( i ) + \" ▁ \" ) ; } for ( int i = 0 ; i < first . size ( ) ; i ++ ) { System . out . print ( second . get ( i ) + ( i == first . size ( ) - 1 ? \" \\n \" : \" ▁ \" ) ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; void go ( ArrayDeque < Integer > q , long x ) { if ( x == 1 ) { return ; } if ( x % 2 == 0 ) { go ( q , x / 2 ) ; q . addLast ( q . size ( ) + 1 ) ; } else { go ( q , x - 1 ) ; q . addFirst ( q . size ( ) + 1 ) ; } } void solve ( ) throws IOException { long x = nextLong ( ) + 1 ; ArrayDeque < Integer > q = new ArrayDeque < > ( ) ; go ( q , x ) ; List < Integer > ans = new ArrayList < > ( ) ; for ( int i = 1 ; i <= q . size ( ) ; i ++ ) { ans . add ( i ) ; } ans . addAll ( q ) ; out . println ( ans . size ( ) ) ; for ( int xx : ans ) { out . print ( xx + \" ▁ \" ) ; } out . println ( ) ; } Main ( ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; solve ( ) ; out . close ( ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) ; } String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { eof = true ; return null ; } } return st . nextToken ( ) ; } String nextString ( ) { try { return br . readLine ( ) ; } catch ( IOException e ) { eof = true ; return null ; } } int nextInt ( ) throws IOException { return Integer . parseInt ( nextToken ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( nextToken ( ) ) ; } double nextDouble ( ) throws IOException { return Double . parseDouble ( nextToken ( ) ) ; } }" ]
[ "n = int ( input ( ) ) + 1 NEW_LINE k = 50 NEW_LINE while ~ n >> k & 1 : NEW_LINE INDENT k -= 1 NEW_LINE DEDENT k -= 1 NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE now = 1 NEW_LINE while k >= 0 : NEW_LINE INDENT a = a + [ now ] NEW_LINE b = b + [ now ] NEW_LINE now += 1 NEW_LINE if n >> k & 1 : NEW_LINE INDENT a = a + [ now ] NEW_LINE b = [ now ] + b NEW_LINE now += 1 NEW_LINE DEDENT k -= 1 NEW_LINE DEDENT print ( len ( a + b ) ) NEW_LINE print ( * ( a + b ) ) NEW_LINE", "def ncr ( n , r ) : NEW_LINE INDENT r = min ( n - r , r ) NEW_LINE up = 1 NEW_LINE down = 1 NEW_LINE for i in range ( r ) : NEW_LINE INDENT up *= ( n - i ) NEW_LINE down *= ( i + 1 ) NEW_LINE DEDENT return up // down NEW_LINE DEDENT def seq ( x ) : NEW_LINE INDENT s = 0 NEW_LINE for i in range ( 1 , x ) : NEW_LINE INDENT j = i * 2 NEW_LINE if j > x : NEW_LINE INDENT break NEW_LINE DEDENT s += ncr ( x , j ) NEW_LINE DEDENT return s NEW_LINE DEDENT def ins ( total , p ) : NEW_LINE INDENT s = 0 NEW_LINE for i in range ( p + 1 ) : NEW_LINE INDENT s += ncr ( p , i ) * ncr ( total - p , i ) NEW_LINE DEDENT return s NEW_LINE DEDENT ans = [ ] NEW_LINE N = int ( input ( ) ) NEW_LINE k = 1 NEW_LINE for i in range ( 41 , 0 , - 1 ) : NEW_LINE INDENT x = seq ( i ) NEW_LINE if N >= x : NEW_LINE INDENT for j in range ( i ) : NEW_LINE INDENT ans . append ( k ) NEW_LINE DEDENT N -= x NEW_LINE k += 1 NEW_LINE break NEW_LINE DEDENT DEDENT size = len ( ans ) NEW_LINE s = size // 2 NEW_LINE while N > 90 : NEW_LINE INDENT m = 0 NEW_LINE t = 0 NEW_LINE for i in range ( s + 1 ) : NEW_LINE INDENT tmp = ins ( size , i ) NEW_LINE if tmp > N : NEW_LINE INDENT break NEW_LINE DEDENT if tmp > t : NEW_LINE INDENT t = tmp NEW_LINE m = i NEW_LINE DEDENT DEDENT N -= t NEW_LINE ans . insert ( m , k ) NEW_LINE ans . append ( k ) NEW_LINE k += 1 NEW_LINE DEDENT while N > 0 : NEW_LINE INDENT for i in range ( 41 , 0 , - 1 ) : NEW_LINE INDENT x = seq ( i ) NEW_LINE if N >= x : NEW_LINE INDENT for j in range ( i ) : NEW_LINE INDENT ans . append ( k ) NEW_LINE DEDENT N -= x NEW_LINE k += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( len ( ans ) ) NEW_LINE print ( \" ▁ \" . join ( [ str ( x ) for x in ans ] ) ) NEW_LINE", "def f ( n ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT return [ ] NEW_LINE DEDENT if n % 2 == 0 : NEW_LINE INDENT r = f ( n // 2 ) NEW_LINE k = len ( r ) NEW_LINE return r + [ k + 1 ] NEW_LINE DEDENT if n % 2 == 1 : NEW_LINE INDENT r = f ( n - 1 ) NEW_LINE k = len ( r ) NEW_LINE return [ k + 1 ] + r NEW_LINE DEDENT DEDENT n = int ( input ( ) ) NEW_LINE r = f ( n + 1 ) NEW_LINE k = len ( r ) NEW_LINE res = r + list ( range ( 1 , k + 1 ) ) NEW_LINE print ( len ( res ) ) NEW_LINE for x in res : NEW_LINE INDENT print ( x , end = ' ▁ ' ) NEW_LINE DEDENT print ( ) NEW_LINE", "fact = [ 1 ] NEW_LINE for i in range ( 1 , 101 ) : NEW_LINE INDENT fact . append ( fact [ - 1 ] * i ) NEW_LINE DEDENT def C ( a , b ) : NEW_LINE INDENT return fact [ a ] // ( fact [ b ] * fact [ a - b ] ) NEW_LINE DEDENT def sC ( a , b ) : NEW_LINE INDENT ret = 0 NEW_LINE for i in range ( min ( b , a - b ) + 1 ) : NEW_LINE INDENT ret += C ( b , i ) * C ( a - b , i ) NEW_LINE DEDENT return ret NEW_LINE DEDENT def calc ( n , k ) : NEW_LINE INDENT if n <= 0 : NEW_LINE INDENT return [ ] NEW_LINE DEDENT i = 0 NEW_LINE while ( 1 << ( i + 1 ) ) - 1 <= n : NEW_LINE INDENT i += 1 NEW_LINE DEDENT ret = [ str ( k ) ] * ( i + 1 ) NEW_LINE rem = n - ( ( 1 << i ) - 1 ) NEW_LINE kk = k + 1 NEW_LINE i += 1 NEW_LINE j = i // 2 NEW_LINE while j > 0 : NEW_LINE INDENT while True : NEW_LINE INDENT tmp = sC ( i , j ) NEW_LINE if tmp <= rem : NEW_LINE INDENT ret . insert ( j , str ( kk ) ) NEW_LINE ret . append ( str ( kk ) ) NEW_LINE kk += 1 NEW_LINE rem -= tmp NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT j -= 1 NEW_LINE DEDENT return ret + calc ( rem , kk ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE X = calc ( N , 1 ) NEW_LINE print ( len ( X ) ) NEW_LINE print ( \" ▁ \" . join ( X ) ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE x = [ ] NEW_LINE y = [ ] NEW_LINE k = 1 NEW_LINE for c in bin ( n + 1 ) [ 2 : ] [ 1 : ] : NEW_LINE INDENT x += [ k ] NEW_LINE y += [ k ] NEW_LINE k += 1 NEW_LINE if int ( c ) : NEW_LINE INDENT x = [ k ] + x NEW_LINE y += [ k ] NEW_LINE k += 1 NEW_LINE DEDENT DEDENT print ( len ( x + y ) ) NEW_LINE print ( * ( x + y ) ) NEW_LINE" ]
atcoder_arc048_C
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] l = new int [ n ] ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { l [ i ] = sc . nextInt ( ) ; min = Math . min ( min , l [ i ] ) ; } int gcd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { gcd = gcd ( gcd , l [ i ] - min ) ; } System . out . println ( pow ( 2 , min + ( gcd + 1 ) / 2 ) ) ; } private static final int MOD = 1_000_000_007 ; private static int gcd ( int n , int m ) { if ( m == 0 ) { return n ; } else { return gcd ( m , n % m ) ; } } private static long pow ( int a , long n ) { long loop = n ; long ret = 1 ; long x = a ; while ( loop > 0 ) { if ( loop % 2 == 1 ) { ret = ret * x % MOD ; } x = x * x % MOD ; loop /= 2 ; } return ret ; } }" ]
[ "import sys NEW_LINE from fractions import gcd NEW_LINE from functools import reduce NEW_LINE N = int ( input ( ) ) NEW_LINE a = sorted ( map ( int , sys . stdin ) ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE if N == 1 : NEW_LINE INDENT print ( pow ( 2 , a [ 0 ] , mod ) ) NEW_LINE exit ( ) NEW_LINE DEDENT gcd = reduce ( gcd , [ n - a [ 0 ] for n in a ] ) NEW_LINE print ( pow ( 2 , a [ 0 ] + ( gcd + 1 ) // 2 , mod ) % mod ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE L = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT L . append ( int ( input ( ) ) ) NEW_LINE DEDENT L . sort ( ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE if N == 1 : NEW_LINE INDENT print ( pow ( 2 , L [ 0 ] , mod ) ) NEW_LINE exit ( ) NEW_LINE DEDENT def gcd ( m , n ) : NEW_LINE INDENT x = max ( m , n ) NEW_LINE y = min ( m , n ) NEW_LINE if y == 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( y , x % y ) NEW_LINE DEDENT DEDENT M = [ ] NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT M . append ( L [ i + 1 ] - L [ i ] ) NEW_LINE DEDENT g = M [ 0 ] NEW_LINE for i in range ( 1 , N - 1 ) : NEW_LINE INDENT g = gcd ( g , M [ i ] ) NEW_LINE DEDENT print ( pow ( 2 , L [ 0 ] + ( g + 1 ) // 2 , mod ) ) NEW_LINE", "MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE L = sorted ( set ( [ int ( input ( ) ) for i in range ( N ) ] ) ) NEW_LINE N = len ( L ) NEW_LINE def gcd ( m , n ) : NEW_LINE INDENT r = m % n NEW_LINE return gcd ( n , r ) if r else n NEW_LINE DEDENT if N == 1 : NEW_LINE INDENT x = 0 NEW_LINE DEDENT else : NEW_LINE INDENT x = L [ 1 ] - L [ 0 ] NEW_LINE for i in range ( 2 , N ) : NEW_LINE INDENT x = gcd ( x , L [ i ] - L [ 0 ] ) NEW_LINE DEDENT DEDENT print ( pow ( 2 , L [ 0 ] + ( x + 1 ) // 2 , MOD ) ) NEW_LINE" ]
atcoder_arc052_A
[ "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 ( ) ; for ( int i = 99 ; i > 0 ; i -- ) { if ( s . contains ( String . valueOf ( i ) ) ) { System . out . println ( i ) ; break ; } } } }", "import java . util . * ; import java . util . regex . Pattern ; import java . util . regex . Matcher ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String chk [ ] = S . split ( \" \" ) ; int cnt = 0 ; StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { String chker = chk [ i ] ; String regex = \" [ 0-9 ] + \" ; Pattern p = Pattern . compile ( regex ) ; Matcher m = p . matcher ( chker ) ; if ( m . find ( ) ) { cnt ++ ; buf . append ( chker ) ; } else if ( cnt >= 1 ) { continue ; } } System . out . println ( buf ) ; } }", "import java . util . * ; public class Main { static int count = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] arr = sc . next ( ) . toCharArray ( ) ; int a1 = - 1 ; int a2 = - 1 ; for ( char c : arr ) { if ( c >= '0' && c <= '9' ) { if ( a1 == - 1 ) { a1 = c - '0' ; } else { a2 = c - '0' ; } } } int ans ; if ( a2 == - 1 ) { ans = a1 ; } else { ans = a1 * 10 + a2 ; } System . out . println ( ans ) ; } }", "import java . util . * ; class Main { void solve ( ) { Scanner in = new Scanner ( System . in ) ; System . out . println ( in . nextLine ( ) . replaceAll ( \" [ a - z ] | [ A - Z ] \" , \" \" ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } }", "public class Main { public static void main ( String [ ] $ ) { System . out . println ( new java . util . Scanner ( System . in ) . next ( ) . replaceAll ( \" \\\\ D \" , \" \" ) ) ; } }" ]
[ "S = str ( input ( ) ) NEW_LINE list = [ ] NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if ord ( S [ i ] ) >= 48 and ord ( S [ i ] ) <= 57 : NEW_LINE INDENT list . append ( S [ i ] ) NEW_LINE DEDENT DEDENT if list [ 0 ] == \"0\" : NEW_LINE INDENT list . pop ( 0 ) NEW_LINE DEDENT ans = \" \" NEW_LINE for i in range ( len ( list ) ) : NEW_LINE INDENT ans += list [ i ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "import re NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE s = input ( ) NEW_LINE pat = r ' ( \\d ) + ' NEW_LINE res = re . search ( pat , s ) NEW_LINE if res : NEW_LINE INDENT print ( res . group ( ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" err \" ) NEW_LINE DEDENT", "import re NEW_LINE print ( re . sub ( ' \\D ' , \" \" , input ( ) ) ) NEW_LINE", "def a_nth_class ( S ) : NEW_LINE INDENT for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i : i + 2 ] . isdigit ( ) : NEW_LINE INDENT return S [ i : i + 2 ] NEW_LINE DEDENT elif S [ i ] . isdigit ( ) : NEW_LINE INDENT return S [ i ] NEW_LINE DEDENT DEDENT return None NEW_LINE DEDENT S = input ( ) NEW_LINE print ( a_nth_class ( S ) ) NEW_LINE", "s = input ( ) NEW_LINE alph = \" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \" NEW_LINE for i in alph : NEW_LINE INDENT s = s . replace ( i , \" \" ) NEW_LINE DEDENT print ( s ) NEW_LINE" ]
atcoder_arc030_A
[ "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( s . nextInt ( ) / 2 >= s . nextInt ( ) ? \" YES \" : \" NO \" ) ; } }", "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 k = sc . nextInt ( ) ; int point = 1 ; if ( k <= point && n >= point ) { System . out . println ( \" YES \" ) ; return ; } n -- ; if ( k <= point && n >= point ) { System . out . println ( \" YES \" ) ; return ; } while ( n > 0 ) { n -- ; point ++ ; if ( k <= point && n >= point ) { System . out . println ( \" YES \" ) ; return ; } } System . out . println ( \" NO \" ) ; } }", "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 ( ) , k = sc . nextInt ( ) ; out . println ( n / 2 < k ? \" NO \" : \" YES \" ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; System . out . println ( ( K <= Math . ceil ( ( float ) ( N - 1 ) / 2 ) ) ? \" YES \" : \" NO \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; if ( N / 2 >= K ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE if n // 2 >= k : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT", "n , k = map ( int , open ( 0 ) ) ; print ( ' YNEOS ' [ n < k * 2 : : 2 ] ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE tmp = 0 NEW_LINE for i in range ( 10 ** 5 ) : NEW_LINE INDENT n = n - 2 NEW_LINE tmp += 1 NEW_LINE if n < 0 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE break NEW_LINE DEDENT if tmp == k : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE break NEW_LINE DEDENT DEDENT", "print ( \" NO \" if int ( input ( ) ) // 2 < int ( input ( ) ) else \" YES \" ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE if n >= 2 * k : 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" ]
atcoder_arc026_B
[ "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long total = 1 ; for ( long i = 2 ; i <= ( int ) Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { total = total + i ; long j = N / i ; if ( j != i ) { total = total + j ; } if ( total > N ) { break ; } } } if ( total == 1 ) { System . out . println ( \" Deficient \" ) ; } else if ( total == N ) { System . out . println ( \" Perfect \" ) ; } else if ( total < N ) { System . out . println ( \" Deficient \" ) ; } else { System . out . println ( \" Abundant \" ) ; } } }", "import java . util . * ; class Main { static long sum ( long n ) { long ret = 1 ; for ( long i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == Math . sqrt ( n ) ) { ret += i ; } else { ret += i ; ret += n / i ; } } } return ret ; } static void solve ( long n ) { if ( n == 1 ) System . out . println ( \" Deficient \" ) ; else if ( sum ( n ) == n ) System . out . println ( \" Perfect \" ) ; else if ( sum ( n ) < n ) System . out . println ( \" Deficient \" ) ; else System . out . println ( \" Abundant \" ) ; } public static void main ( String args [ ] ) { Scanner cin = new Scanner ( System . in ) ; long n = cin . nextLong ( ) ; solve ( n ) ; } }", "import java . util . * ; public class Main { private static long N ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextLong ( ) ; } public static void main ( String args [ ] ) { input ( ) ; long sum = 1 ; for ( long i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) sum += i + N / i ; } if ( N % Math . sqrt ( N ) == 0 ) sum -= Math . sqrt ( N ) ; if ( sum == N ) System . out . println ( \" Perfect \" ) ; else if ( sum > N ) System . out . println ( \" Abundant \" ) ; else System . out . println ( \" Deficient \" ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long M = ( long ) Math . floor ( Math . sqrt ( N ) ) ; if ( N == 1 ) { System . out . println ( \" Deficient \" ) ; return ; } long ans = 1l ; for ( long i = 2l ; i <= M ; i ++ ) { if ( N % i == 0 ) { if ( i != N / i ) { ans += N / i ; } ans += i ; } } if ( ans == N ) { System . out . println ( \" Perfect \" ) ; } else if ( ans < N ) { System . out . println ( \" Deficient \" ) ; } else if ( ans > N ) { System . out . println ( \" Abundant \" ) ; } } }", "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 ) ; long n = Long . parseLong ( sc . next ( ) ) ; sc . close ( ) ; long num = 1 ; for ( long i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == Math . sqrt ( n ) ) num += i ; else num += i + n / i ; } } System . out . println ( n == 1 ? \" Deficient \" : num == n ? \" Perfect \" : num > n ? \" Abundant \" : \" Deficient \" ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE ans = 1 NEW_LINE if n == 1 : NEW_LINE INDENT print ( \" Deficient \" ) NEW_LINE quit ( ) NEW_LINE DEDENT i = 2 NEW_LINE ans_l = [ \" Deficient \" , \" Perfect \" , \" Abundant \" ] NEW_LINE while i ** 2 <= n : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT ans += i NEW_LINE if n // i != i : NEW_LINE INDENT ans += n // i NEW_LINE DEDENT DEDENT i += 1 NEW_LINE DEDENT key = ( ans - n ) // max ( 1 , abs ( ans - n ) ) + 1 NEW_LINE print ( ans_l [ key ] ) NEW_LINE", "def b_perfect_number ( N ) : NEW_LINE INDENT def divisor_list ( n ) : NEW_LINE INDENT ret = [ ] NEW_LINE for k in range ( 1 , int ( n ** 0.5 ) + 1 ) : NEW_LINE INDENT if n % k == 0 : NEW_LINE INDENT ret . append ( k ) NEW_LINE if k != n // k : NEW_LINE INDENT ret . append ( n // k ) NEW_LINE DEDENT DEDENT DEDENT ret . sort ( ) NEW_LINE return ret NEW_LINE DEDENT div_list = divisor_list ( N ) NEW_LINE div_sum = sum ( div_list ) NEW_LINE if div_sum == 2 * N : NEW_LINE INDENT ans = ' Perfect ' NEW_LINE DEDENT elif div_sum < 2 * N : NEW_LINE INDENT ans = ' Deficient ' NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' Abundant ' NEW_LINE DEDENT return ans NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE print ( b_perfect_number ( N ) ) NEW_LINE", "import math NEW_LINE N = int ( input ( ) ) NEW_LINE ans = ( - 1 ) * N NEW_LINE square_root = int ( math . sqrt ( N ) ) NEW_LINE if square_root ** 2 == N : NEW_LINE INDENT end = square_root NEW_LINE ans -= square_root NEW_LINE DEDENT else : NEW_LINE INDENT end = square_root + 1 NEW_LINE DEDENT for i in range ( 1 , end ) : NEW_LINE INDENT if N % i == 0 : NEW_LINE INDENT ans += ( N // i + i ) NEW_LINE DEDENT DEDENT print ( ' Perfect ' if ans == N else ' Abundant ' if ans > N else ' Deficient ' ) NEW_LINE", "from math import sqrt NEW_LINE n = int ( input ( ) ) NEW_LINE nums = set ( ) NEW_LINE d_nums = set ( ) NEW_LINE for i in range ( 1 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 and i != n : NEW_LINE INDENT nums . add ( i ) NEW_LINE DEDENT DEDENT for num in nums : NEW_LINE INDENT p , q = divmod ( n , num ) NEW_LINE if q == 0 and p != n : NEW_LINE INDENT d_nums . add ( p ) NEW_LINE DEDENT DEDENT m_nums = nums | d_nums NEW_LINE t = sum ( m_nums ) NEW_LINE if t == n : NEW_LINE INDENT print ( ' Perfect ' ) NEW_LINE DEDENT elif t > n : NEW_LINE INDENT print ( ' Abundant ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Deficient ' ) NEW_LINE DEDENT", "from collections import defaultdict as dd NEW_LINE from functools import reduce NEW_LINE def calc ( x ) : NEW_LINE INDENT a , b = x NEW_LINE v = 0 NEW_LINE for i in range ( b + 1 ) : NEW_LINE INDENT v += a ** i NEW_LINE DEDENT return v NEW_LINE DEDENT def factorization ( n ) : NEW_LINE INDENT d = dd ( int ) NEW_LINE for i in range ( 2 , 1 + int ( n ** 0.5 ) ) : NEW_LINE INDENT while n % i == 0 : NEW_LINE INDENT d [ i ] += 1 NEW_LINE n //= i NEW_LINE DEDENT DEDENT if n > 1 : d [ n ] += 1 NEW_LINE return d NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( \" Deficient \" ) NEW_LINE DEDENT else : NEW_LINE INDENT d = factorization ( n ) NEW_LINE result = reduce ( lambda x , y : x * y , map ( calc , d . items ( ) ) ) - n NEW_LINE print ( \" Perfect \" if n == result else \" Abundant \" if result > n else \" Deficient \" ) NEW_LINE DEDENT" ]
atcoder_abc054_B
[ "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 n = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int m = Integer . parseInt ( tokenizer . nextToken ( ) ) ; char [ ] [ ] nBoard = new char [ n ] [ ] ; char [ ] [ ] mBoard = new char [ m ] [ ] ; for ( int i = 0 ; i < n ; i ++ ) { nBoard [ i ] = input . readLine ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { mBoard [ i ] = input . readLine ( ) . toCharArray ( ) ; } boolean state = false ; TH : for ( int i = 0 ; i < ( n - m ) + 1 ; i ++ ) { for ( int j = 0 ; j < ( n - m ) + 1 ; j ++ ) { boolean state2 = true ; MT : for ( int k = 0 ; k < m ; k ++ ) { for ( int l = 0 ; l < m ; l ++ ) { if ( nBoard [ i + k ] [ j + l ] != mBoard [ k ] [ l ] ) { state2 = false ; break MT ; } } } if ( state2 ) { state = true ; break TH ; } } } System . out . println ( state ? \" Yes \" : \" No \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] srgs ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String strA [ ] = new String [ a ] ; String strB [ ] = new String [ b ] ; for ( int i = 0 ; i != a ; i ++ ) { strA [ i ] = scan . next ( ) ; } for ( int i = 0 ; i != b ; i ++ ) { strB [ i ] = scan . next ( ) ; } int fig = 0 ; loop : for ( int i = 0 ; i != a - b + 1 ; i ++ ) { for ( int k = 0 ; k != a - b + 1 ; k ++ ) { if ( strA [ i ] . substring ( k , k + b ) . equals ( strB [ 0 ] ) ) { for ( int j = 1 ; j != b + 1 ; j ++ ) { if ( j == b ) { fig = 1 ; break loop ; } if ( strA [ i + j ] . substring ( k , k + b ) . equals ( strB [ j ] ) ) { } else { break ; } } } } } System . out . println ( fig == 1 ? \" Yes \" : \" No \" ) ; } }", "import java . util . Scanner ; public class Main { private static int m ; private static String [ ] [ ] a ; private static String [ ] [ ] b ; private static boolean matched ( int posx , int posy ) { for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( ! a [ posx + i ] [ posy + j ] . equals ( b [ i ] [ j ] ) ) { return false ; } } } return true ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; a = new String [ n ] [ n ] ; b = new String [ m ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] sa = sc . next ( ) . split ( \" \" ) ; for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] = sa [ j ] ; } } for ( int i = 0 ; i < m ; i ++ ) { String [ ] sb = sc . next ( ) . split ( \" \" ) ; for ( int j = 0 ; j < m ; j ++ ) { b [ i ] [ j ] = sb [ j ] ; } } for ( int i = 0 ; i < n - m + 1 ; i ++ ) { for ( int j = 0 ; j < n - m + 1 ; j ++ ) { if ( matched ( i , j ) ) { System . out . println ( \" Yes \" ) ; return ; } } } System . out . println ( \" No \" ) ; } }", "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 ( ) , m = sc . nextInt ( ) ; String [ ] a = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . next ( ) ; } String [ ] b = new String [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < n - m + 1 ; i ++ ) { for ( int j = 0 ; j < n - m + 1 ; j ++ ) { boolean ans = true ; for ( int k = 0 ; k < m ; k ++ ) { for ( int l = 0 ; l < m ; l ++ ) { if ( a [ i + k ] . charAt ( j + l ) != b [ k ] . charAt ( l ) ) { ans = false ; } } } if ( ans ) { System . out . println ( \" Yes \" ) ; return ; } } } System . out . println ( \" No \" ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) , M = Integer . parseInt ( sc . next ( ) ) ; String [ ] A = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . next ( ) ; } String [ ] B = new String [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = sc . next ( ) ; } for ( int i = 0 ; i + M <= N ; i ++ ) { for ( int j = 0 ; j + M <= N ; j ++ ) { boolean yes = true ; for ( int k = 0 ; k < M ; k ++ ) { yes = yes && ( A [ i + k ] . substring ( j , j + M ) . equals ( B [ k ] ) ) ; } if ( yes ) { System . out . println ( \" Yes \" ) ; return ; } } } System . out . println ( \" No \" ) ; } }" ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a_list = [ input ( ) for _ in range ( n ) ] NEW_LINE b_list = [ input ( ) for _ in range ( m ) ] NEW_LINE for i in range ( n - m + 1 ) : NEW_LINE INDENT for j in range ( n - m + 1 ) : NEW_LINE INDENT f = True NEW_LINE for k in range ( m ) : NEW_LINE INDENT for l in range ( m ) : NEW_LINE INDENT if a_list [ i + k ] [ j + l ] != b_list [ k ] [ l ] : NEW_LINE INDENT f = False NEW_LINE break NEW_LINE DEDENT DEDENT if not f : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if f : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT print ( \" No \" ) NEW_LINE", "def do_match ( A : list , B : list , offsets : tuple , size_B : int ) -> bool : NEW_LINE INDENT oh , ow = offsets NEW_LINE for h in range ( size_B ) : NEW_LINE INDENT for w in range ( size_B ) : NEW_LINE INDENT if A [ oh + h ] [ ow + w ] != B [ h ] [ w ] : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT return True NEW_LINE DEDENT def template_matching ( N : int , M : int , A : list , B : list ) -> bool : NEW_LINE INDENT for offset_h in range ( N - M + 1 ) : NEW_LINE INDENT for offset_w in range ( N - M + 1 ) : NEW_LINE INDENT if do_match ( A , B , ( offset_h , offset_w ) , M ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = 0 NEW_LINE M = 0 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ input ( ) for _ in range ( N ) ] NEW_LINE B = [ input ( ) for _ in range ( M ) ] NEW_LINE yes = template_matching ( N , M , A , B ) NEW_LINE print ( ' Yes ' if yes else ' No ' ) NEW_LINE DEDENT", "import numpy as np NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A . append ( list ( input ( ) ) ) NEW_LINE DEDENT B = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT B . append ( list ( input ( ) ) ) NEW_LINE DEDENT A = np . array ( A ) NEW_LINE B = np . array ( B ) NEW_LINE flag = False NEW_LINE for i in range ( N - M + 1 ) : NEW_LINE INDENT for j in range ( N - M + 1 ) : NEW_LINE INDENT if np . all ( A [ i : i + M , j : j + M ] == B ) : NEW_LINE INDENT flag = True NEW_LINE DEDENT DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A , B = [ ] , [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A . append ( input ( ) ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT B . append ( input ( ) ) NEW_LINE DEDENT ans = \" \" NEW_LINE for i in range ( N - M + 1 ) : NEW_LINE INDENT if B [ 0 ] in A [ i ] : NEW_LINE INDENT ans += \" T \" NEW_LINE y = A [ i ] . find ( B [ 0 ] ) NEW_LINE for j in range ( 1 , M ) : NEW_LINE INDENT if A [ i + j ] [ y : y + M ] == B [ j ] : NEW_LINE INDENT ans += \" T \" NEW_LINE DEDENT else : NEW_LINE INDENT ans += \" F \" NEW_LINE DEDENT DEDENT DEDENT DEDENT if \" T \" * M in ans : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT N , M = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE B = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A . append ( list ( _ for _ in input ( ) ) ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT B . append ( list ( _ for _ in input ( ) ) ) NEW_LINE DEDENT for i in range ( N - M + 1 ) : NEW_LINE INDENT for j in range ( N - M + 1 ) : NEW_LINE INDENT flag = True NEW_LINE for k in range ( M ) : NEW_LINE INDENT for l in range ( M ) : NEW_LINE INDENT if A [ i + k ] [ j + l ] != B [ k ] [ l ] : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if ( flag ) : NEW_LINE INDENT ans = ' Yes ' NEW_LINE print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' No ' NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc087_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextInt ( ) ; long a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; System . out . println ( ( x - a ) % b ) ; } }", "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 x = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . println ( ( x - a ) % b ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( \" End ▁ of ▁ Input \" ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }", "import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; import java . util . TreeSet ; import org . omg . Messaging . SyncScopeHelper ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_100 ( ) . doIt ( ) ; } class Test_100 { void doIt ( ) { int X = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = ( X - A ) % B ; System . out . println ( ans ) ; } } }", "import java . io . * ; import java . util . Scanner ; import java . lang . Math ; import java . util . Arrays ; import java . util . List ; import java . util . stream . Collectors ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int X = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( X - A - ( X - A ) / B * B ) ; scanner . close ( ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; a = a - b ; for ( ; ; ) { a -= c ; if ( a < c ) { break ; } } System . out . println ( a ) ; } }" ]
[ "x = int ( input ( ) ) NEW_LINE a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( ( x - a ) % b ) NEW_LINE", "x , a , b = map ( int , open ( 0 ) ) ; print ( ( x - a ) % b ) NEW_LINE", "a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE c = int ( input ( ) ) NEW_LINE print ( ( a - b ) % c ) NEW_LINE", "X = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE B = int ( input ( ) ) NEW_LINE tmp = X - A NEW_LINE tmp = tmp - B * ( tmp // B ) NEW_LINE print ( tmp ) NEW_LINE", "X , A , B = map ( int , [ input ( ) for i in range ( 3 ) ] ) NEW_LINE print ( ( X - A ) % B ) NEW_LINE" ]
atcoder_abc024_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] l = new int [ d ] ; int [ ] r = new int [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { l [ i ] = sc . nextInt ( ) ; r [ i ] = sc . nextInt ( ) ; } int [ ] s = new int [ k ] ; int [ ] t = new int [ k ] ; int [ ] now = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { s [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; now [ i ] = s [ i ] ; } sc . close ( ) ; int [ ] ans = new int [ k ] ; for ( int i = 0 ; i < d ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( ans [ j ] != 0 ) { continue ; } if ( l [ i ] <= now [ j ] && now [ j ] <= r [ i ] ) { if ( now [ j ] < t [ j ] ) { if ( t [ j ] <= r [ i ] ) { now [ j ] = t [ j ] ; ans [ j ] = i + 1 ; } else { now [ j ] = r [ i ] ; } } else { if ( t [ j ] >= l [ i ] ) { now [ j ] = t [ j ] ; ans [ j ] = i + 1 ; } else { now [ j ] = l [ i ] ; } } } } } for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ans [ i ] ) ; } } }", "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , d = scanner . nextInt ( ) , k = scanner . nextInt ( ) ; int [ ] l = new int [ d ] , r = new int [ d ] , s = new int [ k ] , t = new int [ k ] , a = new int [ k ] ; boolean [ ] b = new boolean [ k ] ; for ( int i = 0 ; i < d ; i ++ ) { l [ i ] = scanner . nextInt ( ) ; r [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < k ; i ++ ) b [ i ] = ( s [ i ] = scanner . nextInt ( ) ) < ( t [ i ] = scanner . nextInt ( ) ) ; for ( int i = 0 ; i < d ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( l [ i ] <= s [ j ] && s [ j ] <= r [ i ] ) { s [ j ] = b [ j ] ? Math . max ( s [ j ] , r [ i ] ) : Math . min ( s [ j ] , l [ i ] ) ; if ( ( b [ j ] ? s [ j ] >= t [ j ] : s [ j ] <= t [ j ] ) && a [ j ] == 0 ) a [ j ] = i + 1 ; } } } java . util . Arrays . stream ( a ) . forEach ( 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 ) ; int N = scanner . nextInt ( ) ; int D = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int [ ] L = new int [ D + 1 ] ; int [ ] R = new int [ D + 1 ] ; int [ ] S = new int [ K ] ; int [ ] T = new int [ K ] ; for ( int i = 1 ; i <= D ; i ++ ) { L [ i ] = scanner . nextInt ( ) ; R [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < K ; i ++ ) { S [ i ] = scanner . nextInt ( ) ; T [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < K ; i ++ ) { int now = S [ i ] ; int day = 0 ; for ( int j = 1 ; j <= D ; j ++ ) { day ++ ; if ( S [ i ] < T [ i ] ) { if ( L [ j ] <= now && now <= R [ j ] ) { now = R [ j ] ; if ( now >= T [ i ] ) { System . out . println ( day ) ; break ; } } } else { if ( L [ j ] <= now && now <= R [ j ] ) { now = L [ j ] ; if ( now <= T [ i ] ) { System . out . println ( day ) ; break ; } } } } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Area [ ] areas = new Area [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { areas [ i ] = new Area ( sc . nextInt ( ) , sc . nextInt ( ) ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int now = s ; boolean up = t > s ; for ( int j = 0 ; j < d ; j ++ ) { if ( areas [ j ] . left <= now && areas [ j ] . right >= now ) { if ( areas [ j ] . left <= t && areas [ j ] . right >= t ) { sb . append ( j + 1 ) . append ( \" \\n \" ) ; break ; } if ( up ) { if ( now < areas [ j ] . right ) { now = areas [ j ] . right ; } } else { if ( now > areas [ j ] . left ) { now = areas [ j ] . left ; } } } } } System . out . print ( sb ) ; } static class Area { int left ; int right ; public Area ( int left , int right ) { this . left = left ; this . right = right ; } } }", "import java . util . * ; import java . lang . * ; public class Main { static int n ; static int d ; static int k ; static int [ ] l ; static int [ ] r ; static int [ ] s ; static int [ ] t ; public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; d = sc . nextInt ( ) ; k = sc . nextInt ( ) ; l = new int [ d ] ; r = new int [ d ] ; s = new int [ k ] ; t = new int [ k ] ; int [ ] ans = new int [ k ] ; for ( int i = 0 ; i < d ; i ++ ) { l [ i ] = sc . nextInt ( ) ; r [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < k ; i ++ ) { s [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < d ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( l [ i ] <= s [ j ] && s [ j ] <= r [ i ] && s [ j ] != t [ j ] ) { if ( t [ j ] < s [ j ] && t [ j ] < l [ i ] ) { s [ j ] = l [ i ] ; } else if ( ( t [ j ] < s [ j ] && l [ i ] <= t [ j ] ) || ( s [ j ] < t [ j ] && t [ j ] <= r [ i ] ) ) { s [ j ] = t [ j ] ; ans [ j ] = i + 1 ; } else if ( s [ j ] < t [ j ] && r [ i ] < t [ j ] ) { s [ j ] = r [ i ] ; } } } } for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ans [ i ] ) ; } } }" ]
[ "n , d , k = map ( int , input ( ) . split ( ) ) NEW_LINE rst = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( d ) ] NEW_LINE dd = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( k ) ] NEW_LINE for dpt , dst in dd : NEW_LINE INDENT min_cur , max_cur = dpt , dpt NEW_LINE for i , ( s , e ) in enumerate ( rst ) : NEW_LINE INDENT if not ( min_cur <= s <= max_cur or min_cur <= e <= max_cur or s <= min_cur <= e or s <= max_cur <= e ) : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if min_cur > s : NEW_LINE INDENT min_cur = s NEW_LINE DEDENT if max_cur < e : NEW_LINE INDENT max_cur = e NEW_LINE DEDENT if min_cur <= dst <= max_cur : NEW_LINE INDENT print ( i + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT", "def ethnic_large_movement ( N : int , D : int , K : int , LR : list , ST : list ) -> list : NEW_LINE INDENT ret = [ 0 ] * K NEW_LINE defined = 0 NEW_LINE for d , ( l , r ) in enumerate ( LR ) : NEW_LINE INDENT for k , ( s , t ) in enumerate ( ST ) : NEW_LINE INDENT if ret [ k ] > 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if s < t : NEW_LINE INDENT if r < s or s < l : NEW_LINE INDENT continue NEW_LINE DEDENT if r < t : NEW_LINE INDENT ST [ k ] = ( r , t ) NEW_LINE DEDENT else : NEW_LINE INDENT ST [ k ] = ( t , t ) NEW_LINE ret [ k ] = d + 1 NEW_LINE defined += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if r < s or s < l : NEW_LINE INDENT continue NEW_LINE DEDENT if t < l : NEW_LINE INDENT ST [ k ] = ( l , t ) NEW_LINE DEDENT else : NEW_LINE INDENT ST [ k ] = ( t , t ) NEW_LINE ret [ k ] = d + 1 NEW_LINE defined += 1 NEW_LINE DEDENT DEDENT DEDENT if defined == K : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return ret NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT D = 0 NEW_LINE K = 0 NEW_LINE N , D , K = map ( int , input ( ) . split ( ) ) NEW_LINE LR = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( D ) ] NEW_LINE ST = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( K ) ] NEW_LINE ans = ethnic_large_movement ( N , D , K , LR , ST ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT", "N , D , K = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE LR = [ ] NEW_LINE for i in range ( D ) : NEW_LINE INDENT LR . append ( list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) ) NEW_LINE DEDENT tribePosition = [ 0 for i in range ( K ) ] NEW_LINE destination = [ 0 for i in range ( K ) ] NEW_LINE direction = [ 0 for i in range ( K ) ] NEW_LINE for i in range ( K ) : NEW_LINE INDENT tribePosition [ i ] , destination [ i ] = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE if tribePosition [ i ] - destination [ i ] > 0 : NEW_LINE INDENT direction [ i ] = 0 NEW_LINE DEDENT elif tribePosition [ i ] - destination [ i ] < 0 : NEW_LINE INDENT direction [ i ] = 1 NEW_LINE DEDENT DEDENT ans_days = [ 0 for i in range ( K ) ] NEW_LINE for i in range ( D ) : NEW_LINE INDENT for j in range ( K ) : NEW_LINE INDENT if ans_days [ j ] == 0 : NEW_LINE INDENT if LR [ i ] [ 0 ] <= tribePosition [ j ] <= LR [ i ] [ 1 ] : NEW_LINE INDENT if LR [ i ] [ 0 ] <= destination [ j ] <= LR [ i ] [ 1 ] : NEW_LINE INDENT ans_days [ j ] = i + 1 NEW_LINE DEDENT elif direction [ j ] : NEW_LINE INDENT tribePosition [ j ] = LR [ i ] [ 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT tribePosition [ j ] = LR [ i ] [ 0 ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT for i in range ( K ) : NEW_LINE INDENT print ( ans_days [ i ] ) NEW_LINE DEDENT", "n , d , k = map ( int , input ( ) . split ( ) ) NEW_LINE move = [ ] NEW_LINE for i in range ( d ) : NEW_LINE INDENT x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE move . append ( x ) NEW_LINE DEDENT for i in range ( k ) : NEW_LINE INDENT s , t = map ( int , input ( ) . split ( ) ) NEW_LINE start = s NEW_LINE end = s NEW_LINE if s < t : NEW_LINE INDENT for j in range ( len ( move ) ) : NEW_LINE INDENT if move [ j ] [ 0 ] <= start : NEW_LINE INDENT end = max ( end , move [ j ] [ 1 ] ) NEW_LINE start = end NEW_LINE DEDENT if end >= t : NEW_LINE INDENT print ( j + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for j in range ( len ( move ) ) : NEW_LINE INDENT if move [ j ] [ 1 ] >= start : NEW_LINE INDENT end = min ( end , move [ j ] [ 0 ] ) NEW_LINE start = end NEW_LINE DEDENT if end <= t : NEW_LINE INDENT print ( j + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT", "import sys , itertools NEW_LINE input = sys . stdin . readline NEW_LINE N , D , K = map ( int , input ( ) . split ( ) ) NEW_LINE info1 = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( D ) ] NEW_LINE info2 = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( K ) ] NEW_LINE for s , t in info2 : NEW_LINE INDENT now = s NEW_LINE day = 0 NEW_LINE for l , r in info1 : NEW_LINE INDENT day += 1 NEW_LINE if l <= now <= r : NEW_LINE INDENT if l <= t <= r : NEW_LINE INDENT print ( day ) NEW_LINE break NEW_LINE DEDENT elif t < l : NEW_LINE INDENT now = l NEW_LINE DEDENT elif r < t : NEW_LINE INDENT now = r NEW_LINE DEDENT DEDENT DEDENT DEDENT" ]
atcoder_abc105_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; sc . close ( ) ; if ( n == 0 ) { System . out . println ( 0 ) ; return ; } int [ ] rem = new int [ 40 ] ; for ( int i = 0 ; i < rem . length ; i ++ ) { rem [ i ] = n % - 2 ; n /= - 2 ; if ( rem [ i ] == - 1 ) { n ++ ; rem [ i ] = 1 ; } } int i = rem . length - 1 ; for ( ; i >= 0 ; i -- ) { if ( rem [ i ] == 1 ) { break ; } } for ( ; i >= 0 ; i -- ) { System . out . print ( rem [ i ] ) ; } System . out . println ( ) ; } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; if ( n == 0 ) { System . out . println ( 0 ) ; return ; } while ( n != 0 ) { if ( n % - 2 == 0 ) { sb . append ( \"0\" ) ; n /= - 2 ; } else { sb . append ( \"1\" ) ; if ( n < 0 ) { n /= - 2 ; n ++ ; } else { n /= - 2 ; } } } String xx = sb . reverse ( ) . toString ( ) ; System . out . println ( xx ) ; } } class Pair implements Comparable { int from ; int end ; int num ; int bango ; @ Override public int compareTo ( Object other ) { Pair otherpair = ( Pair ) other ; return from - otherpair . from ; } }", "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 ) ; ABC105_C solver = new ABC105_C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC105_C { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long n = in . nextLong ( ) ; StringBuffer sb = new StringBuffer ( ) ; while ( true ) { if ( n % 2 != 0 ) { sb . append ( 1 ) ; n -- ; } else { sb . append ( 0 ) ; } if ( n == 0 ) { break ; } else { n /= - 2 ; } } out . print ( sb . reverse ( ) . toString ( ) ) ; } } }", "import java . util . Scanner ; class Main { public static int ketasu ( int n ) { if ( n >= 0 ) { int ketasu = 1 ; long jougen = 1 ; long base = 1 ; for ( int i = 0 ; n > jougen ; i ++ ) { ketasu = ketasu + 2 ; base *= 4 ; jougen += base ; } return ketasu ; } else { int ketasu = 0 ; long jougen = 0 ; long base = - 2 ; for ( int i = 0 ; n < jougen ; i ++ ) { ketasu = ketasu + 2 ; jougen += base ; base *= 4 ; } return ketasu ; } } public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; scanner . close ( ) ; int ketasu = ketasu ( n ) ; char [ ] ans = new char [ ketasu ] ; for ( int index = ketasu - 1 ; index >= 0 ; index -- ) { if ( n % 2 == 0 ) { ans [ index ] = '0' ; n /= - 2 ; } else { ans [ index ] = '1' ; n = n - 1 ; n /= - 2 ; } } System . out . println ( String . valueOf ( 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 ( ) ; List < Integer > tmp = new ArrayList ( ) ; if ( N == 0 ) { tmp . add ( 0 ) ; } else { int base = - 2 ; while ( N != 1 ) { int mod = N % base ; switch ( mod ) { case - 1 : tmp . add ( 1 ) ; N = N / base + 1 ; break ; default : tmp . add ( mod ) ; N = N / base ; } } tmp . add ( N ) ; Collections . reverse ( tmp ) ; } String ans = \" \" ; for ( int i = 0 ; i < tmp . size ( ) ; i ++ ) { ans += Integer . toString ( tmp . get ( i ) ) ; } out . println ( ans ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "N = int ( input ( ) ) NEW_LINE a = ' ' NEW_LINE n = 0 NEW_LINE while N != 0 : NEW_LINE INDENT b = '0' if N % ( 2 ** ( n + 1 ) ) == 0 else '1' NEW_LINE a += b NEW_LINE N -= ( ( - 2 ) ** n ) * int ( b ) NEW_LINE n += 1 NEW_LINE DEDENT print ( a [ : : - 1 ] if a else 0 ) NEW_LINE", "import sys NEW_LINE import itertools NEW_LINE import collections NEW_LINE import functools NEW_LINE import math NEW_LINE from queue import Queue NEW_LINE INF = float ( \" inf \" ) NEW_LINE def solve ( N : int ) : NEW_LINE INDENT ans = [ ] NEW_LINE kari = 0 NEW_LINE p = 1 NEW_LINE for i in range ( 40 ) : NEW_LINE INDENT c = N & 1 NEW_LINE if c == ( ( kari >> i ) & 1 ) : NEW_LINE INDENT ans . append ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( 1 ) NEW_LINE kari += p NEW_LINE DEDENT N >>= 1 NEW_LINE p *= - 2 NEW_LINE DEDENT if 1 in ans : NEW_LINE INDENT i = ans [ : : - 1 ] . index ( 1 ) NEW_LINE print ( * ans [ : : - 1 ] [ i : ] , sep = \" \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT 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 solve ( N ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE def solve ( N : int ) : NEW_LINE INDENT if N == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE return NEW_LINE DEDENT result = \" \" NEW_LINE div = 2 NEW_LINE while N != 0 : NEW_LINE INDENT divided = N % div NEW_LINE N -= divided NEW_LINE if divided != 0 : NEW_LINE INDENT result = \"1\" + result NEW_LINE DEDENT else : NEW_LINE INDENT result = \"0\" + result NEW_LINE DEDENT div *= - 2 NEW_LINE DEDENT print ( result ) 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 solve ( N ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE if N == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = \" \" NEW_LINE x = 0 NEW_LINE keta = 0 NEW_LINE while x != N : NEW_LINE INDENT if ( N - x ) % 2 ** ( keta + 1 ) == 0 : NEW_LINE INDENT ans = \"0\" + ans NEW_LINE DEDENT else : NEW_LINE INDENT ans = \"1\" + ans NEW_LINE x += ( - 2 ) ** keta NEW_LINE DEDENT keta += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE while ( 1 ) : NEW_LINE INDENT if ( N == 1 ) : NEW_LINE INDENT ans . append ( '1' ) NEW_LINE break NEW_LINE DEDENT elif ( N == 0 ) : NEW_LINE INDENT ans . append ( '0' ) NEW_LINE break NEW_LINE DEDENT if ( N % ( - 2 ) == - 1 ) : NEW_LINE INDENT ans . append ( '1' ) NEW_LINE N = N // ( - 2 ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( '0' ) NEW_LINE N = N // ( - 2 ) NEW_LINE DEDENT DEDENT ans . reverse ( ) NEW_LINE ans_str = ' ' . join ( ans ) NEW_LINE print ( ans_str ) NEW_LINE" ]
atcoder_arc037_A
[ "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) , sum = 0 ; for ( ; n > 0 ; n -- ) { sum += Math . max ( 0 , 80 - s . nextInt ( ) ) ; } System . out . println ( sum ) ; } }", "import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += max ( 80 - sc . nextInt ( ) , 0 ) ; } out . println ( ans ) ; } }", "import java . util . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { System . out . println ( java . util . stream . IntStream . range ( 0 , scanner . nextInt ( ) ) . map ( i -> scanner . nextInt ( ) ) . filter ( m -> m < 80 ) . map ( m -> 80 - m ) . sum ( ) ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ans = 0 ; int m [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { m [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( m [ i ] >= 80 ) { continue ; } ans += 80 - m [ i ] ; } System . out . println ( ans ) ; } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sub = sc . nextInt ( ) ; int ten = 0 ; for ( int i = 0 ; i < sub ; i ++ ) { ten += Math . max ( 0 , 80 - sc . nextInt ( ) ) ; } System . out . println ( ten ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if L [ i ] >= 80 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT res += 80 - L [ i ] NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE", "n , m = open ( 0 ) ; print ( sum ( max ( 0 , 80 - int ( i ) ) for i in m . split ( ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE m = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE sum = 0 NEW_LINE for i in m : NEW_LINE INDENT sum += max ( 0 , 80 - i ) NEW_LINE DEDENT print ( sum ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE m = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sum_time = 0 NEW_LINE def time_for_test ( score ) : NEW_LINE INDENT gap = 80 - score NEW_LINE if gap <= 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return gap NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT sum_time = sum_time + time_for_test ( m [ i ] ) NEW_LINE DEDENT print ( sum_time ) NEW_LINE", "n , * t = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; print ( sum ( ( 80 - i ) * ( i < 80 ) for i in t ) ) NEW_LINE" ]
atcoder_agc008_A
[ "import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int ans1 = ( int ) 1e9 + 4 ; int ans2 = ( int ) 1e9 + 4 ; int ans3 = ( int ) 1e9 + 4 ; int ans4 = ( int ) 1e9 + 4 ; if ( - x <= - y ) ans1 = - y + x + 2 ; if ( - x <= y ) ans2 = y + x + 1 ; if ( x <= y ) ans3 = y - x ; if ( x <= - y ) ans4 = - y - x + 1 ; out . println ( min ( min ( ans1 , ans2 ) , min ( ans3 , ans4 ) ) ) ; } }", "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 ) ; ASimpleCalculator solver = new ASimpleCalculator ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ASimpleCalculator { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int x = in . ints ( ) , y = in . ints ( ) ; int ans = Integer . MAX_VALUE ; if ( x <= y ) { ans = Math . min ( ans , y - x ) ; } if ( x <= - y ) { ans = Math . min ( ans , 1 - x - y ) ; } if ( - x <= y ) { ans = Math . min ( ans , 1 + x + y ) ; } if ( - x <= - y ) { ans = Math . min ( ans , 2 - y + x ) ; } 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 ( ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; sc . close ( ) ; if ( x == y ) { System . out . println ( 0 ) ; } else if ( - x == y ) { System . out . println ( 1 ) ; } else if ( x < 0 && y < 0 ) { if ( Math . abs ( x ) <= Math . abs ( y ) ) { System . out . println ( 2 + Math . abs ( y - x ) ) ; } else { System . out . println ( Math . abs ( y - x ) ) ; } } else if ( x < 0 && y > 0 ) { if ( Math . abs ( x ) <= Math . abs ( y ) ) { System . out . println ( 1 + Math . abs ( y + x ) ) ; } else { System . out . println ( Math . abs ( y + x ) + 1 ) ; } } else if ( x > 0 && y < 0 ) { System . out . println ( 1 + Math . abs ( y + x ) ) ; } else if ( x > 0 && y > 0 ) { if ( Math . abs ( x ) <= Math . abs ( y ) ) { System . out . println ( Math . abs ( y - x ) ) ; } else { System . out . println ( 2 + Math . abs ( y - x ) ) ; } } if ( x == 0 && y == 0 ) { System . out . println ( 0 ) ; } else if ( x == 0 && y > 0 ) { System . out . println ( y ) ; } else if ( x == 0 && y < 0 ) { System . out . println ( - y + 1 ) ; } else if ( x > 0 && y == 0 ) { System . out . println ( x + 1 ) ; } else if ( x < 0 && y == 0 ) { System . out . println ( - x ) ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int a = nextInt ( ) , b = nextInt ( ) ; int ans = maxInt ; if ( a <= b ) { ans = Math . min ( ans , b - a ) ; } if ( - a <= b ) { ans = Math . min ( ans , b - ( - a ) + 1 ) ; } if ( a <= - b ) { ans = Math . min ( ans , ( - b ) - a + 1 ) ; } if ( - a <= - b ) { ans = Math . min ( ans , ( - b ) - ( - a ) + 2 ) ; } System . out . println ( ans ) ; } 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 \" ; } }", "import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long count = 10000000000L ; long tmp = y - x ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } tmp = y - x * - 1 + 1 ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } tmp = y * - 1 - x + 1 ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } tmp = y * - 1 - x * - 1 + 2 ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } System . out . println ( count ) ; } }" ]
[ "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if abs ( x ) == abs ( y ) : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT elif abs ( x ) < abs ( y ) : NEW_LINE INDENT if y > 0 : NEW_LINE INDENT if x >= 0 : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if x >= 0 : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) + 2 ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if x < 0 : NEW_LINE INDENT if y <= 0 : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if y <= 0 : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) + 2 ) NEW_LINE DEDENT DEDENT DEDENT", "def solve ( ) : NEW_LINE INDENT x , y = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE ans = [ ] NEW_LINE if x <= y : NEW_LINE INDENT ans . append ( y - x ) NEW_LINE DEDENT if - x <= y : NEW_LINE INDENT ans . append ( y + x + 1 ) NEW_LINE DEDENT if x <= - y : NEW_LINE INDENT ans . append ( - y - x + 1 ) NEW_LINE DEDENT if - x <= - y : NEW_LINE INDENT ans . append ( x - y + 2 ) NEW_LINE DEDENT return ( min ( ans ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( ) ) NEW_LINE DEDENT", "input_nums = [ int ( c ) for c in input ( ) . split ( \" ▁ \" ) ] NEW_LINE x = input_nums [ 0 ] NEW_LINE y = input_nums [ 1 ] NEW_LINE ad = 0 NEW_LINE if x > y : NEW_LINE INDENT ad = 2 NEW_LINE DEDENT if ( x < 0 and y > 0 ) or ( x >= 0 and y <= 0 ) : NEW_LINE INDENT ad = 1 NEW_LINE DEDENT if x == y : NEW_LINE INDENT ad = 0 NEW_LINE DEDENT x , y = abs ( x ) , abs ( y ) NEW_LINE print ( abs ( x - y ) + ad ) NEW_LINE", "import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT x , y = LI ( ) NEW_LINE if abs ( x ) <= abs ( y ) : NEW_LINE INDENT cnt = abs ( y ) - abs ( x ) NEW_LINE if x >= 0 : NEW_LINE INDENT if y < 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if y >= 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += 2 NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT cnt = abs ( x ) - abs ( y ) NEW_LINE if x <= 0 : NEW_LINE INDENT if y > 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if y <= 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += 2 NEW_LINE DEDENT DEDENT DEDENT return cnt NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE cnt = float ( ' inf ' ) NEW_LINE for first , add_cnt_f in ( - 1 , 1 ) , ( 1 , 0 ) : NEW_LINE INDENT xx = x * first NEW_LINE for last , add_cnt_l in ( - 1 , 1 ) , ( 1 , 0 ) : NEW_LINE INDENT yy = y * last NEW_LINE if yy >= xx : NEW_LINE INDENT cnt = min ( cnt , add_cnt_f + add_cnt_l + yy - xx ) NEW_LINE DEDENT DEDENT DEDENT print ( cnt ) NEW_LINE" ]
atcoder_arc071_B
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { long PRIME = 1000000007 ; Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ M ] ; for ( int i = 0 ; i < N ; i ++ ) x [ i ] = Long . parseLong ( sc . next ( ) ) ; for ( int j = 0 ; j < M ; j ++ ) y [ j ] = Long . parseLong ( sc . next ( ) ) ; Arrays . sort ( x ) ; Arrays . sort ( y ) ; long xans = 0 ; long yans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { xans = ( xans + ( i - ( N - 1 - i ) ) * x [ i ] ) % PRIME ; } for ( int j = 0 ; j < M ; j ++ ) { yans = ( yans + ( j - ( M - 1 - j ) ) * y [ j ] ) % PRIME ; } System . out . println ( ( xans * yans ) % PRIME ) ; sc . close ( ) ; } }", "import java . io . * ; import java . util . * ; class Main { static final long MOD = 1000000007 ; static long f ( long [ ] a ) { int n = a . length ; long ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] %= MOD ; if ( a [ i ] < 0 ) a [ i ] += MOD ; long f = ( 2 * i - n + 1 + MOD ) % MOD ; ans = ( ans + f * a [ i ] ) % MOD ; } return ans ; } public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long [ ] x = new long [ n ] , y = new long [ m ] ; for ( int i = 0 ; i < n ; ++ i ) x [ i ] = sc . nextLong ( ) ; for ( int i = 0 ; i < m ; ++ i ) y [ i ] = sc . nextLong ( ) ; out . println ( f ( x ) * f ( y ) % MOD ) ; out . close ( ) ; } 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 . io . * ; import java . awt . geom . * ; import java . math . * ; public class Main { static final Scanner in = new Scanner ( System . in ) ; static final PrintWriter out = new PrintWriter ( System . out , false ) ; static boolean debug = false ; static final long MOD = 1_000_000_007 ; static void solve ( ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; long [ ] x = new long [ n ] ; long [ ] y = new long [ m ] ; long sumX = 0 , sumY = 0 ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = in . nextInt ( ) ; if ( i != 0 ) sumX = ( sumX + ( x [ i ] - x [ i - 1 ] ) * i % MOD * ( n - i ) % MOD ) % MOD ; } for ( int i = 0 ; i < m ; i ++ ) { y [ i ] = in . nextInt ( ) ; if ( i != 0 ) sumY = ( sumY + ( y [ i ] - y [ i - 1 ] ) * i % MOD * ( m - i ) % MOD ) % MOD ; } out . println ( sumX * sumY % MOD ) ; } public static void main ( String [ ] args ) { debug = args . length > 0 ; long start = System . nanoTime ( ) ; solve ( ) ; out . flush ( ) ; long end = System . nanoTime ( ) ; dump ( ( end - start ) / 1000000 + \" ▁ ms \" ) ; in . close ( ) ; out . close ( ) ; } static void dump ( Object ... o ) { if ( debug ) System . err . println ( Arrays . deepToString ( o ) ) ; } }", "import java . util . * ; class Main { static int mod = 1000000007 ; static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = s . nextInt ( ) - 1 , m = s . nextInt ( ) - 1 ; long [ ] a = new long [ n ] , b = new long [ m ] ; f ( a ) ; f ( b ) ; System . err . println ( Arrays . toString ( a ) ) ; System . err . println ( Arrays . toString ( b ) ) ; long A = g ( n , a ) , B = g ( m , b ) ; System . out . println ( A * B % mod ) ; } static void f ( long [ ] a ) { long p = s . nextLong ( ) ; for ( int i = 0 ; i < a . length ; ++ i ) { long q = s . nextLong ( ) ; a [ i ] = q - p ; p = q ; } } static long g ( int n , long [ ] a ) { long A = 0 ; for ( int i = 0 ; i < n ; ++ i ) { long p = Math . min ( i , n - 1 - i ) ; A += ( ( p + 1 ) * p + ( n - p * 2 ) * ( p + 1 ) ) % mod * a [ i ] ; A %= mod ; } return 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 n , m ; long [ ] x ; long [ ] y ; void input ( ) { n = ni ( ) ; m = ni ( ) ; x = new long [ n ] ; y = new long [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = nl ( ) ; } for ( int j = 0 ; j < m ; j ++ ) { y [ j ] = nl ( ) ; } } int solve ( ) { long xsum = 0 , ysum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { xsum += x [ i ] * i - x [ i ] * ( n - i - 1 ) ; xsum %= MOD ; } for ( int i = 0 ; i < m ; i ++ ) { ysum += y [ i ] * i - y [ i ] * ( m - i - 1 ) ; ysum %= MOD ; } return ( int ) ( ( xsum * ysum ) % MOD ) ; } }" ]
[ "import collections NEW_LINE mod = 1000000007 NEW_LINE def solve ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE y = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE X = int ( ) NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT X += ( x [ i ] - x [ i - 1 ] ) * i * ( n - i ) NEW_LINE X %= mod NEW_LINE DEDENT Y = int ( ) NEW_LINE for i in range ( 1 , m ) : NEW_LINE INDENT Y += ( y [ i ] - y [ i - 1 ] ) * i * ( m - i ) NEW_LINE Y %= mod NEW_LINE DEDENT print ( ( X * Y ) % mod ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT", "from operator import mul NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE xs = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ys = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE fX = sum ( map ( mul , xs , range ( - n + 1 , n + 1 , 2 ) ) ) % MOD NEW_LINE fY = sum ( map ( mul , ys , range ( - m + 1 , m + 1 , 2 ) ) ) % MOD NEW_LINE print ( ( fX * fY ) % MOD ) NEW_LINE", "def getN ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def getMN ( ) : NEW_LINE INDENT a = input ( ) . split ( ) NEW_LINE b = [ int ( i ) for i in a ] NEW_LINE return b [ 0 ] , b [ 1 ] NEW_LINE DEDENT def getlist ( ) : NEW_LINE INDENT a = input ( ) . split ( ) NEW_LINE b = [ int ( i ) for i in a ] NEW_LINE return b NEW_LINE DEDENT MOD = 1000000007 NEW_LINE n , m = getMN ( ) NEW_LINE anums = getlist ( ) NEW_LINE bnums = getlist ( ) NEW_LINE def calc_accum_width ( nums ) : NEW_LINE INDENT x_pos_acc = 0 NEW_LINE x_width_acc = 0 NEW_LINE for i , a in enumerate ( nums ) : NEW_LINE INDENT x_width_acc += a * i - x_pos_acc NEW_LINE x_pos_acc += a NEW_LINE DEDENT return x_width_acc NEW_LINE DEDENT x_acc = calc_accum_width ( anums ) NEW_LINE y_acc = calc_accum_width ( bnums ) NEW_LINE print ( x_acc * y_acc % MOD ) NEW_LINE", "def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def make ( N ) : NEW_LINE INDENT if N % 2 : NEW_LINE INDENT L = [ N + ( N // 2 ) ** 2 - n ** 2 + 2 * n - 1 for n in range ( 1 , N // 2 + 2 ) ] NEW_LINE L = L [ 1 : : ] [ : : - 1 ] + L NEW_LINE return L NEW_LINE DEDENT else : NEW_LINE INDENT L = [ N + N * ( N - 2 ) // 4 - n ** 2 + n for n in range ( 1 , N // 2 + 1 ) ] NEW_LINE L = L [ : : - 1 ] + L NEW_LINE return L NEW_LINE DEDENT DEDENT N , M = inpl ( ) NEW_LINE X = inpl ( ) NEW_LINE Y = inpl ( ) NEW_LINE A = make ( N - 1 ) NEW_LINE B = make ( M - 1 ) NEW_LINE Sx = 0 NEW_LINE Sy = 0 NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT Sx += a * ( X [ i + 1 ] - X [ i ] ) NEW_LINE DEDENT for j , b in enumerate ( B ) : NEW_LINE INDENT Sy += b * ( Y [ j + 1 ] - Y [ j ] ) NEW_LINE DEDENT print ( ( Sx * Sy ) % ( 10 ** 9 + 7 ) ) NEW_LINE", "mod = 10 ** 9 + 7 NEW_LINE def sum_subarrays ( A ) : NEW_LINE INDENT N = len ( A ) NEW_LINE S = [ 0 ] NEW_LINE for a in A : NEW_LINE INDENT S . append ( S [ - 1 ] + a ) NEW_LINE S [ - 1 ] %= mod NEW_LINE DEDENT return sum ( ( 2 * i - N - 1 ) * s % mod for i , s in enumerate ( S ) ) % mod NEW_LINE DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Y = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE diff_X = [ X [ i + 1 ] - X [ i ] for i in range ( N ) ] NEW_LINE diff_Y = [ Y [ i + 1 ] - Y [ i ] for i in range ( M ) ] NEW_LINE print ( sum_subarrays ( diff_X ) * sum_subarrays ( diff_Y ) % mod ) NEW_LINE" ]
atcoder_agc018_B
[ "import java . util . Arrays ; import java . util . Comparator ; import java . util . PriorityQueue ; 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 ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { a [ i ] [ j ] = sc . nextInt ( ) ; -- a [ i ] [ j ] ; } } boolean [ ] invalid = new boolean [ m ] ; int ans = Integer . MAX_VALUE ; for ( int t = 0 ; t < m ; ++ t ) { int [ ] cnt = new int [ m ] ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { if ( invalid [ a [ i ] [ j ] ] ) continue ; ++ cnt [ a [ i ] [ j ] ] ; break ; } } int max = 0 ; for ( int i = 0 ; i < m ; ++ i ) { max = Math . max ( max , cnt [ i ] ) ; } ans = Math . min ( ans , max ) ; for ( int i = 0 ; i < m ; ++ i ) { if ( cnt [ i ] == max ) { invalid [ i ] = true ; break ; } } } System . out . println ( ans ) ; } 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 ( ) ; int m = sc . nextInt ( ) ; ArrayList [ ] a = new ArrayList [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = new ArrayList < Integer > ( ) ; for ( int j = 0 ; j < m ; j ++ ) { a [ i ] . add ( sc . nextInt ( ) - 1 ) ; } } int min = n ; for ( int i = 0 ; i < m ; i ++ ) { int [ ] mnum = new int [ m ] ; for ( int j = 0 ; j < n ; j ++ ) { mnum [ ( int ) ( a [ j ] . get ( 0 ) ) ] ++ ; } int max = 0 , maxpos = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( mnum [ j ] > max ) { max = mnum [ j ] ; maxpos = j ; } } if ( max < min ) min = max ; for ( int j = 0 ; j < n ; j ++ ) { a [ j ] . removeAll ( Arrays . asList ( new Integer [ ] { maxpos } ) ) ; } } System . out . println ( min ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT a = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE A . append ( a ) NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT res = [ 0 for x in range ( M + 1 ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT res [ A [ i ] [ 0 ] ] += 1 NEW_LINE DEDENT ans = max ( res ) NEW_LINE jud = res . index ( ans ) NEW_LINE for j in range ( N ) : NEW_LINE INDENT A [ j ] . remove ( jud ) NEW_LINE DEDENT return ans NEW_LINE DEDENT minans = N NEW_LINE for i in range ( M ) : NEW_LINE INDENT minans = min ( solve ( ) , minans ) NEW_LINE DEDENT print ( minans ) NEW_LINE", "from collections import Counter NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ [ ] for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A [ i ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT V = [ 1 ] * ( M + 1 ) NEW_LINE ans = N NEW_LINE for _ in range ( M - 1 ) : NEW_LINE INDENT W = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT while True : NEW_LINE INDENT if V [ A [ i ] [ 0 ] ] == 1 : NEW_LINE INDENT W . append ( A [ i ] [ 0 ] ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT A [ i ] . pop ( 0 ) NEW_LINE DEDENT DEDENT DEDENT a , c = Counter ( W ) . most_common ( ) [ 0 ] NEW_LINE ans = min ( ans , c ) NEW_LINE V [ a ] = 0 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys , math , copy NEW_LINE HUGE = 2147483647 NEW_LINE HUGEL = 9223372036854775807 NEW_LINE ABC = \" abcdefghijklmnopqrstuvwxyz \" NEW_LINE def each_attend ( anm , held ) : NEW_LINE INDENT n = len ( anm ) NEW_LINE m = len ( anm [ 0 ] ) NEW_LINE atte = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT aim = anm [ i ] NEW_LINE for k in aim : NEW_LINE INDENT if k in held : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT atte . append ( k ) NEW_LINE DEDENT return atte NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE anm = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT aim = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE anm . append ( aim ) NEW_LINE DEDENT held = set ( range ( 1 , m + 1 ) ) NEW_LINE res = HUGE NEW_LINE while len ( held ) > 0 : NEW_LINE INDENT atte = each_attend ( anm , held ) NEW_LINE num_atte = { k : 0 for k in range ( 1 , m + 1 ) } NEW_LINE for k in atte : NEW_LINE INDENT num_atte [ k ] += 1 NEW_LINE DEDENT ma = max ( num_atte . values ( ) ) NEW_LINE res = min ( res , ma ) NEW_LINE popest_sports = set ( filter ( lambda k : num_atte [ k ] == ma , held ) ) NEW_LINE held -= popest_sports NEW_LINE DEDENT print ( res ) NEW_LINE DEDENT main ( ) NEW_LINE", "def check ( mask ) : NEW_LINE INDENT for e in mask : NEW_LINE INDENT if e == 1 : return True NEW_LINE DEDENT return False NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( \" ▁ \" ) ) NEW_LINE ia = [ list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) for _ in range ( n ) ] NEW_LINE a = [ [ 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 a [ i ] [ ia [ i ] [ j ] - 1 ] = j NEW_LINE DEDENT DEDENT mask = [ 1 for _ in range ( m ) ] NEW_LINE res = 1000 NEW_LINE while check ( mask ) : NEW_LINE INDENT cnt = [ 0 for _ in range ( m ) ] NEW_LINE for alst in a : NEW_LINE INDENT mi = 3000 NEW_LINE pos = - 1 NEW_LINE for i in range ( m ) : NEW_LINE INDENT if alst [ i ] < mi and mask [ i ] == 1 : NEW_LINE INDENT pos = i NEW_LINE mi = alst [ i ] NEW_LINE DEDENT DEDENT cnt [ pos ] += 1 NEW_LINE DEDENT ma = max ( cnt ) NEW_LINE res = min ( res , ma ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT if cnt [ i ] == ma : mask [ i ] = 0 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE DEDENT main ( ) NEW_LINE", "import sys , collections NEW_LINE def input ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) [ : - 1 ] NEW_LINE DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE def calc ( s ) : NEW_LINE INDENT c = collections . Counter ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if a [ i ] [ j ] not in s : NEW_LINE INDENT c [ a [ i ] [ j ] ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT tmp = [ - 1 , - 1 ] NEW_LINE for k , v in c . items ( ) : NEW_LINE INDENT if v > tmp [ 1 ] : NEW_LINE INDENT tmp = [ k , v ] NEW_LINE DEDENT DEDENT del c NEW_LINE return tmp NEW_LINE DEDENT ans , boycott = n , set ( ) NEW_LINE for _ in range ( m - 1 ) : NEW_LINE INDENT res = calc ( boycott ) NEW_LINE ans = min ( ans , res [ 1 ] ) NEW_LINE boycott . add ( res [ 0 ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc022_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] adj = new int [ N ] [ N ] ; for ( int i = 0 ; i < N ; ++ i ) for ( int j = 0 ; j < N ; ++ j ) adj [ i ] [ j ] = 1 << 28 ; for ( int i = 0 ; i < M ; ++ i ) { int u = sc . nextInt ( ) - 1 ; int v = sc . nextInt ( ) - 1 ; int w = sc . nextInt ( ) ; adj [ u ] [ v ] = adj [ v ] [ u ] = w ; } for ( int k = 1 ; k < N ; ++ k ) { for ( int i = 1 ; i < N ; ++ i ) { for ( int j = 1 ; j < N ; ++ j ) { if ( adj [ i ] [ j ] > adj [ i ] [ k ] + adj [ k ] [ j ] ) { adj [ i ] [ j ] = adj [ i ] [ k ] + adj [ k ] [ j ] ; } } } } int minD = 1 << 28 ; for ( int i = 1 ; i < N ; ++ i ) { for ( int j = i + 1 ; j < N ; ++ j ) { if ( adj [ 0 ] [ i ] == 1 << 28 || adj [ 0 ] [ j ] == 1 << 28 ) continue ; minD = Math . min ( minD , adj [ 0 ] [ i ] + adj [ 0 ] [ j ] + adj [ i ] [ j ] ) ; } } if ( minD == 1 << 28 ) { System . out . println ( - 1 ) ; } else { System . out . println ( minD ) ; } } }", "import java . util . Comparator ; import java . util . OptionalInt ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , m = scanner . nextInt ( ) , d [ ] [ ] = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , n ) . map ( j -> i == j ? 0 : 0x1fffffff ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; for ( int i = 0 , u1 , u2 ; i < m ; i ++ ) d [ u1 = scanner . nextInt ( ) - 1 ] [ u2 = scanner . nextInt ( ) - 1 ] = d [ u2 ] [ u1 ] = Math . min ( d [ u1 ] [ u2 ] , scanner . nextInt ( ) ) ; IntStream . range ( 1 , n ) . forEach ( i -> IntStream . range ( 1 , n ) . forEach ( j -> IntStream . range ( 1 , n ) . forEach ( k -> d [ j ] [ k ] = Math . min ( d [ j ] [ k ] , d [ j ] [ i ] + d [ i ] [ k ] ) ) ) ) ; System . out . println ( IntStream . range ( 1 , n ) . mapToObj ( i -> IntStream . range ( i + 1 , n ) . map ( j -> d [ 0 ] [ i ] + d [ i ] [ j ] + d [ j ] [ 0 ] ) . min ( ) ) . filter ( OptionalInt :: isPresent ) . min ( Comparator . comparing ( OptionalInt :: getAsInt ) ) . filter ( o -> o . getAsInt ( ) < 0x1fffffff ) . orElse ( OptionalInt . of ( - 1 ) ) . getAsInt ( ) ) ; } }", "import java . util . * ; import java . util . stream . * ; public class Main { static final int INF = 100000000 ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , m = in . nextInt ( ) ; List < Edge > list = new ArrayList < > ( ) ; int [ ] [ ] route = new int [ n ] [ n ] ; for ( int [ ] arr : route ) { Arrays . fill ( arr , INF ) ; } for ( int i = 0 ; i < n ; i ++ ) { route [ i ] [ i ] = 0 ; } for ( int k = 0 ; k < m ; k ++ ) { int u = in . nextInt ( ) - 1 , v = in . nextInt ( ) - 1 , l = in . nextInt ( ) ; if ( u == 0 || v == 0 ) { list . add ( new Edge ( u == 0 ? v : u , l ) ) ; } else { route [ u ] [ v ] = route [ v ] [ u ] = l ; } } for ( int k = 0 ; k < n ; k ++ ) { for ( int x = 0 ; x < n ; x ++ ) { for ( int y = 0 ; y < n ; y ++ ) { route [ x ] [ y ] = Math . min ( route [ x ] [ y ] , route [ x ] [ k ] + route [ k ] [ y ] ) ; } } } int ans = INF ; for ( Edge a : list ) { for ( Edge b : list ) { if ( a . to != b . to && route [ a . to ] [ b . to ] != INF ) { ans = Math . min ( ans , route [ a . to ] [ b . to ] + a . cost + b . cost ) ; } } } System . out . println ( ans == INF ? - 1 : ans ) ; } } class Edge { int to , cost ; public Edge ( int to , int cost ) { this . to = to ; this . cost = cost ; } }", "import java . util . * ; public class Main { final static long INF = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] [ ] v = new long [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i != j ) { v [ i ] [ j ] = INF ; } } } for ( int i = 0 ; i < M ; i ++ ) { int u1 = sc . nextInt ( ) - 1 ; int u2 = sc . nextInt ( ) - 1 ; int l = sc . nextInt ( ) ; v [ u1 ] [ u2 ] = l ; v [ u2 ] [ u1 ] = l ; } for ( int k = 1 ; k < N ; k ++ ) { for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j < N ; j ++ ) { v [ i ] [ j ] = Math . min ( v [ i ] [ j ] , v [ i ] [ k ] + v [ k ] [ j ] ) ; } } } long ans = INF ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j < N ; j ++ ) { if ( i == j ) { continue ; } long sum = v [ i ] [ j ] + v [ 0 ] [ i ] + v [ 0 ] [ j ] ; ans = Math . min ( ans , sum ) ; } } System . out . println ( ans < INF ? ans : - 1 ) ; } }", "import java . util . Arrays ; import java . util . Comparator ; import java . util . OptionalInt ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , m = scanner . nextInt ( ) ; int [ ] [ ] d = new int [ n ] [ n ] ; Arrays . stream ( d ) . forEach ( a -> Arrays . fill ( a , 0x1fffffff ) ) ; IntStream . range ( 0 , n ) . forEach ( i -> d [ i ] [ i ] = 0 ) ; for ( int i = 0 , u1 , u2 ; i < m ; i ++ ) d [ u1 = scanner . nextInt ( ) - 1 ] [ u2 = scanner . nextInt ( ) - 1 ] = d [ u2 ] [ u1 ] = Math . min ( d [ u1 ] [ u2 ] , scanner . nextInt ( ) ) ; IntStream . range ( 1 , n ) . forEach ( i -> IntStream . range ( 1 , n ) . forEach ( j -> IntStream . range ( 1 , n ) . forEach ( k -> d [ j ] [ k ] = Math . min ( d [ j ] [ k ] , d [ j ] [ i ] + d [ i ] [ k ] ) ) ) ) ; System . out . println ( IntStream . range ( 1 , n ) . mapToObj ( i -> IntStream . range ( i + 1 , n ) . map ( j -> d [ 0 ] [ i ] + d [ i ] [ j ] + d [ j ] [ 0 ] ) . min ( ) ) . filter ( OptionalInt :: isPresent ) . min ( Comparator . comparing ( OptionalInt :: getAsInt ) ) . filter ( o -> o . getAsInt ( ) < 0x1fffffff ) . orElse ( OptionalInt . of ( - 1 ) ) . getAsInt ( ) ) ; } }" ]
[ "from scipy . sparse . csgraph import floyd_warshall as wf NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE uvl = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( m ) ] NEW_LINE INF = float ( ' inf ' ) NEW_LINE d = [ [ INF ] * n for _ in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT d [ i ] [ i ] = 0 NEW_LINE DEDENT for u , v , l in uvl : NEW_LINE INDENT if u != 1 and v != 1 : NEW_LINE INDENT d [ u - 1 ] [ v - 1 ] = l NEW_LINE d [ v - 1 ] [ u - 1 ] = l NEW_LINE DEDENT DEDENT d = wf ( d ) NEW_LINE start = [ ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT if uvl [ i ] [ 0 ] == 1 : NEW_LINE INDENT start . append ( uvl [ i ] ) NEW_LINE DEDENT DEDENT ans = INF NEW_LINE for i in start : NEW_LINE INDENT for j in start : NEW_LINE INDENT if i != j and d [ i [ 1 ] - 1 ] [ j [ 1 ] - 1 ] != INF : NEW_LINE INDENT tmp = i [ 2 ] + j [ 2 ] + d [ i [ 1 ] - 1 ] [ j [ 1 ] - 1 ] NEW_LINE ans = min ( ans , tmp ) NEW_LINE DEDENT DEDENT DEDENT print ( int ( ans ) if ans != INF else - 1 ) NEW_LINE", "import numpy as np , scipy . sparse . csgraph as ssc NEW_LINE inf = 1e9 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE D = np . array ( [ [ inf ] * N ] * N ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT u , v , l = map ( int , input ( ) . split ( ) ) NEW_LINE D [ u - 1 , v - 1 ] = D [ v - 1 , u - 1 ] = l NEW_LINE DEDENT K = np . array ( D ) NEW_LINE K [ : ] [ 0 ] = K [ 0 ] [ : ] = [ inf ] * N ; NEW_LINE K = ssc . floyd_warshall ( K ) NEW_LINE res = min ( min ( D [ 0 , i ] + D [ 0 , j ] + K [ i , j ] for j in range ( i + 1 , N ) ) for i in range ( 1 , N - 1 ) ) NEW_LINE print ( int ( [ - 1 , res ] [ res < inf ] ) ) NEW_LINE", "from itertools import combinations NEW_LINE from scipy . sparse . csgraph import floyd_warshall 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 ans = float ( ' inf ' ) NEW_LINE adj_0 = [ ] NEW_LINE mat = [ [ float ( ' inf ' ) ] * N for _ in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT s , g , w = map ( int , input ( ) . split ( ) ) NEW_LINE if s == 1 : NEW_LINE INDENT adj_0 . append ( [ g - 1 , w ] ) NEW_LINE DEDENT elif g == 1 : NEW_LINE INDENT adj_0 . append ( [ s - 1 , w ] ) NEW_LINE DEDENT else : NEW_LINE INDENT mat [ s - 1 ] [ g - 1 ] = w NEW_LINE mat [ g - 1 ] [ s - 1 ] = w NEW_LINE DEDENT DEDENT mat = floyd_warshall ( mat , directed = False ) NEW_LINE comb = combinations ( adj_0 , 2 ) NEW_LINE for p1 , p2 in comb : NEW_LINE INDENT ans = min ( ans , p1 [ 1 ] + p2 [ 1 ] + mat [ p1 [ 0 ] ] [ p2 [ 0 ] ] ) NEW_LINE DEDENT if ans == float ( ' inf ' ) : NEW_LINE INDENT ans = - 1 NEW_LINE print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( ans ) ) NEW_LINE DEDENT", "import numpy as np NEW_LINE import scipy . sparse . csgraph as spg NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE L = list ( list ( map ( int , input ( ) . split ( ) ) ) for i in range ( M ) ) NEW_LINE matrix = [ [ float ( \" inf \" ) for x in range ( N ) ] for y in range ( N ) ] NEW_LINE A = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT u , v , l = L [ i ] NEW_LINE u -= 1 NEW_LINE v -= 1 NEW_LINE if u == 0 : NEW_LINE INDENT A . append ( ( v , l ) ) NEW_LINE DEDENT else : NEW_LINE INDENT matrix [ u ] [ v ] = l NEW_LINE matrix [ v ] [ u ] = l NEW_LINE DEDENT DEDENT minimum_cost = spg . dijkstra ( matrix ) NEW_LINE ans = float ( \" inf \" ) NEW_LINE for i in range ( len ( A ) ) : NEW_LINE INDENT node_i , cost_i = A [ i ] NEW_LINE for j in range ( len ( A ) ) : NEW_LINE INDENT if i == j : NEW_LINE INDENT continue NEW_LINE DEDENT node_j , cost_j = A [ j ] NEW_LINE ans = min ( ans , cost_i + cost_j + minimum_cost [ node_i ] [ node_j ] ) NEW_LINE DEDENT DEDENT if ans < float ( \" inf \" ) : NEW_LINE INDENT ans = int ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = - 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import numpy as np NEW_LINE from scipy . sparse . csgraph import floyd_warshall as wf NEW_LINE from itertools import combinations NEW_LINE import sys NEW_LINE inp = sys . stdin . readline NEW_LINE x = 10 ** 9 NEW_LINE N , M = map ( int , inp ( ) . split ( ) ) NEW_LINE D = np . zeros ( N ) + x NEW_LINE K = np . zeros ( ( N , N ) ) + x NEW_LINE for _ in range ( M ) : NEW_LINE INDENT u , v , l = map ( int , inp ( ) . split ( ) ) NEW_LINE u -= 1 NEW_LINE v -= 1 NEW_LINE if ( 0 in ( u , v ) ) : NEW_LINE INDENT D [ u + v ] = l NEW_LINE DEDENT else : NEW_LINE INDENT K [ u , v ] = K [ v , u ] = l NEW_LINE DEDENT DEDENT K = wf ( K ) NEW_LINE r = min ( [ D [ i ] + D [ j ] + K [ i , j ] for i , j in combinations ( range ( 0 , N ) , 2 ) ] ) NEW_LINE print ( int ( [ - 1 , r ] [ r < x ] ) ) NEW_LINE" ]
atcoder_agc019_A
[ "import java . util . * ; public class Main { int INF = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long Q = sc . nextLong ( ) ; long H = sc . nextLong ( ) ; long S = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; long N = sc . nextLong ( ) ; long L1 = Math . min ( S , Math . min ( 4 * Q , 2 * H ) ) ; if ( 2 * L1 < D ) { System . out . println ( N * L1 ) ; } else { long x = N / 2 ; System . out . println ( D * x + L1 * ( N % 2 ) ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . stream . LongStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . OptionalLong ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . util . NoSuchElementException ; 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 ) ; AIceTeaStore solver = new AIceTeaStore ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AIceTeaStore { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { long q = in . ints ( ) , h = in . ints ( ) , s = in . ints ( ) , d = in . ints ( ) ; int n = in . ints ( ) ; long min2 = IntMath . min ( 8 * q , 4 * h , 2 * s , d ) ; long min1 = IntMath . min ( 4 * q , 2 * h , s ) ; out . println ( n / 2 * min2 + n % 2 * min1 ) ; } } 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 ( ) ) ; } } static final class IntMath { private IntMath ( ) { } public static long min ( long ... v ) { return Arrays . stream ( v ) . min ( ) . orElseThrow ( NoSuchElementException :: new ) ; } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { final static int ICE_TEA_COUNT = 4 ; final static double SHORT_TEA = 0.25 ; public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] input = br . readLine ( ) . split ( \" ▁ \" ) ; String input2 = br . readLine ( ) ; long [ ] iceTeaList = new long [ 4 ] ; for ( int i = 0 ; i < ICE_TEA_COUNT ; i ++ ) { iceTeaList [ i ] = Integer . parseInt ( input [ i ] ) ; } int max = Integer . parseInt ( input2 ) ; long [ ] resultTea = new long [ 4 ] ; int multiple = 2 ; long beforeResult = 1 ; boolean continueFlag = false ; int point = 0 ; resultTea [ 0 ] = ( long ) ( max / SHORT_TEA ) ; for ( int i = 0 ; i < ICE_TEA_COUNT - 1 ; i ++ ) { if ( beforeResult == 0 ) { continueFlag = true ; } else if ( iceTeaList [ i + point ] * multiple > iceTeaList [ i + 1 ] ) { resultTea [ i + 1 ] = resultTea [ i + point ] / multiple ; resultTea [ i + point ] = resultTea [ i + point ] % multiple ; continueFlag = false ; point = 0 ; multiple = 2 ; } if ( continueFlag ) { point -= 1 ; multiple *= 2 ; if ( i + point >= 0 ) { beforeResult = ( long ) resultTea [ i + point ] ; i -= 1 ; } else { beforeResult = 1 ; } continue ; } beforeResult = resultTea [ i + 1 ] ; } System . out . println ( resultTea [ 0 ] * iceTeaList [ 0 ] + resultTea [ 1 ] * iceTeaList [ 1 ] + resultTea [ 2 ] * iceTeaList [ 2 ] + resultTea [ 3 ] * iceTeaList [ 3 ] ) ; } }", "public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int q = scanner . nextInt ( ) ; int h = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ; long min1 = Math . min ( q * 4L , Math . min ( h * 2L , s ) ) ; long min2 = Math . min ( min1 * 2L , d ) ; System . out . println ( n / 2 * min2 + ( n & 1 ) * min1 ) ; } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int one = min ( nextInt ( ) * 4 , nextInt ( ) * 2 , nextInt ( ) ) ; int two = nextInt ( ) ; int n = nextInt ( ) ; if ( one * 2 <= two ) { System . out . println ( ( long ) one * n ) ; } else { System . out . println ( ( long ) n / 2 * two + ( long ) n % 2 * one ) ; } } 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 \" ; } }" ]
[ "q , h , s , d , n = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; m = min ( 4 * q , 2 * h , s ) ; print ( n // 2 * min ( d , 2 * m ) + n % 2 * m ) NEW_LINE", "Q , H , S , D = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE efficient_num , efficient_cost = 0 , 8 * Q NEW_LINE if ( efficient_cost > 4 * H ) : efficient_num , efficient_cost = 1 , 4 * H NEW_LINE if ( efficient_cost > 2 * S ) : efficient_num , efficient_cost = 2 , 2 * S NEW_LINE if ( efficient_cost > D ) : efficient_num , efficient_cost = 3 , D NEW_LINE min_cost = 0 NEW_LINE if ( N % 2 == 0 ) : NEW_LINE INDENT if ( efficient_num == 0 ) : min_cost = int ( N / 0.25 ) * Q NEW_LINE elif ( efficient_num == 1 ) : min_cost = int ( N / 0.50 ) * H NEW_LINE elif ( efficient_num == 2 ) : min_cost = N * S NEW_LINE elif ( efficient_num == 3 ) : min_cost = ( N // 2 ) * D NEW_LINE DEDENT else : NEW_LINE INDENT N = 2 * ( N // 2 ) NEW_LINE if ( efficient_num == 0 ) : min_cost = int ( N / 0.25 ) * Q NEW_LINE elif ( efficient_num == 1 ) : min_cost = int ( N / 0.50 ) * H NEW_LINE elif ( efficient_num == 2 ) : min_cost = N * S NEW_LINE elif ( efficient_num == 3 ) : min_cost = ( N // 2 ) * D NEW_LINE efficient_num , efficient_cost = 0 , 8 * Q NEW_LINE if ( efficient_cost > 4 * H ) : efficient_num , efficient_cost = 1 , 4 * H NEW_LINE if ( efficient_cost > 2 * S ) : efficient_num , efficient_cost = 2 , 2 * S NEW_LINE if ( efficient_num == 0 ) : min_cost += int ( 1 / 0.25 ) * Q NEW_LINE elif ( efficient_num == 1 ) : min_cost += int ( 1 / 0.50 ) * H NEW_LINE elif ( efficient_num == 2 ) : min_cost += 1 * S NEW_LINE DEDENT print ( min_cost ) NEW_LINE", "import itertools NEW_LINE import collections NEW_LINE import bisect NEW_LINE import sys NEW_LINE input = sys . stdin . readline NEW_LINE def main ( ) : NEW_LINE INDENT Q , H , S , D = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE half = min ( Q * 2 , H ) NEW_LINE one = min ( half * 2 , S ) NEW_LINE two = min ( one * 2 , D ) NEW_LINE print ( two * ( N // 2 ) + one * ( N % 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import math as ma NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE N *= 4 NEW_LINE dp = [ 0 for i in range ( 9 ) ] NEW_LINE for i in range ( 1 , 9 ) : NEW_LINE INDENT dp [ i ] = min ( [ dp [ i - 2 ** j ] + l [ j ] for j in range ( min ( 4 , int ( ma . log2 ( i ) + 1 ) ) ) ] ) NEW_LINE DEDENT ans = float ( ' inf ' ) NEW_LINE for i in range ( 1 , 9 ) : NEW_LINE INDENT ans = min ( ans , N // i * dp [ i ] + dp [ N - N // i * i ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "q , h , s , d = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ q * 8 , h * 4 , s * 2 , d ] NEW_LINE min_s = min ( a [ : 3 ] ) // 2 NEW_LINE min_d = min ( a ) NEW_LINE b , c = divmod ( n , 2 ) NEW_LINE print ( b * min_d + c * min_s ) NEW_LINE" ]
atcoder_arc080_B
[ "import java . util . Scanner ; import java . util . Set ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int h = s . nextInt ( ) ; int w = s . nextInt ( ) ; s . nextLine ( ) ; int n = s . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } int x = 0 , y = 0 ; int turn = 0 ; int [ ] [ ] move = { { 1 , 0 } , { - 1 , 0 } } ; int [ ] [ ] d = new int [ h ] [ w ] ; for ( int i = 0 ; i < n ; i ++ ) { while ( arr [ i ] != 0 ) { arr [ i ] -- ; d [ x ] [ y ] = i + 1 ; x += move [ turn % 2 ] [ 0 ] ; y += move [ turn % 2 ] [ 1 ] ; if ( x < 0 || y < 0 || x == h || y == w ) { turn ++ ; y ++ ; x += move [ turn % 2 ] [ 0 ] ; y += move [ turn % 2 ] [ 1 ] ; } } } for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( j == 0 ) System . out . print ( d [ i ] [ j ] ) ; else System . out . print ( \" ▁ \" + d [ i ] [ j ] ) ; } System . out . println ( ) ; } } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int p = 0 ; String all [ ] = new String [ h * w ] ; for ( int i = 1 ; i <= n ; i ++ ) { int a = sc . nextInt ( ) ; for ( int j = 0 ; j < a ; j ++ ) { all [ p ++ ] = \" \" + i ; } } p = 0 ; for ( int i = 0 ; i < h ; i ++ ) { String c [ ] = new String [ w ] ; if ( i % 2 == 0 ) { for ( int j = 0 ; j < w ; j ++ ) { c [ j ] = all [ p ++ ] ; } } else { for ( int j = w - 1 ; j >= 0 ; j -- ) { c [ j ] = all [ p ++ ] ; } } System . out . println ( String . join ( \" ▁ \" , c ) ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "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 H = sc . nextInt ( ) , W = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int [ ] [ ] ans = new int [ H ] [ W ] ; int row = 0 , col = 0 ; int flag = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int cnt = a [ i ] ; for ( int j = 0 ; j < cnt ; j ++ ) { if ( col == - 1 || col == W ) { col = col == - 1 ? 0 : W - 1 ; row ++ ; flag = flag * ( - 1 ) ; } ans [ row ] [ col ] = i + 1 ; col += flag ; } } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W - 1 ; j ++ ) { System . out . print ( Integer . toString ( ans [ i ] [ j ] ) + \" ▁ \" ) ; } System . out . println ( ans [ i ] [ W - 1 ] ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } System . out . println ( solve ( H , W , N , A ) ) ; } private static String solve ( int H , int W , int N , int [ ] A ) { List < Integer > numbers = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int n = i + 1 ; int a = A [ i ] ; for ( int j = 0 ; j < a ; j ++ ) { numbers . add ( n ) ; } } StringJoiner j = new StringJoiner ( \" \\n \" ) ; for ( int h = 0 ; h < H ; h ++ ) { int start = h * W ; int end = h * W + W ; List < Integer > line = new ArrayList < > ( numbers . subList ( start , end ) ) ; if ( h % 2 == 1 ) { Collections . reverse ( line ) ; } StringJoiner j2 = new StringJoiner ( \" ▁ \" ) ; line . forEach ( i -> j2 . add ( i . toString ( ) ) ) ; j . add ( j2 . toString ( ) ) ; } return j . toString ( ) ; } }", "import java . util . * ; public class Main { static int H , W , N ; static int [ ] [ ] ans ; static void snake ( int n , int x ) { int h = n / W ; int w = n % W ; if ( h % 2 == 1 ) w = W - w - 1 ; ans [ h ] [ w ] = x + 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; H = sc . nextInt ( ) ; W = sc . nextInt ( ) ; N = sc . nextInt ( ) ; ArrayList < Integer > nums = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int a = sc . nextInt ( ) ; for ( int j = 0 ; j < a ; j ++ ) nums . add ( i ) ; } ans = new int [ H ] [ W ] ; for ( int n = 0 ; n < nums . size ( ) ; n ++ ) { snake ( n , nums . get ( n ) ) ; } for ( int i = 0 ; i < H ; i ++ ) { System . out . print ( ans [ i ] [ 0 ] ) ; for ( int j = 1 ; j < W ; j ++ ) System . out . print ( \" ▁ \" + ans [ i ] [ j ] ) ; System . out . print ( ' \\n ' ) ; } } }" ]
[ "height , wide = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE anslist = [ ] NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i , j in enumerate ( a ) : NEW_LINE INDENT for l in range ( j ) : NEW_LINE INDENT anslist . append ( i + 1 ) NEW_LINE DEDENT DEDENT for k in range ( height ) : NEW_LINE INDENT t = anslist [ k * wide : ( k + 1 ) * wide ] NEW_LINE if k % 2 == 1 : NEW_LINE INDENT t . reverse ( ) NEW_LINE DEDENT print ( ' ▁ ' . join ( map ( str , t ) ) ) NEW_LINE DEDENT", "from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" YES \" ) NEW_LINE else : print ( \" NO \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT h , w = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE n = ip ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE horz = 1 NEW_LINE vert = 1 NEW_LINE x = 0 NEW_LINE y = 0 NEW_LINE ans = [ [ 0 for i in range ( w ) ] for i in range ( h ) ] NEW_LINE pos = 0 NEW_LINE for i in range ( h * w ) : NEW_LINE INDENT ans [ y ] [ x ] = pos + 1 NEW_LINE a [ pos ] -= 1 NEW_LINE if a [ pos ] == 0 : NEW_LINE INDENT pos += 1 NEW_LINE DEDENT if y == h - 1 and vert == 1 : NEW_LINE INDENT x += 1 NEW_LINE vert = - 1 NEW_LINE DEDENT elif y == 0 and vert == - 1 : NEW_LINE INDENT x += 1 NEW_LINE vert = 1 NEW_LINE DEDENT else : y += vert NEW_LINE DEDENT for i in range ( h ) : NEW_LINE INDENT for k in range ( w ) : NEW_LINE INDENT if k + 1 != w : print ( ans [ i ] [ k ] , \" \" , end = \" \" ) NEW_LINE else : print ( ans [ i ] [ k ] , end = \" \" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT", "import numpy as np NEW_LINE h , w = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE mat = np . zeros ( ( h , w ) , dtype = int ) NEW_LINE st = 0 NEW_LINE for i in range ( len ( a ) ) : NEW_LINE INDENT for idx in range ( st , st + a [ i ] ) : NEW_LINE INDENT mat [ idx // w ] [ idx % w ] = i + 1 NEW_LINE DEDENT st += a [ i ] NEW_LINE DEDENT for i in range ( 1 , h , 2 ) : NEW_LINE INDENT mat [ i ] = mat [ i ] [ : : - 1 ] NEW_LINE DEDENT for i in range ( h ) : NEW_LINE INDENT for j in range ( w ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = \" ▁ \" ) NEW_LINE DEDENT print ( \" \" ) NEW_LINE DEDENT", "import sys , collections NEW_LINE def solve ( ) : NEW_LINE INDENT H , W = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ [ \" \" for _ in range ( W ) ] for _ in range ( H ) ] NEW_LINE h , w = 0 , 0 NEW_LINE for i , v in enumerate ( L ) : NEW_LINE INDENT while v != 0 : NEW_LINE INDENT if h % 2 == 0 : NEW_LINE INDENT ans [ h ] [ w ] = str ( i + 1 ) NEW_LINE v -= 1 NEW_LINE if w == W - 1 : NEW_LINE INDENT h += 1 NEW_LINE DEDENT else : NEW_LINE INDENT w += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans [ h ] [ w ] = str ( i + 1 ) NEW_LINE v -= 1 NEW_LINE if w == 0 : NEW_LINE INDENT h += 1 NEW_LINE DEDENT else : NEW_LINE INDENT w -= 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for v in ans : NEW_LINE INDENT print ( \" ▁ \" . join ( v ) ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE", "H , W = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( A [ i ] ) : NEW_LINE INDENT C . append ( i + 1 ) NEW_LINE DEDENT DEDENT ans = [ [ 0 ] * W for i in range ( H ) ] NEW_LINE for i in range ( H * W ) : NEW_LINE INDENT y = i // W NEW_LINE if y % 2 == 0 : NEW_LINE INDENT x = i % W NEW_LINE DEDENT else : NEW_LINE INDENT x = W - 1 - i % W NEW_LINE DEDENT ans [ y ] [ x ] = C [ i ] NEW_LINE DEDENT for i in range ( H ) : NEW_LINE INDENT ans [ i ] = [ str ( a ) for a in ans [ i ] ] NEW_LINE print ( \" ▁ \" . join ( ans [ i ] ) ) NEW_LINE DEDENT" ]
atcoder_agc020_D
[ "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int Q = scan . nextInt ( ) ; while ( Q -- > 0 ) { long A = scan . nextLong ( ) ; long B = scan . nextLong ( ) ; long k = ( A + B ) / ( Math . min ( A , B ) + 1 ) ; if ( k <= 1 ) { int C = scan . nextInt ( ) - 1 ; int D = scan . nextInt ( ) - 1 ; String even = ( A >= B ? \" A \" : \" B \" ) ; String odd = ( A >= B ? \" B \" : \" A \" ) ; String ans = \" \" ; for ( int i = C ; i <= D ; ++ i ) { if ( i % 2 == 0 ) ans += even ; else ans += odd ; } System . out . println ( ans ) ; continue ; } long n = ( k * A - B ) / ( k * k - 1 ) ; long m = ( k * B - A ) / ( k * k - 1 ) ; long a = A - n * k - m ; long b = B - m * k - n ; int C = scan . nextInt ( ) - 1 ; int D = scan . nextInt ( ) - 1 ; String ans = \" \" ; for ( int i = C ; i <= D ; ++ i ) { if ( i < n * ( k + 1 ) ) { if ( ( i + 1 ) % ( k + 1 ) == 0 ) ans += \" B \" ; else ans += \" A \" ; } else if ( i >= n * ( k + 1 ) + a + b ) { long index = i - ( n * ( k + 1 ) ) - a - b ; if ( index % ( k + 1 ) == 0 ) ans += \" A \" ; else ans += \" B \" ; } else { long index = i - n * ( k + 1 ) ; if ( index < a ) ans += \" A \" ; else ans += \" B \" ; } } System . out . println ( ans ) ; } } }" ]
[ "import math NEW_LINE Q = int ( input ( ) ) NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE K = math . ceil ( max ( A , B ) / ( min ( A , B ) + 1 ) ) NEW_LINE lo , hi = 0 , A + 1 NEW_LINE while hi - lo > 1 : NEW_LINE INDENT mid = ( lo + hi ) // 2 NEW_LINE rA , rB = A - mid , B - max ( 0 , ( mid - 1 ) // K ) NEW_LINE if ( rA + 1 ) * K < rB : NEW_LINE INDENT hi = mid NEW_LINE DEDENT else : NEW_LINE INDENT lo = mid NEW_LINE DEDENT DEDENT f = ' ' NEW_LINE for i in range ( C - 1 , D ) : NEW_LINE INDENT na = lo NEW_LINE nb = max ( 0 , ( na - 1 ) // K ) NEW_LINE if i < nb * ( K + 1 ) : NEW_LINE INDENT f += ( ' A ' , ' B ' ) [ i % ( K + 1 ) == K ] NEW_LINE DEDENT elif i < na + nb : NEW_LINE INDENT f += ' A ' NEW_LINE DEDENT else : NEW_LINE INDENT j = A + B - i - 1 NEW_LINE nb = B - nb NEW_LINE na = max ( 0 , ( nb - 1 ) // K ) NEW_LINE if j < na * ( K + 1 ) : NEW_LINE INDENT f += ( ' B ' , ' A ' ) [ j % ( K + 1 ) == K ] NEW_LINE DEDENT else : NEW_LINE INDENT f += ' B ' NEW_LINE DEDENT DEDENT DEDENT print ( f ) NEW_LINE DEDENT", "import math NEW_LINE Q = int ( input ( ) ) NEW_LINE num = lambda x : ( x , max ( 0 , ( x - 1 ) // K ) ) NEW_LINE sub = lambda xs , ys : [ x - y for ( x , y ) in zip ( xs , ys ) ] NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE K = math . ceil ( max ( A , B ) / ( min ( A , B ) + 1 ) ) NEW_LINE l , r = 0 , A + 1 NEW_LINE while r - l > 1 : NEW_LINE INDENT m = ( l + r ) // 2 NEW_LINE rA , rB = sub ( ( A , B ) , num ( m ) ) NEW_LINE l , r = ( ( m , r ) , ( l , m ) ) [ ( rA + 1 ) * K < rB ] NEW_LINE DEDENT f = ' ' NEW_LINE for i in range ( C - 1 , D ) : NEW_LINE INDENT na , nb = num ( l ) NEW_LINE if i < na + nb : NEW_LINE INDENT f += ( ' A ' , ' B ' ) [ i % ( K + 1 ) == K ] if i < nb * ( K + 1 ) else ' A ' NEW_LINE DEDENT else : NEW_LINE INDENT nb , na = num ( B - nb ) NEW_LINE j = A + B - i - 1 NEW_LINE f += ( ' B ' , ' A ' ) [ j % ( K + 1 ) == K ] if j < na * ( K + 1 ) else ' B ' NEW_LINE DEDENT DEDENT print ( f ) NEW_LINE DEDENT", "import math NEW_LINE Q = int ( input ( ) ) NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE K = math . ceil ( max ( A , B ) / ( min ( A , B ) + 1 ) ) NEW_LINE lo , hi = 0 , A + 1 NEW_LINE while hi - lo > 1 : NEW_LINE INDENT mid = ( lo + hi ) // 2 NEW_LINE rA , rB = A - mid , B - max ( 0 , ( mid - 1 ) // K ) NEW_LINE if ( rA + 1 ) * K < rB : NEW_LINE INDENT hi = mid NEW_LINE DEDENT else : NEW_LINE INDENT lo = mid NEW_LINE DEDENT DEDENT f = ' ' NEW_LINE for i in range ( C - 1 , D ) : NEW_LINE INDENT na = lo NEW_LINE nb = max ( 0 , ( na - 1 ) // K ) NEW_LINE if i < nb * ( K + 1 ) : NEW_LINE INDENT f += ( ' A ' , ' B ' ) [ i % ( K + 1 ) == K ] NEW_LINE DEDENT elif i < na + nb : f += ' A ' NEW_LINE else : NEW_LINE INDENT j = A + B - i - 1 NEW_LINE nb = B - nb NEW_LINE na = max ( 0 , ( nb - 1 ) // K ) NEW_LINE if j < na * ( K + 1 ) : f += ( ' B ' , ' A ' ) [ j % ( K + 1 ) == K ] NEW_LINE else : f += ' B ' NEW_LINE DEDENT DEDENT print ( f ) NEW_LINE DEDENT" ]
atcoder_arc054_A
[ "import java . util . Scanner ; class Main { static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { long l = gInt ( ) , x = gInt ( ) , y = gInt ( ) , s = gInt ( ) , d = gInt ( ) ; long sl = y + x , sr = y - x ; long dl = d > s ? d - s : d + l - s ; long dr = l - dl ; double tl = dl * 1.0 / sl ; double tr = sr <= 0 ? 1145141919 : dr * 1.0 / sr ; System . out . println ( Math . min ( tl , tr ) ) ; } }", "import java . util . * ; import java . io . * ; import java . awt . geom . * ; import java . math . * ; public class Main { static final Scanner in = new Scanner ( System . in ) ; static final PrintWriter out = new PrintWriter ( System . out , false ) ; static boolean debug = false ; static void solve ( ) { double l = in . nextInt ( ) ; double x = in . nextInt ( ) ; double y = in . nextInt ( ) ; double s = in . nextInt ( ) ; double d = in . nextInt ( ) ; if ( s < d ) { if ( x < y ) { out . printf ( \" % .10f \\n \" , Math . min ( ( d - s ) / ( x + y ) , ( l - ( d - s ) ) / ( y - x ) ) ) ; } else { out . printf ( \" % .10f \\n \" , ( d - s ) / ( x + y ) ) ; } } else if ( s > d ) { if ( x < y ) { out . printf ( \" % .10f \\n \" , Math . min ( ( l - ( s - d ) ) / ( x + y ) , ( s - d ) / ( y - x ) ) ) ; } else { out . printf ( \" % .10f \\n \" , ( l - ( s - d ) ) / ( x + y ) ) ; } } else { out . println ( \"0\" ) ; } } public static void main ( String [ ] args ) { debug = args . length > 0 ; long start = System . nanoTime ( ) ; solve ( ) ; out . flush ( ) ; long end = System . nanoTime ( ) ; dump ( ( end - start ) / 1000000 + \" ▁ ms \" ) ; in . close ( ) ; out . close ( ) ; } static void dump ( Object ... o ) { if ( debug ) System . err . println ( Arrays . deepToString ( o ) ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; double l = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; double s = sc . nextDouble ( ) ; double d = sc . nextDouble ( ) ; double ans = 0 ; if ( s > d ) { if ( y > x ) ans = Math . min ( ( l - s + d ) / ( x + y ) , ( s - d ) / ( y - x ) ) ; else ans = ( l - s + d ) / ( x + y ) ; } else { if ( y > x ) ans = Math . min ( ( d - s ) / ( x + y ) , ( s + l - d ) / ( y - x ) ) ; else ans = ( d - s ) / ( x + y ) ; } System . out . println ( ans ) ; } }", "import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int L = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; double ans ; if ( S >= D ) { double t1 = ( double ) ( S - D ) / ( double ) ( Y - X ) ; double t2 = ( double ) ( L - ( S - D ) ) / ( double ) ( Y + X ) ; if ( t1 < 0 ) ans = t2 ; else ans = min ( t1 , t2 ) ; } else { double t1 = ( double ) ( D - S ) / ( double ) ( Y + X ) ; double t2 = ( double ) ( L - ( D - S ) ) / ( double ) ( Y - X ) ; if ( t2 < 0 ) ans = t1 ; else ans = min ( t1 , t2 ) ; } if ( S == D ) ans = 0 ; out . println ( ans ) ; } }", "import java . util . * ; public class Main { static int count = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double l = sc . nextInt ( ) ; double x = sc . nextInt ( ) ; double y = sc . nextInt ( ) ; double s = sc . nextInt ( ) ; double d = sc . nextInt ( ) ; double ans = 0 ; if ( x >= y ) { double val = d - s ; if ( val < 0 ) { val += l ; } ans = val / ( x + y ) ; } else { double val1 = s - d ; if ( val1 < 0 ) { val1 += l ; } double ans1 = val1 / ( y - x ) ; double val2 = d - s ; if ( val2 < 0 ) { val2 += l ; } double ans2 = val2 / ( y + x ) ; ans = Math . min ( ans1 , ans2 ) ; } System . out . println ( ans ) ; } }" ]
[ "l , x , y , s , d = map ( int , input ( ) . split ( ) ) NEW_LINE if d >= s : NEW_LINE INDENT if y != x : a = ( s + l - d ) / ( y - x ) NEW_LINE b = ( d - s ) / ( x + y ) NEW_LINE DEDENT else : NEW_LINE INDENT if y != x : a = ( s - d ) / ( y - x ) NEW_LINE b = ( d - s + l ) / ( y + x ) NEW_LINE DEDENT if y <= x : print ( b ) NEW_LINE else : print ( min ( a , b ) ) NEW_LINE", "def a_moving_walkway ( L , X , Y , S , D ) : NEW_LINE INDENT distance_start_to_goal = D - S if S <= D else D + ( L - S ) NEW_LINE if X < Y : NEW_LINE INDENT ans = min ( distance_start_to_goal / ( X + Y ) , ( L - distance_start_to_goal ) / ( Y - X ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = distance_start_to_goal / ( X + Y ) NEW_LINE DEDENT ans = round ( ans , 9 ) NEW_LINE return ans NEW_LINE DEDENT L , X , Y , S , D = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( a_moving_walkway ( L , X , Y , S , D ) ) NEW_LINE", "l , x , y , s , d = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE if s <= d : NEW_LINE INDENT ans = ( d - s ) / ( x + y ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( d - s + l ) / ( x + y ) NEW_LINE DEDENT if x < y : NEW_LINE INDENT if s >= d : NEW_LINE INDENT ans = min ( ans , ( s - d ) / ( y - x ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( ans , ( l - d + s ) / ( y - x ) ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT l , x , y , s , d = map ( int , input ( ) . split ( ) ) NEW_LINE if s == d : NEW_LINE INDENT print ( 0 ) NEW_LINE return NEW_LINE DEDENT ds = [ d - l , d ] if s < d else [ d , d + l ] NEW_LINE res = ( ds [ 1 ] - s ) / ( x + y ) NEW_LINE if x < y : NEW_LINE INDENT res = min ( res , ( s - ds [ 0 ] ) / ( y - x ) ) NEW_LINE DEDENT print ( res ) 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 L , X , Y , S , D = map ( int , input ( ) . split ( ) ) NEW_LINE if S >= D : NEW_LINE INDENT distL = S - D NEW_LINE distR = L - distL NEW_LINE velR = X + Y NEW_LINE velL = Y - X NEW_LINE if velL <= 0 : NEW_LINE INDENT ans = distR / velR NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( distR / velR , distL / velL ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT distR = D - S NEW_LINE distL = L - distR NEW_LINE velR = X + Y NEW_LINE velL = Y - X NEW_LINE if velL <= 0 : NEW_LINE INDENT ans = distR / velR NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( distR / velR , distL / velL ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc061_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 K = scn . nextLong ( ) ; Pair [ ] P = new Pair [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { P [ i ] = new Pair ( scn . nextLong ( ) , scn . nextLong ( ) ) ; } Arrays . sort ( P ) ; long ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { K -= P [ i ] . getB ( ) ; if ( K <= 0 ) { ans = P [ i ] . getA ( ) ; break ; } } System . out . println ( ans ) ; } } class Pair implements Comparable < Pair > { long a ; long b ; Pair ( long a , long b ) { this . a = a ; this . b = b ; } @ Override public int compareTo ( Pair o ) { if ( this . getA ( ) > o . getA ( ) ) return 1 ; if ( this . getA ( ) < o . getA ( ) ) return - 1 ; return 0 ; } long getA ( ) { return this . a ; } long getB ( ) { return this . b ; } }", "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_300 ( ) . doIt ( ) ; } class Test_300 { void doIt ( ) { int N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long A [ ] = new long [ 100002 ] ; for ( int i = 0 ; i < N ; i ++ ) { int a = sc . nextInt ( ) ; long b = sc . nextLong ( ) ; A [ a ] = A [ a ] + b ; } long cnt = 0 ; for ( int i = 0 ; i < 100002 ; i ++ ) { cnt = cnt + A [ i ] ; if ( cnt >= K ) { System . out . println ( i ) ; break ; } } } } }", "import java . util . TreeMap ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; long k = scanner . nextLong ( ) ; IntStream . range ( 0 , n ) . boxed ( ) . collect ( Collectors . toMap ( i -> scanner . nextInt ( ) , i -> scanner . nextLong ( ) , Long :: sum , TreeMap :: new ) ) . entrySet ( ) . stream ( ) . reduce ( k , ( rem , entry ) -> { if ( rem != null && ( rem -= entry . getValue ( ) ) <= 0 ) { System . out . println ( entry . getKey ( ) ) ; return null ; } return rem ; } , Long :: sum ) ; } }", "import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; import java . util . Collections ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; List < Pair > pairs = new ArrayList < Pair > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; pairs . add ( new Pair ( a [ i ] , b [ i ] ) ) ; } Collections . sort ( pairs ) ; long cnt = 0 ; sc . close ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int value = pairs . get ( i ) . value ; cnt += value ; if ( cnt >= k ) { System . out . println ( pairs . get ( i ) . key ) ; return ; } } } } class Pair implements Comparable { int key ; int value ; Pair ( int key , int value ) { this . key = key ; this . value = value ; } @ Override public int compareTo ( Object other ) { Pair otherPair = ( Pair ) other ; if ( this . key == otherPair . key ) return this . value - this . value ; return this . key - otherPair . key ; } } 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 ( ) ; long K = sc . nextLong ( ) ; Map < Integer , Long > map = new TreeMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; if ( map . containsKey ( a ) ) { b += map . get ( a ) ; } map . put ( a , b ) ; } for ( Map . Entry entry : map . entrySet ( ) ) { K -= ( long ) entry . getValue ( ) ; if ( K <= 0 ) { out . print ( entry . getKey ( ) ) ; return ; } } } }" ]
[ "import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE A . append ( ( a , b ) ) NEW_LINE DEDENT A = sorted ( A , key = lambda x : x [ 0 ] ) NEW_LINE cnt = 0 NEW_LINE for x in A : NEW_LINE INDENT cnt += x [ 1 ] NEW_LINE if cnt >= K : NEW_LINE INDENT return x [ 0 ] NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "import numpy as np NEW_LINE N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE ab = np . array ( [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( N ) ] ) NEW_LINE idx_ab = np . argsort ( ab [ : , 0 ] ) NEW_LINE ab = ab [ idx_ab , : ] NEW_LINE k_sum = 0 NEW_LINE for record in ab : NEW_LINE INDENT a = record [ 0 ] NEW_LINE b = record [ 1 ] NEW_LINE k_sum += b NEW_LINE if k_sum >= K : NEW_LINE INDENT print ( a ) NEW_LINE break NEW_LINE DEDENT DEDENT", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT N , K = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE dict = { } NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT s1 , s2 = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE if s1 not in dict : NEW_LINE INDENT dict [ s1 ] = s2 NEW_LINE DEDENT else : NEW_LINE INDENT dict [ s1 ] += s2 NEW_LINE DEDENT DEDENT index = 0 NEW_LINE for k , v in sorted ( dict . items ( ) ) : NEW_LINE INDENT index += v NEW_LINE if ( index >= K ) : NEW_LINE INDENT ans = k NEW_LINE break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "ab = [ 0 ] * ( 10 ** 5 + 1 ) NEW_LINE lis = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( lis [ 0 ] ) : NEW_LINE INDENT t = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ab [ t [ 0 ] ] += t [ 1 ] NEW_LINE DEDENT ans = 0 NEW_LINE i = 1 NEW_LINE count = 0 NEW_LINE while count < lis [ 1 ] : NEW_LINE INDENT count += ab [ i ] NEW_LINE ans = i NEW_LINE i += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE fastinput = sys . stdin . readline NEW_LINE N , K = map ( int , fastinput ( ) . split ( ) ) NEW_LINE data = [ [ int ( j ) for j in fastinput ( ) . split ( ) ] for k in range ( N ) ] NEW_LINE ab = sorted ( data , key = lambda x : x [ 0 ] ) NEW_LINE number = 0 NEW_LINE for a , b in ab : NEW_LINE INDENT number += b NEW_LINE if number >= K : NEW_LINE INDENT print ( a ) NEW_LINE break NEW_LINE DEDENT DEDENT" ]
atcoder_agc020_B
[ "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; long [ ] a = new long [ K ] ; for ( int i = 0 ; i < K ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; long max = 2 ; long min = 2 ; for ( int i = K - 1 ; i >= 0 ; i -- ) { min = ( ( min - 1 ) / a [ i ] + 1 ) * a [ i ] ; max = ( ( max ) / a [ i ] ) * a [ i ] + a [ i ] - 1 ; if ( min > max ) { System . out . println ( - 1 ) ; return ; } } System . out . println ( min + \" ▁ \" + max ) ; } }", "import java . io . FileNotFoundException ; import java . util . Arrays ; import java . util . Scanner ; class Main { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; long [ ] A = new long [ K ] ; for ( int i = 0 ; i < K ; ++ i ) { A [ i ] = sc . nextLong ( ) ; } long max = 2 ; long min = 2 ; for ( int i = K - 1 ; i >= 0 ; -- i ) { if ( max < A [ i ] ) { System . out . println ( - 1 ) ; return ; } max = max / A [ i ] * A [ i ] ; min = ( min + A [ i ] - 1 ) / A [ i ] * A [ i ] ; max += A [ i ] - 1 ; if ( max < min ) { System . out . println ( - 1 ) ; return ; } } System . out . println ( min + \" ▁ \" + max ) ; } 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 ) { int k = sc . nextInt ( ) ; long a [ ] = new long [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { a [ k - i - 1 ] = sc . nextInt ( ) ; } if ( a [ 0 ] != 2 ) { System . out . println ( - 1 ) ; return ; } long min = 2 ; long max = 2 ; for ( int i = 0 ; i < k - 1 ; i ++ ) { min = a [ i + 1 ] * ( ( min + a [ i + 1 ] - 1 ) / a [ i + 1 ] ) ; max = a [ i + 1 ] * ( ( max + a [ i ] - 1 ) / a [ i + 1 ] ) ; long minA = a [ i + 1 ] * ( ( min + a [ i + 1 ] - 1 ) / a [ i + 1 ] ) ; if ( minA > max ) { System . out . println ( - 1 ) ; return ; } } max += a [ k - 1 ] - 1 ; System . out . println ( min + \" ▁ \" + max ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { private void doit ( ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int n = sc . nextInt ( ) ; int [ ] data = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { data [ i ] = sc . nextInt ( ) ; } long min = 2 ; long max = 2 ; boolean flg = true ; for ( int i = n - 1 ; i >= 0 ; i -- ) { int now = data [ i ] ; long tempmin = now * ( min / now + ( min % now == 0 ? 0 : 1 ) ) ; long tempmax = now * ( max / now + 1 ) - 1 ; if ( ! ( min <= tempmin / now * now && tempmin / now * now <= max ) ) { flg = false ; break ; } if ( ! ( min <= tempmax / now * now && tempmax / now * now <= max ) ) { flg = false ; break ; } min = tempmin ; max = tempmax ; } if ( flg ) { System . out . println ( min + \" ▁ \" + max ) ; } else { System . out . println ( - 1 ) ; } } } private void debug ( Object ... o ) { System . out . println ( \" debug ▁ = ▁ \" + Arrays . deepToString ( o ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . doit ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long max = 2 ; long min = 2 ; for ( int i = k - 1 ; i >= 0 ; i -- ) { max = ( long ) Math . floor ( ( double ) max / a [ i ] ) * a [ i ] + a [ i ] - 1 ; min = ( long ) Math . ceil ( ( double ) min / a [ i ] ) * a [ i ] ; } if ( max < min ) { System . out . println ( - 1 ) ; } else { System . out . println ( min + \" ▁ \" + max ) ; } } }" ]
[ "import math NEW_LINE K = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) [ : : - 1 ] NEW_LINE mi = 2 NEW_LINE ma = 2 NEW_LINE res = 0 NEW_LINE for i in range ( K ) : NEW_LINE INDENT if ( mi % A [ i ] ) and ( ma % A [ i ] ) and ( ( mi // A [ i ] ) == ( ma // A [ i ] ) ) : NEW_LINE INDENT res = - 1 NEW_LINE break NEW_LINE DEDENT mi = math . ceil ( mi / A [ i ] ) * A [ i ] NEW_LINE ma = math . floor ( ma / A [ i ] ) * A [ i ] + A [ i ] - 1 NEW_LINE DEDENT if res == - 1 : NEW_LINE INDENT print ( res ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( mi , ma ) 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 k = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE if a [ - 1 ] != 2 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT lower = 2 NEW_LINE upper = 3 NEW_LINE exist = True NEW_LINE for ai in a [ - 2 : : - 1 ] : NEW_LINE INDENT if lower % ai > 0 and upper % ai > 0 and lower // ai == upper // ai : NEW_LINE INDENT exist = False NEW_LINE print ( - 1 ) NEW_LINE break NEW_LINE DEDENT lower = - ( - lower // ai ) * ai NEW_LINE upper = ( upper // ai ) * ai + ( ai - 1 ) NEW_LINE DEDENT if exist : NEW_LINE INDENT print ( lower , upper ) NEW_LINE DEDENT DEDENT", "from functools import reduce NEW_LINE from math import floor , ceil NEW_LINE K = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE R = reduce ( lambda acc , a : ( acc if acc [ 0 ] > acc [ 1 ] else ( a * ceil ( acc [ 0 ] / a ) , a * ( floor ( acc [ 1 ] / a ) + 1 ) - 1 ) ) , reversed ( A ) , ( 2 , 2 ) ) NEW_LINE ans = - 1 if R [ 0 ] > R [ 1 ] else ' ▁ ' . join ( map ( str , R ) ) NEW_LINE print ( ans ) NEW_LINE", "def ceil ( a , b ) : NEW_LINE INDENT return - ( ( - a ) // b ) NEW_LINE DEDENT def floor ( a , b ) : NEW_LINE INDENT return a // b NEW_LINE DEDENT K = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE L = [ 0 for i in range ( K + 1 ) ] NEW_LINE R = [ 0 for i in range ( K + 1 ) ] NEW_LINE L [ K ] = 2 NEW_LINE R [ K ] = 2 NEW_LINE for i in range ( 1 , K + 1 ) [ : : - 1 ] : NEW_LINE INDENT L [ i - 1 ] = ceil ( L [ i ] , A [ i - 1 ] ) * A [ i - 1 ] NEW_LINE R [ i - 1 ] = floor ( R [ i ] , A [ i - 1 ] ) * A [ i - 1 ] + A [ i - 1 ] - 1 NEW_LINE DEDENT if L [ 0 ] <= R [ 0 ] : NEW_LINE INDENT print ( L [ 0 ] , R [ 0 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT", "k = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def g ( n , a , k ) : NEW_LINE INDENT for i in range ( k ) : NEW_LINE INDENT n = n - ( n % a [ i ] ) NEW_LINE DEDENT return n NEW_LINE DEDENT s = 0 NEW_LINE t = 2 + k * max ( a ) NEW_LINE while t - s > 1 : NEW_LINE INDENT m = ( s + t ) // 2 NEW_LINE if g ( m , a , k ) > 2 : NEW_LINE INDENT t = m NEW_LINE DEDENT else : NEW_LINE INDENT s = m NEW_LINE DEDENT DEDENT p = 0 NEW_LINE q = 2 + k * max ( a ) NEW_LINE while q - p > 1 : NEW_LINE INDENT m = ( p + q ) // 2 NEW_LINE if g ( m , a , k ) >= 2 : NEW_LINE INDENT q = m NEW_LINE DEDENT else : NEW_LINE INDENT p = m NEW_LINE DEDENT DEDENT c = 1 NEW_LINE if g ( s , a , k ) == 2 : NEW_LINE INDENT res = s NEW_LINE DEDENT elif g ( t , a , k ) == 2 : NEW_LINE INDENT res = t NEW_LINE DEDENT else : NEW_LINE INDENT c = - 1 NEW_LINE DEDENT if g ( q , a , k ) == 2 : NEW_LINE INDENT res2 = q NEW_LINE DEDENT elif g ( p , a , k ) == 2 : NEW_LINE INDENT res2 = p NEW_LINE DEDENT else : NEW_LINE INDENT c = - 1 NEW_LINE DEDENT if c == 1 : NEW_LINE INDENT print ( res2 , res ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT" ]
atcoder_agc018_A
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long [ ] map = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { map [ i ] = sc . nextLong ( ) ; } Arrays . sort ( map ) ; int index = Arrays . binarySearch ( map , K ) ; if ( index >= 0 ) { System . out . println ( \" POSSIBLE \" ) ; return ; } if ( ~ index >= N ) { System . out . println ( \" IMPOSSIBLE \" ) ; return ; } for ( int i = 0 ; i < ( N - 1 ) ; i ++ ) { long A = map [ i ] ; if ( Arrays . binarySearch ( map , A + 1 ) >= 0 || Arrays . binarySearch ( map , A - 1 ) >= 0 ) { System . out . println ( \" POSSIBLE \" ) ; return ; } if ( Arrays . binarySearch ( map , A + A + 1 ) >= 0 || Arrays . binarySearch ( map , A - A - 1 ) >= 0 ) { System . out . println ( \" POSSIBLE \" ) ; return ; } if ( A > K && Arrays . binarySearch ( map , A - K ) >= 0 ) { System . out . println ( \" POSSIBLE \" ) ; return ; } } System . out . println ( \" IMPOSSIBLE \" ) ; } }", "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 ( ) ; int K = sc . nextInt ( ) ; String ans = \" IMPOSSIBLE \" ; int div = sc . nextInt ( ) ; int max = div ; if ( div == K ) ans = \" POSSIBLE \" ; for ( int i = 1 ; i < n ; i ++ ) { int cur = sc . nextInt ( ) ; if ( cur == K ) { ans = \" POSSIBLE \" ; break ; } div = gcd ( div , cur ) ; max = Math . max ( max , cur ) ; } if ( max > K && ( max - K ) % div == 0 ) ans = \" POSSIBLE \" ; System . out . println ( ans ) ; } static int gcd ( int a , int b ) { if ( a < b ) { int med = b ; b = a ; a = med ; } while ( a % b != 0 ) { int s = a ; a = b ; b = s % a ; } return b ; } }", "import java . util . * ; public class Main { int [ ] a ; int cost ; int N ; int [ ] dp ; int INF = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; int M = 0 ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; M = Math . max ( M , A [ i ] ) ; } long g = A [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { g = gcd ( g , A [ i ] ) ; } if ( K % g == 0 && K <= M ) { System . out . println ( \" POSSIBLE \" ) ; } else { System . out . println ( \" IMPOSSIBLE \" ) ; } } long gcd ( long n , long m ) { if ( n < m ) { return gcd ( m , n ) ; } if ( m == 0 ) { return n ; } return gcd ( m , n % m ) ; } }", "import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int m = a ; int g = a ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int b = sc . nextInt ( ) ; m = max ( m , b ) ; g = gcd ( a , b ) ; a = b ; } if ( k <= m && k % g == 0 ) out . println ( \" POSSIBLE \" ) ; else out . println ( \" IMPOSSIBLE \" ) ; } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int GCD = getGCD ( a ) ; Boolean B = false ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= K && ( a [ i ] - K ) % GCD == 0 ) { B = true ; } } if ( B ) { System . out . println ( \" POSSIBLE \" ) ; } else { System . out . println ( \" IMPOSSIBLE \" ) ; } } static int getGCD ( int a , int b ) { if ( a < b ) { int c = a ; a = b ; b = c ; } if ( a % b == 0 ) { return b ; } else { return getGCD ( b , a % b ) ; } } static int getGCD ( int [ ] a ) { int gcd = a [ 0 ] ; int l = a . length ; for ( int i = 1 ; i < l ; i ++ ) { gcd = getGCD ( gcd , a [ i ] ) ; } return gcd ; } }" ]
[ "from functools import reduce NEW_LINE from fractions import gcd NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE M = reduce ( gcd , A ) NEW_LINE if K <= A [ - 1 ] and K % M == 0 : print ( \" POSSIBLE \" ) NEW_LINE else : print ( \" IMPOSSIBLE \" ) NEW_LINE", "def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : return a NEW_LINE return gcd ( b , a % b ) NEW_LINE DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE g = a [ 0 ] NEW_LINE for aa in a : NEW_LINE INDENT g = gcd ( g , aa ) NEW_LINE DEDENT d = ( max ( a ) - K ) NEW_LINE if d >= 0 : NEW_LINE INDENT if d % g == 0 : NEW_LINE INDENT print ( ' POSSIBLE ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' IMPOSSIBLE ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' IMPOSSIBLE ' ) NEW_LINE DEDENT", "from functools import reduce NEW_LINE def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT return gcd ( b , a % b ) NEW_LINE DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE lst_A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE max_A = max ( lst_A ) NEW_LINE gcd_A = reduce ( gcd , lst_A ) NEW_LINE ans = \" IMPOSSIBLE \" NEW_LINE if K % gcd_A == 0 and K <= max_A : NEW_LINE INDENT ans = \" POSSIBLE \" NEW_LINE DEDENT print ( ans ) NEW_LINE", "import fractions as fr NEW_LINE from functools import reduce NEW_LINE def gcd ( a ) : NEW_LINE INDENT return reduce ( fr . gcd , a ) NEW_LINE DEDENT n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE g = gcd ( a ) NEW_LINE print ( \" POSSIBLE \" if ( k in a ) or ( max ( a ) >= k and ( g == 1 or k % g == 0 ) ) else \" IMPOSSIBLE \" ) NEW_LINE", "def gcd ( x , y ) : NEW_LINE INDENT if y == 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( y , x % y ) NEW_LINE DEDENT DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE G = A [ 0 ] NEW_LINE for a in A : NEW_LINE INDENT G = gcd ( a , G ) NEW_LINE DEDENT print ( ' POSSIBLE ' if K % G == 0 and K <= max ( A ) else ' IMPOSSIBLE ' ) NEW_LINE" ]
atcoder_arc046_A
[ "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 ( ) ; int c = 1 ; int [ ] ans = new int [ n + 1 ] ; int i = 1 ; while ( c <= n ) { if ( d ( i ) ) { ans [ c ++ ] = i ; } i ++ ; } out . println ( ans [ n ] ) ; } static boolean d ( int i ) { String s = String . valueOf ( i ) ; HashSet < Character > k = new HashSet < > ( ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { k . add ( s . charAt ( j ) ) ; } return k . size ( ) == 1 ; } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) , len , i , j = 0 , k ; sc . close ( ) ; String tmp ; for ( i = 1 ; j < N ; ++ i ) { tmp = Integer . toString ( i ) ; len = tmp . length ( ) ; for ( k = 1 ; k < len ; ++ k ) { if ( tmp . charAt ( k - 1 ) != tmp . charAt ( k ) ) break ; } if ( k == len ) ++ j ; } System . out . println ( i - 1 ) ; } }", "public class Main { public static void main ( String [ ] $ ) { int n = new java . util . Scanner ( System . in ) . nextInt ( ) - 1 ; System . out . println ( ( n % 9 + 1 ) * ( int ) ( 10 / 9d * Math . pow ( 10 , n / 9 ) ) ) ; } }", "import java . util . Scanner ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int [ ] supportiveArray = { 1 , 11 , 111 , 1111 , 11111 , 111111 } ; int [ ] repdigitArray = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; ArrayList < Integer > repdigitList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 6 ; i ++ ) { int support = supportiveArray [ i ] ; for ( int j = 0 ; j < 9 ; j ++ ) { int repdigit = repdigitArray [ j ] ; int repdigitPattern = support * repdigit ; repdigitList . add ( repdigitPattern ) ; } } System . out . println ( repdigitList . get ( N - 1 ) ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int j = sc . nextInt ( ) ; int num = ( j - 1 ) % 9 + 1 ; int time = ( j + 8 ) / 9 ; for ( int i = 0 ; i < time ; i ++ ) { System . out . print ( num ) ; } System . out . println ( ) ; } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE n = N // 9 + 1 if N % 9 != 0 else N // 9 NEW_LINE a = N % 9 if N % 9 != 0 else 9 NEW_LINE print ( str ( a ) * n ) NEW_LINE", "def same ( i ) : NEW_LINE INDENT return len ( set ( c for c in str ( i ) ) ) == 1 NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE i = 0 NEW_LINE while n > 0 : NEW_LINE INDENT i += 1 NEW_LINE if same ( i ) : NEW_LINE INDENT n -= 1 NEW_LINE DEDENT DEDENT print ( i ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE list = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] NEW_LINE for i in range ( 10 , 100 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 101 , 1000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 1001 , 10000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] and temp [ 2 ] == temp [ 3 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 10001 , 100000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] and temp [ 2 ] == temp [ 3 ] and temp [ 3 ] == temp [ 4 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 100001 , 1000000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] and temp [ 2 ] == temp [ 3 ] and temp [ 3 ] == temp [ 4 ] and temp [ 4 ] == temp [ 5 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT print ( list [ N - 1 ] ) NEW_LINE", "def a_repdigit ( N ) : NEW_LINE INDENT from itertools import repeat NEW_LINE count , digit = 1 , 0 NEW_LINE while True : NEW_LINE INDENT for k in range ( 1 , 10 ) : NEW_LINE INDENT if count == N : NEW_LINE INDENT return ' ' . join ( map ( str , repeat ( k , digit + 1 ) ) ) NEW_LINE DEDENT count += 1 NEW_LINE DEDENT digit += 1 NEW_LINE DEDENT return None NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE print ( a_repdigit ( N ) ) NEW_LINE", "print ( sorted ( [ s * str ( i ) for i in range ( 1 , 10 ) for s in range ( 1 , 7 ) ] , key = lambda x : len ( x ) ) [ int ( input ( ) ) - 1 ] ) NEW_LINE" ]
atcoder_arc072_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; sc . close ( ) ; long count1 = 0 ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( i % 2 == 0 && sum <= 0 ) { count1 += 1 - sum ; sum = 1 ; } else if ( i % 2 == 1 && sum >= 0 ) { count1 += sum + 1 ; sum = - 1 ; } } sum = 0 ; long count2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( i % 2 == 1 && sum <= 0 ) { count2 += 1 - sum ; sum = 1 ; } else if ( i % 2 == 0 && sum >= 0 ) { count2 += sum + 1 ; sum = - 1 ; } } System . out . println ( Math . min ( count1 , count2 ) ) ; } }", "import java . io . IOException ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . concurrent . SynchronousQueue ; class Main { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = sc . nextLong ( ) ; } long [ ] sum = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { sum [ i ] = ( i > 0 ? sum [ i - 1 ] : 0 ) + a [ i ] ; } long ans = Long . MAX_VALUE / 16 ; int [ ] sign = { - 1 , 1 } ; for ( int f = 0 ; f <= 1 ; ++ f ) { long d = 0 ; long cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( sign [ ( i + f ) % 2 ] == sign ( sum [ i ] + d ) ) continue ; cnt += Math . abs ( sign [ ( i + f ) % 2 ] - ( sum [ i ] + d ) ) ; d += sign [ ( i + f ) % 2 ] - ( sum [ i ] + d ) ; } ans = Math . min ( ans , cnt ) ; } System . out . println ( ans ) ; } int sign ( long x ) { return Long . compare ( x , 0 ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static int n ; public static long [ ] nums ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; n = Integer . parseInt ( br . readLine ( ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; nums = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) nums [ i ] = Long . parseLong ( st . nextToken ( ) ) ; long sum = nums [ 0 ] ; if ( sum == 0 ) pw . println ( Math . min ( solve ( 1L , 1L ) , solve ( - 1L , 1L ) ) ) ; else if ( sum > 0 ) pw . println ( Math . min ( solve ( sum , 0L ) , solve ( - 1L , sum + 1L ) ) ) ; else if ( sum < 0 ) pw . println ( Math . min ( solve ( sum , 0L ) , solve ( 1L , - sum + 1L ) ) ) ; br . close ( ) ; pw . close ( ) ; System . exit ( 0 ) ; } public static long solve ( long sum , long ans ) { for ( int i = 1 ; i < n ; i ++ ) { long num = nums [ i ] ; if ( sum > 0 ) { sum += num ; if ( sum >= 0 ) { ans += sum + 1 ; sum = - 1 ; } } else if ( sum < 0 ) { sum += num ; if ( sum <= 0 ) { ans += - sum + 1 ; sum = 1 ; } } } return ans ; } }", "import java . util . Arrays ; 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 ( ) ; long sumOfP = sc . nextLong ( ) ; long countP = 0 ; long sumOfM = sumOfP ; long countM = 0 ; if ( sumOfP <= 0 ) { countP = - sumOfP + 1 ; sumOfP = 1 ; } if ( sumOfM >= 0 ) { countM = sumOfM + 1 ; sumOfM = - 1 ; } for ( int i = 1 ; i < n ; i ++ ) { long a = sc . nextLong ( ) ; if ( sumOfP > 0 ) { if ( sumOfP + a >= 0 ) { countP += sumOfP + a + 1 ; sumOfP = - 1 ; } else { sumOfP += a ; } } else { if ( sumOfP + a <= 0 ) { countP += - ( sumOfP + a ) + 1 ; sumOfP = 1 ; } else { sumOfP += a ; } } if ( sumOfM > 0 ) { if ( sumOfM + a >= 0 ) { countM += sumOfM + a + 1 ; sumOfM = - 1 ; } else { sumOfM += a ; } } else { if ( sumOfM + a <= 0 ) { countM += - ( sumOfM + a ) + 1 ; sumOfM = 1 ; } else { sumOfM += a ; } } } System . out . println ( Math . min ( countP , countM ) ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static int n ; public static void main ( String [ ] __ ) { n = s . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextInt ( ) ; if ( a [ 0 ] != 0 ) { long r1 = solve ( Arrays . copyOf ( a , a . length ) ) ; long r2 = Math . abs ( a [ 0 ] ) + 1 ; a [ 0 ] = - a [ 0 ] / Math . abs ( a [ 0 ] ) ; r2 += solve ( Arrays . copyOf ( a , a . length ) ) ; System . out . println ( Math . min ( r1 , r2 ) ) ; } else { a [ 0 ] = 1 ; long r1 = 1 + solve ( Arrays . copyOf ( a , a . length ) ) ; a [ 0 ] = - 1 ; long r2 = 1 + solve ( Arrays . copyOf ( a , a . length ) ) ; System . out . println ( Math . min ( r1 , r2 ) ) ; } } private static final long solve ( long [ ] a ) { long sum [ ] = new long [ n ] ; sum [ 0 ] = a [ 0 ] ; long res = 0 ; for ( int i = 1 ; i < n ; i ++ ) { sum [ i ] = a [ i ] + sum [ i - 1 ] ; if ( sum [ i - 1 ] > 0 ) { long t = - sum [ i - 1 ] - 1 ; if ( a [ i ] > t ) { res += a [ i ] - t ; a [ i ] = t ; } } else { long t = - sum [ i - 1 ] + 1 ; if ( a [ i ] < t ) { res += t - a [ i ] ; a [ i ] = t ; } } sum [ i ] = a [ i ] + sum [ i - 1 ] ; } return res ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count1 = a [ 0 ] NEW_LINE count2 = a [ 0 ] NEW_LINE answer1 = 0 NEW_LINE answer2 = 0 NEW_LINE if a [ 0 ] <= 0 : NEW_LINE INDENT answer1 += ( 1 - a [ 0 ] ) NEW_LINE count1 = 1 NEW_LINE DEDENT if a [ 0 ] >= 0 : NEW_LINE INDENT answer2 += ( 1 + a [ 0 ] ) NEW_LINE count2 = - 1 NEW_LINE DEDENT for i in a [ 1 : ] : NEW_LINE INDENT if ( count1 > 0 and count1 + i < 0 ) or ( count1 < 0 and count1 + i > 0 ) : NEW_LINE INDENT count1 += i NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT answer1 += abs ( count1 + i ) + 1 NEW_LINE if count1 > 0 : NEW_LINE INDENT count1 = - 1 NEW_LINE DEDENT else : NEW_LINE INDENT count1 = 1 NEW_LINE DEDENT DEDENT DEDENT for i in a [ 1 : ] : NEW_LINE INDENT if ( count2 > 0 and count2 + i < 0 ) or ( count2 < 0 and count2 + i > 0 ) : NEW_LINE INDENT count2 += i NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT answer2 += abs ( count2 + i ) + 1 NEW_LINE if count2 > 0 : NEW_LINE INDENT count2 = - 1 NEW_LINE DEDENT else : NEW_LINE INDENT count2 = 1 NEW_LINE DEDENT DEDENT DEDENT print ( min ( answer1 , answer2 ) ) NEW_LINE", "def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def count ( N , A , initSum ) : NEW_LINE INDENT sm = initSum NEW_LINE cnt = abs ( sm - A [ 0 ] ) NEW_LINE db ( cnt ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT nextSum = sm + A [ i + 1 ] NEW_LINE db ( ( sm , nextSum ) ) NEW_LINE if sm > 0 and nextSum >= 0 : NEW_LINE INDENT cnt += abs ( nextSum ) + 1 NEW_LINE sm = - 1 NEW_LINE DEDENT elif sm < 0 and nextSum <= 0 : NEW_LINE INDENT cnt += abs ( nextSum ) + 1 NEW_LINE sm = 1 NEW_LINE DEDENT else : NEW_LINE INDENT sm = nextSum NEW_LINE DEDENT db ( cnt ) NEW_LINE DEDENT return cnt NEW_LINE DEDENT def probC ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE db ( ( N , A ) ) NEW_LINE if A [ 0 ] != 0 : NEW_LINE INDENT initSum = A [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT initSum = 1 NEW_LINE DEDENT cnt1 = count ( N , A , initSum ) NEW_LINE db ( ( ' a [ 0 ] ▁ or ▁ + 1 : ▁ ' , cnt1 ) ) NEW_LINE if initSum > 0 : NEW_LINE INDENT cnt2 = count ( N , A , - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT cnt2 = count ( N , A , 1 ) NEW_LINE DEDENT db ( ( ' ? ? ? ? ▁ or ▁ - 1 : ▁ ' , cnt2 ) ) NEW_LINE return min ( cnt1 , cnt2 ) NEW_LINE DEDENT debug = False NEW_LINE print ( probC ( ) ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 6 ) NEW_LINE _ = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def solve ( i , s , k , sign ) : NEW_LINE INDENT if i >= len ( A ) : NEW_LINE INDENT return k NEW_LINE DEDENT if sign * ( s + A [ i ] ) > 0 : NEW_LINE INDENT return solve ( i + 1 , s + A [ i ] , k , sign * - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT return solve ( i + 1 , sign , k + abs ( s + A [ i ] ) + 1 , sign * - 1 ) NEW_LINE DEDENT DEDENT print ( min ( solve ( 0 , 0 , 0 , 1 ) , solve ( 0 , 0 , 0 , - 1 ) ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Pnum = 0 NEW_LINE Psum = 0 NEW_LINE if L [ 0 ] >= 1 : NEW_LINE INDENT Pnum = L [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT Psum = 1 - L [ 0 ] NEW_LINE Pnum = 1 NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT if i % 2 == 1 : NEW_LINE INDENT if Pnum + L [ i ] <= - 1 : NEW_LINE INDENT Pnum = Pnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Psum += ( Pnum + L [ i ] + 1 ) NEW_LINE Pnum = - 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if Pnum + L [ i ] >= 1 : NEW_LINE INDENT Pnum = Pnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Psum += ( 1 - Pnum - L [ i ] ) NEW_LINE Pnum = 1 NEW_LINE DEDENT DEDENT DEDENT Mnum = 0 NEW_LINE Msum = 0 NEW_LINE if L [ 0 ] <= - 1 : NEW_LINE INDENT Mnum = L [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT Msum = L [ 0 ] + 1 NEW_LINE Mnum = - 1 NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT if Mnum + L [ i ] <= - 1 : NEW_LINE INDENT Mnum = Mnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Msum += ( Mnum + L [ i ] + 1 ) NEW_LINE Mnum = - 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if Mnum + L [ i ] >= 1 : NEW_LINE INDENT Mnum = Mnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Msum += ( 1 - Mnum - L [ i ] ) NEW_LINE Mnum = 1 NEW_LINE DEDENT DEDENT DEDENT print ( min ( Psum , Msum ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE ans1 = 0 NEW_LINE ans2 = 0 NEW_LINE sum1 = 0 NEW_LINE sum2 = 0 NEW_LINE flag = True NEW_LINE for i in range ( len ( A ) ) : NEW_LINE INDENT sum1 = sum1 + A [ i ] NEW_LINE sum2 = sum2 + A [ i ] NEW_LINE flag = not ( flag ) NEW_LINE if flag : NEW_LINE INDENT if sum1 > 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans1 += abs ( 1 - sum1 ) NEW_LINE sum1 = 1 NEW_LINE DEDENT if sum2 < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans2 += abs ( - 1 - sum2 ) NEW_LINE sum2 = - 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if sum2 > 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans2 += abs ( 1 - sum2 ) NEW_LINE sum2 = 1 NEW_LINE DEDENT if sum1 < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans1 += abs ( - 1 - sum1 ) NEW_LINE sum1 = - 1 NEW_LINE DEDENT DEDENT DEDENT print ( min ( ans1 , ans2 ) ) NEW_LINE" ]
atcoder_abc088_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] [ ] grid = new int [ w ] [ h ] ; int wCount = 0 ; for ( int i = 0 ; i < h ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < w ; j ++ ) { if ( s . charAt ( j ) == ' . ' ) { grid [ j ] [ i ] = - 1 ; wCount ++ ; } else { grid [ j ] [ i ] = Integer . MIN_VALUE ; } } } grid [ 0 ] [ 0 ] = 0 ; for ( int i = 0 ; i < wCount ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { for ( int k = 0 ; k < h ; k ++ ) { if ( grid [ j ] [ k ] == i ) { if ( j != 0 ) { if ( grid [ j - 1 ] [ k ] == - 1 ) { grid [ j - 1 ] [ k ] = i + 1 ; } } if ( j != w - 1 ) { if ( grid [ j + 1 ] [ k ] == - 1 ) { grid [ j + 1 ] [ k ] = i + 1 ; } } if ( k != 0 ) { if ( grid [ j ] [ k - 1 ] == - 1 ) { grid [ j ] [ k - 1 ] = i + 1 ; } } if ( k != h - 1 ) { if ( grid [ j ] [ k + 1 ] == - 1 ) { grid [ j ] [ k + 1 ] = i + 1 ; } } } } } if ( grid [ w - 1 ] [ h - 1 ] != - 1 ) { System . out . println ( wCount - grid [ w - 1 ] [ h - 1 ] - 1 ) ; return ; } } System . out . println ( - 1 ) ; } }" ]
[ "from collections import deque NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE G = [ list ( input ( ) ) for i in range ( H ) ] NEW_LINE first_black = sum ( [ row . count ( ' # ' ) for row in G ] ) NEW_LINE que = deque ( [ ( 0 , 0 ) ] ) NEW_LINE dist = [ [ - 1 ] * W for i in range ( H ) ] NEW_LINE dist [ 0 ] [ 0 ] = 0 NEW_LINE direction = [ ( 0 , 1 ) , ( 0 , - 1 ) , ( 1 , 0 ) , ( - 1 , 0 ) ] NEW_LINE while que : NEW_LINE INDENT nh , nw = que . pop ( ) NEW_LINE for dh , dw in direction : NEW_LINE INDENT if not ( ( 0 <= nh + dh < H ) & ( 0 <= nw + dw < W ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT if G [ nh + dh ] [ nw + dw ] == ' # ' : NEW_LINE INDENT continue NEW_LINE DEDENT if dist [ nh + dh ] [ nw + dw ] > 0 : NEW_LINE INDENT continue NEW_LINE DEDENT dist [ nh + dh ] [ nw + dw ] = dist [ nh ] [ nw ] + 1 NEW_LINE que . appendleft ( ( nh + dh , nw + dw ) ) NEW_LINE DEDENT DEDENT if dist [ - 1 ] [ - 1 ] != - 1 : NEW_LINE INDENT print ( H * W - dist [ - 1 ] [ - 1 ] - first_black - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT", "import queue NEW_LINE h , w = [ int ( i ) for i in input ( ) . split ( \" ▁ \" ) ] NEW_LINE s = [ \" \" for i in range ( 0 , h ) ] NEW_LINE for i in range ( 0 , h ) : NEW_LINE INDENT s [ i ] = input ( ) NEW_LINE DEDENT b = [ [ False for j in range ( 0 , w ) ] for i in range ( 0 , h ) ] NEW_LINE c = 0 NEW_LINE for i in range ( 0 , h ) : NEW_LINE INDENT for j in range ( 0 , w ) : NEW_LINE INDENT if s [ i ] [ j ] == \" . \" : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT DEDENT q = queue . Queue ( ) NEW_LINE q . put ( [ 0 , 0 , 0 ] ) NEW_LINE b [ 0 ] [ 0 ] = True NEW_LINE def addq ( i , j , d ) : NEW_LINE INDENT global b NEW_LINE global q NEW_LINE if 0 <= i and i < h and 0 <= j and j < w and not b [ i ] [ j ] and s [ i ] [ j ] == \" . \" : NEW_LINE INDENT b [ i ] [ j ] = True NEW_LINE q . put ( [ i , j , d ] ) NEW_LINE DEDENT DEDENT f = False NEW_LINE while not q . empty ( ) : NEW_LINE INDENT qi = q . get ( ) NEW_LINE if qi [ 0 ] == h - 1 and qi [ 1 ] == w - 1 : NEW_LINE INDENT f = True NEW_LINE print ( c - qi [ 2 ] - 1 ) NEW_LINE break NEW_LINE DEDENT i = qi [ 0 ] NEW_LINE j = qi [ 1 ] NEW_LINE addq ( i + 1 , j , qi [ 2 ] + 1 ) NEW_LINE addq ( i , j + 1 , qi [ 2 ] + 1 ) NEW_LINE addq ( i - 1 , j , qi [ 2 ] + 1 ) NEW_LINE addq ( i , j - 1 , qi [ 2 ] + 1 ) NEW_LINE DEDENT if not f : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT", "from collections import deque , Counter NEW_LINE from functools import reduce NEW_LINE H , W = map ( int , input ( ) . split ( \" ▁ \" ) ) NEW_LINE area_info = [ input ( ) for _ in range ( H ) ] NEW_LINE is_visit = [ [ False for _ in range ( W ) ] for _ in range ( H ) ] NEW_LINE next_search = deque ( [ [ 0 , 0 , 0 ] , ] ) NEW_LINE def get_shortest_step ( ) : NEW_LINE INDENT shortest_step = - 1 NEW_LINE while len ( next_search ) > 0 : NEW_LINE INDENT nowx , nowy , now_step = next_search . pop ( ) NEW_LINE if is_visit [ nowx ] [ nowy ] : NEW_LINE INDENT continue NEW_LINE DEDENT is_visit [ nowx ] [ nowy ] = True NEW_LINE for stepx , stepy in [ ( 1 , 0 ) , ( 0 , 1 ) , ( - 1 , 0 ) , ( 0 , - 1 ) ] : NEW_LINE INDENT nextx = nowx + stepx NEW_LINE nexty = nowy + stepy NEW_LINE if nextx == H - 1 and nexty == W - 1 : NEW_LINE INDENT shortest_step = now_step + 1 NEW_LINE return shortest_step NEW_LINE DEDENT if 0 <= nextx < H and 0 <= nexty < W : NEW_LINE INDENT if is_visit [ nextx ] [ nexty ] or area_info [ nextx ] [ nexty ] == \" # \" : NEW_LINE INDENT continue NEW_LINE DEDENT next_search . appendleft ( [ nextx , nexty , now_step + 1 ] ) NEW_LINE DEDENT DEDENT DEDENT return shortest_step NEW_LINE DEDENT shortest_step = get_shortest_step ( ) NEW_LINE c = Counter ( \" \" . join ( area_info ) ) NEW_LINE if shortest_step == - 1 : NEW_LINE INDENT print ( \" - 1\" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( c [ ' . ' ] - shortest_step - 1 ) NEW_LINE DEDENT", "h , w = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ [ \" # \" ] * ( w + 2 ) ] + [ [ \" # \" ] + list ( input ( ) ) + [ \" # \" ] for i in range ( h ) ] + [ [ \" # \" ] * ( w + 2 ) ] NEW_LINE p = [ [ 1 , 1 ] ] NEW_LINE d = 0 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 d += 1 NEW_LINE DEDENT DEDENT DEDENT s [ 1 ] [ 1 ] = \" # \" NEW_LINE k = 0 NEW_LINE while [ h , w ] not in p : NEW_LINE INDENT k += 1 NEW_LINE g = [ ] NEW_LINE for i in range ( len ( p ) ) : NEW_LINE INDENT x , y = p [ i ] [ 0 ] , p [ i ] [ 1 ] NEW_LINE if s [ x - 1 ] [ y ] == \" . \" : NEW_LINE INDENT s [ x - 1 ] [ y ] = \" Q \" NEW_LINE g . append ( [ x - 1 , y ] ) NEW_LINE DEDENT if s [ x + 1 ] [ y ] == \" . \" : NEW_LINE INDENT s [ x + 1 ] [ y ] = \" Q \" NEW_LINE g . append ( [ x + 1 , y ] ) NEW_LINE DEDENT if s [ x ] [ y + 1 ] == \" . \" : NEW_LINE INDENT s [ x ] [ y + 1 ] = \" Q \" NEW_LINE g . append ( [ x , y + 1 ] ) NEW_LINE DEDENT if s [ x ] [ y - 1 ] == \" . \" : NEW_LINE INDENT s [ x ] [ y - 1 ] = \" Q \" NEW_LINE g . append ( [ x , y - 1 ] ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT p = g NEW_LINE if len ( p ) == 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( d - k - 1 ) NEW_LINE DEDENT", "from collections import deque NEW_LINE h , w = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE s = [ input ( ) for _ in range ( h ) ] NEW_LINE dist = [ [ - 1 ] * w for _ in range ( h ) ] NEW_LINE black = 0 NEW_LINE for line in s : NEW_LINE INDENT black += line . count ( \" # \" ) NEW_LINE DEDENT que = deque ( ) NEW_LINE que . append ( [ 0 , 0 ] ) NEW_LINE dist [ 0 ] [ 0 ] = 1 NEW_LINE while que : NEW_LINE INDENT x , y = que . popleft ( ) NEW_LINE for i , j in [ ( 1 , 0 ) , ( - 1 , 0 ) , ( 0 , 1 ) , ( 0 , - 1 ) ] : NEW_LINE INDENT nx = x + i NEW_LINE ny = y + j NEW_LINE if nx < 0 or nx >= h or ny < 0 or ny >= w : NEW_LINE INDENT continue NEW_LINE DEDENT if s [ nx ] [ ny ] == \" # \" : NEW_LINE INDENT continue NEW_LINE DEDENT if dist [ nx ] [ ny ] == - 1 : NEW_LINE INDENT dist [ nx ] [ ny ] = dist [ x ] [ y ] + 1 NEW_LINE que . append ( [ nx , ny ] ) NEW_LINE DEDENT DEDENT DEDENT if dist [ h - 1 ] [ w - 1 ] == - 1 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( h * w - dist [ h - 1 ] [ w - 1 ] - black ) NEW_LINE DEDENT" ]
atcoder_abc033_A
[ "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long k = Arrays . stream ( br . readLine ( ) . split ( \" \" ) ) . distinct ( ) . count ( ) ; br . close ( ) ; if ( k == 1 ) { System . out . println ( \" SAME \" ) ; } else { System . out . println ( \" DIFFERENT \" ) ; } } }", "import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { set . add ( s . substring ( i , i + 1 ) ) ; } System . out . println ( set . size ( ) == 1 ? \" SAME \" : \" DIFFERENT \" ) ; } }", "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 ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String S = in . next ( ) ; String ans = \" SAME \" ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( i - 1 ) ) { ans = \" DIFFERENT \" ; 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 int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; out . println ( s . charAt ( 0 ) == s . charAt ( 1 ) && s . charAt ( 1 ) == s . charAt ( 2 ) && s . charAt ( 2 ) == s . charAt ( 3 ) ? \" SAME \" : \" DIFFERENT \" ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; if ( s . charAt ( 0 ) == s . charAt ( 1 ) && s . charAt ( 0 ) == s . charAt ( 2 ) && s . charAt ( 0 ) == s . charAt ( 3 ) ) out . println ( \" SAME \" ) ; else out . println ( \" DIFFERENT \" ) ; } } 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 ( ) ; } } }" ]
[ "N = input ( ) NEW_LINE nCnt = N . count ( N [ 0 ] ) NEW_LINE if nCnt == 4 : NEW_LINE INDENT print ( ' SAME ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' DIFFERENT ' ) NEW_LINE DEDENT", "print ( \" SAME \" if len ( set ( input ( ) ) ) == 1 else \" DIFFERENT \" ) NEW_LINE", "def password ( N : int ) -> bool : NEW_LINE INDENT s = set ( ( N // ( 10 ** i ) ) % 10 for i in range ( 4 ) ) NEW_LINE return len ( s ) == 1 NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE yes = password ( N ) NEW_LINE print ( ' SAME ' if yes else ' DIFFERENT ' ) NEW_LINE DEDENT", "N = input ( ) NEW_LINE x = N [ 0 ] NEW_LINE flag = True NEW_LINE for i in N : NEW_LINE INDENT if ( i != x ) : NEW_LINE INDENT flag = False NEW_LINE DEDENT x = i NEW_LINE DEDENT if ( flag ) : NEW_LINE INDENT print ( ' SAME ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' DIFFERENT ' ) NEW_LINE DEDENT", "n = input ( ) NEW_LINE print ( \" DIFFERENT \" if len ( set ( n ) ) != 1 else \" SAME \" ) NEW_LINE" ]
atcoder_abc021_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; System . out . println ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( 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 . math . BigDecimal ; 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 ( ) ; out . println ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { out . println ( 1 ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . 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 ( ) ; out . println ( n ) ; for ( int i = 0 ; i < n ; i ++ ) out . println ( 1 ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; System . out . println ( a ) ; for ( int i = 0 ; i < a ; i ++ ) { System . out . println ( \"1\" ) ; } } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int n = nextInt ( ) ; out . println ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { out . println ( 1 ) ; } } }" ]
[ "import sys NEW_LINE n = int ( sys . stdin . readline ( ) . rstrip ( ) ) NEW_LINE div , mod = divmod ( n , 2 ) NEW_LINE ans = 0 NEW_LINE if mod : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT ans += div NEW_LINE print ( ans ) NEW_LINE if mod : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT for _ in range ( div ) : NEW_LINE INDENT print ( 2 ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE for x in [ 8 , 4 , 2 , 1 ] : NEW_LINE INDENT while N >= x and N != 0 : NEW_LINE INDENT N -= x NEW_LINE ans . append ( x ) NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for x in ans : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT", "n = input ( ) NEW_LINE print ( n + \" \\n 1\" * int ( n ) ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE for i in range ( 2 ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( 2 ) : NEW_LINE INDENT for l in range ( 2 ) : NEW_LINE INDENT if i * 8 + j * 4 + k * 2 + l * 1 == n : NEW_LINE INDENT print ( i + j + k + l ) NEW_LINE if i == 1 : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT if j == 1 : NEW_LINE INDENT print ( j ) NEW_LINE DEDENT if k == 1 : NEW_LINE INDENT print ( k ) NEW_LINE DEDENT if l == 1 : NEW_LINE INDENT print ( l ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT", "N = int ( input ( ) ) NEW_LINE N1 = 1 NEW_LINE N2 = 2 NEW_LINE N3 = 4 NEW_LINE N4 = 8 NEW_LINE ansList = [ ] NEW_LINE if N >= N4 : NEW_LINE INDENT ansList . append ( N4 ) NEW_LINE N -= N4 NEW_LINE DEDENT elif N >= N3 : NEW_LINE INDENT ansList . append ( N3 ) NEW_LINE N -= N3 NEW_LINE DEDENT if N >= N2 : NEW_LINE INDENT ansList . append ( N2 ) NEW_LINE N -= N2 NEW_LINE DEDENT elif N >= N1 : NEW_LINE INDENT ansList . append ( N1 ) NEW_LINE N -= N1 NEW_LINE DEDENT print ( len ( ansList ) ) NEW_LINE for i in ansList : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT" ]
atcoder_agc007_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 inv [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { inv [ sc . nextInt ( ) - 1 ] = i ; } for ( int i = 0 ; i < N ; i ++ ) { if ( i > 0 ) System . out . print ( \" ▁ \" ) ; System . out . print ( N * ( i + 1 ) ) ; } System . out . println ( \" \" ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( i > 0 ) System . out . print ( \" ▁ \" ) ; System . out . print ( N * ( N - i ) + inv [ i ] ) ; } System . out . println ( \" \" ) ; } }", "import java . io . * ; import java . util . * ; public class Main { private static boolean debug = false ; private static boolean elapsed = false ; private void solve ( Scanner sc , PrintWriter out ) { int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { p [ i ] = sc . nextInt ( ) - 1 ; } int [ ] r = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { r [ p [ i ] ] = i + 1 ; } int [ ] a = new int [ N ] ; int [ ] b = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { a [ i ] = N * ( i + 1 ) ; b [ i ] = N * ( N - i - 1 ) + r [ i ] ; } for ( int i = 0 ; i < N ; ++ i ) { if ( i > 0 ) { out . print ( \" ▁ \" ) ; } out . print ( a [ i ] ) ; } out . println ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( i > 0 ) { out . print ( \" ▁ \" ) ; } out . print ( b [ i ] ) ; } out . println ( ) ; } public static void main ( String [ ] args ) { long S = System . currentTimeMillis ( ) ; Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( sc , out ) ; out . flush ( ) ; long G = System . currentTimeMillis ( ) ; if ( elapsed ) { System . err . println ( ( G - S ) + \" ms \" ) ; } } }", "import java . util . * ; class Main { public static void main ( String args [ ] ) { try ( 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 ] = i * 10001L + 1 ; B [ N - i - 1 ] = i * 10001L + 1 ; } for ( int i = 0 ; i < N ; i ++ ) { int p = sc . nextInt ( ) ; p -- ; A [ p ] += i / 2 ; B [ p ] += i - i / 2 ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i == N - 1 ) { System . out . print ( \" \\n \" ) ; } else { System . out . print ( \" ▁ \" ) ; } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( B [ i ] ) ; if ( i == N - 1 ) { System . out . print ( \" \\n \" ) ; } else { System . out . print ( \" ▁ \" ) ; } } } } }", "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; int [ ] p = new int [ N ] ; int [ ] q = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = sc . nextInt ( ) ; q [ p [ i ] - 1 ] = i + 1 ; } A [ 0 ] = q [ 0 ] ; B [ 0 ] = 0 ; for ( int i = 1 ; i < N ; i ++ ) { if ( q [ i - 1 ] < q [ i ] ) { B [ i ] = B [ i - 1 ] - 1 ; A [ i ] = q [ i ] - B [ i ] ; } else { A [ i ] = A [ i - 1 ] + 1 ; B [ i ] = q [ i ] - A [ i ] ; } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( A [ i ] + \" ▁ \" ) ; } System . out . println ( ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( ( B [ i ] + 1000000000 ) + \" ▁ \" ) ; } } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; int p [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ sc . nextInt ( ) - 1 ] = i + 1 ; a [ i ] = i * n + 1 ; } b [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { b [ i ] = b [ i + 1 ] + n + p [ i ] - p [ i + 1 ] ; } System . out . println ( Arrays . toString ( a ) . replaceAll ( \" [ ^ 0-9 ▁ ] \" , \" \" ) ) ; System . out . println ( Arrays . toString ( b ) . replaceAll ( \" [ ^ 0-9 ▁ ] \" , \" \" ) ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE p = list ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) NEW_LINE r = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT r [ p [ i ] ] = i + 1 NEW_LINE DEDENT A = [ 30000 * i for i in range ( 1 , N + 1 ) ] NEW_LINE B = [ 30000 * ( N - i ) + r [ i - 1 ] for i in range ( 1 , N + 1 ) ] NEW_LINE print ( * A ) NEW_LINE print ( * B ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from itertools import accumulate NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE P = LI ( ) NEW_LINE T = [ 1 ] * N NEW_LINE for i , p in enumerate ( P ) : NEW_LINE INDENT T [ p - 1 ] += i NEW_LINE DEDENT A = list ( accumulate ( T ) ) NEW_LINE B = list ( accumulate ( T [ : : - 1 ] ) ) [ : : - 1 ] NEW_LINE print ( * A ) NEW_LINE print ( * B ) NEW_LINE return 0 NEW_LINE DEDENT main ( ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE P = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = [ N * i + 1 for i in range ( 1 , N + 1 ) ] NEW_LINE B = list ( reversed ( A ) ) NEW_LINE for i , p in enumerate ( P ) : NEW_LINE INDENT A [ p - 1 ] -= N - i NEW_LINE DEDENT print ( * A ) NEW_LINE print ( * B ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE p = [ int ( m ) for m in input ( ) . split ( ) ] NEW_LINE a = [ i * n + ( i - 1 ) for i in range ( 1 , n + 1 ) ] NEW_LINE b = [ i * n + ( i - 1 ) for i in range ( n , 0 , - 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a [ p [ i ] - 1 ] += i + 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( a [ i ] , \" \" , end = \" \" ) NEW_LINE DEDENT print ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( b [ i ] , \" \" , end = \" \" ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE P = [ int ( _ ) - 1 for _ in input ( ) . split ( ) ] NEW_LINE Q = sorted ( [ ( P [ i ] , i ) for i in range ( N ) ] ) NEW_LINE A = [ 1 ] NEW_LINE B = [ 10 ** 9 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT d = Q [ i ] [ 1 ] - Q [ i - 1 ] [ 1 ] NEW_LINE if d > 0 : NEW_LINE INDENT A += [ A [ - 1 ] + d + 1 ] NEW_LINE B += [ B [ - 1 ] - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT A += [ A [ - 1 ] + 1 ] NEW_LINE B += [ B [ - 1 ] + d - 1 ] NEW_LINE DEDENT DEDENT print ( * A , sep = \" ▁ \" ) NEW_LINE print ( * B , sep = \" ▁ \" ) NEW_LINE" ]
atcoder_agc006_B
[ "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x == 1 || x == 2 * N - 1 ) { out . println ( \" No \" ) ; out . flush ( ) ; return ; } out . println ( \" Yes \" ) ; if ( N == 2 ) { for ( int i = 1 , n = 2 * N ; i < n ; ++ i ) { out . println ( i ) ; } } else { if ( x > N ) { for ( int i = N ; i < N * 2 ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } out . println ( x ) ; for ( int i = 1 ; i < N ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } } else { for ( int i = N + 1 ; i < N * 2 ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } out . println ( x ) ; for ( int i = 1 ; i < N + 1 ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } } } out . flush ( ) ; } }", "import java . lang . reflect . Array ; 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 ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int x = Integer . parseInt ( st . nextToken ( ) ) ; if ( x == 1 || x == 2 * n - 1 ) { System . out . print ( \" No \" ) ; return ; } System . out . println ( \" Yes \" ) ; StringBuilder sb = new StringBuilder ( ) ; int array [ ] = new int [ 2 * n ] ; array [ n ] = x ; for ( int i = n - 1 ; i >= 1 ; i -- ) array [ i ] = array [ i + 1 ] - 1 ; for ( int i = n + 1 ; i < array . length ; i ++ ) array [ i ] = array [ i - 1 ] + 1 ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( array [ i ] <= 0 ) array [ i ] += 2 * n - 1 ; if ( array [ i ] > 2 * n - 1 ) array [ i ] -= 2 * n - 1 ; } for ( int i = 1 ; i < 2 * n ; i ++ ) { sb . append ( array [ i ] ) ; sb . append ( ' \\n ' ) ; } System . out . print ( sb ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static int [ ] solve ( int N , int x ) { int [ ] ans = new int [ 2 * N - 1 ] ; if ( N == 2 ) { return new int [ ] { 1 , 2 , 3 } ; } if ( x == 2 ) { ans [ N - 2 ] = 2 * N - 1 ; ans [ N - 1 ] = 2 ; ans [ N ] = 1 ; ans [ N + 1 ] = 2 * N - 2 ; int elm = 3 ; for ( int index = 0 ; index < 2 * N - 1 ; index ++ ) { if ( ans [ index ] == 0 ) { ans [ index ] = elm ; elm ++ ; } } } else { ans [ N - 2 ] = 1 ; ans [ N - 1 ] = x ; ans [ N ] = 2 * N - 1 ; ans [ N + 1 ] = 2 ; int elm = 3 ; for ( int index = 0 ; index < 2 * N - 1 ; index ++ ) { if ( elm == x ) elm ++ ; if ( ans [ index ] == 0 ) { ans [ index ] = elm ; elm ++ ; } } } return ans ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x == 1 || x == 2 * N - 1 ) { System . out . println ( \" No \" ) ; return ; } else { System . out . println ( \" Yes \" ) ; } int [ ] ans = solve ( N , x ) ; for ( int i = 0 ; i < ans . length ; i ++ ) System . out . println ( ans [ i ] ) ; } }", "import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) * 2 - 1 , x = sc . nextInt ( ) ; if ( x == 1 || x == n ) { System . out . println ( \" No \" ) ; return ; } System . out . println ( \" Yes \" ) ; int [ ] ans = new int [ n ] ; ans [ n / 2 ] = x ; ans [ n / 2 - 1 ] = x + 1 ; ans [ n / 2 + 1 ] = x - 1 ; int idx = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( idx == x - 1 ) { idx += 3 ; } if ( i == n / 2 - 1 ) { i += 2 ; continue ; } ans [ i ] = idx ++ ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( ans [ i ] ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int x = scanner . nextInt ( ) ; print ( x , n ) ; } public static void print ( int x , int n ) { int max = n * 2 - 1 ; if ( x == 1 || x == max ) { System . out . println ( \" No \" ) ; return ; } System . out . println ( \" Yes \" ) ; String sep = System . lineSeparator ( ) ; String ans = IntStream . range ( x + n - 1 , x + n + max - 1 ) . mapToObj ( e -> ( e % max + 1 ) + sep ) . collect ( StringBuilder :: new , StringBuilder :: append , StringBuilder :: append ) . toString ( ) ; System . out . println ( ans ) ; } }" ]
[ "n , x = map ( int , input ( ) . split ( ) ) NEW_LINE ans = [ i for i in range ( 1 , 2 * n ) ] NEW_LINE if x == 1 or x == 2 * n - 1 : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( \" Yes \" ) NEW_LINE ans [ n - 1 ] , ans [ x - 1 ] = ans [ x - 1 ] , ans [ n - 1 ] NEW_LINE ans [ n - 2 ] , ans [ 0 ] = ans [ 0 ] , ans [ n - 2 ] NEW_LINE ans [ n ] , ans [ 2 * n - 2 ] = ans [ 2 * n - 2 ] , ans [ n ] NEW_LINE if n == 2 : NEW_LINE INDENT for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT exit ( ) NEW_LINE DEDENT if x < 2 * n - 2 : NEW_LINE INDENT ans [ n - 3 ] , ans [ 2 * n - 3 ] = ans [ 2 * n - 3 ] , ans [ n - 3 ] NEW_LINE DEDENT else : NEW_LINE INDENT ans [ n + 1 ] , ans [ 1 ] = ans [ 1 ] , ans [ n + 1 ] NEW_LINE DEDENT for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT", "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 n , x = LI ( ) NEW_LINE if x == 1 or x == 2 * n - 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE return 0 NEW_LINE DEDENT print ( ' Yes ' ) NEW_LINE if n < 3 : NEW_LINE INDENT print ( * [ n for n in range ( 1 , 2 * n ) ] , sep = ' \\n ' ) NEW_LINE return 1 NEW_LINE DEDENT tmp = [ x - 1 , x , x + 1 ] NEW_LINE remain = list ( set ( [ n for n in range ( 1 , 2 * n ) ] ) - set ( tmp ) ) NEW_LINE k = n - 2 NEW_LINE tmp = remain [ : k ] + tmp + remain [ k : ] NEW_LINE print ( * tmp , sep = ' \\n ' ) NEW_LINE return 1 NEW_LINE DEDENT main ( ) NEW_LINE", "n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if n == 2 and x == 2 : NEW_LINE INDENT print ( ' Yes ' , * [ 1 , 2 , 3 ] , sep = ' \\n ' ) NEW_LINE exit ( ) NEW_LINE DEDENT a = [ [ ] for _ in range ( 2 * n - 1 ) ] NEW_LINE a [ n - 1 ] = x NEW_LINE f = [ 0 ] * 2 * n NEW_LINE f [ x ] = 1 NEW_LINE try : NEW_LINE INDENT if x > 2 * n - 3 : NEW_LINE INDENT a [ n - 3 ] = x - 2 NEW_LINE a [ n - 2 ] = x + 1 NEW_LINE a [ n ] = x - 1 NEW_LINE f [ x - 2 ] = f [ x - 1 ] = f [ x + 1 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT a [ n - 3 ] = x + 2 NEW_LINE a [ n - 2 ] = x - 1 NEW_LINE a [ n ] = x + 1 NEW_LINE f [ x - 1 ] = f [ x + 1 ] = f [ x + 2 ] = 1 NEW_LINE DEDENT if f [ 0 ] : NEW_LINE INDENT 1 / 0 NEW_LINE DEDENT DEDENT except : NEW_LINE INDENT print ( ' No ' ) NEW_LINE exit ( ) NEW_LINE DEDENT i = 0 NEW_LINE for j , v in enumerate ( f [ 1 : ] , 1 ) : NEW_LINE INDENT if v : continue NEW_LINE while a [ i ] : i += 1 NEW_LINE a [ i ] = j NEW_LINE DEDENT print ( ' Yes ' , * a , sep = ' \\n ' ) NEW_LINE", "N , x = map ( int , input ( ) . split ( ) ) NEW_LINE if x == 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT elif x == 2 * N - 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE if N == 2 : NEW_LINE INDENT for i in range ( 1 , 4 ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if x != 2 * N - 2 : NEW_LINE INDENT L = [ ] NEW_LINE M = [ x + 2 , x - 1 , x , x + 1 ] NEW_LINE for i in range ( 1 , 2 * N ) : NEW_LINE INDENT if not i in M : NEW_LINE INDENT L . append ( i ) NEW_LINE DEDENT DEDENT for j in range ( N - 2 ) : NEW_LINE INDENT print ( L [ j ] ) NEW_LINE DEDENT for k in range ( 4 ) : NEW_LINE INDENT print ( M [ k ] ) NEW_LINE DEDENT for l in range ( N - 3 ) : NEW_LINE INDENT print ( L [ l + N - 2 ] ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT L = [ ] NEW_LINE M = [ x - 2 , x , x + 1 , x - 1 ] NEW_LINE for i in range ( 1 , 2 * N ) : NEW_LINE INDENT if not i in M : NEW_LINE INDENT L . append ( i ) NEW_LINE DEDENT DEDENT for j in range ( N - 2 ) : NEW_LINE INDENT print ( L [ j ] ) NEW_LINE DEDENT for k in range ( 4 ) : NEW_LINE INDENT print ( M [ k ] ) NEW_LINE DEDENT for l in range ( N - 3 ) : NEW_LINE INDENT print ( L [ l + N - 2 ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT", "n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if x == 1 or x == ( 2 * n - 1 ) : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( \" Yes \" ) NEW_LINE r = [ x - 1 , x , x + 1 ] NEW_LINE tmp = list ( range ( 1 , x - 1 ) ) + list ( range ( x + 2 , 2 * n ) ) NEW_LINE ans = tmp [ n - 2 : ] + r + tmp [ : n - 2 ] NEW_LINE for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT" ]
atcoder_abc003_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 N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] R = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { R [ i ] = sc . nextInt ( ) ; } Arrays . sort ( R ) ; double ans = 0.0 ; for ( int i = N - K ; i < N ; i ++ ) { ans = ( ans + R [ i ] ) / 2.0 ; } out . println ( ans ) ; } }", "import java . util . * ; class Main { public static int N ; public static int K ; public static ArrayList < Integer > ratelist = new ArrayList < Integer > ( ) ; public static double takahashirate = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; K = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { ratelist . add ( sc . nextInt ( ) ) ; } Collections . sort ( ratelist ) ; List < Integer > sbratelist = ratelist . subList ( N - K , N ) ; for ( int target : sbratelist ) { takahashirate = ( takahashirate + target ) / 2.0 ; } System . out . println ( takahashirate ) ; } }", "import java . math . BigDecimal ; import java . math . RoundingMode ; import java . text . DecimalFormat ; import java . util . ArrayList ; import java . util . Collections ; 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 ( ) ) ; ArrayList < Double > list = new ArrayList < Double > ( ) ; double trate = 0 ; for ( int c = 0 ; c < a ; c ++ ) { if ( sc . hasNextInt ( ) ) { list . add ( Double . parseDouble ( sc . next ( ) ) ) ; } } if ( a != b ) { Collections . sort ( list ) ; for ( int r = a - b ; r < a ; r ++ ) { trate = ( trate + list . get ( r ) ) / 2 ; } } else { Collections . sort ( list ) ; for ( int r = 0 ; r < b ; r ++ ) { trate = ( trate + list . get ( r ) ) / 2 ; } } new DecimalFormat ( \"0.000000\" ) . format ( trate ) ; BigDecimal bd_trate = new BigDecimal ( trate ) ; bd_trate . setScale ( 6 , RoundingMode . HALF_UP ) ; System . out . println ( bd_trate ) ; sc . close ( ) ; } }", "import java . util . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , k = scanner . nextInt ( ) ; System . out . println ( java . util . stream . IntStream . range ( 0 , n ) . mapToDouble ( i -> scanner . nextDouble ( ) ) . sorted ( ) . skip ( n - k ) . reduce ( 0D , ( a , b ) -> ( a + b ) / 2 ) ) ; } }", "import java . io . InputStream ; import java . io . PrintStream ; import java . util . ArrayList ; import java . util . List ; 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 k = sc . nextInt ( ) ; List < Integer > r = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { r . add ( sc . nextInt ( ) ) ; } r . sort ( null ) ; double c = 0 ; for ( int i = n - k ; i < n ; i ++ ) { c = ( c + r . get ( i ) ) / 2 ; } out . println ( c ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }" ]
[ "n , k = map ( int , input ( ) . split ( ) ) NEW_LINE r = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE r . sort ( ) NEW_LINE del r [ : ( n - k ) ] NEW_LINE c = 0 NEW_LINE for i in r : NEW_LINE INDENT c = ( c + i ) / 2 NEW_LINE DEDENT print ( c ) NEW_LINE", "N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE RList = sorted ( [ int ( i ) for i in input ( ) . split ( ) ] , reverse = True ) [ : K ] NEW_LINE ans = 0 NEW_LINE for i , r in enumerate ( RList [ : : - 1 ] ) : NEW_LINE INDENT ans = ( r + ans ) / 2 NEW_LINE DEDENT print ( ans ) NEW_LINE", "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE R = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def sort ( list1 ) : NEW_LINE INDENT return sorting ( list1 ) NEW_LINE DEDENT def sorting ( list1 ) : NEW_LINE INDENT if len ( list1 ) == 1 : NEW_LINE INDENT return list1 NEW_LINE DEDENT mid = len ( list1 ) // 2 NEW_LINE return merge ( sorting ( list1 [ : mid ] ) , sorting ( list1 [ mid : ] ) ) NEW_LINE DEDENT def merge ( list1 , list2 ) : NEW_LINE INDENT result = [ ] NEW_LINE i = 0 NEW_LINE j = 0 NEW_LINE m = len ( list1 ) NEW_LINE n = len ( list2 ) NEW_LINE while ( i + j < m + n ) : NEW_LINE INDENT if j == n or ( i < m and list1 [ i ] < list2 [ j ] ) : NEW_LINE INDENT result += [ list1 [ i ] ] NEW_LINE i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT result += [ list2 [ j ] ] NEW_LINE j += 1 NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT R = sort ( R ) NEW_LINE R [ : N - K ] = [ ] NEW_LINE C = 0 NEW_LINE for x in R : NEW_LINE INDENT if C < x : NEW_LINE INDENT C = ( C + x ) / 2 NEW_LINE DEDENT DEDENT print ( C ) NEW_LINE", "Your_rate = 0 NEW_LINE N , K = ( int ( x ) for x in input ( ) . split ( ) ) NEW_LINE video_rate = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE video_rate . sort ( reverse = True ) NEW_LINE for i in range ( K - 1 , - 1 , - 1 ) : NEW_LINE INDENT Your_rate = ( Your_rate + video_rate [ i ] ) / 2 NEW_LINE DEDENT print ( Your_rate ) NEW_LINE", "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE R = input ( ) . split ( ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT if int ( R [ i ] ) < int ( R [ j ] ) : NEW_LINE INDENT tmp = R [ i ] NEW_LINE R [ i ] = R [ j ] NEW_LINE R [ j ] = tmp NEW_LINE DEDENT DEDENT DEDENT R = R [ 0 : K ] NEW_LINE R . reverse ( ) NEW_LINE sum = 0 NEW_LINE for i in range ( K ) : NEW_LINE INDENT sum += int ( R [ i ] ) * 2 ** i NEW_LINE DEDENT sum /= 2 ** K NEW_LINE print ( sum ) NEW_LINE" ]
atcoder_agc007_A
[ "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 h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < h ; i ++ ) { String row = sc . next ( ) ; for ( char c : row . toCharArray ( ) ) { if ( c == ' # ' ) { count ++ ; } } } System . out . println ( count == h + w - 1 ? \" Possible \" : \" Impossible \" ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . io . UncheckedIOException ; import java . util . stream . Stream ; 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 ) ; AShikAndStone solver = new AShikAndStone ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AShikAndStone { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int h = in . ints ( ) , w = in . ints ( ) ; String [ ] a = in . string ( h ) ; int c = 0 ; for ( String row : a ) { for ( char column : row . toCharArray ( ) ) { if ( column == ' # ' ) { c ++ ; } } } if ( c == h + w - 1 ) { out . println ( \" Possible \" ) ; } else { out . println ( \" Impossible \" ) ; } } } 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 String [ ] string ( int length ) { return IntStream . range ( 0 , length ) . mapToObj ( x -> string ( ) ) . toArray ( String [ ] :: new ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }", "import java . io . InputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . BufferedReader ; class MyScanner { InputStream stream ; public MyScanner ( ) { stream = System . in ; } public int nextInt ( ) { int ret = 0 ; try { while ( true ) { char readed = ( char ) stream . read ( ) ; if ( readed < '0' || readed > '9' ) { break ; } ret = ret * 10 + ( readed - '0' ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { return ret ; } } } class Main { public static void main ( String args [ ] ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; MyScanner sc = new MyScanner ( ) ; int h = sc . nextInt ( ) , w = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < h ; ++ i ) { char [ ] a = br . readLine ( ) . toCharArray ( ) ; for ( int j = 0 ; j < w ; ++ j ) { if ( a [ j ] == ' # ' ) { ++ sum ; } } } if ( sum == h + w - 1 ) { System . out . println ( \" Possible \" ) ; } else { System . out . println ( \" Impossible \" ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } }", "import java . util . * ; import java . awt . geom . Point2D ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; char [ ] [ ] f = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < w ; j ++ ) { f [ i ] [ j ] = s . charAt ( j ) ; } } Point p = new Point ( 0 , 0 ) ; int [ ] dx = { - 1 , 0 , 1 , 0 } ; int [ ] dy = { 0 , - 1 , 0 , 1 } ; Deque < Point > stack = new ArrayDeque < > ( ) ; stack . addFirst ( p ) ; int k = 1 ; while ( stack . size ( ) > 0 ) { k ++ ; Point t = stack . pollFirst ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { int x = t . x + dx [ i ] , y = t . y + dy [ i ] ; if ( D ( h , w , x , y ) ) { if ( f [ y ] [ x ] == ' # ' ) { if ( i == 2 || i == 3 ) { stack . addFirst ( new Point ( x , y ) ) ; f [ t . y ] [ t . x ] = '0' ; } else { out . println ( \" Impossible \" ) ; exit ( 0 ) ; } } } } if ( stack . size ( ) > 1 ) { out . println ( \" Impossible \" ) ; exit ( 0 ) ; } } out . println ( \" Possible \" ) ; } static boolean D ( int h , int w , int x , int y ) { return 0 <= x && x < w && 0 <= y && y < h ; } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int H = ni ( ) ; int W = ni ( ) ; char [ ] [ ] A = new char [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { A [ i ] = sc . next ( ) . toCharArray ( ) ; } for ( int x1 = 0 ; x1 < H ; x1 ++ ) for ( int y1 = 0 ; y1 < W ; y1 ++ ) { for ( int x2 = 0 ; x2 < H ; x2 ++ ) for ( int y2 = 0 ; y2 < W ; y2 ++ ) { if ( x1 < x2 && y2 < y1 && A [ x1 ] [ y1 ] == ' # ' && A [ x2 ] [ y2 ] == ' # ' ) { System . out . println ( \" Impossible \" ) ; return ; } } } System . out . println ( \" Possible \" ) ; } public static int ni ( ) { return Integer . parseInt ( sc . next ( ) ) ; } }" ]
[ "H , W = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE A_s = [ input ( ) for _ in range ( H ) ] NEW_LINE pos = [ 0 , 0 ] NEW_LINE num = 1 NEW_LINE while True : NEW_LINE INDENT if pos == [ H - 1 , W - 1 ] : NEW_LINE INDENT total = sum ( map ( lambda A : A . count ( \" # \" ) , A_s ) ) NEW_LINE ans = total == num NEW_LINE break NEW_LINE DEDENT h , w = pos NEW_LINE if h != H - 1 and A_s [ h + 1 ] [ w ] == \" # \" : NEW_LINE INDENT pos = [ h + 1 , w ] NEW_LINE num += 1 NEW_LINE continue NEW_LINE DEDENT if w != W - 1 and A_s [ h ] [ w + 1 ] == \" # \" : NEW_LINE INDENT pos = [ h , w + 1 ] NEW_LINE num += 1 NEW_LINE continue NEW_LINE DEDENT ans = False NEW_LINE break NEW_LINE DEDENT print ( \" Possible \" if ans else \" Impossible \" ) NEW_LINE", "import re NEW_LINE pattern = re . compile ( ' ^ ( ? : \\ . * ) ( # + ) ( ? : \\ . * ) $ ' ) NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE board = [ input ( ) for i in range ( H ) ] NEW_LINE c = 0 NEW_LINE for row in board : NEW_LINE INDENT result = pattern . match ( row ) NEW_LINE if result == None or result . start ( 1 ) != c : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT c = result . end ( 1 ) - 1 NEW_LINE DEDENT DEDENT print ( \" Possible \" ) NEW_LINE", "h , w = map ( int , input ( ) . split ( ) ) ; c = 0 NEW_LINE for i in range ( h ) : NEW_LINE INDENT a = input ( ) NEW_LINE b = [ ] NEW_LINE for j in range ( w ) : b . append ( a [ j ] ) NEW_LINE c += b . count ( \" # \" ) NEW_LINE DEDENT print ( \" Possible \" if h + w - 1 == c else \" Impossible \" ) NEW_LINE", "from collections import deque NEW_LINE h , w = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = [ [ i for i in input ( ) ] for _ in range ( h ) ] NEW_LINE right_count = sum ( [ sum ( [ 1 for j in range ( w ) if a [ i ] [ j ] == \" # \" ] ) for i in range ( h ) ] ) NEW_LINE pattern = [ ( 1 , 0 ) , ( 0 , 1 ) ] NEW_LINE queue = deque ( [ ( 0 , 0 ) ] ) NEW_LINE def bfs ( ) : NEW_LINE INDENT cnt = 1 NEW_LINE while queue : NEW_LINE INDENT ( x , y ) = queue . popleft ( ) NEW_LINE if ( x , y ) == ( w - 1 , h - 1 ) : NEW_LINE INDENT return cnt NEW_LINE DEDENT around = False NEW_LINE for i , j in pattern : NEW_LINE INDENT if y + i < h and x + j < w : NEW_LINE INDENT if a [ y + i ] [ x + j ] == \" # \" : NEW_LINE INDENT queue . append ( ( x + j , y + i ) ) NEW_LINE around = True NEW_LINE cnt += 1 NEW_LINE DEDENT DEDENT DEDENT if around == False : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT print ( \" Possible \" if bfs ( ) == right_count else \" Impossible \" ) NEW_LINE", "t = open ( 0 ) . read ( ) ; print ( ' I ▁ mPp ' [ t . count ( ' # ' ) < int ( t [ 0 ] ) + int ( t [ 2 ] ) : : 2 ] + ' ossible ' ) NEW_LINE" ]
atcoder_arc089_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 [ ] t = new int [ n + 1 ] ; int [ ] x = new int [ n + 1 ] ; int [ ] y = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { int dt = t [ i ] - t [ i - 1 ] ; int dx = Math . abs ( x [ i ] - x [ i - 1 ] ) ; int dy = Math . abs ( y [ i ] - y [ i - 1 ] ) ; int time = dt - dx - dy ; if ( time < 0 || time % 2 == 1 ) { System . out . println ( \" No \" ) ; return ; } } System . out . println ( \" Yes \" ) ; } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? \" Yes \" : \" No \" ; } public static void main ( String [ ] args ) { int n = nextInt ( ) ; int x = 0 , y = 0 ; long tSum = 0 ; boolean F = true ; for ( int i = 0 ; i < n ; i ++ ) { long t = nextInt ( ) - tSum ; tSum += t ; int tempX = nextInt ( ) ; int tempY = nextInt ( ) ; if ( x == tempX && y == tempY ) { F = false ; break ; } int dist = calcManhatDistance ( x , y , tempX , tempY ) ; if ( dist > t || dist % 2 != t % 2 ) { F = false ; break ; } x = tempX ; y = tempY ; } System . out . println ( yesno ( F ) ) ; } static int calcManhatDistance ( int x1 , int y1 , int x2 , int y2 ) { int d = Math . abs ( x1 - x2 ) + Math . abs ( y1 - y2 ) ; return d ; } static double calcEuclidDistance ( double x1 , double y1 , double x2 , double y2 ) { double d = Math . sqrt ( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) ; return d ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int lastX = 0 , lastY = 0 , lastT = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int t = in . nextInt ( ) , x = in . nextInt ( ) , y = in . nextInt ( ) ; int dist = Math . abs ( x - lastX ) + Math . abs ( y - lastY ) ; if ( dist > t - lastT || dist % 2 != ( t - lastT ) % 2 ) { out . println ( \" No \" ) ; return ; } lastX = x ; lastY = y ; lastT = t ; } out . println ( \" Yes \" ) ; } } static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { String line = null ; try { line = br . readLine ( ) ; } catch ( IOException e ) { } st = new StringTokenizer ( line ) ; } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . Scanner ; class C { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; final int [ ] x = new int [ N + 1 ] ; final int [ ] y = new int [ N + 1 ] ; final int [ ] t = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= N ; i ++ ) { final int dist = Math . abs ( x [ i ] - x [ i - 1 ] ) + Math . abs ( y [ i ] - y [ i - 1 ] ) ; if ( dist > t [ i ] - t [ i - 1 ] || ( dist - t [ i ] + t [ i - 1 ] ) % 2 != 0 ) { System . err . println ( dist + \" ▁ \" + i ) ; System . out . println ( \" No \" ) ; return ; } } System . out . println ( \" Yes \" ) ; } } public class Main { public static void main ( String ... args ) { C . main ( args ) ; } }", "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 stN = sc . nextLine ( ) ; int n = Integer . parseInt ( stN ) ; String line = null ; List < String > lines = null ; int t = 0 ; int x = 0 ; int y = 0 ; int nT = 0 ; int nX = 0 ; int nY = 0 ; int abs = 0 ; while ( sc . hasNext ( ) ) { line = sc . nextLine ( ) ; lines = Arrays . asList ( line . split ( \" ▁ \" ) ) ; nT = Integer . parseInt ( lines . get ( 0 ) ) ; nX = Integer . parseInt ( lines . get ( 1 ) ) ; nY = Integer . parseInt ( lines . get ( 2 ) ) ; abs = Math . abs ( nX - x ) + Math . abs ( nY - y ) ; if ( abs == ( nT - t ) ) { } else if ( abs < ( nT - t ) && ( ( nT - t ) - abs ) % 2 == 0 ) { } else { System . out . println ( \" No \" ) ; return ; } t = nT ; x = nX ; y = nY ; } System . out . println ( \" Yes \" ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE s , a , b = 0 , 0 , 0 NEW_LINE f = True NEW_LINE for _ in [ 0 ] * n : NEW_LINE INDENT t , x , y = map ( int , input ( ) . split ( ) ) NEW_LINE p = t - s - ( abs ( x - a ) + abs ( y - b ) ) NEW_LINE if p % 2 == 1 or p < 0 : NEW_LINE INDENT f = False NEW_LINE DEDENT DEDENT print ( \" Yes \" if f else \" No \" ) NEW_LINE", "import sys NEW_LINE def chk1 ( t , x , y ) : NEW_LINE INDENT return t % 2 == ( x + y ) % 2 NEW_LINE DEDENT def chk2 ( t , x , y ) : NEW_LINE INDENT return t >= abs ( x ) + abs ( y ) NEW_LINE DEDENT def chk ( t , x , y ) : NEW_LINE INDENT return chk1 ( t , x , y ) and chk2 ( t , x , y ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE T = [ 0 ] * ( N + 1 ) NEW_LINE X = [ 0 ] * ( N + 1 ) NEW_LINE Y = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT T [ i ] , X [ i ] , Y [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT dt , dx , dy = T [ i ] - T [ i - 1 ] , X [ i ] - X [ i - 1 ] , Y [ i ] - Y [ i - 1 ] NEW_LINE if not chk ( dt , dx , dy ) : NEW_LINE INDENT print ( ' No ' ) NEW_LINE sys . exit ( 0 ) NEW_LINE DEDENT DEDENT print ( ' Yes ' ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE list = [ ] NEW_LINE list . append ( ( 0 , 0 , 0 ) ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT t , x , y = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE list . append ( ( t , x , y ) ) NEW_LINE DEDENT def isReachable ( t1 , x1 , y1 , t2 , x2 , y2 ) : NEW_LINE INDENT if ( t2 - t1 ) < abs ( x1 - x2 ) + abs ( y1 - y2 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( ( t2 - t1 ) - ( abs ( x1 - x2 ) + abs ( y1 - y2 ) ) ) % 2 == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT ret = True NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT t1 , x1 , y1 = list [ i ] NEW_LINE t2 , x2 , y2 = list [ i + 1 ] NEW_LINE b = isReachable ( t1 , x1 , y1 , t2 , x2 , y2 ) NEW_LINE if b == False : NEW_LINE INDENT ret = False NEW_LINE break NEW_LINE DEDENT DEDENT if ret == True : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE txy = [ input ( ) for i in range ( N ) ] NEW_LINE now_pos = [ 0 , 0 ] NEW_LINE now_time = 0 NEW_LINE fail_flag = False NEW_LINE for i in range ( N ) : NEW_LINE INDENT t , x , y = map ( int , txy [ i ] . split ( ' ▁ ' ) ) NEW_LINE if ( x + y ) % 2 != t % 2 : NEW_LINE INDENT fail_flag = True NEW_LINE DEDENT distance = ( abs ( now_pos [ 0 ] - x ) + abs ( now_pos [ 1 ] - y ) ) NEW_LINE if distance > t - now_time : NEW_LINE INDENT fail_flag = True NEW_LINE DEDENT if fail_flag : NEW_LINE INDENT print ( ' No ' ) NEW_LINE exit ( ) NEW_LINE DEDENT now_pos = [ x , y ] NEW_LINE now_time = t NEW_LINE DEDENT print ( ' Yes ' ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE travel = [ [ 0 , 0 , 0 ] ] + [ list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) for i in range ( N ) ] NEW_LINE ans = ' Yes ' NEW_LINE for i in range ( N ) : NEW_LINE INDENT dt = travel [ i + 1 ] [ 0 ] - travel [ i ] [ 0 ] NEW_LINE dx = abs ( travel [ i + 1 ] [ 1 ] - travel [ i ] [ 1 ] ) NEW_LINE dy = abs ( travel [ i + 1 ] [ 2 ] - travel [ i ] [ 2 ] ) NEW_LINE if dx + dy <= dt and ( dx + dy ) % 2 == dt % 2 : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' No ' NEW_LINE break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc034_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; double max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { max = Math . max ( max , ( sc . nextDouble ( ) + sc . nextDouble ( ) + sc . nextDouble ( ) + sc . nextDouble ( ) ) + ( sc . nextDouble ( ) * 110 / ( double ) 900 ) ) ; } 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 ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; double max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] arr = br . readLine ( ) . split ( \" ▁ \" , 5 ) ; double sum = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { int x = Integer . parseInt ( arr [ j ] ) ; if ( j < 4 ) { sum += x ; } else { sum += ( double ) x * ( 110.0 / 900.0 ) ; } } if ( max < sum ) { max = sum ; } } System . out . println ( max ) ; } }", "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 ( ) ; double ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { double score = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { double s = sc . nextDouble ( ) ; score += j != 4 ? s : s * 11 / 90 ; } ans = max ( score , ans ) ; } out . println ( ans ) ; } }", "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { double res = - 1145141919 ; for ( int n = s . nextInt ( ) ; n > 0 ; n -- ) { double sum = 0 ; for ( int j = 0 ; j < 4 ; j ++ ) sum += s . nextInt ( ) ; sum += s . nextInt ( ) * 110 / 900.0 ; res = Math . max ( res , sum ) ; } System . out . println ( res ) ; } }", "import java . util . * ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; double max = 0 ; for ( int i = 0 ; i < N ; i ++ ) { double sum = 0 ; for ( int j = 0 ; j < 4 ; j ++ ) { sum += sc . nextInt ( ) ; } sum += ( 110 * sc . nextInt ( ) / 900.0 ) ; max = Math . max ( max , sum ) ; } System . out . println ( max ) ; } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for _ in range ( N ) : NEW_LINE INDENT * a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = max ( ans , sum ( a ) + b * 110 / 900 ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "m = 0 ; exec ( ' * a , = map ( int , input ( ) . split ( ) ) ; m = max ( m , sum ( a [ :4 ] , a [ 4 ] * 11/90 ) ) ; ' * int ( input ( ) ) ) ; print ( m ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE L = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE res = - 1 NEW_LINE for l in L : NEW_LINE INDENT tmp = 0 NEW_LINE for i in range ( 5 ) : NEW_LINE INDENT if i == 4 : NEW_LINE INDENT tmp += l [ i ] * 110 / 900 NEW_LINE DEDENT else : NEW_LINE INDENT tmp += l [ i ] NEW_LINE DEDENT DEDENT res = max ( res , tmp ) NEW_LINE DEDENT print ( res ) NEW_LINE", "def ans ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE max_ = 0 NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b , c , d , e = map ( int , input ( ) . split ( ) ) NEW_LINE score = a + b + c + d + e * ( 110 / 900 ) NEW_LINE if ( score > max_ ) : NEW_LINE INDENT max_ = score NEW_LINE DEDENT DEDENT if ( max_ == int ( max_ ) ) : NEW_LINE INDENT print ( int ( max_ ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( max_ ) NEW_LINE DEDENT DEDENT ans ( ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE scores = [ ] NEW_LINE for idx in range ( 0 , N ) : NEW_LINE INDENT scores . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT sums = [ ] NEW_LINE for score in scores : NEW_LINE INDENT sum = score [ 0 ] + score [ 1 ] + score [ 2 ] + score [ 3 ] + score [ 4 ] * 11 / 90.0 NEW_LINE sums . append ( sum ) NEW_LINE DEDENT print ( max ( sums ) ) NEW_LINE" ]
atcoder_abc003_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String l1 = sc . next ( ) ; String l2 = sc . next ( ) ; char temp1 ; char temp2 ; for ( int i = 0 ; i < l1 . length ( ) ; i ++ ) { temp1 = l1 . charAt ( i ) ; temp2 = l2 . charAt ( i ) ; if ( temp1 != temp2 ) { if ( temp1 == ' @ ' && ( temp2 == ' a ' || temp2 == ' t ' || temp2 == ' c ' || temp2 == ' o ' || temp2 == ' d ' || temp2 == ' e ' || temp2 == ' r ' ) ) { } else if ( temp2 == ' @ ' && ( temp1 == ' a ' || temp1 == ' t ' || temp1 == ' c ' || temp1 == ' o ' || temp1 == ' d ' || temp1 == ' e ' || temp1 == ' r ' ) ) { } else { System . out . println ( \" You ▁ will ▁ lose \" ) ; return ; } } } System . out . println ( \" You ▁ can ▁ win \" ) ; } }", "import java . util . * ; class Main { public static boolean d ; public static int fun1 ( String s , String t ) { char [ ] charlist = { ' a ' , ' t ' , ' c ' , ' o ' , ' d ' , ' e ' , ' r ' } ; int i = s . length ( ) ; for ( int n = 0 ; n < i ; n ++ ) { d = false ; if ( s . charAt ( n ) != t . charAt ( n ) ) { if ( s . charAt ( n ) != ' @ ' && t . charAt ( n ) != ' @ ' ) { return 0 ; } else if ( s . charAt ( n ) == ' @ ' && t . charAt ( n ) != ' @ ' ) { for ( char target : charlist ) { if ( t . charAt ( n ) == target ) { d = true ; break ; } } if ( d == false ) { return 0 ; } } else if ( s . charAt ( n ) != ' @ ' && t . charAt ( n ) == ' @ ' ) { for ( char target : charlist ) { if ( s . charAt ( n ) == target ) { d = true ; break ; } } if ( d == false ) { return 0 ; } } } } return 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String t = sc . nextLine ( ) ; int result = fun1 ( s , t ) ; if ( result == 0 ) { System . out . println ( \" You ▁ will ▁ lose \" ) ; } else { System . out . println ( \" You ▁ can ▁ win \" ) ; } } }", "import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { char [ ] sArr = sc . next ( ) . toCharArray ( ) ; char [ ] tArr = sc . next ( ) . toCharArray ( ) ; Set < Character > chars = new HashSet < > ( Arrays . asList ( ' @ ' , ' a ' , ' t ' , ' c ' , ' o ' , ' d ' , ' e ' , ' r ' ) ) ; System . out . println ( isWinner ( chars , sArr , tArr ) ? \" You ▁ can ▁ win \" : \" You ▁ will ▁ lose \" ) ; } static boolean isWinner ( Set < Character > chars , char [ ] sArr , char [ ] tArr ) { for ( int i = 0 ; i < sArr . length ; i ++ ) { for ( int j = 0 ; j < tArr . length ; j ++ ) { if ( isValid ( chars , sArr [ i ] , tArr [ i ] ) ) { continue ; } else { return false ; } } } return true ; } static boolean isValid ( Set < Character > chars , char c1 , char c2 ) { return ( c1 == ' @ ' && chars . contains ( c2 ) ) || ( c2 == ' @ ' && chars . contains ( c1 ) ) || ( c1 == c2 ) ; } }", "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 ) { String a = sc . next ( ) ; String b = sc . next ( ) ; String c = null ; String [ ] list = new String [ a . length ( ) ] ; String [ ] list2 = new String [ a . length ( ) ] ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { list [ i ] = String . valueOf ( a . charAt ( i ) ) ; list2 [ i ] = String . valueOf ( b . charAt ( i ) ) ; } String atc = \" [ a | t | c | o | d | e | r ] \" ; boolean bl = false ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( bl == true || i == 0 ) { if ( list [ i ] . equals ( list2 [ i ] ) ) { bl = true ; } else if ( list [ i ] . equals ( \" @ \" ) ) { bl = list2 [ i ] . matches ( atc ) ; } else if ( list2 [ i ] . equals ( \" @ \" ) ) { bl = list [ i ] . matches ( atc ) ; } else { bl = false ; } } else { break ; } } ; if ( bl == true ) { c = \" You ▁ can ▁ win \" ; } else { c = \" You ▁ will ▁ lose \" ; } System . out . println ( c ) ; System . out . flush ( ) ; sc . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; String t = scanner . nextLine ( ) ; scanner . close ( ) ; String [ ] toReplace = { \" a \" , \" t \" , \" c \" , \" o \" , \" d \" , \" e \" , \" r \" } ; boolean canWin = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! canWin ) { break ; } if ( s . charAt ( i ) == t . charAt ( i ) ) { canWin = true ; } else if ( s . charAt ( i ) == ' @ ' ) { canWin = containToReplace ( t . charAt ( i ) ) ; } else if ( t . charAt ( i ) == ' @ ' ) { canWin = containToReplace ( s . charAt ( i ) ) ; } else { canWin = false ; } } String msg = \" \" ; if ( canWin ) { msg = \" You ▁ can ▁ win \" ; } else { msg = \" You ▁ will ▁ lose \" ; } System . out . println ( msg ) ; } private static boolean containToReplace ( char c ) { char [ ] toReplace = { ' a ' , ' t ' , ' c ' , ' o ' , ' d ' , ' e ' , ' r ' } ; for ( int i = 0 ; i < toReplace . length ; i ++ ) { if ( c == toReplace [ i ] ) { return true ; } } return false ; } }" ]
[ "print ( ' You ▁ can ▁ win ' * all ( s + t in ' @ a @ t @ c @ o @ d @ e @ r @ ' + s * 2 for s , t in zip ( * open ( 0 ) ) ) or ' You ▁ will ▁ lose ' ) NEW_LINE", "S = list ( input ( ) ) NEW_LINE T = list ( input ( ) ) NEW_LINE pit = 0 NEW_LINE N = len ( S ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] != T [ i ] : NEW_LINE INDENT if S [ i ] == ' @ ' : NEW_LINE INDENT if T [ i ] == ' a ' or T [ i ] == ' t ' or T [ i ] == ' c ' or T [ i ] == ' o ' or T [ i ] == ' d ' or T [ i ] == ' e ' or T [ i ] == ' r ' or T [ i ] == ' @ ' : NEW_LINE INDENT pit = pit + 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' You ▁ will ▁ lose ' ) NEW_LINE break NEW_LINE DEDENT DEDENT elif T [ i ] == ' @ ' : NEW_LINE INDENT if S [ i ] == ' a ' or S [ i ] == ' t ' or S [ i ] == ' c ' or S [ i ] == ' o ' or S [ i ] == ' d ' or S [ i ] == ' e ' or S [ i ] == ' r ' or S [ i ] == ' @ ' : NEW_LINE INDENT pit = pit + 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' You ▁ will ▁ lose ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' You ▁ will ▁ lose ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT pit = pit + 1 NEW_LINE DEDENT DEDENT if pit == N : NEW_LINE INDENT print ( ' You ▁ can ▁ win ' ) NEW_LINE DEDENT", "flag1 = False NEW_LINE flag2 = False NEW_LINE s1 = input ( ) NEW_LINE s2 = input ( ) NEW_LINE win = \" You ▁ can ▁ win \" NEW_LINE lose = \" You ▁ will ▁ lose \" NEW_LINE for i in range ( len ( s1 ) ) : NEW_LINE INDENT if s1 [ i ] == \" @ \" : NEW_LINE INDENT if s2 [ i ] != \" a \" and s2 [ i ] != \" t \" and s2 [ i ] != \" c \" and s2 [ i ] != \" o \" and s2 [ i ] != \" d \" and s2 [ i ] != \" e \" and s2 [ i ] != \" r \" and s2 [ i ] != \" @ \" : NEW_LINE INDENT flag1 = True NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if s1 [ i ] != s2 [ i ] : NEW_LINE INDENT if s2 [ i ] != \" @ \" : NEW_LINE INDENT flag1 = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in range ( len ( s2 ) ) : NEW_LINE INDENT if s2 [ i ] == \" @ \" : NEW_LINE INDENT if s1 [ i ] != \" a \" and s1 [ i ] != \" t \" and s1 [ i ] != \" c \" and s1 [ i ] != \" o \" and s1 [ i ] != \" d \" and s1 [ i ] != \" e \" and s1 [ i ] != \" r \" and s1 [ i ] != \" @ \" : NEW_LINE INDENT flag2 = True NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if s1 [ i ] != s2 [ i ] : NEW_LINE INDENT if s1 [ i ] != \" @ \" : NEW_LINE INDENT flag2 = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT if flag1 or flag2 : NEW_LINE INDENT print ( lose ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( win ) NEW_LINE DEDENT", "S = input ( ) NEW_LINE T = input ( ) NEW_LINE lll = [ \" a \" , \" t \" , \" c \" , \" o \" , \" d \" , \" e \" , \" r \" ] NEW_LINE if S == T : NEW_LINE INDENT print ( \" You ▁ can ▁ win \" ) NEW_LINE exit ( ) NEW_LINE DEDENT if \" @ \" not in S and \" @ \" not in T : NEW_LINE INDENT print ( \" You ▁ will ▁ lose \" ) NEW_LINE exit ( ) NEW_LINE DEDENT for i , w in enumerate ( S ) : NEW_LINE INDENT if \" @ \" == w : NEW_LINE INDENT r = T [ i ] NEW_LINE if r not in lll : NEW_LINE INDENT if \" @ \" == r : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" You ▁ will ▁ lose \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if w == T [ i ] : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if T [ i ] == \" @ \" : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" You ▁ will ▁ lose \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT for i , w in enumerate ( T ) : NEW_LINE INDENT if \" @ \" == w : NEW_LINE INDENT r = S [ i ] NEW_LINE if r not in lll : NEW_LINE INDENT if \" @ \" == r : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" You ▁ will ▁ lose \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if w == S [ i ] : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if S [ i ] == \" @ \" : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" You ▁ will ▁ lose \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( \" You ▁ can ▁ win \" ) NEW_LINE", "s = list ( input ( ) ) NEW_LINE t = list ( input ( ) ) NEW_LINE x = list ( \" atcorder @ \" ) NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == \" @ \" and t [ i ] in x : NEW_LINE INDENT continue NEW_LINE DEDENT elif t [ i ] == \" @ \" and s [ i ] in x : NEW_LINE INDENT continue NEW_LINE DEDENT elif s [ i ] == t [ i ] : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" You ▁ will ▁ lose \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( \" You ▁ can ▁ win \" ) NEW_LINE" ]
atcoder_arc001_B
[ "import java . util . * ; import static java . lang . Integer . parseInt ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int question = sc . nextInt ( ) ; ArrayList < String > answers = new ArrayList < String > ( ) ; int scores [ ] = new int [ 4 ] ; answers . add ( sc . next ( ) ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int digit = 0 ; digit < question ; digit ++ ) if ( parseInt ( answers . get ( 0 ) . substring ( digit , digit + 1 ) ) == ( i + 1 ) ) { scores [ i ] = scores [ i ] + 1 ; } } int max = scores [ 0 ] ; int min = scores [ 1 ] ; for ( int i = 0 ; i < scores . length ; i ++ ) { int v = scores [ i ] ; if ( v > max ) { max = v ; } if ( v < min ) { min = v ; } } System . out . println ( max + \" ▁ \" + min ) ; } }", "import java . 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 . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int a [ ] = new int [ 4 ] ; for ( int i = 0 ; i < n ; i ++ ) { switch ( s . charAt ( i ) ) { case ( '1' ) : a [ 0 ] ++ ; break ; case ( '2' ) : a [ 1 ] ++ ; break ; case ( '3' ) : a [ 2 ] ++ ; break ; case ( '4' ) : a [ 3 ] ++ ; break ; } } Arrays . sort ( a ) ; System . out . println ( a [ 3 ] + \" ▁ \" + a [ 0 ] ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }", "import java . util . * ; import java . io . * ; public class Main { public static int solve ( int A , int B ) { int ans = Integer . MAX_VALUE ; for ( int one = - 4 ; one <= 4 ; one ++ ) { for ( int five = - 1 ; five <= 1 ; five ++ ) { for ( int ten = - 10 ; ten <= 10 ; ten ++ ) { if ( A + one + 5 * five + 10 * ten == B ) ans = Math . min ( ans , Math . abs ( one ) + Math . abs ( five ) + Math . abs ( ten ) ) ; } } } return ans ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( solve ( A , B ) ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE cs = input ( ) . strip ( ) NEW_LINE cd = { '1' : 0 , '2' : 0 , '3' : 0 , '4' : 0 } NEW_LINE for c in cs : NEW_LINE INDENT cd [ c ] += 1 NEW_LINE DEDENT print ( max ( v for v in cd . values ( ) ) , min ( v for v in cd . values ( ) ) ) NEW_LINE", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE dis = abs ( b - a ) NEW_LINE ans1 = int ( dis / 10 ) NEW_LINE ex = dis % 10 NEW_LINE if ( ex == 1 or ex == 5 ) : NEW_LINE INDENT ans2 = 1 NEW_LINE DEDENT elif ( ex == 3 or ex == 7 or ex == 8 ) : NEW_LINE INDENT ans2 = 3 NEW_LINE DEDENT elif ( ex == 0 ) : NEW_LINE INDENT ans2 = 0 NEW_LINE DEDENT else : NEW_LINE INDENT ans2 = 2 NEW_LINE DEDENT print ( ans1 + ans2 ) NEW_LINE", "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", "_ , c = open ( 0 ) ; print ( * sorted ( map ( c . count , '1234' ) ) [ : : - 3 ] ) NEW_LINE", "import numpy as np NEW_LINE class Calculator : NEW_LINE INDENT def __init__ ( self , arr ) : NEW_LINE INDENT self . arr = arr NEW_LINE DEDENT def calc ( self ) : NEW_LINE INDENT self . min_num = 9999 NEW_LINE self . max_num = 0 NEW_LINE for i in range ( 1 , 5 ) : NEW_LINE INDENT self . sum = np . sum ( self . arr == i ) NEW_LINE self . min_num = min ( self . min_num , self . sum ) NEW_LINE self . max_num = max ( self . max_num , self . sum ) NEW_LINE DEDENT DEDENT def get_max ( self ) : NEW_LINE INDENT return self . max_num NEW_LINE DEDENT def get_min ( self ) : NEW_LINE INDENT return self . min_num NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N , = map ( int , input ( ) . split ( ) ) NEW_LINE c = list ( map ( int , list ( input ( ) ) ) ) NEW_LINE arr = np . array ( c , dtype = int ) NEW_LINE calc = Calculator ( arr ) NEW_LINE calc . calc ( ) NEW_LINE print ( calc . get_max ( ) , calc . get_min ( ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc070_D
[ "import java . util . Scanner ; import java . util . ArrayList ; import java . util . List ; public class Main { static List < Edge > [ ] list ; static long [ ] dist ; static class Edge { int to ; long cost ; public Edge ( int to , long cost ) { this . to = to ; this . cost = cost ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; list = new ArrayList [ n ] ; dist = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { list [ i ] = new ArrayList < Edge > ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; long c = sc . nextLong ( ) ; list [ a ] . add ( new Edge ( b , c ) ) ; list [ b ] . add ( new Edge ( a , c ) ) ; } int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) - 1 ; dfs ( k , - 1 , 0 ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; System . out . println ( dist [ x ] + dist [ y ] ) ; } } static void dfs ( int place , int front , long cost ) { dist [ place ] = cost ; for ( Edge e : list [ place ] ) { if ( e . to != front ) { dfs ( e . to , place , cost + e . cost ) ; } } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . * ; public class Main { static ArrayList < Route > [ ] lists ; static long [ ] costs ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; lists = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { lists [ i ] = new ArrayList < Route > ( ) ; } for ( int i = 1 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; lists [ a ] . add ( new Route ( b , c ) ) ; lists [ b ] . add ( new Route ( a , c ) ) ; } costs = new long [ n + 1 ] ; Arrays . fill ( costs , - 1 ) ; int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; setCost ( 0 , k ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; sb . append ( costs [ x ] + costs [ y ] ) . append ( \" \\n \" ) ; } System . out . print ( sb ) ; } static void setCost ( long total , int idx ) { if ( costs [ idx ] == - 1 ) { costs [ idx ] = total ; for ( Route r : lists [ idx ] ) { setCost ( total + r . cost , r . point ) ; } } } static class Route { public int point ; public long cost ; public Route ( int point , long cost ) { this . point = point ; this . cost = cost ; } } } 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 { static List < Edge > [ ] list ; static long [ ] dist ; static class Edge { int to ; long cost ; public Edge ( int to , long cost ) { this . to = to ; this . cost = cost ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; list = new ArrayList [ n ] ; dist = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) list [ i ] = new ArrayList < Edge > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; long c = sc . nextLong ( ) ; list [ a ] . add ( new Edge ( b , c ) ) ; list [ b ] . add ( new Edge ( a , c ) ) ; } int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) - 1 ; dfs ( k , - 1 , 0 ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; System . out . println ( dist [ x ] + dist [ y ] ) ; } } static void dfs ( int v , int p , long d ) { dist [ v ] = d ; for ( Edge e : list [ v ] ) { if ( e . to != p ) { dfs ( e . to , v , d + e . cost ) ; } } } } 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 { 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 ( i ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = scanner . nextInt ( ) - 1 ; int b = scanner . nextInt ( ) - 1 ; int c = scanner . nextInt ( ) ; nodes [ a ] . edges . add ( new Edge ( nodes [ b ] , c ) ) ; nodes [ b ] . edges . add ( new Edge ( nodes [ a ] , c ) ) ; } int Q = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) - 1 ; dfs ( nodes [ K ] , 0 ) ; for ( int i = 0 ; i < Q ; i ++ ) { int x = scanner . nextInt ( ) - 1 ; int y = scanner . nextInt ( ) - 1 ; System . out . println ( nodes [ x ] . depth + nodes [ y ] . depth ) ; } } private static void dfs ( Node n , long depth ) { n . depth = depth ; n . visited = true ; for ( Edge e : n . edges ) { if ( ! e . to . visited ) dfs ( e . to , depth + e . dist ) ; } } static class Node { final int id ; boolean visited ; List < Edge > edges = new ArrayList < > ( ) ; long depth = 0 ; Node ( int id ) { this . id = id ; } } static class Edge { final Node to ; final int dist ; Edge ( Node to , int dist ) { this . to = to ; this . dist = dist ; } } }", "import java . util . Scanner ; import java . util . ArrayList ; public class Main { static ArrayList < Edge > [ ] list ; static long [ ] dist ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; list = new ArrayList [ n + 1 ] ; dist = new long [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { list [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long c = sc . nextLong ( ) ; list [ a ] . add ( new Edge ( b , c ) ) ; list [ b ] . add ( new Edge ( a , c ) ) ; } int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; dfs ( k , 0 , - 1 ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; System . out . println ( dist [ x ] + dist [ y ] ) ; } } static void dfs ( int now , long cost , int front ) { dist [ now ] = cost ; for ( Edge i : list [ now ] ) { if ( i . to != front ) { dfs ( i . to , i . cost + cost , now ) ; } } } static class Edge { int to ; long cost ; public Edge ( int to , long cost ) { this . to = to ; this . cost = cost ; } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "import sys NEW_LINE from collections import deque NEW_LINE def dfs ( start , dest , pre , d ) : NEW_LINE INDENT if d [ start ] [ dest ] > 0 : NEW_LINE INDENT return d [ start ] [ dest ] NEW_LINE DEDENT for i in range ( len ( d ) ) : NEW_LINE INDENT if d [ start ] [ i ] > 0 and i != pre : NEW_LINE INDENT c = dfs ( i , dest , start , d ) NEW_LINE if c > 0 : NEW_LINE INDENT return d [ start ] [ i ] + dfs ( i , dest , start , d ) NEW_LINE DEDENT DEDENT DEDENT return 0 NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE d = [ [ ] for _ in range ( N ) ] NEW_LINE for _ in range ( N - 1 ) : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE a , b = a - 1 , b - 1 NEW_LINE d [ a ] . append ( ( b , c ) ) NEW_LINE d [ b ] . append ( ( a , c ) ) NEW_LINE DEDENT Q , K = map ( int , input ( ) . split ( ) ) NEW_LINE K -= 1 NEW_LINE k_dist = [ 0 for _ in range ( N ) ] NEW_LINE start = deque ( ) NEW_LINE start . append ( K ) NEW_LINE while len ( start ) > 0 : NEW_LINE INDENT s = start . popleft ( ) NEW_LINE for dest , cost in d [ s ] : NEW_LINE INDENT if k_dist [ dest ] > 0 : NEW_LINE INDENT continue NEW_LINE DEDENT k_dist [ dest ] = k_dist [ s ] + cost NEW_LINE start . append ( dest ) NEW_LINE DEDENT DEDENT for _ in range ( Q ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = x - 1 , y - 1 NEW_LINE print ( int ( k_dist [ x ] + k_dist [ y ] ) ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 6 ) NEW_LINE n = int ( input ( ) ) NEW_LINE inf = float ( \" inf \" ) NEW_LINE road = [ dict ( ) for _ in range ( n + 1 ) ] NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE road [ a ] [ b ] = c NEW_LINE road [ b ] [ a ] = c NEW_LINE DEDENT q , k = map ( int , input ( ) . split ( ) ) NEW_LINE dfs = [ inf ] * ( n + 1 ) NEW_LINE dfs [ k ] = 0 NEW_LINE def dodfs ( x ) : NEW_LINE INDENT for i in road [ x ] : NEW_LINE INDENT if dfs [ i ] == inf : NEW_LINE INDENT dfs [ i ] = dfs [ x ] + road [ x ] [ i ] NEW_LINE dodfs ( i ) NEW_LINE DEDENT DEDENT return NEW_LINE DEDENT dodfs ( k ) NEW_LINE for _ in range ( q ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE print ( dfs [ x ] + dfs [ y ] ) NEW_LINE DEDENT", "import heapq NEW_LINE def dijkstra_heap ( s ) : NEW_LINE INDENT d = [ float ( \" inf \" ) ] * n NEW_LINE used = [ True ] * n NEW_LINE d [ s ] = 0 NEW_LINE used [ s ] = False NEW_LINE edgelist = [ ] NEW_LINE for e in edge [ s ] : NEW_LINE INDENT heapq . heappush ( edgelist , e ) NEW_LINE DEDENT while len ( edgelist ) : NEW_LINE INDENT minedge = heapq . heappop ( edgelist ) NEW_LINE if not used [ minedge [ 1 ] ] : NEW_LINE INDENT continue NEW_LINE DEDENT v = minedge [ 1 ] NEW_LINE d [ v ] = minedge [ 0 ] NEW_LINE used [ v ] = False NEW_LINE for e in edge [ v ] : NEW_LINE INDENT if used [ e [ 1 ] ] : NEW_LINE INDENT heapq . heappush ( edgelist , [ e [ 0 ] + d [ v ] , e [ 1 ] ] ) NEW_LINE DEDENT DEDENT DEDENT return d NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE edge = [ [ ] for i in range ( n ) ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT x , y , z = map ( int , input ( ) . split ( ) ) NEW_LINE edge [ x - 1 ] . append ( [ z , y - 1 ] ) NEW_LINE edge [ y - 1 ] . append ( [ z , x - 1 ] ) NEW_LINE DEDENT Q , K = map ( int , input ( ) . split ( ) ) NEW_LINE L = dijkstra_heap ( K - 1 ) NEW_LINE query = [ ] NEW_LINE for i in range ( Q ) : NEW_LINE INDENT query . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT for i in range ( Q ) : NEW_LINE INDENT print ( L [ query [ i ] [ 0 ] - 1 ] + L [ query [ i ] [ 1 ] - 1 ] ) NEW_LINE DEDENT", "from queue import Queue NEW_LINE def distances ( tree : list , treeSize : int , root : int ) -> list : NEW_LINE INDENT dists = [ 0 ] * treeSize NEW_LINE q = Queue ( ) NEW_LINE q . put ( ( root , - 1 , 0 ) ) NEW_LINE while not q . empty ( ) : NEW_LINE INDENT v , prev , d2v = q . get ( ) NEW_LINE dists [ v ] = d2v NEW_LINE for u , dv2u in tree [ v ] : NEW_LINE INDENT if prev == u : NEW_LINE INDENT continue NEW_LINE DEDENT q . put ( ( u , v , d2v + dv2u ) ) NEW_LINE DEDENT DEDENT return dists NEW_LINE DEDENT def transit_tree_path ( N : int , edges : list , Q : int , K : int , queries : list ) -> list : NEW_LINE INDENT tree = [ [ ] for _ in range ( N ) ] NEW_LINE for u , v , c in edges : NEW_LINE INDENT tree [ u - 1 ] . append ( ( v - 1 , c ) ) NEW_LINE tree [ v - 1 ] . append ( ( u - 1 , c ) ) NEW_LINE DEDENT d = distances ( tree , N , K - 1 ) NEW_LINE return [ d [ x - 1 ] + d [ y - 1 ] for x , y in queries ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE edges = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N - 1 ) ] NEW_LINE Q = 0 NEW_LINE Q , K = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( Q ) ] NEW_LINE ans = transit_tree_path ( N , edges , Q , K , queries ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT", "def solve ( N , ABCs , Q , K , XYs ) : NEW_LINE INDENT path = [ [ ] for _ in range ( N + 1 ) ] NEW_LINE for ( a , b , c ) in ABCs : NEW_LINE INDENT path [ a ] . append ( ( b , c ) ) NEW_LINE path [ b ] . append ( ( a , c ) ) NEW_LINE DEDENT dst = [ 0 for _ in range ( N + 1 ) ] NEW_LINE q = [ K ] NEW_LINE while len ( q ) : NEW_LINE INDENT index = q . pop ( ) NEW_LINE for n , w in path [ index ] : NEW_LINE INDENT if dst [ n ] == 0 : NEW_LINE INDENT dst [ n ] = dst [ index ] + w NEW_LINE q . append ( n ) NEW_LINE DEDENT DEDENT DEDENT ans = [ ] NEW_LINE for x , y in XYs : NEW_LINE INDENT ans . append ( str ( dst [ x ] + dst [ y ] ) ) NEW_LINE DEDENT return \" \\n \" . join ( ans ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ABCs = [ tuple ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) for _ in range ( N - 1 ) ] NEW_LINE Q , K = tuple ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) NEW_LINE XYs = [ tuple ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) for _ in range ( Q ) ] NEW_LINE print ( solve ( N , ABCs , Q , K , XYs ) ) NEW_LINE DEDENT" ]
atcoder_abc045_B
[ "import java . util . ArrayDeque ; import java . util . Deque ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { Map < String , Deque < String > > deq = new HashMap < > ( ) ; String [ ] participants = new String [ ] { \" a \" , \" b \" , \" c \" } ; for ( int i = 0 ; i < 3 ; i ++ ) { String s = sc . next ( ) ; deq . put ( participants [ i ] , new ArrayDeque < > ( ) ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { deq . get ( participants [ i ] ) . addLast ( s . charAt ( j ) + \" \" ) ; } } String prev = participants [ 0 ] ; while ( true ) { if ( deq . get ( prev ) . size ( ) == 0 ) { System . out . println ( prev . toUpperCase ( ) ) ; return ; } prev = deq . get ( prev ) . pollFirst ( ) ; } } }", "import java . util . Scanner ; class Main { static String a ; static String b ; static String c ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; a = sc . next ( ) ; b = sc . next ( ) ; c = sc . next ( ) ; char ac = a . charAt ( 0 ) ; int ans = 0 ; if ( ac == ' a ' ) { ans = DisCard ( 1 ) ; } else if ( ac == ' b ' ) { ans = DisCard ( 2 ) ; } else { ans = DisCard ( 3 ) ; } String answ = \" \" ; if ( ans == 1 ) { answ = \" A \" ; } else if ( ans == 2 ) { answ = \" B \" ; } else { answ = \" C \" ; } System . out . println ( answ ) ; sc . close ( ) ; } public static int DisCard ( int player ) { if ( player == 1 ) { if ( a . length ( ) == 0 ) { return 1 ; } else { char c = a . charAt ( 0 ) ; a = a . substring ( 1 ) ; if ( c == ' a ' ) { return DisCard ( 1 ) ; } else if ( c == ' b ' ) { return DisCard ( 2 ) ; } else { return DisCard ( 3 ) ; } } } else if ( player == 2 ) { if ( b . length ( ) == 0 ) { return 2 ; } else { char c = b . charAt ( 0 ) ; b = b . substring ( 1 ) ; if ( c == ' a ' ) { return DisCard ( 1 ) ; } else if ( c == ' b ' ) { return DisCard ( 2 ) ; } else { return DisCard ( 3 ) ; } } } else { if ( c . length ( ) == 0 ) { return 3 ; } else { char cha = c . charAt ( 0 ) ; c = c . substring ( 1 ) ; if ( cha == ' a ' ) { return DisCard ( 1 ) ; } else if ( cha == ' b ' ) { return DisCard ( 2 ) ; } else { return DisCard ( 3 ) ; } } } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String s_a = sc . next ( ) ; String s_b = sc . next ( ) ; String s_c = sc . next ( ) ; int la = s_a . length ( ) ; int lb = s_b . length ( ) ; int lc = s_c . length ( ) ; int a = la ; int b = lb ; int c = lc ; char turn = ' a ' ; String ans = null ; boolean end = false ; while ( ! end ) { switch ( turn ) { case ( ' a ' ) : if ( a == 0 ) { end = true ; ans = \" A \" ; break ; } turn = s_a . charAt ( la - a ) ; a -- ; break ; case ( ' b ' ) : if ( b == 0 ) { end = true ; ans = \" B \" ; break ; } turn = s_b . charAt ( lb - b ) ; b -- ; break ; case ( ' c ' ) : if ( c == 0 ) { end = true ; ans = \" C \" ; break ; } turn = s_c . charAt ( lc - c ) ; c -- ; break ; } } 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 . Scanner ; public class Main { public static char abc_ans ( String str_a , String str_b , String str_c ) { char [ ] a = str_a . toCharArray ( ) ; char [ ] b = str_b . toCharArray ( ) ; char [ ] c = str_c . toCharArray ( ) ; int a_count = a . length ; int b_count = b . length ; int c_count = c . length ; int a_number = 0 ; int b_number = 0 ; int c_number = 0 ; char x = a [ a_number ] ; while ( true ) { switch ( x ) { case ' a ' : if ( a_number >= a . length ) { return ( ' A ' ) ; } x = a [ a_number ] ; a_number ++ ; break ; case ' b ' : if ( b_number >= b . length ) { return ( ' B ' ) ; } x = b [ b_number ] ; b_number ++ ; break ; case ' c ' : if ( c_number >= c . length ) { return ( ' C ' ) ; } x = c [ c_number ] ; c_number ++ ; break ; } } } public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String str_a = scan . next ( ) ; String str_b = scan . next ( ) ; String str_c = scan . next ( ) ; System . out . println ( abc_ans ( str_a , str_b , str_c ) ) ; } }", "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 [ ] letters = new String [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { letters [ i ] = input . readLine ( ) ; } int current = 0 ; int [ ] positions = new int [ 3 ] ; while ( true ) { if ( positions [ current ] == letters [ current ] . length ( ) ) { System . out . println ( ( char ) ( current + ' A ' ) ) ; break ; } current = letters [ current ] . charAt ( positions [ current ] ++ ) - ' a ' ; } } }" ]
[ "S = { c : list ( input ( ) ) for c in \" abc \" } NEW_LINE s = \" a \" NEW_LINE while S [ s ] : NEW_LINE INDENT s = S [ s ] . pop ( 0 ) NEW_LINE DEDENT print ( s . upper ( ) ) NEW_LINE", "hoa = list ( input ( ) ) NEW_LINE hob = list ( input ( ) ) NEW_LINE hoc = list ( input ( ) ) NEW_LINE f = \" A \" NEW_LINE while 1 : NEW_LINE INDENT if ( f == \" A \" and len ( hoa ) == 0 ) : NEW_LINE INDENT print ( f ) NEW_LINE break NEW_LINE DEDENT elif ( f == \" B \" and len ( hob ) == 0 ) : NEW_LINE INDENT print ( f ) NEW_LINE break NEW_LINE DEDENT elif ( f == \" C \" and len ( hoc ) == 0 ) : NEW_LINE INDENT print ( f ) NEW_LINE break NEW_LINE DEDENT elif ( f == \" A \" ) : NEW_LINE INDENT if ( hoa [ 0 ] == \" a \" ) : NEW_LINE INDENT f = \" A \" NEW_LINE hoa = hoa [ 1 : ] NEW_LINE DEDENT elif ( hoa [ 0 ] == \" b \" ) : NEW_LINE INDENT f = \" B \" NEW_LINE hoa = hoa [ 1 : ] NEW_LINE DEDENT elif ( hoa [ 0 ] == \" c \" ) : NEW_LINE INDENT f = \" C \" NEW_LINE hoa = hoa [ 1 : ] NEW_LINE DEDENT DEDENT elif ( f == \" B \" ) : NEW_LINE INDENT if ( hob [ 0 ] == \" a \" ) : NEW_LINE INDENT f = \" A \" NEW_LINE hob = hob [ 1 : ] NEW_LINE DEDENT elif ( hob [ 0 ] == \" b \" ) : NEW_LINE INDENT f = \" B \" NEW_LINE hob = hob [ 1 : ] NEW_LINE DEDENT elif ( hob [ 0 ] == \" c \" ) : NEW_LINE INDENT f = \" C \" NEW_LINE hob = hob [ 1 : ] NEW_LINE DEDENT DEDENT elif ( f == \" C \" ) : NEW_LINE INDENT if ( hoc [ 0 ] == \" a \" ) : NEW_LINE INDENT f = \" A \" NEW_LINE hoc = hoc [ 1 : ] NEW_LINE DEDENT elif ( hoc [ 0 ] == \" b \" ) : NEW_LINE INDENT f = \" B \" NEW_LINE hoc = hoc [ 1 : ] NEW_LINE DEDENT elif ( hoc [ 0 ] == \" c \" ) : NEW_LINE INDENT f = \" C \" NEW_LINE hoc = hoc [ 1 : ] NEW_LINE DEDENT DEDENT DEDENT", "def str2turn ( c : str ) -> int : NEW_LINE INDENT if c . lower ( ) == ' a ' : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif c . lower ( ) == ' b ' : NEW_LINE INDENT return 1 NEW_LINE DEDENT return 2 NEW_LINE DEDENT def turn2str ( t : int ) -> str : NEW_LINE INDENT if t == 0 : NEW_LINE INDENT return ' a ' NEW_LINE DEDENT elif t == 1 : NEW_LINE INDENT return ' b ' NEW_LINE DEDENT return ' c ' NEW_LINE DEDENT def card_game_for_three ( Sa : str , Sb : str , Sc : str ) -> str : NEW_LINE INDENT indexes = [ 0 , 0 , 0 ] NEW_LINE limits = [ len ( Sa ) , len ( Sb ) , len ( Sc ) ] NEW_LINE cards = [ Sa , Sb , Sc ] NEW_LINE turn = 0 NEW_LINE while indexes [ turn ] < limits [ turn ] : NEW_LINE INDENT next_turn = str2turn ( cards [ turn ] [ indexes [ turn ] ] ) NEW_LINE indexes [ turn ] += 1 NEW_LINE turn = next_turn NEW_LINE DEDENT return turn2str ( turn ) . upper ( ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT Sa = input ( ) NEW_LINE Sb = input ( ) NEW_LINE Sc = input ( ) NEW_LINE ans = card_game_for_three ( Sa , Sb , Sc ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "def selection ( X , A , B , C ) : NEW_LINE INDENT if X == ' a ' : NEW_LINE INDENT if len ( A ) == 0 : NEW_LINE INDENT print ( ' A ' ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT Y = A . pop ( 0 ) NEW_LINE DEDENT DEDENT if X == ' b ' : NEW_LINE INDENT if len ( B ) == 0 : NEW_LINE INDENT print ( ' B ' ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT Y = B . pop ( 0 ) NEW_LINE DEDENT DEDENT if X == ' c ' : NEW_LINE INDENT if len ( C ) == 0 : NEW_LINE INDENT print ( ' C ' ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT Y = C . pop ( 0 ) NEW_LINE DEDENT DEDENT selection ( Y , A , B , C ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT Sa = list ( input ( ) ) NEW_LINE Sb = list ( input ( ) ) NEW_LINE Sc = list ( input ( ) ) NEW_LINE selection ( ' a ' , Sa , Sb , Sc ) NEW_LINE DEDENT main ( ) NEW_LINE", "import sys NEW_LINE p = [ \" A \" , \" B \" , \" C \" ] NEW_LINE p_dic = { \" a \" : 0 , \" b \" : 1 , \" c \" : 2 } NEW_LINE def card ( cards , player ) : NEW_LINE INDENT if len ( cards [ player ] ) == 0 : NEW_LINE INDENT print ( p [ player ] ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT x = cards [ player ] [ 0 ] NEW_LINE cards [ player ] = cards [ player ] [ 1 : ] NEW_LINE card ( cards , p_dic [ x ] ) NEW_LINE DEDENT DEDENT cards = [ input ( ) for i in range ( 3 ) ] NEW_LINE card ( cards , 0 ) NEW_LINE" ]
atcoder_abc081_B
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int hako [ ] = new int [ a ] ; int cont = 0 ; int flag = 1 ; for ( int i = 0 ; i < a ; i ++ ) { hako [ i ] = sc . nextInt ( ) ; } while ( flag == 1 ) { for ( int i = 0 ; i < a ; i ++ ) { if ( hako [ i ] % 2 == 0 ) { hako [ i ] = hako [ i ] / 2 ; } else { flag = 0 ; } } if ( flag == 1 ) { cont ++ ; } } System . out . print ( cont ) ; } }", "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 ) ) ; int min = 0 ; int n = Integer . parseInt ( input . readLine ( ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int [ ] value = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { value [ i ] = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } boolean state = true ; while ( state ) { for ( int i = 0 ; i < n && state ; i ++ ) { if ( ( value [ i ] & 1 ) == 0 ) { value [ i ] /= 2 ; } else { state = false ; } } if ( state ) min ++ ; } System . out . println ( min ) ; } static int log ( int x , int base ) { return ( int ) ( Math . log ( x ) / Math . log ( base ) ) ; } }", "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 count = scanner . nextInt ( ) ; scanner . nextLine ( ) ; System . out . println ( IntStream . range ( 0 , count ) . map ( i -> devide2Count ( scanner . nextInt ( ) ) ) . min ( ) . getAsInt ( ) ) ; } } private static int devide2Count ( int number ) { int result = 0 ; while ( number % 2 == 0 ) { number = number / 2 ; result ++ ; } return result ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { int n = sc . nextInt ( ) ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; int cnt = 0 ; while ( x % 2 == 0 ) { x /= 2 ; cnt ++ ; } ans = Math . min ( ans , cnt ) ; } System . out . println ( ans ) ; } } }", "import java . util . Scanner ; class Main { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; String [ ] s = S . split ( \" ▁ \" ) ; int [ ] n = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String tmp = s [ i ] ; n [ i ] = Integer . parseInt ( tmp ) ; } System . out . println ( calc ( n ) ) ; } public static int calc ( int n [ ] ) { int count = 0 ; while ( true ) { for ( int j = 0 ; j < n . length ; j ++ ) { if ( n [ j ] % 2 == 0 ) { n [ j ] /= 2 ; } else { return count ; } } count ++ ; } } }" ]
[ "a = int ( input ( ) ) NEW_LINE list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE flag = False NEW_LINE ans = 30 NEW_LINE for i in range ( 31 ) : NEW_LINE INDENT for j in list : NEW_LINE INDENT if j % ( 2 ** i ) != 0 : NEW_LINE INDENT if not ( flag ) : NEW_LINE INDENT flag = True NEW_LINE ans = i - 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import math NEW_LINE n = input ( ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = float ( \" inf \" ) NEW_LINE for i in a : NEW_LINE INDENT ans = min ( ans , len ( bin ( i ) ) - bin ( i ) . rfind ( \"1\" ) - 1 ) NEW_LINE DEDENT print ( round ( ans ) ) NEW_LINE", "import sys NEW_LINE line1 , line2 = [ sys . stdin . readline ( ) for i in range ( 2 ) ] NEW_LINE components = [ int ( i ) for i in line2 . strip ( ) . split ( ) ] NEW_LINE count = 0 NEW_LINE while all ( [ i % 2 == 0 for i in components ] ) : NEW_LINE INDENT count += 1 NEW_LINE components = [ i // 2 for i in components ] NEW_LINE DEDENT else : NEW_LINE INDENT print ( count ) NEW_LINE DEDENT", "num = int ( input ( ) ) NEW_LINE board = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE evener = 0 NEW_LINE ope = True NEW_LINE while True : NEW_LINE INDENT for i in range ( num ) : NEW_LINE INDENT if board [ i ] % 2 == 0 : NEW_LINE INDENT board [ i ] = board [ i ] / 2 NEW_LINE DEDENT else : NEW_LINE INDENT ope = False NEW_LINE break NEW_LINE DEDENT DEDENT if ope == True : NEW_LINE INDENT evener += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( evener ) NEW_LINE", "input ( ) NEW_LINE numbers = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count = 0 NEW_LINE while ( True ) : NEW_LINE INDENT if sum ( list ( map ( lambda x : x % 2 , numbers ) ) ) == 0 : NEW_LINE INDENT numbers = list ( map ( lambda x : x / 2 , numbers ) ) NEW_LINE count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE" ]
atcoder_abc090_A
[ "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String input1 = sc . nextLine ( ) ; String input2 = sc . nextLine ( ) ; String input3 = sc . nextLine ( ) ; System . out . println ( input1 . substring ( 0 , 1 ) + input2 . substring ( 1 , 2 ) + input3 . substring ( 2 , 3 ) ) ; } }", "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 ) { for ( int i = 0 ; i < 3 ; i ++ ) { String S = in . next ( ) ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( i == j ) { out . print ( S . charAt ( i ) ) ; } } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String C1 = sc . next ( ) ; String C2 = sc . next ( ) ; String C3 = sc . next ( ) ; System . out . println ( \" \" + C1 . charAt ( 0 ) + C2 . charAt ( 1 ) + C3 . charAt ( 2 ) ) ; } }", "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 ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , Scanner in , PrintWriter out ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { sb . append ( in . next ( ) . charAt ( i ) ) ; } out . print ( sb . toString ( ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] ary = new String [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { ary [ i ] = sc . next ( ) ; } System . out . println ( ary [ 0 ] . substring ( 0 , 1 ) + ary [ 1 ] . substring ( 1 , 2 ) + ary [ 2 ] . substring ( 2 , 3 ) ) ; } }" ]
[ "C1 = input ( ) NEW_LINE C2 = input ( ) NEW_LINE C3 = input ( ) NEW_LINE print ( C1 [ : 1 ] + C2 [ 1 : 2 ] + C3 [ 2 : ] ) NEW_LINE", "s = [ input ( ) for _ in range ( 3 ) ] NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT print ( s [ i ] [ i ] , end = ' ' ) NEW_LINE DEDENT print ( ' ' ) NEW_LINE", "print ( ' ' . join ( [ input ( ) [ i ] for i in range ( 3 ) ] ) ) NEW_LINE", "A = input ( ) NEW_LINE B = input ( ) NEW_LINE C = input ( ) NEW_LINE print ( A [ 0 ] + B [ 1 ] + C [ - 1 ] ) NEW_LINE", "n = 3 NEW_LINE C = [ None ] * 3 NEW_LINE for i in range ( n ) : NEW_LINE INDENT C [ i ] = input ( ) [ i ] NEW_LINE DEDENT print ( ' ' . join ( C ) ) NEW_LINE" ]
atcoder_abc036_B
[ "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws InterruptedException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] a = new String [ n ] ; String [ ] [ ] s = new String [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { s [ ( n - 1 ) - i ] [ j ] = a [ i ] . substring ( j , j + 1 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( s [ j ] [ i ] ) ; } System . out . print ( \" \\n \" ) ; } sc . close ( ) ; } public static int gcd ( int a , int b ) { if ( a < b ) { int tmp = a ; a = b ; b = tmp ; } int r = - 1 ; while ( r != 0 ) { r = a % b ; a = b ; b = r ; } return a ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . io . UncheckedIOException ; import java . util . stream . Stream ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; String [ ] s = in . string ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { out . print ( s [ n - j - 1 ] . charAt ( i ) ) ; } out . println ( ) ; } } } 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 String [ ] string ( int length ) { return IntStream . range ( 0 , length ) . mapToObj ( x -> string ( ) ) . toArray ( String [ ] :: new ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; String [ ] S = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { S [ i ] = scanner . next ( ) ; } char [ ] [ ] s = new char [ N ] [ N ] ; char [ ] [ ] t = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { s [ i ] [ j ] = S [ i ] . charAt ( j ) ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { t [ j ] [ N - i - 1 ] = s [ i ] [ j ] ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { System . out . print ( t [ i ] [ j ] ) ; } System . out . println ( ) ; } } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; char [ ] [ ] arr = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String line = scanner . nextLine ( ) ; for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = line . charAt ( j ) ; } } for ( int j = 0 ; j < n ; j ++ ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { System . out . print ( arr [ i ] [ j ] ) ; } System . out . print ( \" \\n \" ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char [ ] [ ] mass = new char [ n ] [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { String s = sc . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { mass [ j ] [ i ] = s . charAt ( j ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( char c : mass [ i ] ) System . out . print ( c ) ; System . out . println ( ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE s = [ list ( input ( ) ) for _ in range ( n ) ] NEW_LINE a = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT tmp = [ ] NEW_LINE for j in range ( n ) : NEW_LINE INDENT tmp . append ( s [ n - j - 1 ] [ i ] ) NEW_LINE DEDENT a . append ( tmp ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( ' ' . join ( a [ i ] ) ) NEW_LINE DEDENT", "def rotate ( N : int , S : list ) -> list : NEW_LINE INDENT res = [ ' ' for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT res [ i ] += S [ N - j - 1 ] [ i ] NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE S = [ input ( ) for _ in range ( N ) ] NEW_LINE ans = rotate ( N , S ) NEW_LINE print ( ' \\n ' . join ( ans ) ) NEW_LINE DEDENT", "_ , * t = open ( 0 ) NEW_LINE for x in zip ( * t ) : print ( * x [ : : - 1 ] , sep = ' ' ) NEW_LINE", "import copy NEW_LINE n = int ( input ( ) ) NEW_LINE p = [ [ \" a \" ] * ( n ) ] * ( n ) NEW_LINE q = [ [ \" a \" ] * ( n ) ] * ( n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT p [ i ] = list ( input ( ) ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT q [ i ] [ j ] = p [ n - 1 - j ] [ i ] NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT print ( p [ n - 1 - j ] [ i ] , end = \" \" ) NEW_LINE if j == n - 1 : NEW_LINE INDENT print ( \" \" ) NEW_LINE DEDENT DEDENT DEDENT", "import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE s = np . array ( [ [ c for c in input ( ) ] for _ in range ( N ) ] ) NEW_LINE s = np . rot90 ( s , k = - 1 ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT print ( \" \" . join ( s [ i ] ) ) NEW_LINE DEDENT" ]
atcoder_abc110_C
[ "import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { char [ ] S = sc . next ( ) . toCharArray ( ) ; char [ ] T = sc . next ( ) . toCharArray ( ) ; int [ ] start = new int [ 26 ] ; int [ ] end = new int [ 26 ] ; Arrays . fill ( start , - 1 ) ; Arrays . fill ( end , - 1 ) ; for ( int i = 0 ; i < S . length ; i ++ ) { int a = S [ i ] - ' a ' ; int b = T [ i ] - ' a ' ; if ( ( start [ a ] != - 1 && end [ b ] != a ) || ( end [ b ] != - 1 && start [ a ] != b ) ) { System . out . println ( \" No \" ) ; return ; } start [ a ] = b ; end [ b ] = a ; } System . out . println ( \" Yes \" ) ; } }", "import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Main { public static final String YES = \" Yes \" ; public static final String NO = \" No \" ; public static String process ( TestCase testCase ) { final String S = testCase . S ; final String T = testCase . T ; Map < Character , Integer > sCharFreq = countCharFrequencies ( S ) ; Map < Character , Integer > tCharFreq = countCharFrequencies ( T ) ; Map < Integer , Integer > sFreqMap = toFreqMap ( sCharFreq ) ; Map < Integer , Integer > tFreqMap = toFreqMap ( tCharFreq ) ; return sFreqMap . equals ( tFreqMap ) ? YES : NO ; } private static Map < Character , Integer > countCharFrequencies ( String str ) { Map < Character , Integer > map = new HashMap < > ( ) ; str . chars ( ) . mapToObj ( i -> ( char ) i ) . forEach ( c -> { if ( map . containsKey ( c ) ) { map . put ( c , map . get ( c ) + 1 ) ; } else { map . put ( c , 1 ) ; } } ) ; return map ; } private static Map < Integer , Integer > toFreqMap ( Map < Character , Integer > charFreq ) { Map < Integer , Integer > map = new HashMap < > ( ) ; charFreq . values ( ) . forEach ( c -> { if ( map . containsKey ( c ) ) { map . put ( c , map . get ( c ) + 1 ) ; } else { map . put ( c , 1 ) ; } } ) ; return map ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final String result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; return new TestCase ( S , T ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final String S ; final String T ; public TestCase ( String S , String T ) { this . S = S ; this . T = T ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = new String [ 2 ] ; s [ 0 ] = sc . next ( ) ; s [ 1 ] = sc . next ( ) ; char [ ] c = new char [ ] { ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' , ' G ' , ' H ' , ' I ' , ' J ' , ' K ' , ' L ' , ' M ' , ' N ' , ' O ' , ' P ' , ' Q ' , ' R ' , ' S ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' , ' Z ' } ; for ( int j = 0 ; j < 2 ; j ++ ) { int cidx = 0 ; for ( int i = 0 ; i < s [ j ] . length ( ) ; i ++ ) { char sca = s [ j ] . charAt ( i ) ; if ( Character . isLowerCase ( sca ) ) { s [ j ] = s [ j ] . replace ( sca , c [ cidx ++ ] ) ; } } } System . out . println ( s [ 0 ] . equals ( s [ 1 ] ) ? \" Yes \" : \" No \" ) ; } }", "import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; 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 ( ) ; sc . close ( ) ; Map < Character , Integer > mapS = new HashMap < Character , Integer > ( ) ; Map < Character , Integer > mapT = new HashMap < Character , Integer > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char charS = s . charAt ( i ) ; char charT = t . charAt ( i ) ; if ( mapS . containsKey ( charS ) ) { if ( mapT . containsKey ( charT ) ) { if ( ! mapS . get ( charS ) . equals ( mapT . get ( charT ) ) ) { System . out . println ( \" No \" ) ; return ; } } else { System . out . println ( \" No \" ) ; return ; } } else { if ( mapT . containsKey ( charT ) ) { System . out . println ( \" No \" ) ; return ; } cnt ++ ; mapS . put ( charS , cnt ) ; mapT . put ( charT , cnt ) ; } } System . out . println ( \" Yes \" ) ; } }", "import java . io . InputStream ; import java . io . PrintStream ; import java . util . Arrays ; 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 ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int [ ] ms = new int [ 26 ] ; int [ ] mt = new int [ 26 ] ; Arrays . fill ( ms , - 1 ) ; Arrays . fill ( mt , - 1 ) ; String ans = \" Yes \" ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { int ss = S . charAt ( i ) - ' a ' ; int tt = T . charAt ( i ) - ' a ' ; if ( ( ms [ ss ] == - 1 || ms [ ss ] == tt ) && ( mt [ tt ] == - 1 || mt [ tt ] == ss ) ) { ms [ ss ] = tt ; mt [ tt ] = ss ; } else { ans = \" No \" ; break ; } } out . println ( ans ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }" ]
[ "prj = { } NEW_LINE prj_inv = { } NEW_LINE s = input ( ) NEW_LINE t = input ( ) NEW_LINE for i , j in zip ( s , t ) : NEW_LINE INDENT if i not in prj and j not in prj_inv : NEW_LINE INDENT prj [ i ] = j NEW_LINE prj_inv [ j ] = i NEW_LINE DEDENT elif i in prj and j in prj_inv : NEW_LINE INDENT if prj [ i ] == j : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT", "S = list ( input ( ) ) NEW_LINE T = list ( input ( ) ) NEW_LINE def replacer ( ) : NEW_LINE INDENT m = { } NEW_LINE i = ord ( \" A \" ) NEW_LINE def replace ( c ) : NEW_LINE INDENT nonlocal i NEW_LINE if c not in m : NEW_LINE INDENT m [ c ] = chr ( i ) NEW_LINE i += 1 NEW_LINE DEDENT return m [ c ] NEW_LINE DEDENT return replace NEW_LINE DEDENT rs = \" \" . join ( map ( replacer ( ) , S ) ) NEW_LINE rt = \" \" . join ( map ( replacer ( ) , T ) ) NEW_LINE print ( \" Yes \" if rs == rt else \" No \" ) NEW_LINE", "import sys NEW_LINE import collections NEW_LINE YES = \" Yes \" NEW_LINE NO = \" No \" NEW_LINE def solve ( S : str , T : str ) : NEW_LINE INDENT wcS = collections . defaultdict ( int ) NEW_LINE wcT = collections . defaultdict ( int ) NEW_LINE for c in S : NEW_LINE INDENT wcS [ c ] += 1 NEW_LINE DEDENT for c in T : NEW_LINE INDENT wcT [ c ] += 1 NEW_LINE DEDENT cS = collections . defaultdict ( int ) NEW_LINE cT = collections . defaultdict ( int ) NEW_LINE for key in wcS : NEW_LINE INDENT cS [ wcS [ key ] ] += 1 NEW_LINE DEDENT for key in wcT : NEW_LINE INDENT cT [ wcT [ key ] ] += 1 NEW_LINE DEDENT representable = True NEW_LINE if len ( cT . keys ( ) ) > len ( cS . keys ( ) ) : NEW_LINE INDENT temp = cT NEW_LINE cT = cS NEW_LINE cS = temp NEW_LINE DEDENT for key in cS : NEW_LINE INDENT if cT [ key ] != cS [ key ] : NEW_LINE INDENT representable = False NEW_LINE DEDENT DEDENT print ( YES if representable else NO ) 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 S = next ( tokens ) NEW_LINE T = next ( tokens ) NEW_LINE solve ( S , T ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def check ( s , t ) : NEW_LINE INDENT from collections import Counter NEW_LINE sc = Counter ( s ) NEW_LINE tc = Counter ( t ) NEW_LINE return sorted ( sc . values ( ) ) == sorted ( tc . values ( ) ) NEW_LINE DEDENT print ( [ ' No ' , ' Yes ' ] [ check ( input ( ) , input ( ) ) ] ) NEW_LINE", "S = input ( ) NEW_LINE T = input ( ) NEW_LINE check = { ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' , ' G ' , ' H ' , ' I ' , ' J ' , ' K ' , ' L ' , ' M ' , ' N ' , ' O ' , ' P ' , ' Q ' , ' R ' , ' S ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' , ' Z ' } NEW_LINE alll = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' , ' G ' , ' H ' , ' I ' , ' J ' , ' K ' , ' L ' , ' M ' , ' N ' , ' O ' , ' P ' , ' Q ' , ' R ' , ' S ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' , ' Z ' ] NEW_LINE alfa = { ' a ' , ' b ' , ' c ' , ' d ' , ' e ' , ' f ' , ' g ' , ' h ' , ' i ' , ' j ' , ' k ' , ' l ' , ' m ' , ' n ' , ' o ' , ' p ' , ' q ' , ' r ' , ' s ' , ' t ' , ' u ' , ' v ' , ' w ' , ' x ' , ' y ' , ' z ' } NEW_LINE count_s = set ( ) NEW_LINE count_t = set ( ) NEW_LINE nums = 0 NEW_LINE numt = 0 NEW_LINE for s in range ( len ( S ) ) : NEW_LINE INDENT if count_s == alfa : NEW_LINE INDENT break NEW_LINE DEDENT if S [ s ] in check : NEW_LINE INDENT continue NEW_LINE DEDENT count_s . add ( S [ s ] ) NEW_LINE S = S . replace ( S [ s ] , str ( alll [ nums ] ) ) NEW_LINE nums += 1 NEW_LINE DEDENT for t in range ( len ( T ) ) : NEW_LINE INDENT if count_t == alfa : NEW_LINE INDENT break NEW_LINE DEDENT if T [ t ] in check : NEW_LINE INDENT continue NEW_LINE DEDENT count_t . add ( T [ t ] ) NEW_LINE T = T . replace ( T [ t ] , str ( alll [ numt ] ) ) NEW_LINE numt += 1 NEW_LINE DEDENT if S == T : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : print ( ' No ' ) NEW_LINE" ]
atcoder_abc021_D
[ "import java . util . Scanner ; class Main { static int max = 100002 ; static int MOD = 1000000007 ; static long [ ] fac = new long [ max ] ; static long [ ] finv = new long [ max ] ; static long [ ] inv = new long [ max ] ; public static void main ( String [ ] args ) { COMinit ( ) ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long kotae = COM ( n , 1 ) * COM ( k - 1 , 0 ) ; for ( int i = 2 ; i <= Math . min ( n , k ) ; i ++ ) { kotae += COM ( n , i ) * COM ( k - 1 , i - 1 ) % MOD ; kotae %= MOD ; } System . out . println ( kotae ) ; } static void COMinit ( ) { fac [ 0 ] = fac [ 1 ] = 1 ; finv [ 0 ] = finv [ 1 ] = 1 ; inv [ 1 ] = 1 ; for ( int i = 2 ; i < max ; i ++ ) { fac [ i ] = fac [ i - 1 ] * i % MOD ; inv [ i ] = MOD - inv [ MOD % i ] * ( MOD / i ) % MOD ; finv [ i ] = finv [ i - 1 ] * inv [ i ] % MOD ; } } static long COM ( int n , int k ) { if ( n < k ) return 0 ; if ( n < 0 || k < 0 ) return 0 ; return fac [ n ] * ( finv [ k ] * finv [ n - k ] % MOD ) % MOD ; } }", "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 k = sc . nextInt ( ) ; Init ( 1000000 ) ; out . println ( combi ( n - 1 + k , n - 1 ) ) ; } static long power ( long x , int n ) { long mod = 1000000007 ; if ( n == 0 ) return 1 ; if ( n % 2 == 0 ) { long e = power ( x , n / 2 ) % mod ; return ( e * e ) % mod ; } return ( x * power ( x , n - 1 ) ) % mod ; } static int mod = 1000000007 ; static long [ ] fact ; static long [ ] inv ; static void Init ( int n ) { fact = new long [ n ] ; inv = new long [ n ] ; fact [ 0 ] = inv [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { fact [ i ] = ( fact [ i - 1 ] * i ) % mod ; inv [ i ] = power ( fact [ i ] , mod - 2 ) ; } } static long combi ( int n , int k ) { return ( ( fact [ n ] * inv [ n - k ] ) % mod * inv [ k ] ) % mod ; } }", "import java . util . * ; public class Main { public static long MOD = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long p1 = 1 ; long p2 = 1 ; long p3 = 1 ; for ( long i = 1 ; i <= n + k - 1 ; i ++ ) { p1 = ( p1 * i ) % MOD ; } for ( long i = 1 ; i <= k ; i ++ ) { p2 = ( p2 * i ) % MOD ; } for ( long i = 1 ; i <= n - 1 ; i ++ ) { p3 = ( p3 * i ) % MOD ; } long p = ( p2 * p3 ) % MOD ; long inv = func ( p , MOD - 2 ) ; System . out . println ( ( p1 * inv ) % MOD ) ; } public static long func ( long a , long x ) { if ( x == 0 ) return 1 ; if ( x % 2 == 0 ) { long t = func ( a , x / 2 ) ; return ( t * t ) % MOD ; } long t = func ( a , ( x - 1 ) / 2 ) ; t = ( t * t ) % MOD ; return ( t * a ) % MOD ; } }", "import java . util . Scanner ; public class Main { static final int INF = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; final int K = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( getHomogeneousCombination ( N , K ) ) ; } private static long getHomogeneousCombination ( int n , int r ) { return getCombination ( n - 1 + r , n - 1 ) ; } private static long getCombination ( int n , int r ) { long [ ] modDp = new long [ n + 1 ] ; long [ ] modInvDp = new long [ n + 1 ] ; modDp [ 0 ] = 1 ; modInvDp [ n ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) modDp [ i ] = ( modDp [ i - 1 ] * i ) % INF ; long tmp = modDp [ n ] ; long doubling = INF - 2 ; while ( doubling > 0 ) { if ( doubling % 2 == 1 ) modInvDp [ n ] = ( modInvDp [ n ] * tmp ) % INF ; tmp = ( tmp * tmp ) % INF ; doubling /= 2 ; } for ( int i = n ; i > 0 ; i -- ) modInvDp [ i - 1 ] = modInvDp [ i ] * i % INF ; long ans = modDp [ n ] ; ans = ans * modInvDp [ r ] % INF ; ans = ans * modInvDp [ n - r ] % INF ; return ans ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; long INF = 1000000007 ; long ans = 1 ; for ( int i = k + 1 ; i < n + k ; i ++ ) { ans *= i ; ans %= INF ; } long div [ ] = new long [ 31 ] ; div [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { div [ 0 ] *= i ; div [ 0 ] %= INF ; } int [ ] two = new int [ 31 ] ; two [ 0 ] = 1 ; for ( int i = 1 ; i < 31 ; i ++ ) { two [ i ] = two [ i - 1 ] * 2 ; div [ i ] = div [ i - 1 ] * div [ i - 1 ] ; div [ i ] %= INF ; } long mom = 1 ; for ( int i = 0 ; i < 31 ; i ++ ) { if ( ( two [ i ] & ( INF - 2 ) ) > 0 ) { mom *= div [ i ] ; mom %= INF ; } } ans *= mom ; ans %= INF ; System . out . println ( ans ) ; } }" ]
[ "m = 10 ** 9 + 7 NEW_LINE def f ( a , b ) : NEW_LINE INDENT r = 1 NEW_LINE for i in range ( b ) : NEW_LINE INDENT r = r * ( n + k - 1 - i ) * pow ( i + 1 , m - 2 , m ) % m NEW_LINE DEDENT return r NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE print ( f ( n , k ) ) NEW_LINE", "def get_inverse_element ( x : int , mod : int ) -> int : NEW_LINE INDENT ans = 1 NEW_LINE bit = bin ( mod - 2 ) [ : 1 : - 1 ] NEW_LINE for c in bit : NEW_LINE INDENT if c == \"1\" : NEW_LINE INDENT ans = ans * x % mod NEW_LINE DEDENT x = x * x % mod NEW_LINE DEDENT return ans NEW_LINE DEDENT n , k , mod = int ( input ( ) ) , int ( input ( ) ) , 10 ** 9 + 7 NEW_LINE n1 , n2 , n3 = 1 , 1 , 1 NEW_LINE _n = 1 NEW_LINE for i in range ( 1 , n + k ) : NEW_LINE INDENT _n = ( _n * i ) % mod NEW_LINE if i == n - 1 + k : NEW_LINE INDENT n1 = _n NEW_LINE DEDENT if i == n - 1 : NEW_LINE INDENT n2 = _n NEW_LINE DEDENT if i == k : NEW_LINE INDENT n3 = _n NEW_LINE DEDENT DEDENT n2 = get_inverse_element ( n2 , mod ) NEW_LINE n3 = get_inverse_element ( n3 , mod ) NEW_LINE print ( ( n1 * n2 * n3 ) % mod ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 100000 ) NEW_LINE class Mod1000000007 ( ) : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . n = n % 1000000007 NEW_LINE DEDENT def plus ( self , m ) : NEW_LINE INDENT self . n = ( self . n + m ) % 1000000007 NEW_LINE return self NEW_LINE DEDENT def minus ( self , m ) : NEW_LINE INDENT self . n = ( self . n - m ) % 1000000007 NEW_LINE return self NEW_LINE DEDENT def times ( self , m ) : NEW_LINE INDENT self . n = ( ( self . n ) * ( m % 1000000007 ) ) % 1000000007 NEW_LINE return self NEW_LINE DEDENT def frac ( self , m ) : NEW_LINE INDENT l = [ 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 1 , 0 , 0 , 1 , 1 , 1 , 0 , 1 , 1 , 1 ] NEW_LINE ans = 1 NEW_LINE pow = m % 1000000007 NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if l [ i ] == 1 : NEW_LINE INDENT ans = ( ans * pow ) % 1000000007 NEW_LINE DEDENT if i != len ( l ) - 1 : NEW_LINE INDENT pow = ( pow ** 2 ) % 1000000007 NEW_LINE DEDENT DEDENT return self . times ( ans ) NEW_LINE DEDENT DEDENT ( n , k ) = ( int ( input ( ) ) , int ( input ( ) ) ) NEW_LINE ans = Mod1000000007 ( 1 ) NEW_LINE for j in range ( k ) : NEW_LINE INDENT ans . times ( n + j ) . frac ( j + 1 ) NEW_LINE DEDENT print ( ans . n ) NEW_LINE", "import math NEW_LINE n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE 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 print ( cmb ( n + k - 1 , n - 1 ) % ( 10 ** 9 + 7 ) ) NEW_LINE", "def d_multi_loop ( N , K ) : NEW_LINE INDENT class Combination ( object ) : NEW_LINE INDENT def __init__ ( self , n , mod ) : NEW_LINE INDENT self . mod = mod NEW_LINE self . factorial = [ 1 ] * ( n + 1 ) NEW_LINE for k in range ( 1 , n ) : NEW_LINE INDENT self . factorial [ k + 1 ] = ( self . factorial [ k ] * ( k + 1 ) ) % mod NEW_LINE DEDENT self . fact_inv = [ 1 ] * ( n + 1 ) NEW_LINE self . fact_inv [ n ] = pow ( self . factorial [ n ] , mod - 2 , mod ) NEW_LINE for k in reversed ( range ( 1 , n + 1 ) ) : NEW_LINE INDENT self . fact_inv [ k - 1 ] = ( self . fact_inv [ k ] * k ) % mod NEW_LINE DEDENT DEDENT def comb ( self , n , r ) : NEW_LINE INDENT if n < 0 or r < 0 or n < r : NEW_LINE INDENT return 0 NEW_LINE DEDENT return ( self . factorial [ n ] * self . fact_inv [ r ] * self . fact_inv [ n - r ] ) % self . mod NEW_LINE DEDENT def comb_with_repetition ( self , n , r ) : NEW_LINE INDENT if n == 0 and r > 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT if n >= 0 and r == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT return self . comb ( n + r - 1 , r ) NEW_LINE DEDENT DEDENT ans = Combination ( N + K , 10 ** 9 + 7 ) . comb_with_repetition ( N , K ) NEW_LINE return ans NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE print ( d_multi_loop ( N , K ) ) NEW_LINE" ]
atcoder_abc053_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int num = s . length ( ) ; int min = 10 ; int max = 0 ; for ( int i = 0 ; i < num ; i ++ ) { if ( s . charAt ( i ) == ' A ' ) { min = i ; break ; } } for ( int i = 0 ; i < num ; i ++ ) { if ( s . charAt ( i ) == ' Z ' ) { max = i ; } } System . out . print ( max - min + 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 ) { String s = in . next ( ) ; int a = Integer . MAX_VALUE ; int z = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' ) { a = Math . min ( a , i ) ; } else if ( s . charAt ( i ) == ' Z ' ) { z = i ; } } out . println ( z - a + 1 ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int a = s . indexOf ( \" A \" ) ; int z = s . lastIndexOf ( \" Z \" ) ; String str = s . substring ( a , z + 1 ) ; sc . close ( ) ; System . out . println ( str . length ( ) ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String s = sc . next ( ) ; int l = s . length ( ) ; int st = l - 1 ; int en = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( s . charAt ( i ) == ' A ' ) { st = Math . min ( i , st ) ; } if ( s . charAt ( i ) == ' Z ' ) { en = Math . max ( i , en ) ; } } System . out . println ( en - st + 1 ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; int start = - 1 , end = - 1 ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { if ( word . charAt ( i ) == ' A ' ) { start = i ; break ; } } for ( int i = word . length ( ) - 1 ; i > 0 ; i -- ) { if ( word . charAt ( i ) == ' Z ' ) { end = i ; break ; } } System . out . println ( end - start + 1 ) ; } }" ]
[ "S = input ( ) NEW_LINE A = 0 NEW_LINE Z = 0 NEW_LINE flg = 0 NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i ] == ' A ' and flg == 0 : NEW_LINE INDENT A = i NEW_LINE flg = 1 NEW_LINE DEDENT if S [ i ] == ' Z ' : NEW_LINE INDENT Z = i NEW_LINE DEDENT DEDENT print ( Z - A + 1 ) NEW_LINE", "s = input ( ) NEW_LINE print ( len ( s ) - s [ : : - 1 ] . index ( ' Z ' ) - s . index ( ' A ' ) ) NEW_LINE", "s = input ( ) NEW_LINE index = [ ] NEW_LINE for i , c in enumerate ( s ) : NEW_LINE INDENT if c == \" A \" : NEW_LINE INDENT index . append ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT for i , c in enumerate ( reversed ( s ) ) : NEW_LINE INDENT if c == \" Z \" : NEW_LINE INDENT index . append ( len ( s ) - i ) NEW_LINE break NEW_LINE DEDENT DEDENT count = len ( s [ index [ 0 ] : index [ 1 ] ] ) NEW_LINE print ( count ) NEW_LINE", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT s = list ( _ for _ in input ( ) ) NEW_LINE max_s = 0 NEW_LINE from_i = 0 NEW_LINE to_i = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' A ' : NEW_LINE INDENT from_i = i NEW_LINE break NEW_LINE DEDENT DEDENT s = s [ : : - 1 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' Z ' : NEW_LINE INDENT to_i = i NEW_LINE break NEW_LINE DEDENT DEDENT print ( ( len ( s ) - to_i ) - from_i ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "s = input ( ) NEW_LINE left = 0 NEW_LINE right = 0 NEW_LINE flag = True NEW_LINE for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT if s [ i ] == \" A \" and flag : NEW_LINE INDENT left = i NEW_LINE flag = False NEW_LINE DEDENT if s [ i ] == \" Z \" : NEW_LINE INDENT right = i NEW_LINE DEDENT DEDENT print ( right - left + 1 ) NEW_LINE" ]
atcoder_abc064_D
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; char [ ] s = scanner . next ( ) . toCharArray ( ) ; int left = 0 ; int tmp = 0 ; for ( char ch : s ) { if ( ch == ' ( ' ) tmp -- ; else tmp ++ ; left = Math . max ( left , tmp ) ; } int right = 0 ; tmp = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { char ch = s [ i ] ; if ( ch == ' ) ' ) tmp -- ; else tmp ++ ; right = Math . max ( right , tmp ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < left ; i ++ ) sb . append ( ' ( ' ) ; sb . append ( s ) ; for ( int i = 0 ; i < right ; i ++ ) sb . append ( ' ) ' ) ; System . out . println ( sb . toString ( ) ) ; } }", "import java . util . * ; import java . awt . * ; import java . awt . geom . Point2D ; 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 [ ] c = new int [ n + 1 ] ; String s = sc . next ( ) ; String r = \" \" ; String l = \" \" ; int neg = 101 ; for ( int i = 0 ; i < n ; i ++ ) { char a = s . charAt ( i ) ; if ( a == ' ( ' ) c [ i + 1 ] = c [ i ] + 1 ; else c [ i + 1 ] = c [ i ] - 1 ; neg = min ( c [ i + 1 ] , neg ) ; } for ( int i = 0 ; i < - neg ; i ++ ) { l += \" ( \" ; } s = l + s ; int temp = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' ( ' ) temp ++ ; else temp -- ; } for ( int i = 0 ; i < temp ; i ++ ) { r += \" ) \" ; } out . println ( s + r ) ; } }", "import java . util . * ; public class Main { private static final char LEFT = ' ( ' ; private static final char RIGHT = ' ) ' ; public static void main ( String [ ] args ) { new Main ( ) . execute ( ) ; } public void execute ( ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int [ ] count = new int [ N ] ; count [ 0 ] = ( s . charAt ( 0 ) == LEFT ) ? 1 : - 1 ; int min = Math . min ( 0 , count [ 0 ] ) ; for ( int i = 1 ; i < N ; i ++ ) { switch ( s . charAt ( i ) ) { case LEFT : count [ i ] = count [ i - 1 ] + 1 ; break ; case RIGHT : count [ i ] = count [ i - 1 ] - 1 ; break ; default : throw new IllegalArgumentException ( ) ; } if ( count [ i ] < 0 ) { min = Math . min ( count [ i ] , min ) ; } } StringBuilder str = new StringBuilder ( ) ; for ( int i = 0 , bound = Math . abs ( min ) ; i < bound ; i ++ ) { str . append ( LEFT ) ; } str . append ( s ) ; for ( int i = 0 , bound = count [ N - 1 ] + Math . abs ( min ) ; i < bound ; i ++ ) { str . append ( RIGHT ) ; } System . out . println ( str . toString ( ) ) ; sc . close ( ) ; } }", "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 ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; LinkedList < Character > res = new LinkedList < > ( ) ; int right = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == ' ) ' ) right ++ ; else { if ( right > 0 ) right -- ; else { res . add ( ' ) ' ) ; } } res . addFirst ( s [ i ] ) ; } StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < right ; i ++ ) ans . append ( ' ( ' ) ; while ( res . size ( ) > 0 ) ans . append ( res . poll ( ) ) ; System . out . println ( ans . toString ( ) ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; String x ; int i = 0 , j = 0 ; int a = stdin . nextInt ( ) ; x = stdin . next ( ) ; for ( int k = 1 ; k <= x . length ( ) ; k ++ ) { String xx = x . substring ( k - 1 , k ) ; if ( xx . equals ( \" ( \" ) ) { i ++ ; } else { i -- ; } if ( i < 0 ) { j ++ ; i = 0 ; } } for ( int f = 0 ; f < j ; f ++ ) System . out . print ( \" ( \" ) ; System . out . print ( x ) ; for ( int f = 0 ; f < i ; f ++ ) System . out . print ( \" ) \" ) ; } }" ]
[ "from collections import deque NEW_LINE N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE dq = deque ( ) NEW_LINE ans = deque ( list ( S ) ) NEW_LINE for s in S : NEW_LINE INDENT if not dq : NEW_LINE INDENT dq . append ( s ) NEW_LINE DEDENT else : NEW_LINE INDENT if dq [ - 1 ] == \" ( \" and s == \" ) \" : NEW_LINE INDENT dq . pop ( ) NEW_LINE DEDENT else : NEW_LINE INDENT dq . append ( s ) NEW_LINE DEDENT DEDENT DEDENT while dq : NEW_LINE INDENT value = dq . popleft ( ) NEW_LINE if value == \" ) \" : NEW_LINE INDENT ans . appendleft ( \" ( \" ) NEW_LINE DEDENT elif value == \" ( \" : NEW_LINE INDENT ans . append ( \" ) \" ) NEW_LINE DEDENT DEDENT ans = \" \" . join ( ans ) NEW_LINE print ( ans ) NEW_LINE", "def insertion ( N : int , S : str ) -> str : NEW_LINE INDENT bra , ket = 0 , 0 NEW_LINE for c in S : NEW_LINE INDENT if c == ' ( ' : NEW_LINE INDENT bra += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if bra > 0 : NEW_LINE INDENT bra -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT ket += 1 NEW_LINE DEDENT DEDENT DEDENT ret = ( ' ( ' * ket ) + S NEW_LINE bra , ket = 0 , 0 NEW_LINE for c in reversed ( S ) : NEW_LINE INDENT if c == ' ) ' : NEW_LINE INDENT ket += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if ket > 0 : NEW_LINE INDENT ket -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT bra += 1 NEW_LINE DEDENT DEDENT DEDENT ret = ret + ( ' ) ' * bra ) NEW_LINE return ret NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE ans = insertion ( N , S ) NEW_LINE print ( ans ) 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 n = ni ( ) NEW_LINE s = ns ( ) NEW_LINE stack = [ ] NEW_LINE left = 0 NEW_LINE right = 0 NEW_LINE for si in s : NEW_LINE INDENT if si == ' ( ' : NEW_LINE INDENT stack . append ( ' ( ' ) NEW_LINE DEDENT elif si == ' ) ' : NEW_LINE INDENT if stack : NEW_LINE INDENT stack . pop ( ) NEW_LINE DEDENT else : NEW_LINE INDENT left += 1 NEW_LINE DEDENT DEDENT DEDENT right = len ( stack ) NEW_LINE print ( left * ' ( ' + s + right * ' ) ' ) NEW_LINE", "N = input ( ) NEW_LINE S = input ( ) NEW_LINE st1 = [ ] NEW_LINE st2 = [ ] NEW_LINE tmp = ' ' NEW_LINE for x in S : NEW_LINE INDENT if x == ' ( ' : NEW_LINE INDENT st1 . append ( S ) NEW_LINE DEDENT elif x == ' ) ' : NEW_LINE INDENT if len ( st1 ) > 0 : NEW_LINE INDENT st1 . pop ( ) NEW_LINE DEDENT else : NEW_LINE INDENT tmp = ' ( ' + tmp NEW_LINE DEDENT DEDENT tmp += x NEW_LINE DEDENT ans = tmp NEW_LINE for x in tmp [ : : - 1 ] : NEW_LINE INDENT if x == ' ) ' : NEW_LINE INDENT st2 . append ( S ) NEW_LINE DEDENT elif x == ' ( ' : NEW_LINE INDENT if len ( st2 ) > 0 : NEW_LINE INDENT st2 . pop ( ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ' ) ' NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE s = list ( input ( ) ) NEW_LINE cnt = 0 NEW_LINE res = ' ' NEW_LINE for i in range ( n ) : NEW_LINE INDENT if s [ i ] == ' ( ' : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if cnt > 0 : NEW_LINE INDENT cnt -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT res = ' ( ' + res NEW_LINE DEDENT DEDENT res += s [ i ] NEW_LINE DEDENT for j in range ( cnt ) : NEW_LINE INDENT res += ' ) ' NEW_LINE DEDENT print ( res ) NEW_LINE" ]
atcoder_arc022_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < > ( ) ; int [ ] arr = new int [ n ] ; int max = 0 ; int start = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; arr [ i ] = a ; if ( set . contains ( a ) ) { while ( arr [ start ] != a ) { set . remove ( arr [ start ] ) ; start ++ ; } start ++ ; } else { set . add ( a ) ; int v = set . size ( ) ; if ( max < v ) { max = v ; } } } System . out . println ( max ) ; } }", "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { static int n ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; int [ ] A = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) A [ i ] = sc . nextInt ( ) ; int ans = helper ( A ) ; System . out . println ( ans ) ; } static int helper ( int [ ] a ) { HashSet < Integer > vis = new HashSet < > ( ) ; int left = 0 , right = 0 ; int ans = 0 ; while ( left < n ) { while ( right < n && ! vis . contains ( a [ right ] ) ) vis . add ( a [ right ++ ] ) ; if ( right == n ) { ans = Math . max ( ans , right - left ) ; return ans ; } ans = Math . max ( ans , right - left ) ; while ( left < n && a [ left ] != a [ right ] ) { vis . remove ( a [ left ] ) ; left ++ ; } vis . remove ( a [ left ++ ] ) ; } return ans ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) - 1 ; } int m = 0 ; for ( int i = 0 ; i < n ; i ++ ) m = Math . max ( m , a [ i ] ) ; boolean [ ] use = new boolean [ m + 1 ] ; int s = 1 ; int t = 0 ; use [ a [ 0 ] ] = true ; long ret = 1 ; while ( s < n ) { while ( t < s && use [ a [ s ] ] ) { use [ a [ t ] ] = false ; t ++ ; } while ( s < n && ! use [ a [ s ] ] ) { use [ a [ s ] ] = true ; s ++ ; } ret = Math . max ( ret , s - t ) ; } System . out . println ( ret ) ; } }", "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 ( ) ; } TreeSet < Integer > set = new TreeSet < > ( ) ; int s = 0 ; int ans = 1 ; set . add ( a [ 0 ] ) ; for ( int t = 1 ; t < N ; t ++ ) { if ( set . contains ( a [ t ] ) ) { while ( set . contains ( a [ t ] ) ) { set . remove ( a [ s ] ) ; s ++ ; } set . add ( a [ t ] ) ; ans = Math . max ( ans , t - s + 1 ) ; } else { set . add ( a [ t ] ) ; ans = Math . max ( ans , t - s + 1 ) ; } } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Set < Integer > s = new HashSet < > ( ) ; long ans = syakutori ( a , n , s ) ; System . out . println ( ans ) ; } public static long syakutori ( int [ ] a , int n , Set < Integer > s ) { int right = 0 ; long res = 0 ; long sum = 0 ; for ( int left = 0 ; left < n ; left ++ ) { while ( right < n && ! s . contains ( a [ right ] ) ) { s . add ( a [ right ] ) ; right ++ ; } res = Math . max ( res , right - left ) ; if ( left >= right ) { right ++ ; continue ; } s . remove ( a [ left ] ) ; } return res ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans , l , count , _set = 1 , 0 , 1 , { a [ 0 ] } NEW_LINE add , remove = _set . add , _set . remove NEW_LINE for n in a [ 1 : ] : NEW_LINE INDENT while n in _set : NEW_LINE INDENT remove ( a [ l ] ) NEW_LINE count -= 1 NEW_LINE l += 1 NEW_LINE DEDENT add ( n ) NEW_LINE count += 1 NEW_LINE if ans < count : NEW_LINE INDENT ans = count NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def b_candy ( N , A ) : NEW_LINE INDENT right = 0 NEW_LINE ans = 0 NEW_LINE chosen_candy = set ( ) NEW_LINE for left in range ( N ) : NEW_LINE INDENT while right < N and not ( A [ right ] in chosen_candy ) : NEW_LINE INDENT chosen_candy . add ( A [ right ] ) NEW_LINE right += 1 NEW_LINE DEDENT chosen_candy . remove ( A [ left ] ) NEW_LINE ans = max ( right - left , ans ) NEW_LINE DEDENT return ans NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( b_candy ( N , A ) ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE s = set ( ) NEW_LINE le = 0 NEW_LINE ans = 0 NEW_LINE r = 0 NEW_LINE l = 0 NEW_LINE while l < N and r < N : NEW_LINE INDENT if not A [ r ] in s : NEW_LINE INDENT s . add ( A [ r ] ) NEW_LINE r += 1 NEW_LINE DEDENT else : NEW_LINE INDENT s . remove ( A [ l ] ) NEW_LINE ans = max ( ans , r - l ) NEW_LINE l += 1 NEW_LINE DEDENT DEDENT ans = max ( r - l , ans ) NEW_LINE print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE bf = [ - 1 for i in range ( 10 ** 5 + 1 ) ] NEW_LINE bfn = 0 NEW_LINE ans = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if bf [ A [ i ] ] == - 1 : NEW_LINE INDENT bf [ A [ i ] ] = i NEW_LINE ans = max ( ans , i - bfn + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT if ( bfn == 0 ) : NEW_LINE INDENT ans = max ( ans , i - bf [ A [ i ] ] ) NEW_LINE bfn = bf [ A [ i ] ] + 1 NEW_LINE bf [ A [ i ] ] = i NEW_LINE DEDENT else : NEW_LINE INDENT if ( bfn > bf [ A [ i ] ] ) : NEW_LINE INDENT ans = max ( ans , i - bfn + 1 ) NEW_LINE bf [ A [ i ] ] = i NEW_LINE DEDENT elif bfn == bf [ A [ i ] ] : NEW_LINE INDENT ans = max ( ans , i - bfn ) NEW_LINE bfn = bf [ A [ i ] ] + 1 NEW_LINE bf [ A [ i ] ] = i NEW_LINE DEDENT else : NEW_LINE INDENT ans = max ( ans , i - bf [ A [ i ] ] ) NEW_LINE bfn = bf [ A [ i ] ] + 1 NEW_LINE bf [ A [ i ] ] = i NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "def func ( n , a ) : NEW_LINE INDENT table = [ 0 for _ in range ( 10 ** 6 ) ] NEW_LINE under = 0 NEW_LINE top = 0 NEW_LINE length = 0 NEW_LINE while under < len ( a ) and top < len ( a ) : NEW_LINE INDENT while top < len ( a ) and table [ a [ top ] ] == 0 : NEW_LINE INDENT table [ a [ top ] ] = 1 NEW_LINE top += 1 NEW_LINE DEDENT length = max ( length , top - under ) NEW_LINE while under < top < len ( a ) and table [ a [ top ] ] > 0 : NEW_LINE INDENT table [ a [ under ] ] -= 1 NEW_LINE under += 1 NEW_LINE DEDENT DEDENT print ( length ) NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE func ( n , a ) NEW_LINE" ]
atcoder_abc031_D
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } int n , k ; int [ ] v ; String [ ] w ; int [ ] table ; String [ ] ans ; void solve ( ) { Scanner sc = new Scanner ( System . in ) ; k = sc . nextInt ( ) ; n = sc . nextInt ( ) ; v = new int [ n ] ; w = new String [ n ] ; ans = new String [ k + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { v [ i ] = sc . nextInt ( ) ; w [ i ] = sc . next ( ) ; } table = new int [ k + 1 ] ; for ( int i = 0 ; i < Math . pow ( 3 , k ) ; i ++ ) { int ni = i ; for ( int j = 0 ; j < k ; j ++ ) { int p = ni % 3 + 1 ; ni /= 3 ; table [ j + 1 ] = p ; } if ( check ( ) ) { for ( int p = 0 ; p < n ; p ++ ) { int count = 0 ; int vp = v [ p ] ; while ( vp > 0 ) { count += table [ vp % 10 ] ; String wi = w [ p ] ; int begin = wi . length ( ) - count ; int end = begin + table [ vp % 10 ] ; ans [ vp % 10 ] = wi . substring ( begin , end ) ; vp /= 10 ; } } for ( int q = 1 ; q <= k ; q ++ ) { System . out . println ( ans [ q ] ) ; } return ; } } } boolean check ( ) { for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; int vi = v [ i ] ; while ( vi > 0 ) { count += table [ vi % 10 ] ; vi /= 10 ; } if ( count != w [ i ] . length ( ) ) return false ; } return true ; } }" ]
[ "k , n = map ( int , input ( ) . split ( ) ) NEW_LINE vw = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = input ( ) . split ( ) NEW_LINE vw . append ( [ list ( map ( lambda x : int ( x ) - 1 , list ( a ) ) ) , list ( b ) ] ) NEW_LINE DEDENT d = [ 0 ] * k NEW_LINE while 1 : NEW_LINE INDENT for i in range ( k - 1 ) : NEW_LINE INDENT if d [ i ] == 3 : NEW_LINE INDENT d [ i ] = 0 NEW_LINE d [ i + 1 ] += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if d [ k - 1 ] >= 3 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT c = [ [ ] for _ in range ( k ) ] NEW_LINE flag = 0 NEW_LINE for v , w in vw : NEW_LINE INDENT p = 0 NEW_LINE for x in v : NEW_LINE INDENT if p + d [ x ] >= len ( w ) : NEW_LINE INDENT flag = 1 NEW_LINE break NEW_LINE DEDENT elif len ( c [ x ] ) > 0 : NEW_LINE INDENT if ' ' . join ( c [ x ] ) != ' ' . join ( w [ p : p + d [ x ] + 1 ] ) : NEW_LINE INDENT flag = 1 NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT c [ x ] = [ ] + w [ p : p + d [ x ] + 1 ] NEW_LINE DEDENT p += d [ x ] + 1 NEW_LINE DEDENT if p != len ( w ) : NEW_LINE INDENT flag = 1 NEW_LINE break NEW_LINE DEDENT elif flag == 1 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if flag == 0 : NEW_LINE INDENT break NEW_LINE DEDENT d [ 0 ] += 1 NEW_LINE DEDENT for x in c : NEW_LINE INDENT print ( ' ' . join ( x ) ) NEW_LINE DEDENT", "def goro_awase ( K : int , N : int , goro : list ) -> list : NEW_LINE INDENT for i in range ( 3 ** K ) : NEW_LINE INDENT d = { } NEW_LINE for k in range ( K ) : NEW_LINE INDENT d [ k + 1 ] = ( i % 3 ) + 1 NEW_LINE i //= 3 NEW_LINE DEDENT for n , w in goro : NEW_LINE INDENT assumpt_len = 0 NEW_LINE while n > 0 : NEW_LINE INDENT assumpt_len += d [ n % 10 ] NEW_LINE n //= 10 NEW_LINE DEDENT if assumpt_len != len ( w ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res = { } NEW_LINE for n , w in goro : NEW_LINE INDENT idx = 0 NEW_LINE digits = [ ] NEW_LINE while n > 0 : NEW_LINE INDENT k = n % 10 NEW_LINE n //= 10 NEW_LINE digits . append ( k ) NEW_LINE DEDENT for k in reversed ( digits ) : NEW_LINE INDENT sk = w [ idx : idx + d [ k ] ] NEW_LINE idx = idx + d [ k ] NEW_LINE if k in res and res [ k ] != sk : NEW_LINE INDENT break NEW_LINE DEDENT res [ k ] = sk NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT break NEW_LINE DEDENT else : NEW_LINE INDENT return res NEW_LINE DEDENT DEDENT DEDENT return None NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = 0 NEW_LINE K , N = map ( int , input ( ) . split ( ) ) NEW_LINE goro = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT v , w = input ( ) . split ( ) NEW_LINE goro . append ( ( int ( v ) , w ) ) NEW_LINE DEDENT ans = goro_awase ( K , N , goro ) NEW_LINE if ans is None : NEW_LINE INDENT raise Exception ( ' error ' ) NEW_LINE DEDENT else : NEW_LINE INDENT for _ , s in sorted ( ans . items ( ) ) : NEW_LINE INDENT print ( s ) NEW_LINE DEDENT DEDENT DEDENT", "def dfs ( i , f ) : NEW_LINE INDENT global K , N , vw , num NEW_LINE if i < 10 : NEW_LINE INDENT if not f : NEW_LINE INDENT num [ i ] = 1 NEW_LINE f = dfs ( i + 1 , f ) NEW_LINE DEDENT if not f : NEW_LINE INDENT num [ i ] = 2 NEW_LINE f = dfs ( i + 1 , f ) NEW_LINE DEDENT if not f : NEW_LINE INDENT num [ i ] = 3 NEW_LINE f = dfs ( i + 1 , f ) NEW_LINE DEDENT return f NEW_LINE DEDENT else : NEW_LINE INDENT ans = [ \" \" for _ in range ( 10 ) ] NEW_LINE for j in range ( N ) : NEW_LINE INDENT s = vw [ j ] [ 1 ] NEW_LINE for k in range ( len ( vw [ j ] [ 0 ] ) ) : NEW_LINE INDENT if len ( s ) < num [ int ( vw [ j ] [ 0 ] [ k ] ) ] : NEW_LINE INDENT return False NEW_LINE DEDENT if ans [ int ( vw [ j ] [ 0 ] [ k ] ) ] == \" \" : NEW_LINE INDENT ans [ int ( vw [ j ] [ 0 ] [ k ] ) ] = s [ : num [ int ( vw [ j ] [ 0 ] [ k ] ) ] ] NEW_LINE s = s [ num [ int ( vw [ j ] [ 0 ] [ k ] ) ] : ] NEW_LINE DEDENT else : NEW_LINE INDENT if ans [ int ( vw [ j ] [ 0 ] [ k ] ) ] != s [ : num [ int ( vw [ j ] [ 0 ] [ k ] ) ] ] : NEW_LINE INDENT return False NEW_LINE DEDENT s = s [ num [ int ( vw [ j ] [ 0 ] [ k ] ) ] : ] NEW_LINE DEDENT DEDENT if s != \" \" : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT for j in range ( 1 , K + 1 ) : NEW_LINE INDENT print ( ans [ j ] ) NEW_LINE DEDENT return True NEW_LINE DEDENT DEDENT K , N = map ( int , input ( ) . split ( ) ) NEW_LINE vw = [ input ( ) . split ( ) for _ in range ( N ) ] NEW_LINE num = [ 0 for _ in range ( 10 ) ] NEW_LINE dfs ( 1 , False ) NEW_LINE", "K , N = map ( int , input ( ) . split ( ) ) NEW_LINE vs = [ None ] * N NEW_LINE ws = [ None ] * N NEW_LINE num = [ 0 ] * K NEW_LINE def solve ( ) : NEW_LINE INDENT ans = [ None ] * K NEW_LINE for v , w in zip ( vs , ws ) : NEW_LINE INDENT cur = 0 NEW_LINE for n in map ( lambda x : int ( x ) - 1 , v ) : NEW_LINE INDENT if ans [ n ] is not None and ans [ n ] != w [ cur : cur + num [ n ] ] : NEW_LINE INDENT return None NEW_LINE DEDENT ans [ n ] = w [ cur : cur + num [ n ] ] NEW_LINE cur += num [ n ] NEW_LINE DEDENT if cur != len ( w ) : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT def dfs ( k ) : NEW_LINE INDENT if k == K : NEW_LINE INDENT return solve ( ) NEW_LINE DEDENT for i in range ( 3 ) : NEW_LINE INDENT num [ k ] = i + 1 NEW_LINE ans = dfs ( k + 1 ) NEW_LINE if ans is not None : NEW_LINE INDENT return ans NEW_LINE DEDENT DEDENT DEDENT for i in range ( N ) : NEW_LINE INDENT vs [ i ] , ws [ i ] = input ( ) . split ( ) NEW_LINE DEDENT print ( * dfs ( 0 ) , sep = ' \\n ' ) NEW_LINE", "from itertools import product NEW_LINE k , n = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE x = [ [ i for i in input ( ) . split ( ) ] for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT y = [ ] NEW_LINE for j in x [ i ] [ 0 ] : y . append ( int ( j ) ) NEW_LINE x [ i ] [ 0 ] = y NEW_LINE DEDENT def match ( q ) : NEW_LINE INDENT ans = True NEW_LINE for i , j in x : NEW_LINE INDENT num = 0 NEW_LINE for i2 in i : num += q [ i2 - 1 ] NEW_LINE if len ( j ) != num : NEW_LINE INDENT ans = False NEW_LINE break NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT def match2 ( q ) : NEW_LINE INDENT if match ( q ) : NEW_LINE INDENT w = [ \" \" for i in range ( k ) ] NEW_LINE for i , j in x : NEW_LINE INDENT num = 0 NEW_LINE for i2 in i : NEW_LINE INDENT if w [ i2 - 1 ] == \" \" or w [ i2 - 1 ] == j [ num : num + q [ i2 - 1 ] ] : NEW_LINE INDENT w [ i2 - 1 ] = j [ num : num + q [ i2 - 1 ] ] NEW_LINE num += q [ i2 - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT w = [ ] NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT return w NEW_LINE DEDENT else : return False NEW_LINE DEDENT for i in product ( range ( 1 , 4 ) , repeat = k ) : NEW_LINE INDENT m = match2 ( i ) NEW_LINE if m : NEW_LINE INDENT for j in m : print ( j ) NEW_LINE break NEW_LINE DEDENT DEDENT" ]
atcoder_abc112_C
[ "import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; int calcH ( int cx , int cy , int x , int y , int h ) { return h + Math . abs ( cx - x ) + Math . abs ( cy - y ) ; } boolean check ( int cx , int cy , int ch , int x , int y , int h ) { if ( h > 0 ) { return ch == calcH ( cx , cy , x , y , h ) ; } else { return ch <= calcH ( cx , cy , x , y , h ) ; } } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int N = sc . nextInt ( ) ; int [ ] [ ] xyh = new int [ N ] [ 3 ] ; for ( int i = 0 ; i < N ; i ++ ) { xyh [ i ] = new int [ ] { sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) } ; } sc . close ( ) ; int p = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( xyh [ i ] [ 2 ] > 0 ) { p = i ; break ; } } for ( int cx = 0 ; cx <= 100 ; cx ++ ) { for ( int cy = 0 ; cy <= 100 ; cy ++ ) next_point : { int H = calcH ( cx , cy , xyh [ p ] [ 0 ] , xyh [ p ] [ 1 ] , xyh [ p ] [ 2 ] ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! check ( cx , cy , H , xyh [ i ] [ 0 ] , xyh [ i ] [ 1 ] , xyh [ i ] [ 2 ] ) ) { break next_point ; } } out . println ( cx + \" ▁ \" + cy + \" ▁ \" + H ) ; return ; } } } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }", "import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static long nextLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; long [ ] [ ] values = new long [ N ] [ 3 ] ; for ( int i = 0 ; i < N ; i ++ ) { values [ i ] = new long [ ] { nextLong ( ) , nextLong ( ) , nextLong ( ) } ; } String ans = null ; for ( int i = 0 ; i <= 100 ; i ++ ) { for ( int j = 0 ; j <= 100 ; j ++ ) { int [ ] centerPosi = new int [ ] { i , j } ; long H = 0 ; for ( int k = 0 ; k < N ; k ++ ) { long x = values [ k ] [ 0 ] ; long y = values [ k ] [ 1 ] ; long h = values [ k ] [ 2 ] ; if ( h != 0 ) { H = h + Math . abs ( centerPosi [ 0 ] - x ) + Math . abs ( centerPosi [ 1 ] - y ) ; break ; } } boolean isOK = true ; for ( int k = 0 ; k < N ; k ++ ) { long x = values [ k ] [ 0 ] ; long y = values [ k ] [ 1 ] ; long h = values [ k ] [ 2 ] ; long estimatedH = Math . max ( ( H - Math . abs ( x - centerPosi [ 0 ] ) - Math . abs ( y - centerPosi [ 1 ] ) ) , 0 ) ; isOK = isOK && ( estimatedH == h ) ; } if ( isOK ) { ans = i + \" ▁ \" + j + \" ▁ \" + H ; } } } 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 ( ) ; Point [ ] points = new Point [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { points [ i ] = new Point ( sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) ) ; } sc . close ( ) ; int ansX = - 1 ; int ansY = - 1 ; int ansH = - 1 ; label : for ( int x = 0 ; x < 101 ; x ++ ) { for ( int y = 0 ; y < 101 ; y ++ ) { int baseH = - 1 ; boolean flg = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( points [ i ] . h > 0 ) { int h = points [ i ] . h + Math . abs ( x - points [ i ] . x ) + Math . abs ( y - points [ i ] . y ) ; if ( baseH == - 1 ) { baseH = h ; } else if ( baseH != h ) { flg = false ; break ; } } } if ( flg ) { for ( int i = 0 ; i < n ; i ++ ) { if ( points [ i ] . h == 0 ) { if ( baseH > Math . abs ( x - points [ i ] . x ) + Math . abs ( y - points [ i ] . y ) ) { flg = false ; break ; } } } if ( ! flg ) { continue ; } ansX = x ; ansY = y ; ansH = baseH ; break label ; } } } System . out . println ( ansX + \" ▁ \" + ansY + \" ▁ \" + ansH ) ; } static class Point { int x ; int y ; int h ; public Point ( int x , int y , int h ) { this . x = x ; this . y = y ; this . h = h ; } } }", "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 [ ] xa = new int [ n ] , ya = new int [ n ] , ha = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { xa [ i ] = scanner . nextInt ( ) ; ya [ i ] = scanner . nextInt ( ) ; ha [ i ] = scanner . nextInt ( ) ; } for ( int x = 0 ; x <= 100 ; x ++ ) { for ( int y = 0 ; y <= 100 ; y ++ ) { int x1 = x , y1 = y , h = IntStream . range ( 0 , n ) . filter ( k -> ha [ k ] != 0 ) . reduce ( 0 , ( l , i ) -> ha [ i ] + Math . abs ( xa [ i ] - x1 ) + Math . abs ( ya [ i ] - y1 ) ) ; if ( IntStream . range ( 0 , n ) . allMatch ( k -> ha [ k ] == Math . max ( h - Math . abs ( xa [ k ] - x1 ) - Math . abs ( ya [ k ] - y1 ) , 0 ) ) ) System . out . printf ( \" % s ▁ % s ▁ % s \\n \" , x , y , h ) ; } } } }", "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 [ ] x = new int [ N ] ; int [ ] y = new int [ N ] ; int [ ] h = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; h [ i ] = sc . nextInt ( ) ; } for ( int cx = 0 ; cx <= 100 ; cx ++ ) { for ( int cy = 0 ; cy <= 100 ; cy ++ ) { int H = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( h [ i ] != 0 ) { H = h [ i ] + Math . abs ( x [ i ] - cx ) + Math . abs ( y [ i ] - cy ) ; break ; } } boolean isAns = true ; for ( int i = 0 ; i < N ; i ++ ) { int htmp = Math . max ( H - Math . abs ( x [ i ] - cx ) - Math . abs ( y [ i ] - cy ) , 0 ) ; if ( htmp != h [ i ] ) { isAns = false ; break ; } } if ( isAns ) { out . println ( cx + \" ▁ \" + cy + \" ▁ \" + H ) ; return ; } } } } }" ]
[ "import sys NEW_LINE write = sys . stdout . write NEW_LINE def valid ( x , y ) : NEW_LINE INDENT H = info [ nzpoint ] [ 2 ] + abs ( info [ nzpoint ] [ 0 ] - x ) + abs ( info [ nzpoint ] [ 1 ] - y ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if i == nzpoint : NEW_LINE INDENT continue NEW_LINE DEDENT if max ( 0 , H - abs ( x - info [ i ] [ 0 ] ) - abs ( y - info [ i ] [ 1 ] ) ) != info [ i ] [ 2 ] : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def printheight ( i , j ) : NEW_LINE INDENT write ( str ( info [ nzpoint ] [ 2 ] + abs ( i - info [ nzpoint ] [ 0 ] ) + abs ( j - info [ nzpoint ] [ 1 ] ) ) + \" \\n \" ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE info = [ ] NEW_LINE nzpoint = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT info . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE if info [ i ] [ 2 ] > 0 : NEW_LINE INDENT nzpoint = i NEW_LINE DEDENT DEDENT for i in range ( 101 ) : NEW_LINE INDENT for j in range ( 101 ) : NEW_LINE INDENT if valid ( i , j ) : NEW_LINE INDENT write ( str ( i ) + \" ▁ \" + str ( j ) + \" ▁ \" ) NEW_LINE printheight ( i , j ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT DEDENT", "class Info ( ) : NEW_LINE INDENT def __init__ ( self , x , y , h ) : NEW_LINE INDENT self . X = x NEW_LINE self . Y = y NEW_LINE self . H = h NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE infos = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y , h = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) NEW_LINE infos . append ( Info ( x , y , h ) ) NEW_LINE DEDENT MAX = 100 NEW_LINE for posY in range ( 0 , MAX + 1 ) : NEW_LINE INDENT for posX in range ( 0 , MAX + 1 ) : NEW_LINE INDENT ans_h = - 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if infos [ i ] . H > 0 : NEW_LINE INDENT H = infos [ i ] . H + abs ( posY - infos [ i ] . Y ) + abs ( posX - infos [ i ] . X ) NEW_LINE if ans_h == - 1 : NEW_LINE INDENT ans_h = H NEW_LINE DEDENT else : NEW_LINE INDENT if ans_h != H : NEW_LINE INDENT ans_h = - 2 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT if ans_h == - 2 : NEW_LINE INDENT continue NEW_LINE DEDENT is_ok = True NEW_LINE for i in range ( N ) : NEW_LINE INDENT if infos [ i ] . H == 0 : NEW_LINE INDENT if ans_h - abs ( posY - infos [ i ] . Y ) - abs ( posX - infos [ i ] . X ) <= 0 : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT is_ok = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if is_ok : NEW_LINE INDENT print ( posX , posY , ans_h ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE INF = float ( \" inf \" ) NEW_LINE def solve ( N : int , x : \" List [ int ] \" , y : \" List [ int ] \" , h : \" List [ int ] \" ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if h [ i ] > 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT cand = [ [ 0 ] * 101 for _ in range ( 101 ) ] NEW_LINE for j in range ( 101 ) : NEW_LINE INDENT for k in range ( 101 ) : NEW_LINE INDENT cand [ j ] [ k ] = h [ i ] + abs ( x [ i ] - k ) + abs ( y [ i ] - j ) NEW_LINE DEDENT DEDENT for i in range ( 101 ) : NEW_LINE INDENT for j in range ( 101 ) : NEW_LINE INDENT flags = [ max ( cand [ i ] [ j ] - abs ( x [ k ] - j ) - abs ( y [ k ] - i ) , 0 ) == h [ k ] for k in range ( N ) ] NEW_LINE if all ( flags ) : NEW_LINE INDENT print ( j , i , cand [ i ] [ j ] ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT 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 x = [ int ( ) ] * ( N ) NEW_LINE y = [ int ( ) ] * ( N ) NEW_LINE h = [ 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 h [ i ] = int ( next ( tokens ) ) NEW_LINE DEDENT solve ( N , x , y , h ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "A = abs ; p = eval ( ' list ( map ( int , input ( ) . split ( ) ) ) , ' * int ( input ( ) ) ) ; x , y , h = [ x for x in p if x [ 2 ] ] [ 0 ] NEW_LINE for I in range ( 10201 ) : j , i = I // 101 , I % 101 ; H = h + A ( x - j ) + A ( y - i ) ; print ( * ( j , i , H ) * all ( u == max ( H - A ( s - j ) - A ( t - i ) , 0 ) for s , t , u in p ) ) NEW_LINE", "from itertools import * NEW_LINE n = int ( input ( ) ) NEW_LINE xyh = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT xyh += [ list ( map ( int , input ( ) . split ( ) ) ) ] NEW_LINE DEDENT xyh . sort ( reverse = True , key = lambda x : x [ 2 ] ) NEW_LINE [ x0 , y0 , h0 ] = xyh [ 0 ] NEW_LINE for x , y in product ( range ( 0 , 101 ) , range ( 0 , 101 ) ) : NEW_LINE INDENT h = h0 + abs ( x - x0 ) + abs ( y - y0 ) NEW_LINE for k in xyh [ 1 : ] : NEW_LINE INDENT if k [ 2 ] != max ( h - abs ( x - k [ 0 ] ) - abs ( y - k [ 1 ] ) , 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( x , y , h ) NEW_LINE" ]
atcoder_abc084_B
[ "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 ( ) ) ; String word = input . readLine ( ) ; int size = 0 ; boolean correct = true ; boolean foundMinuse = false ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { if ( Character . isDigit ( word . charAt ( i ) ) ) { size ++ ; } else { if ( size != a ) { correct = false ; break ; } size = 0 ; foundMinuse = true ; } } if ( foundMinuse && size == b ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }", "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 length = a + b + 1 ; String post = sc . next ( ) ; char c = post . charAt ( a ) ; String start = post . substring ( 0 , a ) ; String end = post . substring ( a + 1 , post . length ( ) ) ; String ans = \" \" ; if ( post . length ( ) == length ) { if ( c == ' - ' ) { if ( start . contains ( \" - \" ) || end . contains ( \" - \" ) ) { ans = \" No \" ; } else { ans = \" Yes \" ; } } else { ans = \" No \" ; } } else { ans = \" No \" ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { boolean j = true ; Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; String [ ] strArray = s . split ( \" \" ) ; if ( strArray . length != a + b + 1 ) j = false ; if ( strArray [ a ] . equals ( \" - \" ) ) { for ( int i = 0 ; i < strArray . length ; i ++ ) { if ( i != a ) { if ( ! ( strArray [ i ] . equals ( \" - \" ) ) ) { int x = Integer . parseInt ( strArray [ i ] ) ; if ( x >= 10 && x < 0 ) j = false ; } else j = false ; } } } else j = false ; if ( j ) System . out . println ( \" Yes \" ) ; else if ( ! j ) System . out . println ( \" No \" ) ; sc . close ( ) ; } }", "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 ) ) ; int [ ] nums = Arrays . stream ( stdin . readLine ( ) . split ( \" ▁ \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; String postalCode = stdin . readLine ( ) ; String regexp = \" [ 0-9 ] { \" + nums [ 0 ] + \" } - [0-9 ] { \" + nums [ 1 ] + \" } \" ; String answer = postalCode . matches ( regexp ) ? \" Yes \" : \" No \" ; System . out . println ( answer ) ; } }", "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 ( ) ; String S = sc . next ( ) ; if ( S . substring ( 0 , A ) . contains ( \" - \" ) ) { System . out . println ( \" No \" ) ; return ; } if ( ! ( S . substring ( A , A + 1 ) . contains ( \" - \" ) ) ) { System . out . println ( \" No \" ) ; return ; } if ( S . substring ( A + 1 , A + B + 1 ) . contains ( \" - \" ) ) { System . out . println ( \" No \" ) ; return ; } System . out . println ( \" Yes \" ) ; } }" ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE s = input ( ) NEW_LINE flag = True NEW_LINE if s [ n : n + 1 ] != ' - ' : NEW_LINE INDENT flag = False NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if s [ i ] == ' - ' : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT for i in range ( n + 1 , len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' - ' : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "a , s = open ( 0 ) ; print ( ' YNeos ' [ s . count ( ' - ' ) != 1 or ' - ' < s [ int ( a [ 0 ] ) ] : : 2 ] ) NEW_LINE", "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE S = list ( input ( ) ) NEW_LINE suji = [ str ( i ) for i in range ( 0 , 10 ) ] NEW_LINE try : NEW_LINE INDENT a = int ( \" \" . join ( S [ : A ] ) ) NEW_LINE b = int ( \" \" . join ( S [ B : ] ) ) NEW_LINE if ( S [ A ] in suji ) : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT DEDENT except : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT", "import sys NEW_LINE a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE x = input ( ) NEW_LINE if not ( x [ 0 : a ] . isdigit ( ) ) & ( len ( x [ 0 : a ] ) == a ) : NEW_LINE INDENT print ( ' No ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT if x [ a ] != ' - ' : NEW_LINE INDENT print ( ' No ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT if not ( x [ a + 1 : a + 1 + b ] . isdigit ( ) ) & ( len ( x [ a + 1 : a + 1 + b ] ) == b ) : NEW_LINE INDENT print ( ' No ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT print ( ' Yes ' ) NEW_LINE", "import re NEW_LINE a , b = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE s = input ( ) NEW_LINE m = re . match ( ' [ 0-9 ] { { { 0 } } } - [0-9 ] { { { 1 } } } ' . format ( a , b ) , s ) NEW_LINE print ( ' Yes ' if m else ' No ' ) NEW_LINE" ]
atcoder_arc059_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 ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { System . out . println ( ( i + 1 ) + \" ▁ \" + ( i + 2 ) ) ; return ; } } for ( int i = 0 ; i < s . length ( ) - 2 ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 2 ) ) { System . out . println ( ( i + 1 ) + \" ▁ \" + ( i + 3 ) ) ; return ; } } System . out . println ( \" - 1 ▁ - 1\" ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; 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 . nextLine ( ) ; if ( s . length ( ) >= 2 ) { for ( int i = 0 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { out . println ( ( i + 1 ) + \" ▁ \" + ( i + 2 ) ) ; return ; } if ( i + 2 < s . length ( ) && s . charAt ( i ) == s . charAt ( i + 2 ) ) { out . println ( ( i + 1 ) + \" ▁ \" + ( i + 3 ) ) ; return ; } } } out . println ( \" - 1 ▁ - 1\" ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } }", "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 boolean unbalanced ( String s ) { int [ ] count = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count [ s . charAt ( i ) - ' a ' ] ++ ; } return maxOfArray ( count ) > s . length ( ) / 2 ; } public static String solve ( String s ) { if ( s . length ( ) < 3 ) return ( unbalanced ( s ) ? \"1 ▁ 2\" : \" - 1 ▁ - 1\" ) ; for ( int i = 0 ; i < s . length ( ) - 2 ; i ++ ) { if ( unbalanced ( s . substring ( i , i + 3 ) ) ) return ( ( i + 1 ) + \" ▁ \" + ( i + 3 ) ) ; } return \" - 1 ▁ - 1\" ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; System . out . println ( solve ( s ) ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String t = sc . next ( ) ; sc . close ( ) ; int n = t . length ( ) ; if ( n == 2 ) { if ( t . charAt ( 0 ) == t . charAt ( 1 ) ) { System . out . println ( \"1 ▁ 2\" ) ; } else { System . out . println ( \" - 1 ▁ - 1\" ) ; } System . exit ( 0 ) ; } for ( int i = 0 ; i < n - 2 ; i ++ ) { char c0 = t . charAt ( i ) ; char c1 = t . charAt ( i + 1 ) ; char c2 = t . charAt ( i + 2 ) ; int [ ] k = new int [ 26 ] ; k [ ( int ) ( c0 - ' a ' ) ] ++ ; k [ ( int ) ( c1 - ' a ' ) ] ++ ; k [ ( int ) ( c2 - ' a ' ) ] ++ ; Arrays . sort ( k ) ; if ( k [ 25 ] == 2 ) { System . out . printf ( \" % d ▁ % d \\n \" , i + 1 , i + 3 ) ; System . exit ( 0 ) ; } } System . out . println ( \" - 1 ▁ - 1\" ) ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { char s [ ] = sc . next ( ) . toCharArray ( ) ; int len = s . length ; int a = - 1 ; int b = - 1 ; for ( int i = 0 ; i < len - 1 ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) { a = i + 1 ; b = i + 2 ; break ; } if ( i + 2 < len && s [ i ] == s [ i + 2 ] ) { a = i + 1 ; b = i + 3 ; break ; } } System . out . println ( a + \" ▁ \" + b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }" ]
[ "s = input ( ) NEW_LINE if len ( s ) == 2 and s [ 0 ] == s [ 1 ] : print ( 1 , 2 ) NEW_LINE else : NEW_LINE INDENT for i in range ( 3 , len ( s ) + 1 ) : NEW_LINE INDENT a = s [ i - 3 : i ] NEW_LINE if len ( set ( a ) ) != 3 : NEW_LINE INDENT print ( i - 2 , i ) NEW_LINE break NEW_LINE DEDENT DEDENT else : print ( - 1 , - 1 ) NEW_LINE DEDENT", "S = input ( ) NEW_LINE c = { } NEW_LINE for i in [ chr ( ord ( ' a ' ) + i ) for i in range ( 26 ) ] : NEW_LINE INDENT c [ i ] = 0 NEW_LINE DEDENT for i in range ( len ( S ) ) : NEW_LINE INDENT if i < 3 : NEW_LINE INDENT c [ S [ i ] ] += 1 NEW_LINE if c [ S [ i ] ] >= 2 : NEW_LINE INDENT print ( 1 , i + 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT c [ S [ i - 3 ] ] -= 1 NEW_LINE c [ S [ i ] ] += 1 NEW_LINE if c [ S [ i ] ] >= 2 : NEW_LINE INDENT print ( i - 1 , i + 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT print ( - 1 , - 1 ) NEW_LINE", "s = input ( ) NEW_LINE k = - 1 NEW_LINE l = - 1 NEW_LINE flag = False NEW_LINE for i in range ( 0 , len ( s ) - 1 ) : NEW_LINE INDENT if s [ i ] == s [ i + 1 ] : NEW_LINE INDENT flag = True NEW_LINE k = i + 1 NEW_LINE l = i + 2 NEW_LINE break NEW_LINE DEDENT DEDENT if not flag : NEW_LINE INDENT if len ( s ) > 2 : NEW_LINE INDENT for j in range ( 0 , len ( s ) - 2 ) : NEW_LINE INDENT if s [ j ] == s [ j + 2 ] : NEW_LINE INDENT flag = True NEW_LINE k = j + 1 NEW_LINE l = j + 3 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT None NEW_LINE DEDENT DEDENT print ( k , l ) NEW_LINE", "def main ( ) : NEW_LINE INDENT s = input ( ) . strip ( ) NEW_LINE if len ( s ) == 2 : NEW_LINE INDENT return ( \"1 ▁ 2\" if s [ 0 ] == s [ 1 ] else \" - 1 ▁ - 1\" ) NEW_LINE DEDENT for i in range ( len ( s ) - 2 ) : NEW_LINE INDENT if len ( set ( s [ i : i + 3 ] ) ) <= 2 : NEW_LINE INDENT return \" { } ▁ { } \" . format ( i + 1 , i + 3 ) NEW_LINE DEDENT DEDENT return \" - 1 ▁ - 1\" NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 10000 ) NEW_LINE S = input ( ) NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if i <= len ( S ) - 2 : NEW_LINE INDENT if S [ i ] == S [ i + 1 ] : NEW_LINE INDENT print ( \" { } ▁ { } \" . format ( i + 1 , i + 2 ) ) NEW_LINE break NEW_LINE DEDENT DEDENT if i <= len ( S ) - 3 : NEW_LINE INDENT if S [ i ] == S [ i + 2 ] : NEW_LINE INDENT print ( \" { } ▁ { } \" . format ( i + 1 , i + 3 ) ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( \" - 1 ▁ - 1\" ) NEW_LINE DEDENT" ]
atcoder_arc084_B
[ "import java . util . Arrays ; import java . util . PriorityQueue ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int K = scan . nextInt ( ) ; int [ ] dp = new int [ K ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; class Node { int to , cost ; Node ( int to , int cost ) { this . to = to ; this . cost = cost ; } } PriorityQueue < Node > que = new PriorityQueue < > ( ( a , b ) -> a . cost - b . cost ) ; for ( int i = 1 ; i < Math . min ( 10 , K ) ; ++ i ) { dp [ i ] = i ; que . add ( new Node ( i , i ) ) ; } while ( ! que . isEmpty ( ) ) { Node node = que . poll ( ) ; int v = node . to ; int c = node . cost ; if ( c > dp [ v ] ) continue ; for ( int i = 0 ; i < 10 ; ++ i ) { int nextv = ( v * 10 + i ) % K ; int nextc = c + i ; if ( dp [ nextv ] > nextc ) { dp [ nextv ] = nextc ; que . add ( new Node ( nextv , nextc ) ) ; } } } System . out . println ( dp [ 0 ] ) ; } }", "import java . util . * ; public class Main { int n ; ArrayList < ArrayList < Edge > > ns ; public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . read ( ) ; m . solve ( ) ; } private void read ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; ns = new ArrayList < > ( n + 1 ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) ns . add ( new ArrayList < > ( ) ) ; } private void solve ( ) { for ( int i = 0 ; i < n + 1 ; i ++ ) { int nxt = ( i + 1 ) % n ; int nxt2 = ( i * 10 ) % n ; ns . get ( i ) . add ( new Edge ( i , nxt , 1 ) ) ; ns . get ( i ) . add ( new Edge ( i , nxt2 , 0 ) ) ; } int [ ] ds = new int [ n + 1 ] ; Arrays . fill ( ds , n + 1 ) ; Deque < Edge > deq = new ArrayDeque < > ( ) ; ds [ 1 ] = 1 ; for ( Edge e : ns . get ( 1 ) ) if ( e . c == 0 ) deq . addFirst ( e ) ; else deq . addLast ( e ) ; while ( ! deq . isEmpty ( ) ) { Edge e = deq . pollFirst ( ) ; int dist = ds [ e . cur ] + e . c ; ds [ e . to ] = Math . min ( dist , ds [ e . to ] ) ; for ( Edge nxt : ns . get ( e . to ) ) { if ( ds [ nxt . to ] > ds [ e . to ] + nxt . c ) { if ( nxt . c == 0 ) deq . addFirst ( nxt ) ; else deq . addLast ( nxt ) ; } } } System . out . println ( ds [ 0 ] ) ; } private class Edge { int cur ; int to ; int c ; Edge ( int cur , int to , int c ) { this . cur = cur ; this . to = to ; this . c = c ; } } }", "import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; Deque < Point > dq = new ArrayDeque < Point > ( ) ; boolean [ ] judge = new boolean [ k ] ; Arrays . fill ( judge , true ) ; Point now = new Point ( 1 , 1 ) ; dq . add ( now ) ; while ( ! dq . isEmpty ( ) ) { Point z = dq . removeFirst ( ) ; if ( ! judge [ ( z . x ) ] ) { continue ; } judge [ ( z . x ) ] = false ; if ( z . x == 0 ) { System . out . println ( z . y ) ; break ; } if ( judge [ ( z . x * 10 ) % k ] ) { dq . addFirst ( new Point ( ( z . x * 10 ) % k , z . y ) ) ; } if ( judge [ ( z . x + 1 ) % k ] ) { dq . addLast ( new Point ( ( z . x + 1 ) % k , z . y + 1 ) ) ; } } } } class Point { int x ; int y ; Point ( int x , int y ) { this . x = x ; this . y = y ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int [ ] dist = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { dist [ i ] = Integer . MAX_VALUE ; } dist [ 1 ] = 0 ; Deque < Integer > deque = new ArrayDeque < > ( ) ; deque . addFirst ( 1 ) ; int [ ] visit = new int [ k ] ; visit [ 1 ] = 1 ; while ( deque . size ( ) > 0 ) { int u = deque . pollFirst ( ) ; int v1 = ( 10 * u ) % k ; int v2 = ( u + 1 ) % k ; if ( visit [ v1 ] == 0 ) { dist [ v1 ] = Math . min ( dist [ v1 ] , dist [ u ] ) ; deque . addFirst ( v1 ) ; visit [ v1 ] = 1 ; } else { if ( dist [ v1 ] > dist [ u ] ) { dist [ v1 ] = dist [ u ] ; deque . remove ( v1 ) ; deque . addFirst ( v1 ) ; } } if ( visit [ v2 ] == 0 ) { dist [ v2 ] = Math . min ( dist [ v2 ] , dist [ u ] + 1 ) ; deque . addLast ( v2 ) ; visit [ v2 ] = 1 ; } } System . out . println ( dist [ 0 ] + 1 ) ; } }", "import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Deque ; import java . util . List ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int [ ] one = new int [ K ] ; int [ ] zero = new int [ K ] ; for ( int i = 1 ; i < K ; i ++ ) { one [ i ] = ( i + 1 ) % K ; zero [ i ] = ( i * 10 ) % K ; } Deque < Integer > que = new ArrayDeque < > ( ) ; int [ ] min = new int [ K ] ; for ( int i = 0 ; i < K ; i ++ ) { min [ i ] = Integer . MAX_VALUE ; } que . addLast ( 1 ) ; min [ 1 ] = 1 ; while ( ! que . isEmpty ( ) ) { int cur = que . pollFirst ( ) ; if ( min [ cur ] + 1 < min [ one [ cur ] ] ) { que . addLast ( one [ cur ] ) ; min [ one [ cur ] ] = min [ cur ] + 1 ; } if ( min [ cur ] < min [ zero [ cur ] ] ) { que . addFirst ( zero [ cur ] ) ; min [ zero [ cur ] ] = min [ cur ] ; } } System . out . println ( min [ 0 ] ) ; } }" ]
[ "from collections import deque NEW_LINE def inpl ( ) : return tuple ( map ( int , input ( ) . split ( ) ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE visited = [ False for _ in range ( K ) ] NEW_LINE dq = deque ( [ ( 1 , 1 ) ] ) NEW_LINE while True : NEW_LINE INDENT c , m = dq . popleft ( ) NEW_LINE visited [ m ] = True NEW_LINE if m == 0 : NEW_LINE INDENT print ( c ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT if not visited [ ( m * 10 ) % K ] : NEW_LINE INDENT dq . appendleft ( ( c , ( m * 10 ) % K ) ) NEW_LINE DEDENT if not visited [ ( m + 1 ) % K ] : NEW_LINE INDENT dq . append ( ( c + 1 , ( m + 1 ) % K ) ) NEW_LINE DEDENT DEDENT DEDENT", "from heapq import heappush , heappop NEW_LINE K = int ( input ( ) ) NEW_LINE table = [ [ ] for i in range ( K ) ] NEW_LINE for i in range ( K ) : NEW_LINE INDENT table [ i ] . append ( [ 1 , ( i + 1 ) % K ] ) NEW_LINE t = ( 10 * i ) % K NEW_LINE if t != i : NEW_LINE INDENT table [ i ] . append ( [ 0 , t ] ) NEW_LINE DEDENT DEDENT dij = [ ] NEW_LINE visit = [ False ] * K NEW_LINE val = [ 10 ** 9 ] * K NEW_LINE val [ 1 ] = 0 NEW_LINE heappush ( dij , [ 0 , 1 ] ) NEW_LINE while dij : NEW_LINE INDENT d , x = heappop ( dij ) NEW_LINE if val [ x ] < d : NEW_LINE INDENT continue NEW_LINE DEDENT for q , y in table [ x ] : NEW_LINE INDENT if val [ y ] > val [ x ] + q : NEW_LINE INDENT val [ y ] = val [ x ] + q NEW_LINE heappush ( dij , [ val [ y ] , y ] ) NEW_LINE DEDENT DEDENT DEDENT print ( val [ 0 ] + 1 ) NEW_LINE", "from queue import * NEW_LINE class Edge ( object ) : NEW_LINE INDENT def __init__ ( self , dst , len_ ) : NEW_LINE INDENT self . dst = dst NEW_LINE self . len = len_ NEW_LINE DEDENT DEDENT MAX_K = int ( 1e5 + 5 ) NEW_LINE INF = int ( 1e9 ) NEW_LINE K = 0 NEW_LINE dis = [ INF for i in range ( 0 , MAX_K ) ] NEW_LINE vis = [ False for i in range ( 0 , MAX_K ) ] NEW_LINE edge = [ [ ] for i in range ( 0 , MAX_K ) ] NEW_LINE q = PriorityQueue ( ) NEW_LINE def add ( s , t , d ) : NEW_LINE INDENT edge [ s ] . append ( Edge ( t , d ) ) NEW_LINE DEDENT def build ( ) : NEW_LINE INDENT for i in range ( 1 , K ) : NEW_LINE INDENT add ( i , i * 10 % K , 0 ) NEW_LINE add ( i , ( i + 1 ) % K , 1 ) NEW_LINE DEDENT DEDENT def dij ( s ) : NEW_LINE INDENT dis [ s ] = 0 NEW_LINE q . put ( ( 0 , s ) ) NEW_LINE while not q . empty ( ) : NEW_LINE INDENT x = q . get ( ) [ 1 ] NEW_LINE if vis [ x ] : NEW_LINE INDENT continue NEW_LINE DEDENT vis [ x ] = True NEW_LINE for e in edge [ x ] : NEW_LINE INDENT if dis [ e . dst ] > dis [ x ] + e . len : NEW_LINE INDENT dis [ e . dst ] = dis [ x ] + e . len NEW_LINE q . put ( ( dis [ e . dst ] , e . dst ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT K = int ( input ( ) ) NEW_LINE build ( ) NEW_LINE dij ( 1 ) NEW_LINE print ( dis [ 0 ] + 1 ) NEW_LINE DEDENT", "import heapq NEW_LINE k = int ( input ( ) ) NEW_LINE j = [ 0 ] * k NEW_LINE for i in range ( k ) : NEW_LINE INDENT j [ i ] = [ ( tuple ( [ ( i * 10 ) % k , 0 ] ) ) ] NEW_LINE j [ i ] . append ( tuple ( [ ( i + 1 ) % k , 1 ] ) ) NEW_LINE DEDENT min_cost = [ float ( \" inf \" ) ] * k NEW_LINE def dijkstra ( s ) : NEW_LINE INDENT queue = [ tuple ( [ 1 , s ] ) ] NEW_LINE while queue : NEW_LINE INDENT p = heapq . heappop ( queue ) NEW_LINE for e in j [ p [ 1 ] ] : NEW_LINE INDENT if p [ 0 ] + e [ 1 ] >= min_cost [ e [ 0 ] ] : NEW_LINE INDENT continue NEW_LINE DEDENT min_cost [ e [ 0 ] ] = p [ 0 ] + e [ 1 ] NEW_LINE heapq . heappush ( queue , tuple ( [ min_cost [ e [ 0 ] ] , e [ 0 ] ] ) ) NEW_LINE DEDENT DEDENT DEDENT dijkstra ( 1 ) NEW_LINE print ( min_cost [ 0 ] ) NEW_LINE", "from collections import deque NEW_LINE K = int ( input ( ) ) NEW_LINE dp = [ float ( \" inf \" ) ] * ( K + 1 ) NEW_LINE dq = deque ( [ ( 1 , 1 ) ] ) NEW_LINE popleft , append , append_left = dq . popleft , dq . append , dq . appendleft NEW_LINE while dq : NEW_LINE INDENT v , cost = popleft ( ) NEW_LINE if v == 0 : NEW_LINE INDENT print ( cost ) NEW_LINE exit ( ) NEW_LINE DEDENT if dp [ v ] < cost : NEW_LINE INDENT continue NEW_LINE DEDENT plus_10 , plus_1 = ( v * 10 ) % K , ( v + 1 ) % K NEW_LINE if dp [ plus_10 ] > cost : NEW_LINE INDENT dp [ plus_10 ] = cost NEW_LINE append_left ( ( plus_10 , cost ) ) NEW_LINE DEDENT if dp [ plus_1 ] > cost + 1 : NEW_LINE INDENT dp [ plus_1 ] = cost + 1 NEW_LINE append ( ( plus_1 , cost + 1 ) ) NEW_LINE DEDENT DEDENT" ]
atcoder_arc071_C
[ "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 ) ; ETrBBnsformBBtion solver = new ETrBBnsformBBtion ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ETrBBnsformBBtion { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) , t = in . next ( ) ; int [ ] cs = new int [ s . length ( ) + 1 ] , ct = new int [ t . length ( ) + 1 ] ; for ( int i = 1 ; i <= s . length ( ) ; i ++ ) { cs [ i ] = cs [ i - 1 ] + s . charAt ( i - 1 ) - ' A ' + 1 ; } for ( int i = 1 ; i <= t . length ( ) ; i ++ ) { ct [ i ] = ct [ i - 1 ] + t . charAt ( i - 1 ) - ' A ' + 1 ; } int q = in . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int a = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) , d = in . nextInt ( ) ; if ( ( cs [ b ] - cs [ a - 1 ] ) % 3 == ( ct [ d ] - ct [ c - 1 ] ) % 3 ) { out . println ( \" YES \" ) ; } else { out . println ( \" NO \" ) ; } } } } }", "import java . io . * ; import java . util . * ; public class Main { private static int [ ] prep ( String s ) { int [ ] sPre = new int [ s . length ( ) + 1 ] ; for ( int i = 1 ; i <= s . length ( ) ; i ++ ) { char c = s . charAt ( i - 1 ) ; if ( c == ' A ' ) { sPre [ i ] = sPre [ i - 1 ] + 1 ; } else { sPre [ i ] = sPre [ i - 1 ] + 2 ; } } return sPre ; } public static void main ( String [ ] args ) throws IOException { BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = f . readLine ( ) ; String t = f . readLine ( ) ; int [ ] sPre = prep ( s ) ; int [ ] tPre = prep ( t ) ; int q = Integer . parseInt ( f . readLine ( ) ) ; for ( int i = 0 ; i < q ; i ++ ) { StringTokenizer st = new StringTokenizer ( f . readLine ( ) ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int c = Integer . parseInt ( st . nextToken ( ) ) ; int d = Integer . parseInt ( st . nextToken ( ) ) ; if ( ( sPre [ b ] - sPre [ a - 1 ] ) % 3 == ( tPre [ d ] - tPre [ c - 1 ] ) % 3 ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } } }", "import java . util . * ; public class Main { private class Query { int a , b , c , d ; public Query ( int a , int b , int c , int d ) { this . a = a ; this . b = b ; this . c = c ; this . d = d ; } } public void main ( Scanner sc ) { char s [ ] = sc . next ( ) . toCharArray ( ) ; char t [ ] = sc . next ( ) . toCharArray ( ) ; int q = sc . nextInt ( ) ; Query data [ ] = new Query [ q ] ; for ( int i = 0 ; i < q ; i ++ ) { data [ i ] = new Query ( sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) ) ; } int sums [ ] = new int [ s . length + 1 ] ; int sumt [ ] = new int [ t . length + 1 ] ; for ( int i = 0 ; i < s . length ; i ++ ) { sums [ i + 1 ] = ( sums [ i ] + ( s [ i ] == ' A ' ? 1 : 2 ) ) % 3 ; } for ( int i = 0 ; i < t . length ; i ++ ) { sumt [ i + 1 ] = ( sumt [ i ] + ( t [ i ] == ' A ' ? 1 : 2 ) ) % 3 ; } int a , b , c , d ; for ( int i = 0 ; i < q ; i ++ ) { a = sums [ data [ i ] . a - 1 ] ; b = sums [ data [ i ] . b ] ; c = sumt [ data [ i ] . c - 1 ] ; d = sumt [ data [ i ] . d ] ; System . out . println ( ( ( 3 + b - a ) % 3 == ( 3 + d - c ) % 3 ) ? \" YES \" : \" NO \" ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] __ ) { int [ ] from , to ; { String buf = s . next ( ) ; from = new int [ buf . length ( ) + 1 ] ; for ( int i = 0 ; i < buf . length ( ) ; i ++ ) from [ i + 1 ] = buf . charAt ( i ) == ' A ' ? 1 : 2 ; buf = s . next ( ) ; to = new int [ buf . length ( ) + 1 ] ; for ( int i = 0 ; i < buf . length ( ) ; i ++ ) to [ i + 1 ] = buf . charAt ( i ) == ' A ' ? 1 : 2 ; Arrays . parallelPrefix ( from , ( a , b ) -> a + b ) ; Arrays . parallelPrefix ( to , ( a , b ) -> a + b ) ; } for ( int q = s . nextInt ( ) ; q > 0 ; q -- ) { int f = - from [ s . nextInt ( ) - 1 ] + from [ s . nextInt ( ) ] , t = - to [ s . nextInt ( ) - 1 ] + to [ s . nextInt ( ) ] ; System . out . println ( f % 3 == t % 3 ? \" YES \" : \" NO \" ) ; } } }", "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 ( ) { solve ( ) ; } String S ; String T ; int N ; void solve ( ) { S = line ( ) ; T = line ( ) ; int [ ] sums = new int [ S . length ( ) + 1 ] ; int [ ] sumt = new int [ T . length ( ) + 1 ] ; sums [ 1 ] = S . charAt ( 0 ) - ' A ' + 1 ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { sums [ i + 1 ] = sums [ i ] + S . charAt ( i ) - ' A ' + 1 ; } sumt [ 1 ] = T . charAt ( 0 ) - ' A ' + 1 ; for ( int i = 1 ; i < T . length ( ) ; i ++ ) { sumt [ i + 1 ] = sumt [ i ] + T . charAt ( i ) - ' A ' + 1 ; } N = ni ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int a = ni ( ) ; int b = ni ( ) ; int c = ni ( ) ; int d = ni ( ) ; if ( ( sums [ b ] - sums [ a - 1 ] ) % 3 == ( sumt [ d ] - sumt [ c - 1 ] ) % 3 ) { println ( \" YES \" ) ; } else { println ( \" NO \" ) ; } } } }" ]
[ "s = input ( ) NEW_LINE t = input ( ) NEW_LINE q = int ( input ( ) ) NEW_LINE info = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( q ) ] NEW_LINE MOD = 3 NEW_LINE memo = { \" A \" : 1 , \" B \" : 2 } NEW_LINE s_ruiseki = [ 0 ] * ( len ( s ) + 1 ) NEW_LINE for i in range ( 1 , len ( s ) + 1 ) : NEW_LINE INDENT s_ruiseki [ i ] = ( s_ruiseki [ i - 1 ] + memo [ s [ i - 1 ] ] ) % MOD NEW_LINE DEDENT t_ruiseki = [ 0 ] * ( len ( t ) + 1 ) NEW_LINE for i in range ( 1 , len ( t ) + 1 ) : NEW_LINE INDENT t_ruiseki [ i ] = ( t_ruiseki [ i - 1 ] + memo [ t [ i - 1 ] ] ) % MOD NEW_LINE DEDENT for i in range ( q ) : NEW_LINE INDENT ans1 = ( 2 * s_ruiseki [ info [ i ] [ 0 ] - 1 ] + s_ruiseki [ info [ i ] [ 1 ] ] ) % MOD NEW_LINE ans2 = ( 2 * t_ruiseki [ info [ i ] [ 2 ] - 1 ] + t_ruiseki [ info [ i ] [ 3 ] ] ) % MOD NEW_LINE print ( \" YES \" if ans1 == ans2 else \" NO \" ) NEW_LINE DEDENT", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE S = input ( ) NEW_LINE T = input ( ) NEW_LINE typeS = [ 0 for _ in range ( 1 + len ( S ) ) ] NEW_LINE typeT = [ 0 for _ in range ( 1 + len ( T ) ) ] NEW_LINE typeS [ 0 ] = typeT [ 0 ] = 0 NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT ctr = 2 NEW_LINE if S [ i ] == ' A ' : NEW_LINE INDENT ctr = 1 NEW_LINE DEDENT typeS [ i + 1 ] = ( typeS [ i ] + ctr ) % 3 NEW_LINE DEDENT for i in range ( len ( T ) ) : NEW_LINE INDENT ctr = 2 NEW_LINE if T [ i ] == ' A ' : NEW_LINE INDENT ctr = 1 NEW_LINE DEDENT typeT [ i + 1 ] = ( typeT [ i ] + ctr ) % 3 NEW_LINE DEDENT Q = int ( input ( ) ) NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT a , b , c , d = inpl ( ) NEW_LINE if ( typeS [ b ] - typeS [ a - 1 ] ) % 3 == ( typeT [ d ] - typeT [ c - 1 ] ) % 3 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT 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 s = ns ( ) NEW_LINE t = ns ( ) NEW_LINE q = ni ( ) NEW_LINE sa = [ 0 ] NEW_LINE sb = [ 0 ] NEW_LINE ta = [ 0 ] NEW_LINE tb = [ 0 ] NEW_LINE for si in s : NEW_LINE INDENT if si == \" A \" : NEW_LINE INDENT sa . append ( sa [ - 1 ] + 1 ) NEW_LINE sb . append ( sb [ - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT sa . append ( sa [ - 1 ] ) NEW_LINE sb . append ( sb [ - 1 ] + 1 ) NEW_LINE DEDENT DEDENT for ti in t : NEW_LINE INDENT if ti == \" A \" : NEW_LINE INDENT ta . append ( ta [ - 1 ] + 1 ) NEW_LINE tb . append ( tb [ - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT ta . append ( ta [ - 1 ] ) NEW_LINE tb . append ( tb [ - 1 ] + 1 ) NEW_LINE DEDENT DEDENT for _ in range ( q ) : NEW_LINE INDENT a , b , c , d = li ( ) NEW_LINE sanum = sa [ b ] - sa [ a - 1 ] NEW_LINE sbnum = sb [ b ] - sb [ a - 1 ] NEW_LINE tanum = ta [ d ] - ta [ c - 1 ] NEW_LINE tbnum = tb [ d ] - tb [ c - 1 ] NEW_LINE sanum += 2 * sbnum NEW_LINE tanum += 2 * tbnum NEW_LINE if sanum % 3 == tanum % 3 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT DEDENT", "def getN ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def getMN ( ) : NEW_LINE INDENT a = input ( ) . split ( ) NEW_LINE b = [ int ( i ) for i in a ] NEW_LINE return b [ 0 ] , b [ 1 ] NEW_LINE DEDENT def getlist ( ) : NEW_LINE INDENT a = input ( ) . split ( ) NEW_LINE b = [ int ( i ) for i in a ] NEW_LINE return b NEW_LINE DEDENT astr = input ( ) NEW_LINE bstr = input ( ) NEW_LINE n = getN ( ) NEW_LINE queries = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT queries . append ( getlist ( ) ) NEW_LINE DEDENT s1 = 1 if astr [ 0 ] == \" A \" else 2 NEW_LINE t1 = 1 if bstr [ 0 ] == \" A \" else 2 NEW_LINE s_acc = [ 0 ] NEW_LINE t_acc = [ 0 ] NEW_LINE tmp = 0 NEW_LINE for s in astr : NEW_LINE INDENT if s == \" A \" : NEW_LINE INDENT s_acc . append ( s_acc [ - 1 ] + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT s_acc . append ( s_acc [ - 1 ] + 2 ) NEW_LINE DEDENT DEDENT for s in bstr : NEW_LINE INDENT if s == \" A \" : NEW_LINE INDENT t_acc . append ( t_acc [ - 1 ] + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT t_acc . append ( t_acc [ - 1 ] + 2 ) NEW_LINE DEDENT DEDENT for q in queries : NEW_LINE INDENT x , y , z , w = q NEW_LINE if ( s_acc [ y ] - s_acc [ x - 1 ] ) % 3 == ( t_acc [ w ] - t_acc [ z - 1 ] ) % 3 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT DEDENT", "S = input ( ) NEW_LINE T = input ( ) NEW_LINE def sign ( s ) : NEW_LINE INDENT if len ( s ) == 1 : NEW_LINE INDENT return s NEW_LINE DEDENT elif s == \" AA \" : NEW_LINE INDENT return \" B \" NEW_LINE DEDENT elif s in [ \" AB \" , \" BA \" ] : NEW_LINE INDENT return \" \" NEW_LINE DEDENT elif s == \" BB \" : NEW_LINE INDENT return \" A \" NEW_LINE DEDENT DEDENT def diff ( a , b ) : NEW_LINE INDENT if b == \" \" : NEW_LINE INDENT return a NEW_LINE DEDENT elif b == a : NEW_LINE INDENT return \" \" NEW_LINE DEDENT elif a == \" \" : NEW_LINE INDENT if b == \" A \" : NEW_LINE INDENT return \" B \" NEW_LINE DEDENT elif b == \" B \" : NEW_LINE INDENT return \" A \" NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return b NEW_LINE DEDENT DEDENT a = \" \" NEW_LINE Sn = [ \" \" ] NEW_LINE for s in S : NEW_LINE INDENT a = sign ( a + s ) NEW_LINE Sn . append ( a ) NEW_LINE DEDENT a = \" \" NEW_LINE Tn = [ \" \" ] NEW_LINE for t in T : NEW_LINE INDENT a = sign ( a + t ) NEW_LINE Tn . append ( a ) NEW_LINE DEDENT q = int ( input ( ) ) NEW_LINE for i in range ( q ) : NEW_LINE INDENT a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE if diff ( Sn [ b ] , Sn [ a - 1 ] ) == diff ( Tn [ d ] , Tn [ c - 1 ] ) : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT DEDENT" ]
atcoder_arc066_C
[ "import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; long [ ] sum = new long [ N ] ; long [ ] a = new long [ N ] ; long [ ] abssum = new long [ N + 1 ] ; List < Integer > minusIndex = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( i == 0 ) { a [ i ] = scan . nextLong ( ) ; sum [ i ] = a [ i ] ; } else { boolean minus = ( scan . next ( ) . equals ( \" - \" ) ) ; a [ i ] = scan . nextLong ( ) ; sum [ i ] = sum [ i - 1 ] + a [ i ] * ( minus ? - 1 : 1 ) ; if ( minus ) minusIndex . add ( i - 1 ) ; } } for ( int i = N - 1 ; i >= 0 ; -- i ) abssum [ i ] = abssum [ i + 1 ] + a [ i ] ; long ans = sum [ N - 1 ] ; for ( int i = 0 ; i < minusIndex . size ( ) - 1 ; ++ i ) { ans = Math . max ( ans , sum [ minusIndex . get ( i ) ] - abssum [ minusIndex . get ( i ) + 1 ] + 2 * abssum [ minusIndex . get ( i + 1 ) + 1 ] ) ; } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { private void solve ( ) throws IOException { int n = nextInt ( ) ; long [ ] a = new long [ n ] ; char [ ] c = new char [ n ] ; c [ 0 ] = ' + ' ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 0 ) { c [ i ] = next ( ) . charAt ( 0 ) ; } a [ i ] = nextInt ( ) ; } long s = 0 ; long ss = 0 ; long ans = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( c [ i ] == ' + ' ) { s += a [ i ] ; } else { ans = Math . max ( - a [ i ] + s + ans , - a [ i ] - s + ss ) ; ss += s + a [ i ] ; s = 0 ; } } ans += s ; out . println ( ans ) ; } BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; PrintWriter out = new PrintWriter ( System . out ) ; String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } return st . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } private void run ( ) throws IOException { solve ( ) ; out . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] [ ] dp = new long [ n ] [ 3 ] ; long a0 = sc . nextLong ( ) ; dp [ 0 ] [ 0 ] = a0 ; dp [ 0 ] [ 1 ] = Long . MIN_VALUE / 10 ; dp [ 0 ] [ 2 ] = Long . MIN_VALUE / 10 ; for ( int i = 1 ; i < n ; i ++ ) { String str = sc . next ( ) ; long v = sc . nextLong ( ) ; if ( str . equals ( \" + \" ) ) { dp [ i ] [ 0 ] = Math . max ( Math . max ( dp [ i - 1 ] [ 0 ] + v , dp [ i - 1 ] [ 1 ] + v ) , dp [ i - 1 ] [ 2 ] + v ) ; dp [ i ] [ 1 ] = Math . max ( dp [ i - 1 ] [ 1 ] - v , dp [ i - 1 ] [ 2 ] + v ) ; dp [ i ] [ 2 ] = dp [ i - 1 ] [ 2 ] + v ; } else { dp [ i ] [ 0 ] = Math . max ( Math . max ( dp [ i - 1 ] [ 0 ] - v , dp [ i - 1 ] [ 1 ] + v ) , dp [ i - 1 ] [ 2 ] + v ) ; dp [ i ] [ 1 ] = Math . max ( Math . max ( dp [ i - 1 ] [ 0 ] - v , dp [ i - 1 ] [ 1 ] + v ) , dp [ i - 1 ] [ 2 ] + v ) ; dp [ i ] [ 2 ] = Math . max ( dp [ i - 1 ] [ 1 ] + v , dp [ i - 1 ] [ 2 ] + v ) ; } } System . out . println ( dp [ n - 1 ] [ 0 ] ) ; } }" ]
[ "input ( ) NEW_LINE sm = de = 0 NEW_LINE ans = 10 ** 15 NEW_LINE for s in ( input ( ) + \" - 0\" ) . split ( ' - ' ) : NEW_LINE INDENT a = list ( map ( int , s . split ( ' + ' ) ) ) NEW_LINE if sm : NEW_LINE INDENT ans = min ( ans , sum ( a ) + de ) NEW_LINE de += a [ 0 ] NEW_LINE DEDENT sm += sum ( a ) NEW_LINE DEDENT print ( sm - 2 * ans ) NEW_LINE" ]
atcoder_abc103_B
[ "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; String str2 = sc . nextLine ( ) ; int size = str . length ( ) ; int size2 = str2 . length ( ) ; int flag = 1 ; while ( true ) { if ( str . equals ( str2 ) ) { break ; } else { size2 = size2 - 1 ; String str3 = str . substring ( 0 , 1 ) ; str = str . substring ( 1 , size ) ; str = str . concat ( str3 ) ; if ( size2 == 0 ) { flag = 0 ; break ; } } } if ( flag == 1 ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveB ( ) ; } private void solveA ( ) { Scanner scanner = null ; try { scanner = new Scanner ( System . in ) ; int [ ] wk = new int [ 3 ] ; for ( int i = 0 ; i < wk . length ; i ++ ) { wk [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( wk ) ; int res = Math . abs ( wk [ 0 ] - wk [ 1 ] ) + Math . abs ( wk [ 1 ] - wk [ 2 ] ) ; System . out . println ( res ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; String s ; String t ; try { scanner = new Scanner ( System . in ) ; s = scanner . next ( ) ; t = scanner . next ( ) ; s = s + s ; System . out . println ( s . contains ( t ) ? \" Yes \" : \" No \" ) ; } 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 br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String A = br . readLine ( ) ; String B = br . readLine ( ) ; int lengths = A . length ( ) ; boolean Bb [ ] = new boolean [ lengths ] ; for ( int i = 0 ; i < lengths ; i ++ ) { Bb [ i ] = false ; } int k = 0 ; for ( int i = 0 ; i < lengths ; i ++ ) { if ( i == 0 ) { for ( int j = 0 ; ; j ++ ) { if ( j == lengths ) { System . out . println ( \" No \" ) ; System . exit ( 0 ) ; } if ( ! Bb [ j ] && A . substring ( i , i + 1 ) . equals ( B . substring ( j , j + 1 ) ) ) { Bb [ j ] = true ; k = j ; break ; } } } else { int l = k + i >= lengths ? k + i - lengths : k + i ; if ( ! A . substring ( i , i + 1 ) . equals ( B . substring ( l , l + 1 ) ) ) { i = - 1 ; } } } System . out . println ( \" Yes \" ) ; } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { ArrayList < String > list = new ArrayList < > ( ) ; Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String T = sc . nextLine ( ) ; String tmp ; int L = S . length ( ) ; boolean check = true ; for ( int i = 0 ; i < L ; i ++ ) { list . add ( String . valueOf ( S . charAt ( i ) ) ) ; } for ( int i = 0 ; i < L ; i ++ ) { tmp = list . get ( L - 1 ) ; list . add ( 0 , tmp ) ; list . remove ( list . size ( ) - 1 ) ; int cnt = 0 ; for ( int j = 0 ; j < L ; j ++ ) { if ( list . get ( j ) . equals ( String . valueOf ( T . charAt ( j ) ) ) ) { cnt ++ ; } } if ( cnt == L ) { System . out . println ( \" Yes \" ) ; check = false ; break ; } } if ( check ) { System . out . println ( \" No \" ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder s , t ; s = new StringBuilder ( sc . next ( ) ) ; t = new StringBuilder ( sc . next ( ) ) ; boolean flag = false ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { s = new StringBuilder ( Rotate ( s ) ) ; if ( t . toString ( ) . equals ( s . toString ( ) ) ) { flag = true ; break ; } } if ( flag == true ) System . out . println ( \" Yes \" ) ; else System . out . println ( \" No \" ) ; } public static StringBuilder Rotate ( StringBuilder str ) { int len = str . length ( ) ; char t = str . charAt ( 0 ) ; for ( int i = 0 ; i < len - 1 ; i ++ ) { str . setCharAt ( i , str . charAt ( i + 1 ) ) ; } str . setCharAt ( len - 1 , t ) ; return str ; } }" ]
[ "S = input ( ) NEW_LINE T = input ( ) NEW_LINE s = len ( S ) NEW_LINE if S == T : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE exit ( ) NEW_LINE DEDENT for i in range ( s + 1 ) : NEW_LINE INDENT S = S [ - 1 ] + S [ 0 : s - 1 ] NEW_LINE if S == T : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( ' No ' ) NEW_LINE", "s = input ( ) NEW_LINE t = input ( ) NEW_LINE i = 0 NEW_LINE count = 0 NEW_LINE while i < len ( s ) : NEW_LINE INDENT s = list ( s ) NEW_LINE a = s . pop ( 0 ) NEW_LINE s . append ( a ) NEW_LINE s = ' ' . join ( s ) NEW_LINE if s == t : NEW_LINE INDENT count += 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT if count >= 1 : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "def rot ( s ) : NEW_LINE INDENT ret = s [ - 1 ] + s [ : - 1 ] NEW_LINE return ret NEW_LINE DEDENT s1 = input ( ) NEW_LINE s2 = input ( ) NEW_LINE tmp = s1 NEW_LINE flag = False NEW_LINE for i in range ( len ( s1 ) ) : NEW_LINE INDENT tmp = rot ( tmp ) NEW_LINE if tmp == s2 : NEW_LINE INDENT flag = True NEW_LINE DEDENT DEDENT if flag : 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 ans = 0 NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT S . insert ( 0 , S [ - 1 ] ) NEW_LINE del S [ - 1 ] NEW_LINE if S == T : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( \" Yes \" if ans != 0 else \" No \" ) NEW_LINE", "s = input ( ) NEW_LINE t = input ( ) NEW_LINE count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s != t : NEW_LINE INDENT count += 1 NEW_LINE s = s [ - 1 ] + s [ : - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( \" No \" if count == len ( s ) else \" Yes \" ) NEW_LINE" ]
atcoder_abc024_B
[ "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int sum = 0 ; int s = sc . nextInt ( ) ; int g = s + T ; for ( int i = 1 ; i < N ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp > g ) { sum += g - s ; s = tmp ; g = tmp + T ; } else if ( tmp <= g ) { g = tmp + T ; } } sum += g - s ; System . out . println ( sum ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . io . UncheckedIOException ; import java . util . stream . LongStream ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) , t = in . ints ( ) ; long [ ] a = in . longs ( n ) ; long ans = 0 ; long last = - 10000000 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < last + t ) { ans += a [ i ] - last ; } else { ans += t ; } last = a [ i ] ; } out . println ( ans ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } public long longs ( ) { return Long . parseLong ( string ( ) ) ; } public long [ ] longs ( int length ) { return IntStream . range ( 0 , length ) . mapToLong ( x -> longs ( ) ) . toArray ( ) ; } } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; long n = stdIn . nextLong ( ) , t = stdIn . nextLong ( ) , tmp = stdIn . nextLong ( ) , a , i , s = 0 ; for ( i = 1 ; i < n ; i ++ ) { a = stdIn . nextLong ( ) ; if ( t > a - tmp ) s += a - tmp ; else s += t ; tmp = a ; } s += t ; System . out . println ( s ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) A [ i ] = sc . nextInt ( ) ; sc . close ( ) ; int ans = 0 ; int currentTime = A [ 0 ] ; for ( int i = 1 ; i < N ; ++ i ) { if ( currentTime + T < A [ i ] ) { ans += T ; } else { ans += A [ i ] - A [ i - 1 ] ; } currentTime = A [ i ] ; } ans += T ; System . out . println ( ans ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] line = scanner . nextLine ( ) . split ( \" ▁ \" , 2 ) ; int n = Integer . parseInt ( line [ 0 ] ) ; int t = Integer . parseInt ( line [ 1 ] ) ; int total = 0 ; int lastOpen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = Integer . parseInt ( scanner . nextLine ( ) ) ; total += Math . max ( ( a + t ) - Math . max ( lastOpen , a ) , 0 ) ; lastOpen = Math . max ( a + t , lastOpen ) ; } System . out . println ( total ) ; } }" ]
[ "n , t = map ( int , input ( ) . split ( ' ▁ ' ) ) NEW_LINE a = [ ] NEW_LINE x = 0 NEW_LINE y = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT a . append ( int ( input ( ) ) ) NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if abs ( a [ i ] - a [ i - 1 ] ) > t : NEW_LINE INDENT x += t NEW_LINE DEDENT elif abs ( a [ i ] - a [ i - 1 ] ) - y <= t : NEW_LINE INDENT x += abs ( a [ i ] - a [ i - 1 ] ) NEW_LINE y = t NEW_LINE DEDENT DEDENT print ( x + t ) NEW_LINE", "def autodoor ( N : int , T : int , A : list ) -> int : NEW_LINE INDENT open_time , close_time = 0 , 0 NEW_LINE total_opening_time = 0 NEW_LINE for a in A : NEW_LINE INDENT if a > close_time : NEW_LINE INDENT total_opening_time += close_time - open_time NEW_LINE open_time = a NEW_LINE DEDENT close_time = a + T NEW_LINE DEDENT else : NEW_LINE INDENT total_opening_time += close_time - open_time NEW_LINE DEDENT return total_opening_time NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = 0 NEW_LINE N , T = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE ans = autodoor ( N , T , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "N , T = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE time = int ( input ( ) . rstrip ( ) ) NEW_LINE total = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT nexttime = int ( input ( ) . rstrip ( ) ) NEW_LINE dif = nexttime - time NEW_LINE total += dif NEW_LINE if dif - T > 0 : NEW_LINE INDENT total -= dif - T NEW_LINE DEDENT time = nexttime NEW_LINE DEDENT print ( total + T ) NEW_LINE", "n , t = map ( int , input ( ) . split ( ) ) NEW_LINE door = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE total = 0 NEW_LINE for i , v in enumerate ( door ) : NEW_LINE INDENT total += t NEW_LINE if i != 0 and door [ i - 1 ] + t >= v : NEW_LINE INDENT total -= ( t + door [ i - 1 ] - v ) NEW_LINE DEDENT DEDENT print ( total ) NEW_LINE", "N , T = map ( int , input ( ) . split ( ) ) NEW_LINE amount = 0 NEW_LINE pre = int ( input ( ) ) NEW_LINE for _ in range ( N - 1 ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE if ( a - pre ) < T : NEW_LINE INDENT amount += ( a - pre ) NEW_LINE DEDENT else : NEW_LINE INDENT amount += T NEW_LINE DEDENT pre = a NEW_LINE DEDENT amount += T NEW_LINE print ( amount ) NEW_LINE" ]
atcoder_abc006_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; long array [ ] = new long [ num + 5 ] ; for ( int i = 1 ; i <= num ; i ++ ) { array [ i ] = i == 1 || i == 2 ? 0 : i == 3 ? 1 : array [ i - 1 ] + array [ i - 2 ] + array [ i - 3 ] ; array [ i ] = mod ( array [ i ] ) ; } System . out . println ( array [ num ] ) ; } static long divisor = 10007 ; public static long mod ( long i ) { return i % divisor + ( ( i % divisor ) < 0 ? divisor : 0 ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] map = new long [ 1_000_000 ] ; map [ 0 ] = 0 ; map [ 1 ] = 0 ; map [ 2 ] = 1 ; for ( int i = 3 ; i < map . length ; i ++ ) { long num = map [ i - 3 ] + map [ i - 2 ] + map [ i - 1 ] ; map [ i ] = num % 10_007 ; } System . out . println ( map [ N - 1 ] ) ; } }", "import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; scanner . close ( ) ; ArrayList < Integer > tribonach = new ArrayList < Integer > ( ) ; tribonach . add ( 0 ) ; tribonach . add ( 0 ) ; tribonach . add ( 1 ) ; for ( int i = 3 ; i < n ; i ++ ) { int a = ( tribonach . get ( i - 1 ) + tribonach . get ( i - 2 ) + tribonach . get ( i - 3 ) ) % 10007 ; tribonach . add ( a ) ; } int an = tribonach . get ( n - 1 ) ; System . out . println ( an ) ; } }", "import java . util . * ; public class Main { static final int MOD = 10007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n == 1 || n == 2 ) { System . out . println ( 0 ) ; return ; } else if ( n == 3 ) { System . out . println ( 1 ) ; return ; } int a1 = 0 ; int a2 = 0 ; int a3 = 1 ; for ( int i = 4 ; i <= n ; i ++ ) { int x = a1 + a2 + a3 ; x %= MOD ; a1 = a2 ; a2 = a3 ; a3 = x ; } System . out . println ( a3 ) ; } }", "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 + 1 ] ; t [ 0 ] = 0 ; t [ 1 ] = 0 ; if ( n >= 2 ) { t [ 2 ] = 0 ; if ( n >= 3 ) { t [ 3 ] = 1 ; if ( n >= 4 ) { for ( int i = 4 ; i <= n ; i ++ ) { t [ i ] = t [ i - 1 ] + t [ i - 2 ] + t [ i - 3 ] ; if ( t [ i ] > 10007 ) { t [ i ] = t [ i ] % 10007 ; } } } } } System . out . println ( t [ n ] ) ; } catch ( Exception e ) { System . out . println ( \" out \" ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE a = [ 0 ] * n NEW_LINE if n >= 3 : NEW_LINE INDENT a [ 2 ] = 1 NEW_LINE DEDENT for i in range ( 3 , n ) : NEW_LINE INDENT a [ i ] = ( a [ i - 1 ] + a [ i - 2 ] + a [ i - 3 ] ) % 10007 NEW_LINE DEDENT print ( a [ - 1 ] ) NEW_LINE", "from sys import stdin NEW_LINE n = int ( stdin . readline ( ) . rstrip ( ) ) NEW_LINE def tribonacci ( n ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif n == 2 : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif n == 3 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT newN = n - 3 NEW_LINE num1 , num2 , num3 = 0 , 0 , 1 NEW_LINE for i in range ( newN ) : NEW_LINE INDENT num1 , num2 , num3 = num2 % 10007 , num3 % 10007 , ( num1 + num2 + num3 ) % 10007 NEW_LINE DEDENT return num3 NEW_LINE DEDENT DEDENT print ( tribonacci ( n ) ) NEW_LINE", "a = [ 0 , 0 , 1 ] NEW_LINE n = int ( input ( ) ) NEW_LINE if n < 4 : exec ( \" print ( a [ n - 1 ] ) ; exit ( ) \" ) NEW_LINE for i in range ( n - 3 ) : a [ 0 ] , a [ 1 ] , a [ 2 ] = a [ 1 ] , a [ 2 ] , ( a [ 0 ] + a [ 1 ] + a [ 2 ] ) % 10007 NEW_LINE print ( a [ 2 ] % ( 10007 ) ) NEW_LINE", "a , b , c = 0 , 0 , 1 NEW_LINE for i in range ( int ( input ( ) ) - 1 ) : NEW_LINE INDENT a , b , c = b , c , ( a + b + c ) % 10007 NEW_LINE DEDENT print ( a ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE w = 10007 NEW_LINE a = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i == 2 : NEW_LINE INDENT a [ i ] = 1 NEW_LINE DEDENT elif i > 2 : NEW_LINE INDENT a [ i ] = a [ i - 1 ] + a [ i - 2 ] + a [ i - 3 ] NEW_LINE a [ i ] %= w NEW_LINE DEDENT DEDENT print ( a [ n - 1 ] ) NEW_LINE" ]
atcoder_abc057_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 [ ] [ ] stu = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < stu . length ; i ++ ) { stu [ i ] [ 0 ] = sc . nextInt ( ) ; stu [ i ] [ 1 ] = sc . nextInt ( ) ; } int [ ] [ ] cp = new int [ m ] [ 2 ] ; for ( int i = 0 ; i < cp . length ; i ++ ) { cp [ i ] [ 0 ] = sc . nextInt ( ) ; cp [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < stu . length ; i ++ ) { int min = - 1 ; int d = 1000000000 ; for ( int j = 0 ; j < cp . length ; j ++ ) { int temp = Math . abs ( stu [ i ] [ 0 ] - cp [ j ] [ 0 ] ) + Math . abs ( stu [ i ] [ 1 ] - cp [ j ] [ 1 ] ) ; if ( d > temp ) { min = j ; d = temp ; } } System . out . println ( min + 1 ) ; } } }", "import java . util . Scanner ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; Point [ ] student = new Point [ n ] ; Point [ ] checkPoint = new Point [ m ] ; for ( int i = 0 ; i < n ; i ++ ) student [ i ] = new Point ( sc . nextInt ( ) , sc . nextInt ( ) ) ; for ( int i = 0 ; i < m ; i ++ ) checkPoint [ i ] = new Point ( sc . nextInt ( ) , sc . nextInt ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { int minNum = - 1 ; int minValue = Integer . MAX_VALUE ; for ( int j = 0 ; j < m ; j ++ ) { int d = calcManhatDistance ( student [ i ] . getX ( ) , student [ i ] . getY ( ) , checkPoint [ j ] . getX ( ) , checkPoint [ j ] . getY ( ) ) ; if ( d < minValue ) { minValue = d ; minNum = j ; } } System . out . println ( minNum + 1 ) ; } } static int calcManhatDistance ( int x1 , int y1 , int x2 , int y2 ) { int d = Math . abs ( x1 - x2 ) + Math . abs ( y1 - y2 ) ; return d ; } static double calcEuclidDistance ( double x1 , double y1 , double x2 , double y2 ) { double d = Math . sqrt ( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) ; return d ; } } class Point { private int x ; private int y ; Point ( int a , int b ) { x = a ; y = b ; } int getX ( ) { return x ; } int getY ( ) { return y ; } void setX ( int n ) { x = n ; } void setY ( int n ) { y = n ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) , M = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ N ] , b = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; b [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int [ ] c = new int [ M ] , d = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { c [ i ] = Integer . parseInt ( sc . next ( ) ) ; d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < N ; i ++ ) { int checkPoint = 0 ; for ( int j = 0 ; j < M ; j ++ ) { if ( Math . abs ( a [ i ] - c [ j ] ) + Math . abs ( b [ i ] - d [ j ] ) < Math . abs ( a [ i ] - c [ checkPoint ] ) + Math . abs ( b [ i ] - d [ checkPoint ] ) ) { checkPoint = j ; } } System . out . println ( checkPoint + 1 ) ; } } }", "import java . util . Scanner ; import java . util . ArrayList ; import java . util . List ; public class Main { public static int abs ( int x ) { return ( x > 0 ) ? x : - x ; } public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; List < Integer > list_a = new ArrayList < Integer > ( ) ; List < Integer > list_b = new ArrayList < Integer > ( ) ; List < Integer > list_c = new ArrayList < Integer > ( ) ; List < Integer > list_d = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int p = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; list_a . add ( p ) ; list_b . add ( q ) ; } for ( int i = 0 ; i < m ; i ++ ) { int p = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; list_c . add ( p ) ; list_d . add ( q ) ; } for ( int i = 0 ; i < n ; i ++ ) { int minIndex = 0 , minDiff = 1234567890 ; for ( int j = 0 ; j < m ; j ++ ) { int diff = abs ( list_a . get ( i ) - list_c . get ( j ) ) + abs ( list_b . get ( i ) - list_d . get ( j ) ) ; if ( diff < minDiff ) { minIndex = j + 1 ; minDiff = diff ; } } System . out . println ( minIndex ) ; } } }", "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 ( ) ; long [ ] [ ] map = new long [ N ] [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; map [ i ] [ 0 ] = a ; map [ i ] [ 1 ] = b ; } long [ ] [ ] points = new long [ M ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; points [ i ] [ 0 ] = c ; points [ i ] [ 1 ] = d ; } for ( int i = 0 ; i < N ; i ++ ) { long a = map [ i ] [ 0 ] ; long b = map [ i ] [ 1 ] ; int point = - 1 ; long min = Long . MAX_VALUE ; for ( int j = 0 ; j < M ; j ++ ) { long c = points [ j ] [ 0 ] ; long d = points [ j ] [ 1 ] ; long km = Math . abs ( a - c ) + Math . abs ( b - d ) ; if ( min > km ) { point = j + 1 ; min = km ; } } System . out . println ( point ) ; } } }" ]
[ "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE STUDENTS = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE CHECKPOINTS = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( M ) ] NEW_LINE for student in STUDENTS : NEW_LINE INDENT L = 10 ** 10 NEW_LINE for i , checkpoint in enumerate ( CHECKPOINTS ) : NEW_LINE INDENT l = abs ( checkpoint [ 0 ] - student [ 0 ] ) + abs ( checkpoint [ 1 ] - student [ 1 ] ) NEW_LINE if l < L : NEW_LINE INDENT nc = i + 1 NEW_LINE L = l NEW_LINE DEDENT DEDENT print ( nc ) NEW_LINE DEDENT", "( n , m ) , * a = [ list ( map ( int , s . split ( ) ) ) for s in open ( 0 ) ] NEW_LINE for i , j in a [ : n ] : l = [ abs ( x - i ) + abs ( y - j ) for x , y in a [ n : ] ] ; print ( 1 + l . index ( min ( l ) ) ) NEW_LINE", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT N , M = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE c = [ ] NEW_LINE d = [ ] NEW_LINE ans = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT t1 , t2 = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE a . append ( t1 ) NEW_LINE b . append ( t2 ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT t1 , t2 = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE c . append ( t1 ) NEW_LINE d . append ( t2 ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT min_dist = 1e10 NEW_LINE ans . append ( 0 ) NEW_LINE for j in range ( M ) : NEW_LINE INDENT dist = abs ( a [ i ] - c [ j ] ) + abs ( b [ i ] - d [ j ] ) NEW_LINE if min_dist > dist : NEW_LINE INDENT ans [ i ] = str ( j + 1 ) NEW_LINE min_dist = dist NEW_LINE DEDENT DEDENT DEDENT print ( ' \\n ' . join ( ans ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE ni = lambda : int ( sys . stdin . readline ( ) . rstrip ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE INF = 10 ** 9 NEW_LINE n , m = nm ( ) NEW_LINE ab = [ nl ( ) for i in range ( n ) ] NEW_LINE cd = [ nl ( ) for i in range ( m ) ] NEW_LINE ans = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT temp = INF NEW_LINE a = ab [ i ] [ 0 ] NEW_LINE b = ab [ i ] [ 1 ] NEW_LINE for j in range ( m - 1 , - 1 , - 1 ) : NEW_LINE INDENT c = cd [ j ] [ 0 ] NEW_LINE d = cd [ j ] [ 1 ] NEW_LINE if abs ( a - c ) + abs ( b - d ) <= temp : NEW_LINE INDENT temp = abs ( a - c ) + abs ( b - d ) NEW_LINE idx = j + 1 NEW_LINE DEDENT DEDENT ans . append ( str ( idx ) ) NEW_LINE DEDENT print ( ' \\n ' . join ( ans ) ) NEW_LINE", "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE hoge_x = [ ] NEW_LINE hoge_y = [ ] NEW_LINE huga_x = [ ] NEW_LINE huga_y = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE hoge_x . append ( a ) NEW_LINE hoge_y . append ( b ) NEW_LINE DEDENT for j in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE huga_x . append ( a ) NEW_LINE huga_y . append ( b ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT ans_kyori = - 1 NEW_LINE ans_index = - 1 NEW_LINE for j in range ( m ) : NEW_LINE INDENT kyori = abs ( hoge_x [ i ] - huga_x [ j ] ) + abs ( hoge_y [ i ] - huga_y [ j ] ) NEW_LINE if ( kyori < ans_kyori or ans_kyori == - 1 ) : NEW_LINE INDENT ans_kyori = kyori NEW_LINE ans_index = j + 1 NEW_LINE DEDENT DEDENT print ( ans_index ) NEW_LINE DEDENT" ]
atcoder_abc004_D
[ "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 [ ] yo = Arrays . asList ( br . readLine ( ) . split ( \" ▁ \" ) ) . stream ( ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int r = yo [ 0 ] ; int g = yo [ 1 ] ; int b = yo [ 2 ] ; long ans = 1252521830252521L ; final int OH = 1500 ; int [ ] arr = new int [ OH ] ; for ( int gl = - 1000 ; gl <= 700 ; gl ++ ) { long cnt = 0 ; for ( int i = 0 ; i < g ; i ++ ) { cnt += Math . abs ( gl + i ) ; } { for ( int i = 0 ; i < OH ; i ++ ) { int p = gl - 1 - i ; arr [ i ] = Math . abs ( p - ( - 100 ) ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < r ; i ++ ) { cnt += arr [ i ] ; } } { for ( int i = 0 ; i < OH ; i ++ ) { int p = gl + g + i ; arr [ i ] = Math . abs ( p - ( 100 ) ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < b ; i ++ ) { cnt += arr [ i ] ; } } ans = Math . min ( ans , cnt ) ; } System . out . println ( ans ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D solver = new D ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int r = in . nextInt ( ) , g = in . nextInt ( ) , b = in . nextInt ( ) ; int minAns = Integer . MAX_VALUE ; for ( int gr = - 1000 ; gr < 1000 ; gr ++ ) { int gl = 1 + gr - g ; int ans = calc ( 0 , gl , gr ) ; int rl = - r / 2 - 100 , rr = ( r - 1 ) / 2 - 100 ; int bl = - b / 2 + 100 , br = ( b - 1 ) / 2 + 100 ; if ( rr >= gl ) { int d = rr - gl + 1 ; rl -= d ; rr -= d ; } if ( gr >= bl ) { int d = gr - bl + 1 ; bl += d ; br += d ; } ans += calc ( - 100 , rl , rr ) ; ans += calc ( 100 , bl , br ) ; minAns = Math . min ( minAns , ans ) ; } out . println ( minAns ) ; } private static int calc ( int orig , int left , int right ) { int l = left - orig ; int r = right - orig ; if ( l <= 0 && 0 <= r ) { return ( l * ( l - 1 ) + r * ( r + 1 ) ) / 2 ; } else if ( r < 0 ) { return ( l * ( l - 1 ) - r * ( r + 1 ) ) / 2 ; } else { return ( r * ( r + 1 ) - l * ( l - 1 ) ) / 2 ; } } } }", "import java . util . Scanner ; public class Main { private static int dp [ ] [ ] ; private static final int SIZE = 2000 ; private static int R ; private static int G ; private static int B ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; R = sc . nextInt ( ) ; G = sc . nextInt ( ) ; B = sc . nextInt ( ) ; sc . close ( ) ; dp = new int [ SIZE ] [ R + G + B + 1 ] ; for ( int i = 0 ; i < SIZE ; i ++ ) { for ( int j = 0 ; j < R + G + B + 1 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } System . out . println ( dfs ( 0 , R + G + B ) ) ; } private static int dfs ( int pos , int num ) { if ( num == 0 ) { return 0 ; } if ( dp [ pos ] [ num ] >= 0 ) { return dp [ pos ] [ num ] ; } int move = 0 ; if ( num > G + B ) { move = Math . abs ( SIZE / 2 - 100 - pos ) ; } else if ( num > B ) { move = Math . abs ( SIZE / 2 - pos ) ; } else if ( num > 0 ) { move = Math . abs ( SIZE / 2 + 100 - pos ) ; } if ( pos >= SIZE - num ) { dp [ pos ] [ num ] = dfs ( pos + 1 , num - 1 ) + move ; } else { dp [ pos ] [ num ] = Math . min ( dfs ( pos + 1 , num ) , dfs ( pos + 1 , num - 1 ) + move ) ; } return dp [ pos ] [ num ] ; } }", "import java . util . * ; public class Main { public static int r , g , b , total ; public static int ENOUGH_BIG = ( int ) Math . pow ( 10 , 9 ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; r = sc . nextInt ( ) ; g = sc . nextInt ( ) ; b = sc . nextInt ( ) ; total = r + g + b ; int table [ ] [ ] = new int [ 1000 ] [ 1000 ] ; for ( int i = 0 ; i < 1000 ; ++ i ) { for ( int j = 0 ; j < 1000 ; ++ j ) { if ( j == total ) { table [ i ] [ j ] = 0 ; } else { table [ i ] [ j ] = ENOUGH_BIG ; } } } for ( int i = 1 ; i < 999 ; ++ i ) { for ( int j = 0 ; j < total ; ++ j ) { table [ i ] [ j ] = Math . min ( table [ i - 1 ] [ j ] , table [ i - 1 ] [ j + 1 ] + cost ( i , j + 1 ) ) ; } } int minScore = ENOUGH_BIG ; for ( int i = 0 ; i < 1000 ; ++ i ) { minScore = Math . min ( minScore , table [ i ] [ 0 ] ) ; } System . out . println ( minScore ) ; } public static int cost ( int i , int j ) { int result ; if ( j > g + b ) { result = Math . abs ( i - 400 ) ; } else if ( j > b ) { result = Math . abs ( i - 500 ) ; } else { result = Math . abs ( i - 600 ) ; } return result ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int r , g , b ; r = sc . nextInt ( ) ; g = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int [ ] f = new int [ r + g + b + 1 ] ; Arrays . fill ( f , Integer . MAX_VALUE / 3 ) ; f [ r + g + b ] = 0 ; for ( int i = - 1000 ; i <= 1000 ; ++ i ) { for ( int res = 1 ; res <= r + g + b ; ++ res ) { if ( res > g + b ) { f [ res - 1 ] = Math . min ( f [ res - 1 ] , f [ res ] + Math . abs ( - 100 - i ) ) ; } else if ( res > b && g + b >= res ) { f [ res - 1 ] = Math . min ( f [ res - 1 ] , f [ res ] + Math . abs ( i ) ) ; } else { f [ res - 1 ] = Math . min ( f [ res - 1 ] , f [ res ] + Math . abs ( 100 - i ) ) ; } } } System . out . println ( f [ 0 ] ) ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }" ]
[ "r , g , b = map ( int , input ( ) . split ( ) ) NEW_LINE def count ( remaining , place ) : NEW_LINE INDENT if remaining == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif 0 < remaining <= b : NEW_LINE INDENT return abs ( place - 600 ) NEW_LINE DEDENT elif b < remaining <= b + g : NEW_LINE INDENT return abs ( place - 500 ) NEW_LINE DEDENT elif b + g < remaining <= b + g + r : NEW_LINE INDENT return abs ( place - 400 ) NEW_LINE DEDENT DEDENT dp = [ [ 10 ** 8 for i in range ( r + g + b + 1 ) ] for j in range ( 1000 ) ] NEW_LINE dp [ 0 ] [ r + g + b ] = 0 NEW_LINE dp [ 0 ] [ r + g + b - 1 ] = count ( r + g + b , 0 ) NEW_LINE for i in range ( 1 , 1000 ) : NEW_LINE INDENT if dp [ i - 1 ] [ 0 ] != 10 ** 8 : NEW_LINE INDENT dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] NEW_LINE DEDENT for j in range ( 1 , r + g + b + 1 ) : NEW_LINE INDENT if dp [ i - 1 ] [ j ] != 10 ** 8 : NEW_LINE INDENT dp [ i ] [ j ] = min ( dp [ i - 1 ] [ j ] , dp [ i ] [ j ] ) NEW_LINE dp [ i ] [ j - 1 ] = min ( dp [ i - 1 ] [ j ] + count ( j , i ) , dp [ i ] [ j - 1 ] ) NEW_LINE DEDENT DEDENT DEDENT print ( dp [ 999 ] [ 0 ] ) NEW_LINE", "R , G , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 10 ** 10 NEW_LINE def prog ( n ) : NEW_LINE INDENT return n * ( n + 1 ) // 2 NEW_LINE DEDENT for g_left in range ( - 49 - G , 51 ) : NEW_LINE INDENT g_right = g_left + G - 1 NEW_LINE if - 100 + ( R - 1 ) // 2 < g_left : NEW_LINE INDENT r_left = - 100 - R // 2 NEW_LINE r_right = r_left + R - 1 NEW_LINE DEDENT else : NEW_LINE INDENT r_right = g_left - 1 NEW_LINE r_left = r_right - R + 1 NEW_LINE DEDENT if g_right < 100 - ( B - 1 ) // 2 : NEW_LINE INDENT b_right = 100 + B // 2 NEW_LINE b_left = b_right - B + 1 NEW_LINE DEDENT else : NEW_LINE INDENT b_left = g_right + 1 NEW_LINE b_right = b_left + B - 1 NEW_LINE DEDENT res = 0 NEW_LINE if r_left <= - 100 <= r_right : NEW_LINE INDENT res += prog ( - 100 - r_left ) NEW_LINE res += prog ( r_right - ( - 100 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT res += prog ( R ) NEW_LINE res += R * ( - 100 - r_right - 1 ) NEW_LINE DEDENT if b_left <= 100 <= b_right : NEW_LINE INDENT res += prog ( 100 - b_left ) NEW_LINE res += prog ( b_right - 100 ) NEW_LINE DEDENT else : NEW_LINE INDENT res += prog ( B ) NEW_LINE res += B * ( b_left - 100 - 1 ) NEW_LINE DEDENT if g_left <= 0 <= g_right : NEW_LINE INDENT res += prog ( - g_left ) NEW_LINE res += prog ( g_right ) NEW_LINE DEDENT elif g_right < 0 : NEW_LINE INDENT res += prog ( G ) NEW_LINE res += G * ( - g_right - 1 ) NEW_LINE DEDENT elif 0 < g_left : NEW_LINE INDENT res += prog ( G ) NEW_LINE res += G * ( g_left - 1 ) NEW_LINE DEDENT ans = min ( ans , res ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "from functools import lru_cache NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10000 ) NEW_LINE sb = [ - 100 , 0 , 100 ] NEW_LINE @ lru_cache ( maxsize = None ) NEW_LINE def ops ( l , m ) : NEW_LINE INDENT global marble NEW_LINE r = l + marble [ m ] - 1 NEW_LINE if l < sb [ m ] < r : NEW_LINE INDENT ln = abs ( l - sb [ m ] ) NEW_LINE rn = marble [ m ] - ln - 1 NEW_LINE op = ( ln * ( ln + 1 ) + rn * ( rn + 1 ) ) // 2 NEW_LINE DEDENT else : NEW_LINE INDENT ofs = abs ( r - sb [ m ] ) if r <= sb [ m ] else abs ( l - sb [ m ] ) NEW_LINE n = marble [ m ] - 1 NEW_LINE op = ( n * ( n + 1 ) ) // 2 + ofs * marble [ m ] NEW_LINE DEDENT return ( op ) NEW_LINE DEDENT @ lru_cache ( maxsize = None ) NEW_LINE def plcMbl ( b , m ) : NEW_LINE INDENT if b + sum ( marble [ m : ] ) > 500 : NEW_LINE INDENT return ( float ( ' inf ' ) ) NEW_LINE DEDENT if m == 3 : NEW_LINE INDENT return ( 0 ) NEW_LINE DEDENT op = ops ( b , m ) NEW_LINE opl = [ plcMbl ( b + 1 , m ) , op + plcMbl ( b + marble [ m ] , m + 1 ) ] NEW_LINE return ( min ( opl ) ) NEW_LINE DEDENT marble = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE print ( plcMbl ( - 500 , 0 ) ) NEW_LINE", "from math import * NEW_LINE R , G , B = [ int ( x ) for x in input ( ) . strip ( ) . split ( ) ] NEW_LINE pr = - 100 NEW_LINE pg = 0 NEW_LINE pb = 100 NEW_LINE R0min = min ( floor ( - ( R - 1 ) / 2 ) + pr , floor ( - ( B - 1 ) / 2 ) - G - R ) NEW_LINE R0max = ceil ( - ( R - 1 ) / 2 ) + pr NEW_LINE B0min = floor ( - ( B - 1 ) / 2 ) + pb NEW_LINE B0max = max ( ceil ( - ( B - 1 ) / 2 ) + pb , ceil ( ( R - 1 ) / 2 ) + G ) NEW_LINE def sumn ( n ) : NEW_LINE INDENT return int ( n * ( n + 1 ) / 2 ) NEW_LINE DEDENT def calc_count ( n , p0 , p1 , c ) : NEW_LINE INDENT if p0 <= c and p1 >= c : NEW_LINE INDENT return sumn ( abs ( p0 - c ) ) + sumn ( abs ( p1 - c ) ) NEW_LINE DEDENT elif p0 > c : NEW_LINE INDENT return ( p0 - c ) * n + sumn ( n - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT return ( c - p1 ) * n + sumn ( n - 1 ) NEW_LINE DEDENT DEDENT minmove = 2 ** 31 NEW_LINE for r0 in range ( R0min , R0max + 1 ) : NEW_LINE INDENT for b0 in range ( B0min , B0max + 1 ) : NEW_LINE INDENT r1 = r0 + R - 1 NEW_LINE b1 = b0 + B - 1 NEW_LINE if G >= b0 - r1 : NEW_LINE INDENT continue NEW_LINE DEDENT if - ( r1 + 1 ) <= b0 - 1 : NEW_LINE INDENT g0 = max ( floor ( - ( G - 1 ) / 2 ) , r1 + 1 ) NEW_LINE g1 = g0 + G - 1 NEW_LINE DEDENT else : NEW_LINE INDENT g1 = min ( ceil ( ( G - 1 ) / 2 ) , b0 - 1 ) NEW_LINE g0 = g1 - G + 1 NEW_LINE DEDENT count = 0 NEW_LINE count += calc_count ( R , r0 , r1 , pr ) NEW_LINE count += calc_count ( G , g0 , g1 , pg ) NEW_LINE count += calc_count ( B , b0 , b1 , pb ) NEW_LINE if count <= minmove : NEW_LINE INDENT minmove = count NEW_LINE DEDENT DEDENT DEDENT print ( minmove ) NEW_LINE", "iR , iG , iB = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE if iR < iB : NEW_LINE INDENT iR , iB = iB , iR NEW_LINE DEDENT def calcMoveEach ( n ) : NEW_LINE INDENT return n * ( n + 1 ) // 2 NEW_LINE DEDENT def calcMove ( a , l ) : NEW_LINE INDENT if l < a : NEW_LINE INDENT return calcMoveEach ( l ) + calcMoveEach ( a - l - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT return calcMoveEach ( l ) - calcMoveEach ( l - a ) NEW_LINE DEDENT DEDENT def diffmod2 ( t ) : NEW_LINE INDENT return 1 if t % 2 == 0 else 0 NEW_LINE DEDENT if iR < 100 and iG < 100 and iB < 100 : NEW_LINE INDENT print ( calcMove ( iR , iR // 2 ) + calcMove ( iG , iG // 2 ) + calcMove ( iB , iB // 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT iDiff = max ( iG , iR , iB ) NEW_LINE iAns = calcMove ( iDiff , 900 ) NEW_LINE for iED in range ( - iDiff , iDiff ) : NEW_LINE INDENT lG = iG + iED NEW_LINE lR = max ( 100 + iR // 2 , iR + lG ) NEW_LINE rB = max ( 100 + iB // 2 , iB + ( iG - lG - 1 ) ) NEW_LINE iLLL = calcMove ( iR , lR - 100 ) + calcMove ( iG , max ( lG , iG - lG - 1 ) ) + calcMove ( iB , rB - 100 ) NEW_LINE iAns = min ( iAns , iLLL ) NEW_LINE DEDENT print ( iAns ) NEW_LINE NEW_LINE DEDENT" ]
atcoder_agc027_A
[ "import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; 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 n = sc . nextInt ( ) ; long x = sc . nextLong ( ) ; List < Long > a = new ArrayList < > ( ) ; IntStream . range ( 0 , n ) . forEach ( i -> a . add ( sc . nextLong ( ) ) ) ; Collections . sort ( a ) ; int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( x < a . get ( i ) ) { break ; } x -= a . get ( i ) ; count ++ ; } if ( x == a . get ( n - 1 ) ) { count ++ ; } System . out . println ( count ) ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = ni ( ) ; int x = ni ( ) ; int [ ] a = niarr ( N ) ; Arrays . sort ( a ) ; int num = 0 ; int i = 0 ; while ( i < N && x >= a [ i ] ) { x -= a [ i ] ; i ++ ; num ++ ; } if ( x > 0 && num > 0 && i == N ) { num -- ; } out . println ( num ) ; } static int ni ( ) { return sc . nextInt ( ) ; } static long nl ( ) { return sc . nextLong ( ) ; } static String ns ( ) { return sc . next ( ) ; } static int [ ] niarr ( int N ) { int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } return a ; } static long [ ] nlarr ( int N ) { long [ ] a = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } return a ; } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int [ ] a_ = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a_ [ i ] = scan . nextInt ( ) ; } Arrays . sort ( a_ ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { x -= a_ [ i ] ; if ( x < 0 ) { break ; } else { ans ++ ; } } if ( x > 0 ) { ans -- ; } System . out . println ( 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 ( ) , x = scanner . nextInt ( ) , ans = 0 ; int [ ] a = IntStream . range ( 0 , n ) . map ( i -> scanner . nextInt ( ) ) . sorted ( ) . toArray ( ) ; for ( int i = 0 ; i < n ; i ++ , ans ++ ) { if ( x >= a [ i ] ) { x -= a [ i ] ; } else { break ; } } if ( ans == n && x != 0 ) { ans -- ; } System . out . println ( ans ) ; } }", "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 x = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; sc . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list , Comparator . naturalOrder ( ) ) ; int index = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( x < list . get ( i ) ) { break ; } if ( i == list . size ( ) - 1 && x > list . get ( i ) ) { break ; } index ++ ; x -= list . get ( i ) ; } System . out . println ( index ) ; } }" ]
[ "n , x = map ( int , input ( ) . split ( ) ) ; a = list ( map ( int , input ( ) . split ( ) ) ) ; a . sort ( ) ; ans = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] > x : break NEW_LINE else : NEW_LINE INDENT ans += 1 NEW_LINE x -= a [ i ] NEW_LINE if i == n - 1 and x != 0 : ans -= 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "n , x = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = sorted ( [ int ( i ) for i in input ( ) . split ( ) ] ) NEW_LINE if sum ( a ) == x : NEW_LINE INDENT print ( n ) NEW_LINE DEDENT elif sum ( a ) < x : NEW_LINE INDENT print ( n - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE for i in a : NEW_LINE INDENT x -= i NEW_LINE if x >= 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT", "import numpy as np NEW_LINE N , x = map ( int , input ( ) . split ( ) ) NEW_LINE a = np . array ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE a . sort ( ) NEW_LINE s = np . cumsum ( a ) NEW_LINE b = ( s <= x ) NEW_LINE if b . all ( ) : NEW_LINE INDENT if s [ - 1 ] == x : NEW_LINE INDENT c = b . sum ( ) NEW_LINE DEDENT else : NEW_LINE INDENT c = b . sum ( ) - 1 NEW_LINE DEDENT DEDENT elif b . any ( ) : NEW_LINE INDENT c = b . sum ( ) NEW_LINE r = x - s [ c - 1 ] NEW_LINE if ( r == a [ c : ] ) . any ( ) : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT c = 0 NEW_LINE DEDENT print ( c ) NEW_LINE", "N , x = map ( int , input ( ) . split ( ) ) NEW_LINE a = sorted ( int ( x ) for x in input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for ai in a : NEW_LINE INDENT x -= ai NEW_LINE if x < 0 : NEW_LINE INDENT break NEW_LINE DEDENT ans += 1 NEW_LINE DEDENT if 0 < x : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT N , x = map ( int , input ( ) . split ( ) ) NEW_LINE num = x NEW_LINE a_s = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a_s . sort ( ) NEW_LINE cnt = 0 NEW_LINE for i , a in enumerate ( a_s ) : NEW_LINE INDENT if num >= a : NEW_LINE INDENT num -= a NEW_LINE cnt += 1 NEW_LINE DEDENT DEDENT if cnt == N and num > 0 : NEW_LINE INDENT cnt -= 1 NEW_LINE DEDENT print ( cnt ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_arc029_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int [ ] t = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { t [ i ] = scanner . nextInt ( ) ; } int time = 0 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < ( 1 << N ) ; i ++ ) { int timeA = 0 ; int timeB = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( ( i >> j & 1 ) == 1 ) { timeA += t [ j ] ; } else { timeB += t [ j ] ; } } time = Math . max ( timeA , timeB ) ; ans = Math . min ( time , ans ) ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static int N ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; String t = \" \" ; for ( int i = 0 ; i < N ; i ++ ) { int tmp = sc . nextInt ( ) ; t += Integer . toString ( tmp ) ; if ( i != N - 1 ) { t += \" : \" ; } } String p1 = \"0\" ; String p2 = \"0\" ; System . out . println ( dfs ( 0 , t , p1 , p2 ) ) ; } public static int dfs ( int depth , String t , String p1 , String p2 ) { if ( depth == N ) { int sum1 = 0 ; int sum2 = 0 ; String [ ] p1_ary = p1 . split ( \" : \" ) ; String [ ] p2_ary = p2 . split ( \" : \" ) ; for ( int i = 0 ; i < p1_ary . length ; i ++ ) { sum1 += Integer . parseInt ( p1_ary [ i ] ) ; } for ( int i = 0 ; i < p2_ary . length ; i ++ ) { sum2 += Integer . parseInt ( p2_ary [ i ] ) ; } return Math . max ( sum1 , sum2 ) ; } String [ ] t_ary = t . split ( \" : \" ) ; String add = t_ary [ 0 ] ; String t_new = \" \" ; for ( int i = 1 ; i < t_ary . length ; i ++ ) { t_new += t_ary [ i ] ; if ( i != t_ary . length - 1 ) { t_new += \" : \" ; } } return Math . min ( dfs ( depth + 1 , t_new , p1 + \" : \" + add , p2 ) , dfs ( depth + 1 , t_new , p1 , p2 + \" : \" + add ) ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int [ ] t = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { t [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; if ( N == 1 ) { System . out . println ( t [ 0 ] ) ; } else if ( N == 2 ) { System . out . println ( Math . max ( t [ 0 ] , t [ 1 ] ) ) ; } else if ( N == 3 ) { Arrays . sort ( t ) ; System . out . println ( Math . max ( t [ 0 ] + t [ 1 ] , t [ 2 ] ) ) ; } else { Arrays . sort ( t ) ; if ( t [ 3 ] >= t [ 0 ] + t [ 1 ] + t [ 2 ] ) { System . out . println ( t [ 3 ] ) ; return ; } if ( t [ 0 ] + t [ 3 ] > t [ 0 ] + t [ 1 ] + t [ 2 ] ) { System . out . println ( t [ 0 ] + t [ 1 ] + t [ 2 ] ) ; return ; } System . out . println ( Math . max ( t [ 0 ] + t [ 3 ] , t [ 1 ] + t [ 2 ] ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . execute ( ) ; } public void execute ( ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; int T [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { T [ i ] = sc . nextInt ( ) ; } int minTime = Integer . MAX_VALUE ; for ( int ptn = 0 , bound = 1 << N ; ptn < bound ; ptn ++ ) { boolean [ ] pattern = getPatten ( N , ptn ) ; int nikuTimeA = 0 ; int nikuTimeB = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( pattern [ i ] ) { nikuTimeA += T [ i ] ; } else { nikuTimeB += T [ i ] ; } } int nikuTime = Math . max ( nikuTimeA , nikuTimeB ) ; minTime = Math . min ( minTime , nikuTime ) ; } System . out . println ( minTime ) ; sc . close ( ) ; } private boolean [ ] getPatten ( int n , int ptn ) { boolean [ ] pattern = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int mask = 1 << i ; if ( ( ptn & mask ) > 0 ) { pattern [ i ] = true ; } } return pattern ; } }", "import java . util . Scanner ; public class Main { private static int loast ( int [ ] t , int n , int i , int a , int b ) { if ( i == n ) return Math . max ( a , b ) ; return Math . min ( loast ( t , n , i + 1 , a + t [ i ] , b ) , loast ( t , n , i + 1 , a , b + t [ i ] ) ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] t = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { t [ i ] = sc . nextInt ( ) ; } System . out . println ( loast ( t , n , 0 , 0 , 0 ) ) ; sc . close ( ) ; } }" ]
[ "n = int ( input ( ) ) NEW_LINE t = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE t . sort ( reverse = True ) NEW_LINE yaki1 = 0 NEW_LINE yaki2 = 0 NEW_LINE for i in t : NEW_LINE INDENT if yaki1 <= yaki2 : NEW_LINE INDENT yaki1 += i NEW_LINE DEDENT else : NEW_LINE INDENT yaki2 += i NEW_LINE DEDENT DEDENT print ( max ( yaki1 , yaki2 ) ) NEW_LINE", "from itertools import permutations NEW_LINE def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE ts = [ int ( input ( ) ) for _ in range ( n ) ] NEW_LINE res = 1 << 30 NEW_LINE for us in permutations ( ts ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT res = min ( res , max ( sum ( us [ : i ] ) , sum ( us [ i : ] ) ) ) NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE print ( min ( max ( sum ( a [ s ] * ( t >> s & 1 ) for s in range ( n ) ) , sum ( a [ s ] * ( not t >> s & 1 ) for s in range ( n ) ) ) for t in range ( 2 ** n ) ) ) NEW_LINE", "print ( ( lambda N : ( lambda T , d : min ( d . update ( a = [ [ T [ - 1 ] ] , [ ] ] ) or any ( d [ ' a ' ] [ i >> j & 1 ] . append ( T [ j ] ) for j in range ( N - 1 ) ) or max ( map ( sum , d [ ' a ' ] ) ) for i in range ( 1 << N - 1 ) ) ) ( [ int ( input ( ) ) for _ in [ 0 ] * N ] , { } ) ) ( int ( input ( ) ) ) ) NEW_LINE", "from itertools import product NEW_LINE ans = 10 ** 9 NEW_LINE N = int ( input ( ) ) NEW_LINE m = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE for i in range ( 1 << N ) : NEW_LINE INDENT a , b = 0 , 0 NEW_LINE for j in range ( N ) : NEW_LINE INDENT if ( ( i >> j ) & 1 ) == 0 : NEW_LINE INDENT a += m [ j ] NEW_LINE DEDENT else : NEW_LINE INDENT b += m [ j ] NEW_LINE DEDENT DEDENT ans = min ( ans , max ( a , b ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc023_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String X = sc . next ( ) ; int sum = 0 ; sum += X . charAt ( 0 ) - '0' ; sum += X . charAt ( 1 ) - '0' ; System . out . println ( sum ) ; } }", "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 = 0 ; for ( char cc : in . next ( ) . toCharArray ( ) ) n += cc - '0' ; out . println ( n ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; System . out . println ( a / 10 + a % 10 ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }", "import java . io . 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 X = in . next ( ) ; int ans = Character . getNumericValue ( X . charAt ( 1 ) ) + Character . getNumericValue ( X . charAt ( 0 ) ) ; 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 . * ; 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 ) { String s = sc . next ( ) ; out . println ( ( s . charAt ( 0 ) - '0' ) + ( s . charAt ( 1 ) - '0' ) ) ; } }" ]
[ "X = input ( ) NEW_LINE print ( sum ( map ( int , X ) ) ) NEW_LINE", "x = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE while x > 0 : NEW_LINE INDENT ans += x % 10 NEW_LINE x //= 10 NEW_LINE DEDENT print ( ans ) NEW_LINE", "def plus_king ( X : int ) -> int : NEW_LINE INDENT return X // 10 + X % 10 NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT X = int ( input ( ) ) NEW_LINE ans = plus_king ( X ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "print ( sum ( [ int ( i ) for i in input ( ) ] ) ) NEW_LINE", "def digit ( i , lst = [ ] ) : NEW_LINE INDENT if i > 0 : NEW_LINE INDENT lst . append ( i % 10 ) NEW_LINE return digit ( i // 10 , lst ) NEW_LINE DEDENT else : NEW_LINE INDENT lst . reverse ( ) NEW_LINE return lst NEW_LINE DEDENT DEDENT print ( sum ( digit ( int ( input ( ) ) ) ) ) NEW_LINE" ]
atcoder_abc101_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; String [ ] stringS = new String [ 4 ] ; try { scanner = new Scanner ( System . in ) ; stringS = scanner . next ( ) . split ( \" \" ) ; int res = 0 ; for ( int i = 0 ; i < stringS . length ; i ++ ) { if ( stringS [ i ] . equals ( \" + \" ) ) { res ++ ; } else if ( stringS [ i ] . equals ( \" - \" ) ) { res -- ; } } System . out . println ( res ) ; } 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 . InputStreamReader ; import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; br . close ( ) ; int p = s . length ( ) - s . replaceAll ( \" \\\\ + \" , \" \" ) . length ( ) ; int m = s . length ( ) - p ; System . out . println ( p - m ) ; } }", "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 < 4 ; i ++ ) { if ( S . charAt ( i ) == ' + ' ) count ++ ; if ( S . charAt ( i ) == ' - ' ) count -- ; } System . out . println ( count ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int sum = 0 ; for ( char x : str . toCharArray ( ) ) { if ( x == ' + ' ) sum ++ ; else if ( x == ' - ' ) sum -- ; } System . out . println ( sum ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; int ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' + ' ) { ans ++ ; } else { ans -- ; } } System . out . println ( ans ) ; } }" ]
[ "s = input ( ) NEW_LINE s_list = list ( s ) NEW_LINE count = 0 NEW_LINE for i in range ( len ( s_list ) ) : NEW_LINE INDENT if s_list [ i ] == ' + ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT elif s_list [ i ] == ' - ' : NEW_LINE INDENT count -= 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE", "import collections NEW_LINE S = input ( ) NEW_LINE c = collections . Counter ( S ) NEW_LINE print ( c . get ( ' + ' , 0 ) - c . get ( ' - ' , 0 ) ) NEW_LINE", "def main ( ) : NEW_LINE INDENT chars = list ( input ( ) ) NEW_LINE n = 0 NEW_LINE for c in chars : NEW_LINE INDENT n = n + 1 if c == ' + ' else n - 1 NEW_LINE DEDENT print ( n ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "s = input ( ) NEW_LINE print ( s . count ( ' + ' ) * 2 - 4 ) NEW_LINE", "S = input ( ) NEW_LINE ans = 0 NEW_LINE for s in S : NEW_LINE INDENT if s == ' + ' : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc002_B
[ "import java . io . * ; import java . time . ZonedDateTime ; import java . time . format . DateTimeFormatter ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 == args . length ; debug2 = 2 == args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; ZonedDateTime date = ZonedDateTime . parse ( in . readLine ( ) . replaceAll ( \" / \" , \" - \" ) + \" T00:00:00Z \" ) ; while ( true ) { if ( date . getYear ( ) % date . getMonthValue ( ) == 0 && date . getYear ( ) / date . getMonthValue ( ) % date . getDayOfMonth ( ) == 0 ) { System . out . println ( date . format ( DateTimeFormatter . ISO_LOCAL_DATE ) . replaceAll ( \" - \" , \" / \" ) ) ; break ; } date = date . plusDays ( 1 ) ; } } }", "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 ) { Scanner sc = new Scanner ( System . in ) ; String YMD = sc . next ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( \" yyyy / MM / dd \" ) ; SimpleDateFormat sdf2 = new SimpleDateFormat ( \" yyyyMMdd \" ) ; Date date = new Date ( ) ; Date d1 = new Date ( ) ; String Day1 = \" \" ; String Day2 = \" \" ; try { date = sdf . parse ( YMD ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } Calendar calendar = Calendar . getInstance ( ) ; calendar . setTime ( date ) ; Day1 = sdf2 . format ( date ) ; if ( Double . valueOf ( Day1 . substring ( 0 , 4 ) ) / Double . valueOf ( Day1 . substring ( 4 , 6 ) ) % Integer . valueOf ( Day1 . substring ( 6 , 8 ) ) == 0 ) { System . out . println ( sdf . format ( date ) ) ; } else { while ( 1 == 1 ) { calendar . add ( Calendar . DATE , 1 ) ; d1 = calendar . getTime ( ) ; Day1 = sdf2 . format ( d1 ) ; if ( Double . valueOf ( Day1 . substring ( 0 , 4 ) ) / Double . valueOf ( Day1 . substring ( 4 , 6 ) ) % Integer . valueOf ( Day1 . substring ( 6 , 8 ) ) == 0 ) { System . out . println ( sdf . format ( d1 ) ) ; break ; } } } } }", "import java . io . * ; import java . util . * ; public class Main { public static boolean find_date ( Calendar cal ) { int year = cal . get ( Calendar . YEAR ) ; int month = cal . get ( Calendar . MONTH ) + 1 ; int day = cal . get ( Calendar . DATE ) ; if ( year % month == 0 && year / month % day == 0 ) return true ; else return false ; } public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String date [ ] = scan . next ( ) . split ( \" / \" , 0 ) ; int year = Integer . parseInt ( date [ 0 ] ) ; int month = Integer . parseInt ( date [ 1 ] ) ; int day = Integer . parseInt ( date [ 2 ] ) ; Calendar cal = Calendar . getInstance ( ) ; cal . set ( year , month - 1 , day ) ; while ( ! ( find_date ( cal ) ) ) cal . add ( Calendar . DAY_OF_MONTH , 1 ) ; year = cal . get ( Calendar . YEAR ) ; month = cal . get ( Calendar . MONTH ) + 1 ; day = cal . get ( Calendar . DATE ) ; System . out . printf ( \" % 4d / %02d / %02d \\n \" , year , month , day ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int md [ ] = new int [ ] { - 1 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ; String S = sc . next ( ) ; String sp [ ] = S . split ( \" / \" ) ; int Y = Integer . parseInt ( sp [ 0 ] ) ; int M = Integer . parseInt ( sp [ 1 ] ) ; int D = Integer . parseInt ( sp [ 2 ] ) ; int ansy = 0 ; int ansm = 0 ; int ansd = 0 ; int y = Y ; int m = M ; while ( ansy == 0 ) { int day = md [ m ] ; if ( m == 2 ) { boolean flag = false ; if ( y % 4 == 0 ) { flag = true ; } if ( y % 100 == 0 ) { flag = false ; } if ( y % 400 == 0 ) { flag = true ; } if ( flag ) { day ++ ; } } for ( int d = D ; d <= day ; d ++ ) { if ( y % m == 0 ) { int y1 = y / m ; if ( y1 % d == 0 ) { ansy = y ; ansm = m ; ansd = d ; break ; } } } D = 1 ; m ++ ; if ( m == 13 ) { m = 1 ; } if ( m == 1 ) y ++ ; } String sy = String . valueOf ( ansy ) ; String sm = String . valueOf ( ansm ) ; String sd = String . valueOf ( ansd ) ; if ( ansm < 10 ) { sm = \"0\" + sm ; } if ( ansd < 10 ) { sd = \"0\" + sd ; } System . out . println ( sy + \" / \" + sm + \" / \" + sd ) ; } }", "import java . util . * ; public class Main { private static int y ; private static int m ; private static int d ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; String [ ] date = str . split ( \" / \" , 0 ) ; y = Integer . parseInt ( date [ 0 ] ) ; m = Integer . parseInt ( date [ 1 ] ) ; d = Integer . parseInt ( date [ 2 ] ) ; } public static void main ( String args [ ] ) { input ( ) ; Calendar calendar = Calendar . getInstance ( ) ; calendar . set ( y , ( m - 1 ) , d ) ; String answer = \" \" ; while ( true ) { int year = calendar . get ( Calendar . YEAR ) ; int month = calendar . get ( Calendar . MONTH ) + 1 ; int day = calendar . get ( Calendar . DATE ) ; if ( ( year % ( month * day ) ) == 0 ) { answer = year + \" / \" + ( ( month >= 10 ) ? month : \"0\" + month ) + \" / \" + ( ( day >= 10 ) ? day : \"0\" + day ) ; break ; } calendar . add ( Calendar . DAY_OF_MONTH , 1 ) ; } System . out . println ( answer ) ; } }" ]
[ "def main ( ) : NEW_LINE INDENT from datetime import datetime NEW_LINE from datetime import timedelta NEW_LINE ymd = input ( ) NEW_LINE fmt = ' % Y / % m / % d ' NEW_LINE current_date = datetime . strptime ( ymd , fmt ) NEW_LINE while True : NEW_LINE INDENT year = current_date . year NEW_LINE month = current_date . month NEW_LINE day = current_date . day NEW_LINE candidate = datetime . strftime ( current_date , fmt ) NEW_LINE if year % ( month * day ) == 0 and candidate >= ymd : NEW_LINE INDENT print ( candidate ) NEW_LINE exit ( ) NEW_LINE DEDENT current_date += timedelta ( days = 1 ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "n = input ( ) NEW_LINE y , m , d = int ( n [ 0 ] + n [ 1 ] + n [ 2 ] + n [ 3 ] ) , int ( n [ 5 ] + n [ 6 ] ) , int ( n [ 8 ] + n [ 9 ] ) NEW_LINE D = [ 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] NEW_LINE def uruu ( ) : NEW_LINE INDENT global y , m NEW_LINE if m == 2 : NEW_LINE INDENT if y % 400 == 0 : return 1 NEW_LINE elif y % 100 == 0 : return 0 NEW_LINE elif y % 4 == 0 : return 1 NEW_LINE else : return 0 NEW_LINE DEDENT return 0 NEW_LINE DEDENT while 1 : NEW_LINE INDENT if y / ( m * d ) % 1 == 0 : break NEW_LINE d += 1 NEW_LINE if d > D [ m - 1 ] + uruu ( ) : NEW_LINE INDENT d = 1 NEW_LINE m += 1 NEW_LINE if m == 13 : NEW_LINE INDENT m = 1 NEW_LINE y += 1 NEW_LINE DEDENT DEDENT DEDENT if m > 9 and d > 9 : print ( str ( y ) + \" / \" + str ( m ) + \" / \" + str ( d ) ) NEW_LINE elif m > 9 : print ( str ( y ) + \" / \" + str ( m ) + \" / 0\" + str ( d ) ) NEW_LINE elif d > 9 : print ( str ( y ) + \" / 0\" + str ( m ) + \" / \" + str ( d ) ) NEW_LINE else : print ( str ( y ) + \" / 0\" + str ( m ) + \" / 0\" + str ( d ) ) NEW_LINE", "y , m , d = map ( int , input ( ) . split ( ' / ' ) ) NEW_LINE def leap_year ( y ) : NEW_LINE INDENT if y % 400 == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT if y % 100 == 0 : NEW_LINE INDENT return False NEW_LINE DEDENT if y % 4 == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT lims = { 1 : 31 , 2 : 28 , 3 : 31 , 4 : 30 , 5 : 31 , 6 : 30 , 7 : 31 , 8 : 31 , 9 : 30 , 10 : 31 , 11 : 30 , 12 : 31 } NEW_LINE while m <= 12 : NEW_LINE INDENT lim = lims [ m ] NEW_LINE if leap_year ( y ) and m == 2 : NEW_LINE INDENT lim += 1 NEW_LINE DEDENT while d <= lim : NEW_LINE INDENT if y % ( m * d ) == 0 : NEW_LINE INDENT print ( \" { year : 02d } / { month : 02d } / { date : 02d } \" . format ( year = y , month = m , date = d ) ) NEW_LINE exit ( ) NEW_LINE DEDENT d += 1 NEW_LINE DEDENT d = 1 NEW_LINE m += 1 NEW_LINE DEDENT print ( \" { year : 02d } / { month : 02d } / { date : 02d } \" . format ( year = y + 1 , month = 1 , date = 1 ) ) NEW_LINE", "def is_leap ( year ) : NEW_LINE INDENT if year % 400 == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT elif year % 100 == 0 : NEW_LINE INDENT return False NEW_LINE DEDENT elif year % 4 == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT from datetime import datetime NEW_LINE ymd = input ( ) NEW_LINE ymd_mod = list ( map ( int , ymd . split ( ' / ' ) ) ) NEW_LINE days = [ 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] NEW_LINE for year in range ( ymd_mod [ 0 ] , 3000 ) : NEW_LINE INDENT for month , day in enumerate ( days , 1 ) : NEW_LINE INDENT for d in range ( 1 , day + 1 ) : NEW_LINE INDENT if is_leap ( year ) and month == 2 and d == 29 : NEW_LINE INDENT candidate = datetime ( year , month , d ) . strftime ( ' % Y / % m / % d ' ) NEW_LINE if year % ( month * d ) == 0 and candidate >= ymd : NEW_LINE INDENT print ( candidate ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT elif not is_leap ( year ) and month == 2 and d == 29 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT candidate = datetime ( year , month , d ) . strftime ( ' % Y / % m / % d ' ) NEW_LINE if year % ( month * d ) == 0 and candidate >= ymd : NEW_LINE INDENT print ( candidate ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( '3000/01/01' ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "month = [ 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] NEW_LINE S = list ( map ( int , input ( ) . split ( \" / \" ) ) ) NEW_LINE while S [ 0 ] / S [ 1 ] / S [ 2 ] != S [ 0 ] // S [ 1 ] // S [ 2 ] : NEW_LINE INDENT Y = S [ 0 ] NEW_LINE flag = False NEW_LINE if Y % 400 == 0 : NEW_LINE INDENT flag = True NEW_LINE DEDENT elif Y % 100 == 0 : NEW_LINE INDENT flag = False NEW_LINE DEDENT elif Y % 4 == 0 : NEW_LINE INDENT flag = True NEW_LINE DEDENT m = 0 NEW_LINE if S [ 1 ] == 2 and flag : NEW_LINE INDENT m = 1 NEW_LINE DEDENT S [ 2 ] += 1 NEW_LINE if month [ S [ 1 ] - 1 ] + m < S [ 2 ] : NEW_LINE INDENT S [ 2 ] = 1 NEW_LINE S [ 1 ] += 1 NEW_LINE if S [ 1 ] == 13 : NEW_LINE INDENT S [ 1 ] = 1 NEW_LINE S [ 0 ] += 1 NEW_LINE DEDENT DEDENT DEDENT T = [ str ( S [ 0 ] ) ] NEW_LINE if S [ 1 ] // 10 == 0 : NEW_LINE INDENT T . append ( \"0\" + str ( S [ 1 ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT T . append ( str ( S [ 1 ] ) ) NEW_LINE DEDENT if S [ 2 ] // 10 == 0 : NEW_LINE INDENT T . append ( \"0\" + str ( S [ 2 ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT T . append ( str ( S [ 2 ] ) ) NEW_LINE DEDENT print ( \" / \" . join ( T ) ) NEW_LINE" ]
atcoder_agc003_A
[ "import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int N = 0 , W = 0 , E = 0 , S = 0 ; String s = sc . next ( ) ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { switch ( s . charAt ( i ) ) { case ' N ' : ++ N ; break ; case ' W ' : ++ W ; break ; case ' S ' : ++ S ; break ; case ' E ' : ++ E ; break ; default : break ; } } String ans = \" Yes \" ; if ( ( N == 0 || S == 0 ) && ( N + S > 0 ) ) ans = \" No \" ; else if ( ( W == 0 || E == 0 ) && ( W + E > 0 ) ) ans = \" No \" ; out . println ( ans ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; Boolean a = true ; if ( S . contains ( \" N \" ) ) { if ( S . contains ( \" S \" ) ) { } else { a = false ; } } if ( S . contains ( \" W \" ) ) { if ( S . contains ( \" E \" ) ) { } else { a = false ; } } if ( S . contains ( \" S \" ) ) { if ( S . contains ( \" N \" ) ) { } else { a = false ; } } if ( S . contains ( \" E \" ) ) { if ( S . contains ( \" W \" ) ) { } else { a = false ; } } if ( a ) { 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 . 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 ) ; AWannaGoBackHome solver = new AWannaGoBackHome ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AWannaGoBackHome { private static final String YES = \" Yes \" ; private static final String NO = \" No \" ; public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String s = in . string ( ) ; int mask = 0 ; for ( char c : s . toCharArray ( ) ) { switch ( c ) { case ' N ' : mask |= 0b0001 ; break ; case ' S ' : mask |= 0b0010 ; break ; case ' E ' : mask |= 0b0100 ; break ; case ' W ' : mask |= 0b1000 ; break ; } } if ( mask == 3 || mask == 12 || mask == 15 ) { out . println ( YES ) ; } else { out . println ( NO ) ; } } } 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 ( ) ; } } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a [ ] = new int [ 4 ] , ns = 0 , we = 0 ; String s = new String ( ) ; s = sc . next ( ) ; sc . close ( ) ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( s . charAt ( i ) == ' N ' ) ++ a [ 0 ] ; else if ( s . charAt ( i ) == ' W ' ) ++ a [ 1 ] ; else if ( s . charAt ( i ) == ' S ' ) ++ a [ 2 ] ; else ++ a [ 3 ] ; } for ( int i = 0 ; i < 4 ; i += 2 ) if ( a [ i ] > 0 ) ++ ns ; for ( int i = 1 ; i < 4 ; i += 2 ) if ( a [ i ] > 0 ) ++ we ; System . out . print ( ns % 2 > 0 || we % 2 > 0 ? \" No \" : \" Yes \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] srgs ) { Scanner scan = new Scanner ( System . in ) ; String a = scan . next ( ) ; boolean fig1 = false ; boolean fig2 = false ; boolean fig3 = false ; boolean fig4 = false ; for ( int i = 0 ; i != a . length ( ) ; i ++ ) { char ch = a . charAt ( i ) ; switch ( ch ) { case ' S ' : fig1 = true ; break ; case ' E ' : fig2 = true ; break ; case ' N ' : fig3 = true ; break ; case ' W ' : fig4 = true ; break ; } } boolean ans = false ; if ( fig3 && fig1 && fig2 == false && fig4 == false ) { ans = true ; } if ( fig3 == false && fig1 == false && fig2 && fig4 ) { ans = true ; } if ( fig1 && fig2 && fig3 && fig4 ) { ans = true ; } System . out . println ( ans ? \" Yes \" : \" No \" ) ; scan . close ( ) ; } }" ]
[ "S = input ( ) NEW_LINE s = set ( S [ : ] ) NEW_LINE ans = s == set ( [ \" N \" , \" W \" , \" S \" , \" E \" ] ) or s == set ( [ \" N \" , \" S \" ] ) or s == set ( [ \" W \" , \" E \" ] ) NEW_LINE print ( \" Yes \" if ans else \" No \" ) NEW_LINE", "print ( ' NYoe ▁ s ' [ set ( input ( ) ) in map ( set , [ ' ' , ' NS ' , ' EW ' , ' NSEW ' ] ) : : 2 ] ) NEW_LINE", "S = input ( ) NEW_LINE N = len ( S ) NEW_LINE d = [ 0 , 0 , 0 , 0 ] NEW_LINE s = [ ' N ' , ' W ' , ' S ' , ' E ' ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( 4 ) : NEW_LINE INDENT if S [ i ] == s [ j ] : NEW_LINE INDENT d [ j ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT flag = True NEW_LINE if ( d [ 0 ] == 0 and d [ 2 ] == 0 ) or ( d [ 0 ] != 0 and d [ 2 ] != 0 ) : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT flag = False NEW_LINE DEDENT if ( d [ 1 ] == 0 and d [ 3 ] == 0 ) or ( d [ 1 ] != 0 and d [ 3 ] != 0 ) : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT flag = False NEW_LINE DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT", "s = set ( list ( input ( ) ) ) NEW_LINE if \" S \" in s : NEW_LINE INDENT if not \" N \" in s : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT if \" N \" in s : NEW_LINE INDENT if not \" S \" in s : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT if \" E \" in s : NEW_LINE INDENT if not \" W \" in s : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT if \" W \" in s : NEW_LINE INDENT if not \" E \" in s : NEW_LINE INDENT print ( \" No \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( \" Yes \" ) NEW_LINE", "S = input ( ) NEW_LINE flag = 1 NEW_LINE if S . count ( \" W \" ) == 0 and S . count ( \" E \" ) == 0 : NEW_LINE INDENT if S . count ( \" N \" ) == 0 or S . count ( \" S \" ) == 0 : NEW_LINE INDENT flag = 0 NEW_LINE DEDENT else : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT DEDENT elif S . count ( \" W \" ) == 0 or S . count ( \" E \" ) == 0 : NEW_LINE INDENT flag = 0 NEW_LINE DEDENT elif S . count ( \" N \" ) == 0 and S . count ( \" S \" ) == 0 : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT elif S . count ( \" N \" ) == 0 or S . count ( \" S \" ) == 0 : NEW_LINE INDENT flag = 0 NEW_LINE DEDENT else : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT if flag == 1 : NEW_LINE INDENT print ( \" Yes \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No \" ) NEW_LINE DEDENT" ]
atcoder_abc116_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 N = sc . nextInt ( ) ; int ans = 0 ; int count = 0 ; boolean watered = false ; int [ ] h = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { h [ i ] = sc . nextInt ( ) ; if ( h [ i ] == 0 ) { count ++ ; } } while ( count < h . length ) { for ( int i = 0 ; i < N ; i ++ ) { if ( h [ i ] > 0 ) { h [ i ] -- ; if ( h [ i ] == 0 ) { count ++ ; } watered = true ; continue ; } if ( watered ) { ans ++ ; watered = false ; } } if ( watered ) { ans ++ ; watered = false ; } } out . println ( ans ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int N = Integer . parseInt ( bf . readLine ( ) ) ; String [ ] str = bf . readLine ( ) . split ( \" ▁ \" ) ; List < Integer > h = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { h . add ( Integer . parseInt ( str [ i ] ) ) ; } System . out . println ( count ( h ) ) ; } public static Integer min ( List < Integer > data ) { Integer min = data . get ( 0 ) ; for ( int i = 1 ; i < data . size ( ) ; i ++ ) { Integer value = data . get ( i ) ; if ( value < min ) { min = value ; } } return min ; } public static int count ( List < Integer > data ) { int min = min ( data ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { Integer value = data . get ( i ) ; data . set ( i , value - min ) ; } boolean zero = true ; List < List > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { int value = data . get ( i ) ; if ( zero && value > 0 ) { a . add ( new ArrayList < Integer > ( ) ) ; a . get ( a . size ( ) - 1 ) . add ( value ) ; zero = false ; } else if ( ! zero ) { if ( value > 0 ) { a . get ( a . size ( ) - 1 ) . add ( value ) ; } else { zero = true ; } } } int answer = min ; for ( int i = 0 ; i < a . size ( ) ; i ++ ) { answer += count ( a . get ( i ) ) ; } return answer ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; int next ( int [ ] h , int idx ) { for ( int i = idx ; i < h . length ; i ++ ) { if ( h [ i ] != 0 ) { return i ; } } return - 1 ; } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int [ ] h = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int idx = 0 ; while ( true ) { idx = next ( h , idx ) ; if ( idx == - 1 ) { break ; } while ( h [ idx ] > 0 ) { ans ++ ; for ( int i = idx ; i < n && h [ i ] > 0 ; i ++ ) { h [ i ] -- ; } } } out . println ( ans ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }", "import java . util . Scanner ; public class Main { static int N ; static int [ ] flowers ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; flowers = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { flowers [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 0 ; int cur = 0 ; for ( int k = 0 ; k < N ; k ++ ) { if ( flowers [ k ] > cur ) { ans += flowers [ k ] - cur ; } cur = flowers [ k ] ; } 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 n = scanner . nextInt ( ) , last = 0 , ans = 0 ; for ( int i = 0 , j ; i < n ; i ++ , last = j ) if ( last >= ( j = scanner . nextInt ( ) ) ) ans += last - j ; System . out . println ( last + ans ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE H = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE S = sum ( H ) NEW_LINE ans = 0 NEW_LINE while S > 0 : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if H [ i ] > 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT for j in range ( i , N ) : NEW_LINE INDENT if H [ j ] == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if j == N - 1 and H [ j ] > 0 : NEW_LINE INDENT j += 1 NEW_LINE DEDENT for k in range ( i , j ) : NEW_LINE INDENT H [ k ] -= 1 NEW_LINE DEDENT ans += 1 NEW_LINE S -= j - i NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE def solve ( N : int , h : \" List [ int ] \" ) : NEW_LINE INDENT cost = 0 NEW_LINE CUR = [ 0 for i in range ( len ( h ) ) ] NEW_LINE for i in range ( len ( CUR ) ) : NEW_LINE INDENT while CUR [ i ] != h [ i ] : NEW_LINE INDENT l = i NEW_LINE r = i NEW_LINE for j in range ( i , len ( CUR ) ) : NEW_LINE INDENT if CUR [ i ] >= h [ j ] : NEW_LINE INDENT break NEW_LINE DEDENT r += 1 NEW_LINE DEDENT grow = 10 ** 16 NEW_LINE for j in range ( l , r ) : NEW_LINE INDENT grow = min ( grow , h [ j ] - CUR [ j ] ) NEW_LINE DEDENT for j in range ( l , r ) : NEW_LINE INDENT CUR [ j ] += grow NEW_LINE DEDENT cost += grow NEW_LINE DEDENT DEDENT print ( cost ) 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 h = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , h ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import sys NEW_LINE 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 count ( hh , n ) : NEW_LINE INDENT c = 0 NEW_LINE b = False NEW_LINE for h in hh : NEW_LINE INDENT if h >= n : NEW_LINE INDENT if b == False : NEW_LINE INDENT b = True NEW_LINE c += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if b == True : NEW_LINE INDENT b = False NEW_LINE DEDENT DEDENT DEDENT return c NEW_LINE DEDENT def main ( ss ) : NEW_LINE INDENT hh = sp2nn ( ss [ 1 ] ) NEW_LINE total = 0 NEW_LINE n = 1 NEW_LINE while True : NEW_LINE INDENT c = count ( hh , n ) NEW_LINE if c == 0 : NEW_LINE INDENT break NEW_LINE DEDENT total += c NEW_LINE n += 1 NEW_LINE DEDENT print ( total ) NEW_LINE DEDENT main ( ii2ss ( 2 ) ) NEW_LINE", "import sys NEW_LINE def f ( k ) : NEW_LINE INDENT global N , h , update NEW_LINE if k == N : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if h [ k ] == 0 : NEW_LINE INDENT return k NEW_LINE DEDENT else : NEW_LINE INDENT h [ k ] -= 1 NEW_LINE update = True NEW_LINE f ( k + 1 ) NEW_LINE DEDENT DEDENT update = False NEW_LINE N = int ( input ( ) ) NEW_LINE h = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) NEW_LINE r = 0 NEW_LINE s = 0 NEW_LINE try : NEW_LINE INDENT while True : NEW_LINE INDENT if h [ s ] != 0 : NEW_LINE INDENT break NEW_LINE DEDENT s += 1 NEW_LINE DEDENT DEDENT except Exception : NEW_LINE INDENT print ( 0 ) NEW_LINE sys . exit ( 0 ) NEW_LINE DEDENT while True : NEW_LINE INDENT f ( s ) NEW_LINE if update : NEW_LINE INDENT r += 1 NEW_LINE while s != N - 1 and h [ s ] == 0 : NEW_LINE INDENT s += 1 NEW_LINE DEDENT update = False NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( r ) NEW_LINE", "def gcd_core ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT else : NEW_LINE INDENT return gcd_core ( b , a % b ) NEW_LINE DEDENT DEDENT def gcd ( arr ) : NEW_LINE INDENT g = gcd_core ( arr [ 0 ] , arr [ 1 ] ) NEW_LINE for i in range ( 2 , len ( arr ) ) : NEW_LINE INDENT g = gcd_core ( g , arr [ i ] ) NEW_LINE DEDENT return g NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE bef = arr [ 0 ] NEW_LINE cst = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if bef < arr [ i ] : NEW_LINE INDENT cst += arr [ i ] - bef NEW_LINE DEDENT bef = arr [ i ] NEW_LINE DEDENT print ( cst ) NEW_LINE" ]
atcoder_abc120_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 ( ) ; int C = sc . nextInt ( ) ; int ans ; if ( B >= A * C ) { ans = C ; } else { ans = ( int ) B / A ; } System . out . println ( ans ) ; } }", "import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; if ( b / a > c ) { count = c ; } else { count = b / a ; } System . out . println ( count ) ; System . out . flush ( ) ; sc . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( final String [ ] args ) { try ( final Scanner sc = new Scanner ( System . in ) ) { final int A = sc . nextInt ( ) ; final int B = sc . nextInt ( ) ; final int C = sc . nextInt ( ) ; System . out . println ( Math . min ( B / A , C ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int A , B , C ; A = s . nextInt ( ) ; B = s . nextInt ( ) ; C = s . nextInt ( ) ; System . out . println ( Math . min ( B / A , C ) ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( a * c <= b ) { System . out . println ( c ) ; } else { int count = 0 ; for ( int i = 1 ; i <= c ; i ++ ) { if ( i * a <= b ) { count ++ ; } else { break ; } } System . out . println ( count ) ; } sc . close ( ) ; } }" ]
[ "A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE print ( min ( B // A , C ) ) NEW_LINE", "import math NEW_LINE i = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = i [ 0 ] NEW_LINE B = i [ 1 ] NEW_LINE C = i [ 2 ] NEW_LINE if ( A * C <= B ) : NEW_LINE INDENT print ( C ) NEW_LINE DEDENT if ( A * C > B ) : NEW_LINE INDENT if ( B >= A ) : NEW_LINE INDENT print ( math . floor ( B / A ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT", "a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE res = 0 NEW_LINE if a > b : NEW_LINE INDENT res = 0 NEW_LINE DEDENT else : NEW_LINE INDENT res = b // a NEW_LINE DEDENT if res <= c : NEW_LINE INDENT print ( res ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT", "m = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = m [ 0 ] NEW_LINE b = m [ 1 ] NEW_LINE c = m [ 2 ] NEW_LINE if ( b >= a * c ) : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( b // a ) NEW_LINE DEDENT", "A , B , C = [ int ( v ) for v in input ( ) . split ( ) ] NEW_LINE print ( min ( B // A , C ) ) NEW_LINE" ]
atcoder_abc057_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; System . out . println ( ( a + x ) % 24 ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { out . println ( ( in . nextInt ( ) + in . nextInt ( ) ) % 24 ) ; } } 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 . 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 < 24 ) { out . println ( a + b ) ; } else { out . println ( a + b - 24 ) ; } } } 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 ans = ( a + b ) % 24 ; System . out . print ( ans ) ; } }", "import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( ( sc . nextInt ( ) + sc . nextInt ( ) ) % 24 ) ; } }" ]
[ "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( a + b ) % 24 ) NEW_LINE", "print ( eval ( ' ( ' + input ( ) . replace ( ' ▁ ' , ' + ' ) + ' ) %24' ) ) 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 return ( A + B ) % 24 NEW_LINE 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 = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE print ( ( a + b ) % 24 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "a , b = map ( int , input ( ) . split ( ) ) NEW_LINE c = a + b NEW_LINE if c <= 23 : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( c - 24 ) NEW_LINE DEDENT" ]
atcoder_abc012_C
[ "public class Main { public static void main ( String [ ] $ ) { int n = 2025 - new java . util . Scanner ( System . in ) . nextInt ( ) ; java . util . stream . IntStream . range ( 1 , 10 ) . filter ( i -> n % i == 0 && n / i <= 9 ) . forEach ( i -> System . out . println ( i + \" ▁ x ▁ \" + n / i ) ) ; } }", "import java . util . * ; public class Main { static final int SUM = 2025 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = SUM - n ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { for ( int j = 1 ; j <= 9 ; j ++ ) { if ( i * j == ans ) { sb . append ( i ) . append ( \" ▁ x ▁ \" ) . append ( j ) . append ( \" \\n \" ) ; } } } System . out . print ( sb ) ; } }", "import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; @ SuppressWarnings ( \" unchecked \" ) public class Main { 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 ) ; int N = Integer . parseInt ( s ) ; int [ ] [ ] tbl = new int [ 9 ] [ 9 ] ; int sum = 0 ; for ( int i = 0 ; i < tbl . length ; i ++ ) { for ( int j = 0 ; j < tbl [ i ] . length ; j ++ ) { tbl [ i ] [ j ] = ( i + 1 ) * ( j + 1 ) ; sum += tbl [ i ] [ j ] ; } } int x = sum - N ; for ( int i = 0 ; i < tbl . length ; i ++ ) for ( int j = 0 ; j < tbl [ i ] . length ; j ++ ) if ( tbl [ i ] [ j ] == x ) out . println ( ( i + 1 ) + \" ▁ x ▁ \" + ( j + 1 ) ) ; out . flush ( ) ; } }", "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 ( ) ; n = 2025 - n ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = 1 ; j < 10 ; j ++ ) { if ( i * j == n ) out . println ( i + \" ▁ x ▁ \" + j ) ; } } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . nextLine ( ) ) ; int N = 2025 - n ; List < String > list = new ArrayList < > ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { for ( int j = i ; j <= 9 ; j ++ ) { if ( i * j == N && i == j ) { list . add ( new String ( i + \" ▁ x ▁ \" + j ) ) ; } else if ( i * j == N ) { list . add ( new String ( i + \" ▁ x ▁ \" + j ) ) ; list . add ( new String ( j + \" ▁ x ▁ \" + i ) ) ; } } } Collections . sort ( list ) ; for ( String s : list ) { System . out . println ( s ) ; } } }" ]
[ "n = int ( input ( ) ) NEW_LINE for i in range ( 1 , 10 ) : NEW_LINE INDENT for j in range ( 1 , 10 ) : NEW_LINE INDENT if i * j + n == 2025 : NEW_LINE INDENT print ( ' { } ▁ x ▁ { } ' . format ( i , j ) ) NEW_LINE DEDENT DEDENT DEDENT", "max = 2025 NEW_LINE kuku = int ( input ( ) ) NEW_LINE diff = max - kuku NEW_LINE for i in range ( 1 , 10 ) : NEW_LINE INDENT if i * 9 < diff or diff < i : NEW_LINE INDENT continue NEW_LINE DEDENT for j in range ( 1 , 10 ) : NEW_LINE INDENT if i * j == diff : NEW_LINE INDENT print ( \" { } ▁ x ▁ { } \" . format ( i , j ) ) NEW_LINE DEDENT DEDENT DEDENT", "n = int ( input ( ) ) NEW_LINE a = 2025 - n NEW_LINE divs = [ ] NEW_LINE for i in range ( 1 , int ( a ** 0.5 ) + 1 ) : NEW_LINE INDENT if a % i == 0 : NEW_LINE INDENT divs . append ( i ) NEW_LINE if i != a // i : NEW_LINE INDENT divs . append ( a // i ) NEW_LINE DEDENT DEDENT DEDENT divs . sort ( ) NEW_LINE for x in divs : NEW_LINE INDENT y = int ( a / x ) NEW_LINE if x < 10 and y < 10 : NEW_LINE INDENT print ( str ( x ) + ' ▁ x ▁ ' + str ( y ) ) NEW_LINE DEDENT DEDENT", "N = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( 1 , 2026 - N ) : NEW_LINE INDENT if i >= 10 : NEW_LINE INDENT break NEW_LINE DEDENT if ( 2025 - N ) % i == 0 and ( 2025 - N ) // i < 10 : NEW_LINE INDENT ans . append ( str ( i ) + ' ▁ x ▁ ' + str ( ( 2025 - N ) // i ) ) NEW_LINE DEDENT DEDENT print ( * ans , sep = ' \\n ' ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE dic = { } NEW_LINE for i in range ( 1 , 10 ) : NEW_LINE INDENT for j in range ( 1 , 10 ) : NEW_LINE INDENT if i * j in dic . keys ( ) : NEW_LINE INDENT dic [ i * j ] . append ( str ( i ) + \" ▁ x ▁ \" + str ( j ) ) NEW_LINE DEDENT else : NEW_LINE INDENT dic [ i * j ] = [ str ( i ) + \" ▁ x ▁ \" + str ( j ) ] NEW_LINE DEDENT DEDENT DEDENT ls = sorted ( dic [ 2025 - n ] ) NEW_LINE for i in ls : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT" ]
atcoder_abc113_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cnt = 0 ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; System . out . println ( N + M / 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 x = in . nextInt ( ) ; int y = in . nextInt ( ) ; out . println ( x + y / 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 int process ( TestCase testCase ) { int X = testCase . X ; int Y = testCase . Y ; return X + Y / 2 ; } private static boolean is753 ( int x ) { return x == 7 || x == 5 || x == 3 ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final int result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; return new TestCase ( X , Y ) ; } private static void output ( int result ) { System . out . println ( result ) ; } public static class TestCase { final int X ; final int Y ; public TestCase ( int X , int Y ) { this . X = X ; this . Y = Y ; } } }", "import java . io . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( a + ( b / 2 ) ) ; } }", "import java . io . * ; import java . util . Scanner ; import java . lang . Math ; import java . util . Arrays ; import java . util . List ; import java . util . stream . Collectors ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; scanner . close ( ) ; System . out . println ( N + A / 2 ) ; } }" ]
[ "X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE print ( X + Y // 2 ) NEW_LINE", "import sys NEW_LINE INF = float ( \" inf \" ) NEW_LINE def solve ( X : int , Y : int ) : NEW_LINE INDENT print ( X + Y // 2 ) 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 X = int ( next ( tokens ) ) NEW_LINE Y = int ( next ( tokens ) ) NEW_LINE solve ( X , Y ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "train , bus = map ( int , input ( ) . split ( ' ▁ ' ) ) NEW_LINE print ( int ( train + ( bus / 2 ) ) ) NEW_LINE", "x , y = map ( int , input ( ) . split ( ) ) NEW_LINE ans = x + ( y // 2 ) NEW_LINE print ( ans ) NEW_LINE", "X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE Z = int ( X + Y / 2 ) NEW_LINE print ( Z ) NEW_LINE" ]
atcoder_arc039_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; Koshi koshi = new Koshi ( 0 , 0 ) ; koshi . reLink ( ) ; for ( int i = 0 ; i < K ; i ++ ) { switch ( s [ i ] ) { case ' L ' : koshi = koshi . left ; break ; case ' R ' : koshi = koshi . right ; break ; case ' U ' : koshi = koshi . up ; break ; case ' D ' : koshi = koshi . down ; break ; } koshi . reLink ( ) ; } System . out . println ( koshi . x + \" ▁ \" + koshi . y ) ; } static class Koshi { static HashMap < String , Koshi > map = new HashMap < String , Koshi > ( ) ; Koshi up , down , left , right ; int x , y ; Koshi ( int x , int y ) { this . x = x ; this . y = y ; map . put ( hash ( ) , this ) ; } void reLink ( ) { if ( left == null ) left = get ( x - 1 , y ) ; if ( right == null ) right = get ( x + 1 , y ) ; if ( up == null ) up = get ( x , y + 1 ) ; if ( down == null ) down = get ( x , y - 1 ) ; left . right = right ; right . left = left ; up . down = down ; down . up = up ; } String hash ( ) { return x + \" ▁ \" + y ; } String hash ( int x , int y ) { return x + \" ▁ \" + y ; } Koshi get ( int x , int y ) { if ( map . containsKey ( hash ( x , y ) ) ) { return map . get ( hash ( x , y ) ) ; } return new Koshi ( x , y ) ; } } }" ]
[ "K = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE dxdys = { ' R ' : ( 1 , 0 ) , ' L ' : ( - 1 , 0 ) , ' U ' : ( 0 , 1 ) , ' D ' : ( 0 , - 1 ) } NEW_LINE inv = { ' R ' : ' L ' , ' L ' : ' R ' , ' U ' : ' D ' , ' D ' : ' U ' } NEW_LINE x , y = 0 , 0 NEW_LINE boundary = { ( 0 , 0 ) : { ' R ' : ( 0 , 0 ) , ' L ' : ( 0 , 0 ) , ' U ' : ( 0 , 0 ) , ' D ' : ( 0 , 0 ) } } NEW_LINE for i in range ( K ) : NEW_LINE INDENT c = S [ i ] NEW_LINE nx , ny = boundary [ ( x , y ) ] [ c ] NEW_LINE nx += dxdys [ c ] [ 0 ] NEW_LINE ny += dxdys [ c ] [ 1 ] NEW_LINE boundary [ ( nx , ny ) ] = { ' R ' : ( nx , ny ) , ' L ' : ( nx , ny ) , ' U ' : ( nx , ny ) , ' D ' : ( nx , ny ) } NEW_LINE for cc in dxdys : NEW_LINE INDENT nnx = nx + dxdys [ cc ] [ 0 ] NEW_LINE nny = ny + dxdys [ cc ] [ 1 ] NEW_LINE if ( nnx , nny ) in boundary : NEW_LINE INDENT boundary [ ( nx , ny ) ] [ cc ] = boundary [ ( nnx , nny ) ] [ cc ] NEW_LINE boundary [ boundary [ ( nx , ny ) ] [ inv [ cc ] ] ] [ cc ] = boundary [ ( nx , ny ) ] [ cc ] NEW_LINE boundary [ boundary [ ( nx , ny ) ] [ cc ] ] [ inv [ cc ] ] = boundary [ ( nx , ny ) ] [ inv [ cc ] ] NEW_LINE DEDENT DEDENT x , y = nx , ny NEW_LINE DEDENT print ( x , y ) NEW_LINE", "K = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE unit = 400001 NEW_LINE center = 200000 NEW_LINE current_pos = center * unit + center NEW_LINE d = { current_pos : [ current_pos + unit , current_pos + 1 , current_pos - unit , current_pos - 1 ] } NEW_LINE _dir = { \" U \" : 0 , \" R \" : 1 , \" D \" : 2 , \" L \" : 3 } NEW_LINE for c in s : NEW_LINE INDENT dir1 , dir2 = _dir [ c ] , ( _dir [ c ] + 2 ) % 4 NEW_LINE opposite = d [ current_pos ] [ dir2 ] NEW_LINE next_pos = d [ current_pos ] [ dir1 ] NEW_LINE while next_pos in d : NEW_LINE INDENT d [ next_pos ] [ dir2 ] = opposite NEW_LINE next_pos = d [ next_pos ] [ dir1 ] NEW_LINE DEDENT d [ next_pos ] = [ next_pos + unit , next_pos + 1 , next_pos - unit , next_pos - 1 ] NEW_LINE d [ next_pos ] [ dir2 ] = opposite NEW_LINE d [ current_pos ] [ dir1 ] = d [ next_pos ] [ dir1 ] NEW_LINE current_pos = next_pos NEW_LINE DEDENT print ( current_pos % unit - center , current_pos // unit - center ) NEW_LINE" ]
atcoder_abc119_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; double sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { double x = sc . nextDouble ( ) ; if ( \" JPY \" . equals ( sc . next ( ) ) ) { sum += x ; } else { sum += x * 380000 ; } } System . out . println ( sum ) ; } }", "import java . math . BigDecimal ; 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 count = scanner . nextInt ( ) ; scanner . nextLine ( ) ; BigDecimal rate = new BigDecimal ( \"380000.0\" ) ; System . out . println ( IntStream . range ( 0 , count ) . mapToObj ( i -> { String amount = scanner . next ( ) ; String currency = scanner . next ( ) ; scanner . nextLine ( ) ; if ( \" JPY \" . equals ( currency ) ) { return new BigDecimal ( amount ) ; } else { return ( new BigDecimal ( amount ) ) . multiply ( rate ) ; } } ) . reduce ( BigDecimal . ZERO , BigDecimal :: add ) ) ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int N = sc . nextInt ( ) ; double [ ] x = new double [ N ] ; double sum = 0 ; String [ ] u = new String [ N ] ; for ( int i = 0 ; i < u . length ; i ++ ) { x [ i ] = sc . nextDouble ( ) ; u [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < u . length ; i ++ ) { if ( u [ i ] . equals ( \" JPY \" ) ) { sum += x [ i ] ; } else { sum += x [ i ] * 380000.0 ; } } PrintWriter out = new PrintWriter ( System . out ) ; out . print ( sum ) ; out . flush ( ) ; } 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 . 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 ) ; int c = Integer . parseInt ( scan . next ( ) ) ; scan . nextLine ( ) ; double yourfortune = 0 ; double btcprice = 380000.0 ; for ( int i = 0 ; i < c ; i ++ ) { double a = 0 ; a = Double . parseDouble ( scan . next ( ) ) ; String b = null ; if ( scan . hasNext ( ) ) { b = scan . next ( ) ; } else { b = \" \" ; } if ( b . equals ( \" JPY \" ) ) { yourfortune += a ; } else { yourfortune += ( a * btcprice ) ; } } String ans = null ; PrintWriter out = new PrintWriter ( System . out ) ; out . println ( yourfortune ) ; out . flush ( ) ; scan . close ( ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskAtCoder19B solver = new TaskAtCoder19B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskAtCoder19B { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int N = in . nextInt ( ) ; double res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { double tmp = Double . parseDouble ( in . next ( ) ) ; if ( in . next ( ) . equals ( \" BTC \" ) ) tmp *= 380000.0 ; res += tmp ; } out . println ( res ) ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = [ list ( map ( str , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE ans = 0 NEW_LINE for value , unit in A : NEW_LINE INDENT if unit == \" BTC \" : NEW_LINE INDENT ans += float ( value ) * 380000 NEW_LINE DEDENT else : NEW_LINE INDENT ans += float ( value ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE n = int ( input ( ) ) NEW_LINE money = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT y = sys . stdin . readline ( ) . rstrip ( ' \\n ' ) NEW_LINE a , b = y . split ( ' ▁ ' ) NEW_LINE x = float ( a ) NEW_LINE if b == ' JPY ' : NEW_LINE INDENT money = money + x NEW_LINE DEDENT else : NEW_LINE INDENT money = money + x * 380000.0 NEW_LINE DEDENT DEDENT print ( money ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE rate = 380000.0 NEW_LINE ans = 0.0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , u = input ( ) . split ( ) NEW_LINE x = float ( x ) NEW_LINE ans += x * rate if u == ' BTC ' else x NEW_LINE DEDENT print ( ' { : . 11f } ' . format ( ans ) ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE x = [ ] NEW_LINE u = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT xu = list ( map ( str , input ( ) . split ( ) ) ) NEW_LINE x . append ( float ( xu [ 0 ] ) ) NEW_LINE mon = xu [ 1 ] NEW_LINE if mon == \" JPY \" : NEW_LINE INDENT u . append ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT u . append ( 380000 ) NEW_LINE DEDENT DEDENT s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT s = s + x [ i ] * u [ i ] NEW_LINE DEDENT print ( s ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE xu = [ input ( ) . split ( ) for i in range ( n ) ] NEW_LINE for i in xu : NEW_LINE INDENT i [ 0 ] = float ( i [ 0 ] ) NEW_LINE DEDENT for i in xu : NEW_LINE INDENT if i [ 1 ] == ' BTC ' : NEW_LINE INDENT i [ 0 ] *= 380000 NEW_LINE DEDENT DEDENT print ( sum ( xu [ i ] [ 0 ] for i in range ( n ) ) ) NEW_LINE" ]
atcoder_agc002_C
[ "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; long limit = sc . nextLong ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } boolean ok = false ; int ans [ ] = new int [ n - 1 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] + a [ i + 1 ] >= limit ) { ans [ i ] = n - 1 ; ok = true ; break ; } } if ( ! ok ) { System . out . println ( \" Impossible \" ) ; return ; } int p = 1 ; for ( int i = 0 ; ans [ i ] == 0 ; i ++ ) { ans [ i ] = p ++ ; } for ( int i = n - 2 ; ans [ i ] == 0 ; i -- ) { ans [ i ] = p ++ ; } System . out . println ( \" Possible \" ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { System . out . println ( ans [ i ] ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { InputReader cin = new InputReader ( System . in ) ; PrintWriter cout = new PrintWriter ( System . out ) ; Task task = new Task ( ) ; task . run ( cin , cout ) ; cout . close ( ) ; } } class Task { void run ( InputReader cin , PrintWriter cout ) { int n = cin . nextInt ( ) ; int l = cin . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = cin . nextInt ( ) ; } int p = 0 ; for ( int i = 1 ; i < n ; ++ i ) { if ( a [ i - 1 ] + a [ i ] >= l ) { p = i ; break ; } } if ( p == 0 ) { cout . printf ( \" Impossible \\n \" ) ; } else { cout . printf ( \" Possible \\n \" ) ; for ( int i = 1 ; i < p ; ++ i ) { cout . println ( i ) ; } for ( int i = n - 1 ; i >= p + 1 ; -- i ) { cout . println ( i ) ; } cout . println ( p ) ; } } } class InputReader { private BufferedReader reader ; private StringTokenizer tokenizer ; private int BUFFER_SIZE = 32768 ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , BUFFER_SIZE ) ; tokenizer = null ; } public boolean hasNext ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { String line ; try { line = reader . readLine ( ) ; if ( line == null ) { return false ; } tokenizer = new StringTokenizer ( line ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return true ; } public String next ( ) { if ( ! hasNext ( ) ) { return null ; } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( this . next ( ) ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) throws Exception { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; String input [ ] = br . readLine ( ) . split ( \" ▁ \" ) ; int count = Integer . parseInt ( input [ 0 ] ) ; int maxLength = Integer . parseInt ( input [ 1 ] ) ; String input2 [ ] = br . readLine ( ) . split ( \" ▁ \" ) ; ArrayList < Integer > result = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < count ; i ++ ) { if ( i + 1 >= count ) { break ; } int num = Integer . parseInt ( input2 [ i ] ) ; int num2 = Integer . parseInt ( input2 [ i + 1 ] ) ; if ( num + num2 >= maxLength ) { for ( int j = 0 ; j < i ; j ++ ) { result . add ( j + 1 ) ; } for ( int n = count - 1 ; n > i + 1 ; n -- ) { result . add ( n ) ; } result . add ( i + 1 ) ; System . out . println ( \" Possible \" ) ; for ( int re : result ) { System . out . println ( re ) ; } return ; } } System . out . println ( \" Impossible \" ) ; } }", "import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] array ; array = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( array [ 0 ] ) ; int l = Integer . parseInt ( array [ 1 ] ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( String str : br . readLine ( ) . split ( \" ▁ \" ) ) { list . add ( Integer . parseInt ( str ) ) ; } int index = - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( list . get ( i ) + list . get ( i + 1 ) >= l ) { index = i ; break ; } } if ( index < 0 ) { System . out . println ( \" Impossible \" ) ; } else { System . out . println ( \" Possible \" ) ; for ( int i = 0 ; i < index ; i ++ ) { System . out . println ( i + 1 ) ; } for ( int i = n - 1 ; index < i ; i -- ) { System . out . println ( i ) ; } } } }", "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 ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int b = last ( a , l ) ; if ( b == - 1 ) { System . out . println ( \" Impossible \" ) ; } else { System . out . println ( \" Possible \" ) ; for ( int i = 0 ; i < b ; i ++ ) { System . out . println ( i + 1 ) ; } for ( int i = n - 2 ; i > b ; i -- ) { System . out . println ( i + 1 ) ; } System . out . println ( b + 1 ) ; } } static int last ( int [ ] a , int l ) { for ( int i = 0 ; i < a . length - 1 ; i ++ ) { if ( a [ i ] + a [ i + 1 ] >= l ) { return i ; } } return - 1 ; } }" ]
[ "N , L = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE I = [ i + 1 for i in range ( N - 1 ) if a [ i ] + a [ i + 1 ] >= L ] NEW_LINE ans = ( ' Possible \\n { } ' . format ( ' \\n ' . join ( map ( str , list ( range ( 1 , I [ 0 ] ) ) + list ( range ( N - 1 , I [ 0 ] , - 1 ) ) + [ I [ 0 ] ] ) ) ) if I else ) 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 , l = LI ( ) NEW_LINE A = LI ( ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if A [ i ] + A [ i + 1 ] >= l : NEW_LINE INDENT k = i NEW_LINE print ( ' Possible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE return 0 NEW_LINE DEDENT for i in range ( k ) : NEW_LINE INDENT print ( i + 1 ) NEW_LINE DEDENT for i in range ( k , n - 1 ) [ : : - 1 ] : NEW_LINE INDENT print ( i + 1 ) NEW_LINE DEDENT return 1 NEW_LINE DEDENT main ( ) NEW_LINE", "n , l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE max_len = a [ 0 ] + a [ 1 ] NEW_LINE max_joint = 1 NEW_LINE for i in range ( 1 , n - 1 ) : NEW_LINE INDENT len = a [ i ] + a [ i + 1 ] NEW_LINE if len > max_len : NEW_LINE INDENT max_len = len NEW_LINE max_joint = i + 1 NEW_LINE DEDENT DEDENT if max_len < l : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Possible \" ) NEW_LINE for i in range ( 1 , max_joint ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT for i in range ( n - 1 , max_joint , - 1 ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT print ( max_joint ) NEW_LINE DEDENT", "import sys NEW_LINE input = sys . stdin . readline NEW_LINE inf = float ( \" inf \" ) NEW_LINE n , L = map ( int , input ( ) . split ( ) ) NEW_LINE a = tuple ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if a [ i ] + a [ i - 1 ] >= L : NEW_LINE INDENT print ( ' Possible ' ) NEW_LINE for j in range ( 1 , i ) : NEW_LINE INDENT print ( j ) NEW_LINE DEDENT for j in range ( n - 1 , i , - 1 ) : NEW_LINE INDENT print ( j ) NEW_LINE DEDENT print ( i ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( ' Impossible ' ) NEW_LINE", "N , L = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE P = \" Possible \" NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if a [ i ] + a [ i + 1 ] >= L : NEW_LINE INDENT start = i NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT P = \" Impossible \" NEW_LINE DEDENT print ( P ) NEW_LINE if P == \" Possible \" : NEW_LINE INDENT ans = [ start ] NEW_LINE if start > 0 : NEW_LINE INDENT ans += reversed ( list ( range ( start ) ) ) NEW_LINE DEDENT if start != N - 2 : NEW_LINE INDENT ans += list ( range ( start + 1 , N - 1 ) ) NEW_LINE DEDENT ans . reverse ( ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a + 1 ) NEW_LINE DEDENT DEDENT" ]
atcoder_arc085_B
[ "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int max = Math . abs ( a [ n - 1 ] - y ) ; if ( n != 1 ) max = Math . max ( max , Math . abs ( a [ n - 1 ] - a [ n - 2 ] ) ) ; System . out . println ( max ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( \" ▁ \" ) ; int n = Integer . parseInt ( tmpArray [ 0 ] ) ; int z = Integer . parseInt ( tmpArray [ 1 ] ) ; int w = Integer . parseInt ( tmpArray [ 2 ] ) ; int [ ] input = new int [ n ] ; tmpArray = br . readLine ( ) . split ( \" ▁ \" ) ; for ( int i = 0 ; i < n ; i ++ ) { input [ i ] = Integer . parseInt ( tmpArray [ i ] ) ; } int score = 0 ; if ( n == 1 ) { score = Math . abs ( w - input [ n - 1 ] ) ; } else { score = Math . max ( Math . abs ( input [ n - 2 ] - input [ n - 1 ] ) , Math . abs ( w - input [ n - 1 ] ) ) ; } System . out . println ( score ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long x = sc . nextLong ( ) , y = sc . nextLong ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; System . out . println ( max ( a , 0 , y ) ) ; } static HashMap < Long , Long > minmap = new HashMap < > ( ) ; static long min ( long [ ] a , int teban , long taro ) { long res = Math . abs ( a [ a . length - 1 ] - taro ) ; long key = taro * 10000 + teban ; if ( minmap . containsKey ( key ) ) return minmap . get ( key ) ; for ( int i = teban ; i < a . length - 1 ; i ++ ) { res = Math . min ( res , max ( a , i + 1 , a [ i ] ) ) ; } minmap . put ( key , res ) ; return res ; } static HashMap < Long , Long > maxmap = new HashMap < > ( ) ; static long max ( long [ ] a , int teban , long ziro ) { long res = Math . abs ( a [ a . length - 1 ] - ziro ) ; long key = ziro * 10000 + teban ; if ( maxmap . containsKey ( key ) ) return maxmap . get ( key ) ; for ( int i = teban ; i < a . length - 1 ; i ++ ) { res = Math . max ( res , min ( a , i + 1 , a [ i ] ) ) ; } maxmap . put ( key , res ) ; return res ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] cards = new int [ n + 2 ] ; for ( int i = 0 ; i < n + 2 ; i ++ ) { cards [ i ] = sc . nextInt ( ) ; } int [ ] [ ] mainTable = new int [ n + 2 ] [ n + 2 ] ; int [ ] [ ] subTable = new int [ n + 2 ] [ n + 2 ] ; for ( int j = 0 ; j < n + 1 ; j ++ ) { mainTable [ j ] [ n + 1 ] = Math . abs ( cards [ j ] - cards [ n + 1 ] ) ; mainTable [ n + 1 ] [ j ] = Math . abs ( cards [ j ] - cards [ n + 1 ] ) ; subTable [ j ] [ n + 1 ] = Math . abs ( cards [ j ] - cards [ n + 1 ] ) ; subTable [ n + 1 ] [ j ] = Math . abs ( cards [ j ] - cards [ n + 1 ] ) ; } for ( int i = n ; i >= 1 ; i -- ) { for ( int j = 0 ; j < i ; j ++ ) { mainTable [ i ] [ j ] = subTable [ i ] [ i + 1 ] ; subTable [ i ] [ j ] = Math . max ( mainTable [ i ] [ j ] , subTable [ i + 1 ] [ j ] ) ; mainTable [ j ] [ i ] = subTable [ i + 1 ] [ i ] ; subTable [ j ] [ i ] = Math . min ( mainTable [ j ] [ i ] , subTable [ j ] [ i + 1 ] ) ; } } System . out . println ( mainTable [ 0 ] [ 1 ] ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = sc . nextInt ( ) ; } if ( n >= 2 ) { System . out . println ( Math . max ( Math . abs ( w - a [ n - 1 ] ) , Math . abs ( a [ n - 1 ] - a [ n - 2 ] ) ) ) ; } else if ( n == 1 ) { System . out . println ( Math . abs ( w - a [ 0 ] ) ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }" ]
[ "import sys NEW_LINE fin = sys . stdin . readline NEW_LINE N , Z , W = [ int ( elem ) for elem in fin ( ) . split ( ) ] NEW_LINE a_list = [ int ( elem ) for elem in fin ( ) . split ( ) ] NEW_LINE assert len ( a_list ) == N NEW_LINE if N == 1 : NEW_LINE INDENT print ( abs ( a_list [ - 1 ] - W ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( max ( abs ( a_list [ - 1 ] - W ) , abs ( a_list [ - 2 ] - a_list [ - 1 ] ) ) ) NEW_LINE DEDENT", "ai = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE n , z , w = ai ( ) NEW_LINE a = ai ( ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( abs ( a [ - 1 ] - w ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( max ( abs ( a [ - 1 ] - w ) , abs ( a [ - 1 ] - a [ - 2 ] ) ) ) NEW_LINE DEDENT", "def main ( ) : NEW_LINE INDENT n , z , w = input ( ) . split ( ) NEW_LINE n = int ( n ) NEW_LINE w = int ( w ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = [ w ] + a NEW_LINE sx = s_min = s_max = abs ( a [ n ] - a [ n - 1 ] ) NEW_LINE for i in range ( n - 1 , 0 , - 1 ) : NEW_LINE INDENT sx = max ( s_max , abs ( a [ n ] - a [ i - 1 ] ) ) NEW_LINE sy = min ( s_min , abs ( a [ n ] - a [ i - 1 ] ) ) NEW_LINE s_max = max ( s_max , sy ) NEW_LINE s_min = min ( s_min , sx ) NEW_LINE DEDENT print ( sx ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "N , Z , W = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ int ( a ) for a in input ( ) . split ( ) ] NEW_LINE if N == 1 : print ( abs ( A [ 0 ] - W ) ) NEW_LINE else : print ( max ( abs ( A [ - 2 ] - A [ - 1 ] ) , abs ( A [ - 1 ] - W ) ) ) NEW_LINE", "n , z , w = map ( int , input ( ) . split ( ) ) NEW_LINE a = tuple ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = abs ( a [ - 1 ] - w ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT cand = abs ( a [ - 1 ] - a [ i ] ) NEW_LINE for j in range ( i + 1 , n - 1 ) : NEW_LINE INDENT cand = min ( a [ j ] - a [ - 1 ] , cand ) NEW_LINE DEDENT res = max ( res , cand ) NEW_LINE DEDENT print ( res ) NEW_LINE" ]
atcoder_abc051_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i <= Math . min ( s , k ) ; i ++ ) { ans += Math . max ( 0 , Math . min ( s - i + 1 , k + 1 ) - Math . max ( 0 , s - i - k ) ) ; } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { FastScanner fc = new FastScanner ( System . in ) ; int K = fc . nextInt ( ) ; int S = fc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { for ( int j = 0 ; j <= K ; j ++ ) { int temp = S - i - j ; if ( temp >= 0 && temp <= K ) count ++ ; } } System . out . println ( count ) ; } static class FastScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public FastScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; tokenizer = null ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public String nextLine ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( \" \\n \" ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public int [ ] nextIntArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } public long [ ] nextLongArray ( int n ) { long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; } } }", "import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter out = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int k = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int s = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int count = 0 ; for ( int i = 0 ; i <= k ; i ++ ) { for ( int j = 0 ; j <= k ; j ++ ) { if ( s >= i + j && s - ( i + j ) <= k ) { count ++ ; } if ( s < i + j ) break ; } if ( s < i ) break ; } out . write ( String . valueOf ( count ) ) ; out . write ( \" \\n \" ) ; out . close ( ) ; } }", "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 K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x <= K ; x ++ ) { for ( int y = 0 ; y <= K ; y ++ ) { if ( S - x - y <= K && S >= x + y ) { count ++ ; } } } System . out . println ( count ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int C = 0 ; int nam = 0 ; for ( int a = 0 ; a <= K ; a ++ ) { for ( int b = 0 ; b <= K ; b ++ ) { C = S - a - b ; if ( 0 <= C && C <= K ) { nam = nam + 1 ; } } } System . out . print ( nam ) ; } }" ]
[ "k , s = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for x in range ( k + 1 ) : NEW_LINE INDENT for y in range ( k + 1 ) : NEW_LINE INDENT if s - x - y >= 0 and s - x - y <= k : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import itertools NEW_LINE K , S = map ( int , input ( ) . split ( ) ) NEW_LINE count = 0 NEW_LINE for x , y in itertools . product ( range ( 0 , K + 1 ) , range ( 0 , K + 1 ) ) : NEW_LINE INDENT z = S - x - y NEW_LINE if 0 <= z <= K : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE", "A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE K = A [ 0 ] NEW_LINE S = A [ 1 ] NEW_LINE count = 0 NEW_LINE for a in range ( K + 1 ) : NEW_LINE INDENT for b in range ( K + 1 ) : NEW_LINE INDENT c = S - a - b NEW_LINE if 0 <= c <= K : NEW_LINE INDENT count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT DEDENT print ( count ) NEW_LINE", "k , s = map ( int , input ( ) . split ( ) ) NEW_LINE print ( len ( [ 1 for z in range ( k + 1 ) for y in range ( k + 1 ) if 0 <= s - y - z <= k ] ) ) NEW_LINE", "K , S = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for x in range ( 0 , K + 1 ) : NEW_LINE INDENT for y in range ( 0 , K + 1 ) : NEW_LINE INDENT if 0 <= S - ( x + y ) <= K : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc074_B
[ "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; long a [ ] = new long [ 3 * n ] ; for ( int i = 0 ; i < 3 * n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long sumr [ ] = new long [ n + 1 ] ; long sumb [ ] = new long [ n + 1 ] ; Queue < Long > rq = new PriorityQueue < > ( ( o1 , o2 ) -> Long . compare ( o1 , o2 ) ) ; Queue < Long > bq = new PriorityQueue < > ( ( o1 , o2 ) -> Long . compare ( o2 , o1 ) ) ; for ( int i = 0 ; i < n ; i ++ ) { rq . add ( a [ i ] ) ; sumr [ 0 ] += a [ i ] ; bq . add ( a [ 2 * n + i ] ) ; sumb [ n ] += a [ 2 * n + i ] ; } for ( int i = n ; i < 2 * n ; i ++ ) { sumr [ i - n + 1 ] = sumr [ i - n ] + a [ i ] ; rq . add ( a [ i ] ) ; sumr [ i - n + 1 ] -= rq . poll ( ) ; sumb [ 2 * n - i - 1 ] = sumb [ 2 * n - i ] + a [ 3 * n - i - 1 ] ; bq . add ( a [ 3 * n - i - 1 ] ) ; sumb [ 2 * n - i - 1 ] -= bq . poll ( ) ; } long ans = sumr [ n ] - sumb [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . max ( ans , sumr [ i ] - sumb [ i ] ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; PriorityQueue < Long > left = new PriorityQueue < > ( n ) ; long [ ] center = new long [ n ] ; PriorityQueue < Long > right = new PriorityQueue < > ( ( l1 , l2 ) -> { return l2 . compareTo ( l1 ) ; } ) ; for ( int i = 0 ; i < n ; i ++ ) { left . add ( sc . nextLong ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { center [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { right . add ( sc . nextLong ( ) ) ; } long [ ] lmove = new long [ n + 1 ] ; lmove [ 0 ] = left . stream ( ) . mapToLong ( i -> i ) . sum ( ) ; long [ ] rmove = new long [ n + 1 ] ; rmove [ 0 ] = right . stream ( ) . mapToLong ( i -> i ) . sum ( ) ; for ( int i = 0 ; i < n ; i ++ ) { left . add ( center [ i ] ) ; lmove [ i + 1 ] = lmove [ i ] - left . poll ( ) + center [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { right . add ( center [ n - 1 - i ] ) ; rmove [ i + 1 ] = rmove [ i ] - right . poll ( ) + center [ n - 1 - i ] ; } long ans = Long . MIN_VALUE ; for ( int i = 0 ; i <= n ; i ++ ) { long temp = lmove [ i ] - rmove [ n - i ] ; ans = Math . max ( temp , ans ) ; } System . out . println ( ans ) ; } }", "import java . util . Comparator ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { int n ; long [ ] as ; PriorityQueue < Long > maxQueue ; PriorityQueue < Long > minQueue ; public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . read ( ) ; m . solve ( ) ; } private void read ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; as = new long [ 3 * n ] ; for ( int i = 0 ; i < as . length ; i ++ ) { as [ i ] = sc . nextLong ( ) ; } } private void solve ( ) { maxQueue = new PriorityQueue < > ( ) ; minQueue = new PriorityQueue < > ( Comparator . reverseOrder ( ) ) ; long [ ] maxs = new long [ n + 1 ] ; long [ ] mins = new long [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { maxQueue . add ( as [ i ] ) ; maxs [ 0 ] += as [ i ] ; minQueue . add ( as [ 3 * n - 1 - i ] ) ; mins [ mins . length - 1 ] += as [ 3 * n - 1 - i ] ; } for ( int i = n ; i < 2 * n ; i ++ ) { maxQueue . add ( as [ i ] ) ; long e = maxQueue . poll ( ) ; maxs [ i - n + 1 ] = maxs [ i - n ] + as [ i ] - e ; } for ( int i = 2 * n - 1 ; i >= n ; i -- ) { minQueue . add ( as [ i ] ) ; long e = minQueue . poll ( ) ; mins [ i - n ] = mins [ i - n + 1 ] + as [ i ] - e ; } long ans = maxs [ 0 ] - mins [ 0 ] ; for ( int i = 0 ; i <= n ; i ++ ) { ans = Math . max ( ans , maxs [ i ] - mins [ i ] ) ; } System . out . println ( ans ) ; } }", "import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; PriorityQueue < Integer > mae = new PriorityQueue < Integer > ( ) ; PriorityQueue < Integer > ato = new PriorityQueue < Integer > ( ( Integer x1 , Integer x2 ) -> x2 - x1 ) ; long [ ] maeSum = new long [ N + 1 ] ; long [ ] atoSum = new long [ N + 1 ] ; long ans = Long . MIN_VALUE ; int [ ] A = new int [ N * 3 ] ; for ( int i = 0 ; i < N * 3 ; i ++ ) { int a = sc . nextInt ( ) ; A [ i ] = a ; if ( i < N ) { mae . add ( a ) ; maeSum [ 0 ] += a ; } else if ( i >= N * 2 ) { ato . add ( a ) ; atoSum [ N ] += a ; } } for ( int i = N ; i < N * 2 ; i ++ ) { int k = i - ( N - 1 ) ; if ( A [ i ] > mae . peek ( ) ) { maeSum [ k ] = maeSum [ k - 1 ] - mae . poll ( ) + A [ i ] ; mae . add ( A [ i ] ) ; } else { maeSum [ k ] = maeSum [ k - 1 ] ; } } for ( int i = N * 2 - 1 ; i >= N ; i -- ) { int k = i - N ; if ( A [ i ] < ato . peek ( ) ) { atoSum [ k ] = atoSum [ k + 1 ] - ato . poll ( ) + A [ i ] ; ato . add ( A [ i ] ) ; } else { atoSum [ k ] = atoSum [ k + 1 ] ; } } for ( int i = 0 ; i <= N ; i ++ ) { ans = Math . max ( ans , maeSum [ i ] - atoSum [ i ] ) ; } System . out . println ( ans ) ; sc . close ( ) ; } }", "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 ( ) ; long [ ] a = new long [ n * 3 ] ; for ( int i = 0 ; i < 3 * n ; ++ i ) { a [ i ] = scanner . nextLong ( ) ; } final PriorityQueue < Long > firstHalf = new PriorityQueue < > ( ) ; final PriorityQueue < Long > secondHalf = new PriorityQueue < > ( Comparator . reverseOrder ( ) ) ; long [ ] leftSum = new long [ n + 1 ] ; long [ ] rightSum = new long [ n + 1 ] ; for ( int i = 0 ; i < n ; ++ i ) { firstHalf . add ( a [ i ] ) ; leftSum [ 0 ] += a [ i ] ; } for ( int i = n ; i < 2 * n ; ++ i ) { firstHalf . add ( a [ i ] ) ; long head = firstHalf . poll ( ) ; leftSum [ i - n + 1 ] = leftSum [ i - n ] + a [ i ] - head ; } for ( int i = 3 * n - 1 ; i >= 2 * n ; -- i ) { secondHalf . add ( a [ i ] ) ; rightSum [ n ] += a [ i ] ; } for ( int i = 2 * n - 1 ; i >= n ; -- i ) { secondHalf . add ( a [ i ] ) ; long head = secondHalf . poll ( ) ; rightSum [ i - n ] = rightSum [ i - n + 1 ] + a [ i ] - head ; } long result = Long . MIN_VALUE ; for ( int i = 0 ; i <= n ; ++ i ) { result = Math . max ( result , leftSum [ i ] - rightSum [ i ] ) ; } System . out . println ( result ) ; } }" ]
[ "import heapq NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE selectleft , selectright = [ ] , [ ] NEW_LINE leftscore , rightscore = [ ] , [ ] NEW_LINE for i in range ( 1 , n + 1 ) : heapq . heappush ( selectleft , a [ i ] ) NEW_LINE leftscore . append ( sum ( selectleft ) ) NEW_LINE for i in range ( n + 1 , 2 * n + 1 ) : NEW_LINE INDENT heapq . heappush ( selectleft , a [ i ] ) NEW_LINE tmpscore = leftscore [ - 1 ] + a [ i ] NEW_LINE poped = heapq . heappop ( selectleft ) NEW_LINE tmpscore -= poped NEW_LINE leftscore . append ( tmpscore ) NEW_LINE DEDENT for i in range ( 2 * n + 1 , 3 * n + 1 ) : NEW_LINE INDENT heapq . heappush ( selectright , ( - 1 ) * a [ i ] ) NEW_LINE DEDENT rightscore . append ( sum ( selectright ) * ( - 1 ) ) NEW_LINE for i in range ( 2 * n , n , - 1 ) : NEW_LINE INDENT heapq . heappush ( selectright , ( - 1 ) * a [ i ] ) NEW_LINE tmpscore = rightscore [ - 1 ] + a [ i ] NEW_LINE poped = heapq . heappop ( selectright ) * ( - 1 ) NEW_LINE tmpscore -= poped NEW_LINE rightscore . append ( tmpscore ) NEW_LINE DEDENT rightscore . reverse ( ) NEW_LINE print ( max ( map ( lambda x , y : x - y , leftscore , rightscore ) ) ) NEW_LINE", "ai = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE a = ai ( ) NEW_LINE big = sum ( a [ : n ] ) NEW_LINE small = sum ( a [ 2 * n : ] ) NEW_LINE import heapq NEW_LINE af = a [ : n ] NEW_LINE heapq . heapify ( af ) NEW_LINE ar = [ - i for i in a [ 2 * n : ] ] NEW_LINE heapq . heapify ( ar ) NEW_LINE ans = [ [ 0 , 0 ] for _ in range ( n + 1 ) ] NEW_LINE ans [ 0 ] [ 0 ] = big NEW_LINE ans [ - 1 ] [ 1 ] = small NEW_LINE for k in range ( n ) : NEW_LINE INDENT if af [ 0 ] < a [ n + k ] : NEW_LINE INDENT b = heapq . heapreplace ( af , a [ n + k ] ) NEW_LINE big += a [ n + k ] - b NEW_LINE DEDENT ans [ k + 1 ] [ 0 ] = big NEW_LINE DEDENT for k in range ( n ) : NEW_LINE INDENT if - ar [ 0 ] > a [ - n - k - 1 ] : NEW_LINE INDENT s = heapq . heapreplace ( ar , - a [ - n - k - 1 ] ) NEW_LINE small += a [ - n - k - 1 ] + s NEW_LINE DEDENT ans [ - k - 2 ] [ 1 ] = small NEW_LINE DEDENT print ( max ( i - j for i , j in ans ) ) NEW_LINE", "from heapq import heappush , heappushpop , heapify NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE q = [ ] NEW_LINE s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT heappush ( q , a [ i ] ) NEW_LINE s += a [ i ] NEW_LINE DEDENT left = [ s ] NEW_LINE for k in range ( n ) : NEW_LINE INDENT x = heappushpop ( q , a [ n + k ] ) NEW_LINE s = s - x + a [ n + k ] NEW_LINE left . append ( s ) NEW_LINE DEDENT q = [ ] NEW_LINE s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT heappush ( q , - 1 * a [ 3 * n - 1 - i ] ) NEW_LINE s += a [ 3 * n - 1 - i ] NEW_LINE DEDENT right = [ 0 for _ in range ( n + 1 ) ] NEW_LINE right [ n ] = s NEW_LINE for k in range ( n ) : NEW_LINE INDENT x = heappushpop ( q , - 1 * a [ 2 * n - 1 - k ] ) NEW_LINE s = s - ( - 1 * x ) + a [ 2 * n - 1 - k ] NEW_LINE right [ n - 1 - k ] = s NEW_LINE DEDENT m = None NEW_LINE for k in range ( n + 1 ) : NEW_LINE INDENT if m is None : NEW_LINE INDENT m = left [ k ] - right [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT m = max ( m , left [ k ] - right [ k ] ) NEW_LINE DEDENT DEDENT print ( m ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 100000 ) NEW_LINE import heapq NEW_LINE n = int ( input ( ) ) NEW_LINE data = [ ] NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE amax = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT heapq . heappush ( data , a [ i ] ) NEW_LINE amax += a [ i ] NEW_LINE DEDENT ansdata = [ amax ] NEW_LINE for i in range ( n , 2 * n ) : NEW_LINE INDENT heapq . heappush ( data , a [ i ] ) NEW_LINE amax += a [ i ] NEW_LINE amax -= heapq . heappop ( data ) NEW_LINE ansdata . append ( amax ) NEW_LINE DEDENT data = [ ] NEW_LINE bmin = 0 NEW_LINE for i in range ( 2 * n , 3 * n ) : NEW_LINE INDENT heapq . heappush ( data , - a [ i ] ) NEW_LINE bmin += a [ i ] NEW_LINE DEDENT ansdata [ - 1 ] -= bmin NEW_LINE for i in range ( n ) : NEW_LINE INDENT t = i NEW_LINE i = 2 * n - 1 - i NEW_LINE heapq . heappush ( data , - a [ i ] ) NEW_LINE bmin += a [ i ] NEW_LINE bmin += heapq . heappop ( data ) NEW_LINE ansdata [ - t - 2 ] -= bmin NEW_LINE DEDENT print ( max ( ansdata ) ) NEW_LINE", "import heapq NEW_LINE N = int ( input ( ) ) NEW_LINE a_ls = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE before = [ ] NEW_LINE _sum_before = 0 NEW_LINE before_scores = [ ] NEW_LINE after = [ ] NEW_LINE _sum_after = 0 NEW_LINE after_scores = [ ] NEW_LINE best = None NEW_LINE for i in range ( 2 * N ) : NEW_LINE INDENT _sum_before += a_ls [ i ] NEW_LINE heapq . heappush ( before , a_ls [ i ] ) NEW_LINE _sum_after += a_ls [ - i - 1 ] NEW_LINE heapq . heappush ( after , - a_ls [ - i - 1 ] ) NEW_LINE if i >= N : NEW_LINE INDENT _sum_before -= heapq . heappop ( before ) NEW_LINE _sum_after -= - heapq . heappop ( after ) NEW_LINE DEDENT if i >= N - 1 : NEW_LINE INDENT before_scores . append ( _sum_before ) NEW_LINE after_scores . append ( _sum_after ) NEW_LINE DEDENT DEDENT after_scores = after_scores [ : : - 1 ] NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT score = before_scores [ i ] - after_scores [ i ] NEW_LINE if best is None : NEW_LINE INDENT best = score NEW_LINE DEDENT best = score if best < score else best NEW_LINE DEDENT print ( best ) NEW_LINE" ]
atcoder_arc037_C
[ "import java . util . * ; class Main { static long [ ] a , b ; static int n ; static long count ( long v ) { long res = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int l = - 1 , r = n ; while ( r - l > 1 ) { int c = ( l + r ) / 2 ; if ( a [ i ] * b [ c ] <= v ) l = c ; else r = c ; } res += r ; } return res ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; a = new long [ n ] ; b = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) a [ i ] = sc . nextLong ( ) ; for ( int i = 0 ; i < n ; ++ i ) b [ i ] = sc . nextLong ( ) ; Arrays . sort ( a ) ; Arrays . sort ( b ) ; long l = 0 , r = Long . MAX_VALUE / 2 ; while ( r - l > 1L ) { long c = ( l + r ) / 2 ; if ( count ( c ) < k ) l = c ; else r = c ; } System . out . println ( r ) ; } }", "import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Main implements Runnable { public static void main ( String [ ] args ) { new Thread ( null , new Main ( ) , \" \" , Runtime . getRuntime ( ) . maxMemory ( ) ) . start ( ) ; } boolean check ( long [ ] a , long [ ] b , long middle , int k ) { int n = a . length ; long sum = 0 ; int h = n - 1 ; for ( int i = 0 ; i < n ; ++ i ) { while ( h > 0 && a [ i ] * b [ h ] > middle ) { -- h ; } if ( a [ i ] * b [ h ] <= middle ) sum += h + 1 ; } return sum >= k ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; long [ ] b = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < n ; ++ i ) { b [ i ] = sc . nextLong ( ) ; } Arrays . sort ( a ) ; Arrays . sort ( b ) ; long ng = 0 ; long ok = a [ n - 1 ] * b [ n - 1 ] ; while ( ok - ng > 1 ) { long middle = ( ok + ng ) / 2 ; if ( check ( a , b , middle , k ) ) { ok = middle ; } else { ng = middle ; } } System . out . println ( ok ) ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }", "import java . util . * ; class Main { static int inf = Integer . MAX_VALUE ; static int n , k ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = Integer . parseInt ( sc . next ( ) ) ; k = Integer . parseInt ( sc . next ( ) ) ; long [ ] hori = new long [ n ] ; long [ ] vert = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) vert [ i ] = Long . parseLong ( sc . next ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) hori [ i ] = Long . parseLong ( sc . next ( ) ) ; Arrays . sort ( vert ) ; Arrays . sort ( hori ) ; long hi = hori [ n - 1 ] * vert [ n - 1 ] ; long lo = hori [ 0 ] * vert [ 0 ] - 1 ; long mid ; while ( hi - lo > 1 ) { mid = ( hi + lo ) / 2 ; if ( check ( vert , hori , mid ) ) hi = mid ; else lo = mid ; } System . out . println ( hi ) ; } static boolean check ( long [ ] vert , long [ ] hori , long guess ) { int cnt = 0 ; for ( int x = 0 ; x < n ; x ++ ) { long target = guess / hori [ x ] ; int cur = binary ( vert , target ) ; cnt += cur ; if ( cnt >= k ) return true ; } return cnt >= k ; } static int binary ( long [ ] a , long target ) { if ( target < a [ 0 ] ) return 0 ; if ( target >= a [ n - 1 ] ) return n ; int hi = n - 1 ; int lo = - 1 ; int mid ; while ( hi - lo > 1 ) { mid = ( hi + lo ) / 2 ; if ( a [ mid ] <= target ) lo = mid ; else hi = mid ; } return hi ; } }", "import java . util . * ; public class Main { static int n ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long [ ] a = new long [ n ] ; long [ ] b = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextLong ( ) ; } Arrays . sort ( a ) ; Arrays . sort ( b ) ; long max = a [ n - 1 ] * b [ n - 1 ] ; System . out . println ( binSearch ( max , - 1 , k , a , b ) ) ; } public static long binSearch ( long ok , long ng , long k , long [ ] a , long [ ] b ) { while ( Math . abs ( ok - ng ) > 1 ) { long mid = ( ok + ng ) / 2 ; if ( solve ( mid , a , b ) >= k ) { ok = mid ; } else { ng = mid ; } } return ok ; } public static long solve ( long k , long [ ] a , long [ ] b ) { long cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( b [ 0 ] * a [ i ] > k ) { continue ; } long ok = 0 ; long ng = n ; while ( Math . abs ( ok - ng ) > 1 ) { long mid = ( ok + ng ) / 2 ; if ( b [ ( int ) mid ] * a [ i ] <= k ) { ok = mid ; } else { ng = mid ; } } cnt += ok + 1 ; } return cnt ; } }" ]
[ "N , K = map ( int , input ( ) . split ( ) ) NEW_LINE * A , = map ( int , input ( ) . split ( ) ) NEW_LINE * B , = map ( int , input ( ) . split ( ) ) NEW_LINE A . sort ( reverse = 1 ) ; B . sort ( ) NEW_LINE def check ( mid ) : NEW_LINE INDENT j = 0 NEW_LINE res = 0 NEW_LINE for a in A : NEW_LINE INDENT while j < N and a * B [ j ] <= mid : NEW_LINE INDENT j += 1 NEW_LINE DEDENT res += j NEW_LINE DEDENT return K <= res NEW_LINE DEDENT left = 0 ; right = 10 ** 18 + 1 NEW_LINE while left + 1 < right : NEW_LINE INDENT mid = ( left + right ) // 2 NEW_LINE if check ( mid ) : NEW_LINE INDENT right = mid NEW_LINE DEDENT else : NEW_LINE INDENT left = mid NEW_LINE DEDENT DEDENT print ( right ) NEW_LINE", "import bisect NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE B = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE minp = A [ 0 ] * B [ 0 ] NEW_LINE maxp = A [ - 1 ] * B [ - 1 ] NEW_LINE if K == 1 : NEW_LINE INDENT print ( minp ) NEW_LINE exit ( ) NEW_LINE DEDENT if K == N * N : NEW_LINE INDENT print ( maxp ) NEW_LINE exit ( ) NEW_LINE DEDENT def enough ( n ) : NEW_LINE INDENT cnt = 0 NEW_LINE for a in A : NEW_LINE INDENT cnt += bisect . bisect_right ( B , n // a ) NEW_LINE if cnt >= K : return True NEW_LINE DEDENT return False NEW_LINE DEDENT ng = 0 NEW_LINE ok = maxp NEW_LINE while ok - ng > 1 : NEW_LINE INDENT m = ( ok + ng ) // 2 NEW_LINE if enough ( m ) : NEW_LINE INDENT ok = m NEW_LINE DEDENT else : NEW_LINE INDENT ng = m NEW_LINE DEDENT DEDENT print ( ok ) NEW_LINE", "import sys , bisect NEW_LINE input = sys . stdin . readline NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = sorted ( tuple ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE b = tuple ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sma = 1 NEW_LINE big = 10 ** 18 NEW_LINE while big - sma > 1 : NEW_LINE INDENT mid = ( big + sma ) // 2 NEW_LINE cnt = 0 NEW_LINE for e in b : NEW_LINE INDENT p = mid // e NEW_LINE q = bisect . bisect_right ( a , p ) NEW_LINE cnt += q NEW_LINE DEDENT if cnt >= k : NEW_LINE INDENT big = mid NEW_LINE DEDENT else : NEW_LINE INDENT sma = mid NEW_LINE DEDENT DEDENT cnt = 0 NEW_LINE for e in b : NEW_LINE INDENT p = sma // e NEW_LINE q = bisect . bisect_right ( a , p ) NEW_LINE cnt += q NEW_LINE DEDENT if cnt >= k : NEW_LINE INDENT print ( sma ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( big ) NEW_LINE DEDENT", "import bisect NEW_LINE def solve ( n , k , a , b ) : NEW_LINE INDENT b . sort ( ) NEW_LINE lo = 0 NEW_LINE hi = 10 ** 18 NEW_LINE while lo + 1 < hi : NEW_LINE INDENT mid = ( lo + hi ) // 2 NEW_LINE c = 0 NEW_LINE for ai in a : NEW_LINE INDENT p = mid // ai NEW_LINE j = bisect . bisect_right ( b , p ) NEW_LINE c += j NEW_LINE DEDENT if k <= c : NEW_LINE INDENT hi = mid NEW_LINE DEDENT else : NEW_LINE INDENT lo = mid NEW_LINE DEDENT DEDENT return hi NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n , k = input ( ) . split ( ) NEW_LINE n = int ( n ) NEW_LINE k = int ( k ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( solve ( n , k , a , b ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "from bisect import bisect_right NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l , r = 0 , 10 ** 18 + 1 NEW_LINE while r - l > 1 : NEW_LINE INDENT x = ( r + l ) // 2 NEW_LINE count = sum ( bisect_right ( a , x // bi ) for bi in b ) NEW_LINE if count < k : NEW_LINE INDENT l = x NEW_LINE DEDENT else : NEW_LINE INDENT r = x NEW_LINE DEDENT DEDENT print ( r ) NEW_LINE" ]
atcoder_abc009_C
[ "import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner in = new Scanner ( System . in ) ; int n , k ; String s ; void solve ( ) { n = in . nextInt ( ) ; k = in . nextInt ( ) ; in . nextLine ( ) ; s = in . nextLine ( ) ; char [ ] c = s . toCharArray ( ) ; Arrays . sort ( c ) ; String ans = \" \" ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( c [ j ] == ' \\0' ) continue ; if ( count ( ans , c , c [ j ] ) <= k ) { ans += c [ j ] ; c [ j ] = ' \\0' ; break ; } } } System . out . println ( ans ) ; } int count ( String ans , char [ ] c , char ch ) { int diff = 0 ; for ( int i = 0 ; i < ans . length ( ) ; i ++ ) { diff += s . charAt ( i ) == ans . charAt ( i ) ? 0 : 1 ; } if ( ch != s . charAt ( ans . length ( ) ) ) { diff ++ ; } int [ ] a = new int [ 26 ] ; for ( char b : c ) { if ( b == ' \\0' ) continue ; a [ b - ' a ' ] ++ ; } a [ ch - ' a ' ] -- ; for ( int i = ans . length ( ) + 1 ; i < s . length ( ) ; i ++ ) { int idx = s . charAt ( i ) - ' a ' ; if ( a [ idx ] > 0 ) { a [ idx ] -- ; } else { diff ++ ; } } return diff ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; char s [ ] = sc . next ( ) . toCharArray ( ) ; char t [ ] = s . clone ( ) ; char ans [ ] = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { Arrays . sort ( t , i , n ) ; for ( int j = i ; j < n ; j ++ ) { ans [ i ] = t [ j ] ; t [ j ] = t [ i ] ; int diff = count1 ( s , ans , i + 1 ) + count2 ( s , t , i + 1 , n ) ; if ( diff <= k ) { break ; } t [ j ] = ans [ i ] ; } } System . out . println ( ans ) ; } private int count1 ( char sr [ ] , char tg [ ] , int e ) { int diff = 0 ; for ( int i = 0 ; i < e ; i ++ ) { if ( sr [ i ] != tg [ i ] ) { diff ++ ; } } return diff ; } private int count2 ( char sr [ ] , char tg [ ] , int s , int e ) { int diff = e - s ; int i = 0 ; int j = 0 ; char src [ ] = Arrays . copyOfRange ( sr , s , e ) ; char tgt [ ] = Arrays . copyOfRange ( tg , s , e ) ; Arrays . sort ( src ) ; Arrays . sort ( tgt ) ; while ( i < src . length && j < tgt . length ) { if ( src [ i ] < tgt [ j ] ) { i ++ ; } else if ( src [ i ] > tgt [ j ] ) { j ++ ; } else { diff -- ; i ++ ; j ++ ; } } return diff ; } 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 String S ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . nextLine ( ) ; S = sc . nextLine ( ) ; char [ ] c = S . toCharArray ( ) ; Arrays . sort ( c ) ; String ans = \" \" ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( c [ j ] == ' \\0' ) continue ; if ( count ( ans , c , c [ j ] ) > K ) continue ; ans += c [ j ] ; c [ j ] = ' \\0' ; break ; } } System . out . println ( ans ) ; } private static int count ( String ans , char [ ] c , char ch ) { int diff = 0 ; for ( int i = 0 ; i < ans . length ( ) ; i ++ ) { diff += S . charAt ( i ) == ans . charAt ( i ) ? 0 : 1 ; } if ( ch != S . charAt ( ans . length ( ) ) ) diff ++ ; int [ ] a = new int [ 26 ] ; for ( char b : c ) { if ( b == ' \\0' ) continue ; a [ b - ' a ' ] ++ ; } a [ ch - ' a ' ] -- ; for ( int i = ans . length ( ) + 1 ; i < S . length ( ) ; i ++ ) { int idx = S . charAt ( i ) - ' a ' ; if ( a [ idx ] > 0 ) { a [ idx ] -- ; } else { diff ++ ; } } return diff ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] nk = scanner . nextLine ( ) . split ( \" ▁ \" , 2 ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; String s = scanner . nextLine ( ) ; char [ ] orig = s . toCharArray ( ) ; char [ ] chars = s . toCharArray ( ) ; if ( k == chars . length ) { Arrays . sort ( chars ) ; System . out . println ( new String ( chars ) ) ; return ; } for ( int i = 0 ; i < chars . length ; i ++ ) { int minI = i ; for ( int j = i + 1 ; j < chars . length ; j ++ ) { if ( chars [ minI ] > chars [ j ] ) { char tmp = chars [ i ] ; chars [ i ] = chars [ j ] ; chars [ j ] = tmp ; int count = replaceCount ( orig , chars ) ; if ( count <= k ) { minI = j ; } tmp = chars [ i ] ; chars [ i ] = chars [ j ] ; chars [ j ] = tmp ; } } if ( i != minI ) { char tmp = chars [ i ] ; chars [ i ] = chars [ minI ] ; chars [ minI ] = tmp ; } } System . out . println ( new String ( chars ) ) ; } private static int replaceCount ( char [ ] orig , char [ ] chars ) { int count = 0 ; for ( int i = 0 ; i < orig . length ; i ++ ) { if ( orig [ i ] != chars [ i ] ) { count ++ ; } } return count ; } }", "import java . util . LinkedList ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] ans = new char [ n ] ; LinkedList < Character > list = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( s [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { PriorityQueue < Character > pq = new PriorityQueue < > ( ) ; for ( int j = 0 ; j < list . size ( ) ; j ++ ) { pq . add ( list . get ( j ) ) ; } loop : while ( true ) { char first = pq . poll ( ) ; int tmp = k ; LinkedList < Character > tmpList = ( LinkedList < Character > ) list . clone ( ) ; tmpList . remove ( ( Character ) first ) ; if ( first != s [ i ] ) { tmp -- ; if ( tmp < 0 ) continue ; } for ( int j = i + 1 ; j < n ; j ++ ) { if ( tmpList . contains ( ( Character ) s [ j ] ) ) { tmpList . remove ( ( Character ) s [ j ] ) ; } else { tmp -- ; if ( tmp < 0 ) continue loop ; } } if ( first != s [ i ] ) k -- ; ans [ i ] = first ; list . remove ( ( Character ) first ) ; break ; } } System . out . println ( String . valueOf ( ans ) ) ; sc . close ( ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "from copy import copy NEW_LINE def main ( ) : NEW_LINE INDENT n , k = map ( int , input ( ) . split ( ) ) NEW_LINE s = list ( input ( ) ) NEW_LINE print ( \" \" . join ( smallest ( k , s , s ) ) ) NEW_LINE DEDENT def smallest ( k , s , avail ) : NEW_LINE INDENT assert len ( s ) == len ( avail ) NEW_LINE assert k >= 0 NEW_LINE if len ( s ) == 1 : NEW_LINE INDENT return avail NEW_LINE DEDENT else : NEW_LINE INDENT for x in sorted ( avail ) : NEW_LINE INDENT k2 = k if x == s [ 0 ] else k - 1 NEW_LINE if is_possible ( k2 , s [ 1 : ] , sub ( avail , x ) ) : NEW_LINE INDENT return [ x ] + smallest ( k2 , s [ 1 : ] , sub ( avail , x ) ) NEW_LINE DEDENT DEDENT raise Exception NEW_LINE DEDENT DEDENT def is_possible ( k , s , avail ) : NEW_LINE INDENT return diff_multisets ( s , avail ) <= k NEW_LINE DEDENT def diff_multisets ( s , t ) : NEW_LINE INDENT assert len ( s ) == len ( t ) NEW_LINE ss = copy ( s ) NEW_LINE tt = copy ( t ) NEW_LINE for x in ss : NEW_LINE INDENT if x in tt : NEW_LINE INDENT i = tt . index ( x ) NEW_LINE tt = tt [ : i ] + tt [ i + 1 : ] NEW_LINE DEDENT DEDENT return len ( tt ) NEW_LINE DEDENT def sub ( li , x ) : NEW_LINE INDENT assert x in li NEW_LINE i = li . index ( x ) NEW_LINE return li [ : i ] + li [ i + 1 : ] NEW_LINE DEDENT main ( ) NEW_LINE", "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 random NEW_LINE def LI ( ) : return list ( map ( int , input ( ) . 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 ( ) ) [ : - 1 ] 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 score ( x ) : NEW_LINE INDENT res = 0 NEW_LINE for i in d . keys ( ) : NEW_LINE INDENT res += min ( c [ i ] , d [ i ] ) NEW_LINE DEDENT return x - res NEW_LINE DEDENT n , k = LI ( ) NEW_LINE s = S ( ) NEW_LINE t = [ ] NEW_LINE l = [ 1 for i in range ( n ) ] NEW_LINE c = defaultdict ( int ) NEW_LINE d = defaultdict ( int ) NEW_LINE for i in s : NEW_LINE INDENT c [ i ] += 1 NEW_LINE d [ i ] += 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT c [ s [ i ] ] -= 1 NEW_LINE for j in sorted ( list ( d . keys ( ) ) ) : NEW_LINE INDENT if d [ j ] : NEW_LINE INDENT d [ j ] -= 1 NEW_LINE sc = score ( n - i - 1 ) NEW_LINE if k >= sc : NEW_LINE INDENT if s [ i ] == j : NEW_LINE INDENT t . append ( j ) NEW_LINE break NEW_LINE DEDENT elif k > sc : NEW_LINE INDENT k -= 1 NEW_LINE t . append ( j ) NEW_LINE break NEW_LINE DEDENT DEDENT d [ j ] += 1 NEW_LINE DEDENT DEDENT DEDENT for i in t : NEW_LINE INDENT print ( i , end = \" \" ) NEW_LINE DEDENT print ( ) NEW_LINE NEW_LINE", "from copy import deepcopy as dc NEW_LINE import sys NEW_LINE def swap ( a , b , l ) : NEW_LINE INDENT s = dc ( l ) NEW_LINE s [ a ] , s [ b ] = s [ b ] , s [ a ] NEW_LINE return s NEW_LINE DEDENT def diff ( e , d ) : NEW_LINE INDENT cnt = 0 NEW_LINE for i in range ( len ( e ) ) : NEW_LINE INDENT if e [ i ] != d [ i ] : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT input = sys . stdin . readline NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE S = input ( ) [ : - 1 ] NEW_LINE m = list ( S ) NEW_LINE c = [ i for i in m ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT x = i NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT if ( c [ x ] > c [ j ] ) and ( diff ( m , swap ( i , j , c ) ) <= k ) : NEW_LINE INDENT x = j NEW_LINE DEDENT DEDENT c = swap ( i , x , c ) NEW_LINE DEDENT print ( \" \" . join ( c ) ) NEW_LINE", "import sys NEW_LINE from collections import Counter NEW_LINE inp = sys . stdin . readline NEW_LINE N , K = map ( int , inp ( ) . split ( ) ) NEW_LINE S = inp ( ) . replace ( \" \\n \" , \" \" ) NEW_LINE sort_S = sorted ( S ) NEW_LINE T = \" \" NEW_LINE cnt = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT count = Counter ( S [ : i + 1 ] ) - Counter ( list ( T ) ) NEW_LINE sum_ = sum ( count . values ( ) ) NEW_LINE for ss in sort_S : NEW_LINE INDENT if ( ss != S [ i ] ) : NEW_LINE INDENT miss = cnt + 1 NEW_LINE DEDENT else : NEW_LINE INDENT miss = cnt NEW_LINE DEDENT if ( count [ ss ] > 0 ) : NEW_LINE INDENT dif = sum_ - 1 NEW_LINE DEDENT else : NEW_LINE INDENT dif = sum_ NEW_LINE DEDENT if ( miss + dif <= K ) : NEW_LINE INDENT T += ss NEW_LINE sort_S . remove ( ss ) NEW_LINE cnt = miss NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( T ) NEW_LINE", "def replace ( s : list , a ) : NEW_LINE INDENT s = list ( s ) NEW_LINE i = s . index ( a ) NEW_LINE s [ 0 ] , s [ i ] = s [ i ] , s [ 0 ] NEW_LINE return s NEW_LINE DEDENT def adopt ( s : list , s0 : list ) : NEW_LINE INDENT res = [ 0 ] * len ( s ) NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s0 [ i ] in s : NEW_LINE INDENT res [ i ] = s0 [ i ] NEW_LINE s [ s . index ( s0 [ i ] ) ] = 0 NEW_LINE DEDENT DEDENT import collections NEW_LINE rest = collections . deque ( [ c for c in s if c != 0 ] ) NEW_LINE for i in range ( 0 , len ( res ) ) : NEW_LINE INDENT if res [ i ] == 0 : NEW_LINE INDENT res [ i ] = rest . pop ( ) NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE s = list ( input ( ) ) NEW_LINE s0 = list ( s ) NEW_LINE for pos in range ( len ( s ) ) : NEW_LINE INDENT pq = sorted ( s [ pos : ] ) NEW_LINE for a in pq : NEW_LINE INDENT t = replace ( s [ pos : ] , a ) [ 1 : ] NEW_LINE t = adopt ( t , s0 [ pos + 1 : ] ) NEW_LINE ss = s [ : pos ] + [ a ] + t NEW_LINE kk = sum ( [ ss [ i ] != s0 [ i ] for i in range ( len ( ss ) ) ] ) NEW_LINE if kk > K : NEW_LINE INDENT continue NEW_LINE DEDENT if len ( t ) != 0 : NEW_LINE INDENT s = ss NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( \" \" . join ( s ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc119_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) , q = sc . nextInt ( ) ; TreeSet < Long > t = new TreeSet < Long > ( ) , s = new TreeSet < Long > ( ) ; for ( int i = 0 ; i < a ; i ++ ) s . add ( sc . nextLong ( ) ) ; for ( int i = 0 ; i < b ; i ++ ) t . add ( sc . nextLong ( ) ) ; for ( int i = 0 ; i < q ; i ++ ) { long pos = sc . nextLong ( ) ; Long tl = t . floor ( pos ) , tr = t . ceiling ( pos ) , sl = s . floor ( pos ) , sr = s . ceiling ( pos ) ; if ( tl == null ) tl = - 1L << 60 ; if ( tr == null ) tr = 1L << 60 ; if ( sl == null ) sl = - 1L << 60 ; if ( sr == null ) sr = 1L << 60 ; Long min = 1L << 60 ; min = Math . min ( Math . max ( pos - tl , pos - sl ) , Math . max ( tr - pos , sr - pos ) ) ; min = Math . min ( min , ( pos - tl ) + ( sr - pos ) + Math . min ( ( pos - tl ) , ( sr - pos ) ) ) ; min = Math . min ( min , ( tr - pos ) + ( pos - sl ) + Math . min ( ( tr - pos ) , ( pos - sl ) ) ) ; System . out . println ( min ) ; } } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; long [ ] a1 = new long [ a + 2 ] ; long [ ] b1 = new long [ b + 2 ] ; a1 [ 0 ] = b1 [ 0 ] = Long . MIN_VALUE ; a1 [ a + 1 ] = b1 [ b + 1 ] = Long . MAX_VALUE / 2 ; long [ ] ans1 = new long [ q ] ; for ( int i = 1 ; i <= a ; i ++ ) { a1 [ i ] = sc . nextLong ( ) ; } for ( int i = 1 ; i <= b ; i ++ ) { b1 [ i ] = sc . nextLong ( ) ; } for ( int k = 0 ; k < q ; k ++ ) { long x = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; int idxa = - Arrays . binarySearch ( a1 , x ) - 1 ; int [ ] a2 = { idxa , ( idxa == 1 ) ? a + 1 : idxa - 1 } ; int idxb = - Arrays . binarySearch ( b1 , x ) - 1 ; int [ ] b2 = { idxb , ( idxb == 1 ) ? b + 1 : idxb - 1 } ; for ( int i : a2 ) { for ( int j : b2 ) { ans = Math . min ( ans , Math . abs ( a1 [ i ] - x ) + Math . abs ( a1 [ i ] - b1 [ j ] ) ) ; ans = Math . min ( ans , Math . abs ( b1 [ j ] - x ) + Math . abs ( a1 [ i ] - b1 [ j ] ) ) ; } } ans1 [ k ] = ans ; } for ( int i = 0 ; i < q ; i ++ ) { System . out . println ( ans1 [ i ] ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { long inf = ( long ) Math . pow ( 10 , 11 ) ; Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; long [ ] s = new long [ A + 2 ] ; s [ 0 ] = - inf ; s [ A + 1 ] = inf ; for ( int i = 1 ; i < A + 1 ; i ++ ) s [ i ] = sc . nextLong ( ) ; long [ ] t = new long [ B + 2 ] ; t [ 0 ] = - inf ; t [ B + 1 ] = inf ; for ( int i = 1 ; i < B + 1 ; i ++ ) t [ i ] = sc . nextLong ( ) ; long [ ] x = new long [ Q ] ; for ( int i = 0 ; i < Q ; i ++ ) x [ i ] = sc . nextLong ( ) ; for ( int i = 0 ; i < Q ; i ++ ) { int b = Math . abs ( Arrays . binarySearch ( s , x [ i ] ) ) - 1 ; int d = Math . abs ( Arrays . binarySearch ( t , x [ i ] ) ) - 1 ; long res = inf ; for ( int j = b - 1 ; j <= b ; j ++ ) { for ( int k = d - 1 ; k <= d ; k ++ ) { long d1 = Math . abs ( s [ j ] - x [ i ] ) + Math . abs ( s [ j ] - t [ k ] ) ; long d2 = Math . abs ( t [ k ] - x [ i ] ) + Math . abs ( s [ j ] - t [ k ] ) ; res = Math . min ( res , Math . min ( d1 , d2 ) ) ; } } System . out . println ( res ) ; } } }" ]
[ "from bisect import bisect_left NEW_LINE a , b , q = map ( int , input ( ) . split ( ) ) NEW_LINE inf = float ( ' inf ' ) NEW_LINE S = [ - inf ] + [ int ( input ( ) ) for i in range ( a ) ] + [ inf ] NEW_LINE T = [ - inf ] + [ int ( input ( ) ) for i in range ( b ) ] + [ inf ] NEW_LINE def f ( S , T ) : NEW_LINE INDENT res = 10 ** 30 NEW_LINE s = bisect_left ( S , x ) NEW_LINE ans = 0 NEW_LINE t = bisect_left ( T , S [ s - 1 ] ) NEW_LINE ans += abs ( x - S [ s - 1 ] ) + min ( abs ( S [ s - 1 ] - T [ t - 1 ] ) , abs ( S [ s - 1 ] - T [ t ] ) ) NEW_LINE if ans <= res : NEW_LINE INDENT res = ans NEW_LINE DEDENT ans = 0 NEW_LINE t = bisect_left ( T , S [ s ] ) NEW_LINE ans += abs ( x - S [ s ] ) + min ( abs ( S [ s ] - T [ t - 1 ] ) , abs ( S [ s ] - T [ t ] ) ) NEW_LINE if ans <= res : NEW_LINE INDENT res = ans NEW_LINE DEDENT return res NEW_LINE DEDENT for i in range ( q ) : NEW_LINE INDENT x = int ( input ( ) ) NEW_LINE print ( min ( f ( S , T ) , f ( T , S ) ) ) NEW_LINE DEDENT", "A , B , Q = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ ] NEW_LINE t = [ ] NEW_LINE x = [ ] NEW_LINE for _ in range ( A ) : NEW_LINE INDENT s . append ( int ( input ( ) ) ) NEW_LINE DEDENT for _ in range ( B ) : NEW_LINE INDENT t . append ( int ( input ( ) ) ) NEW_LINE DEDENT for _ in range ( Q ) : NEW_LINE INDENT x . append ( int ( input ( ) ) ) NEW_LINE DEDENT import sys NEW_LINE INT_MAX = sys . maxsize NEW_LINE s . insert ( 0 , - 1 * INT_MAX ) NEW_LINE s . append ( INT_MAX ) NEW_LINE t . insert ( 0 , - 1 * INT_MAX ) NEW_LINE t . append ( INT_MAX ) NEW_LINE import bisect NEW_LINE for xi in x : NEW_LINE INDENT si = bisect . bisect_right ( s , xi ) NEW_LINE ti = bisect . bisect_right ( t , xi ) NEW_LINE sa = s [ si ] NEW_LINE ta = t [ ti ] NEW_LINE sb = s [ si - 1 ] NEW_LINE tb = t [ ti - 1 ] NEW_LINE ans = min ( [ abs ( xi - sa ) + abs ( sa - ta ) , abs ( xi - sa ) + abs ( sa - tb ) , abs ( xi - sb ) + abs ( sb - ta ) , abs ( xi - sb ) + abs ( sb - tb ) , abs ( xi - ta ) + abs ( ta - sa ) , abs ( xi - ta ) + abs ( ta - sb ) , abs ( xi - tb ) + abs ( tb - sa ) , abs ( xi - tb ) + abs ( tb - sb ) ] ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "import sys NEW_LINE def solve ( N : int , M : int , Q : int , s : \" List [ int ] \" , t : \" List [ int ] \" , x : \" List [ int ] \" ) : NEW_LINE INDENT def binary_search ( ary , val ) : NEW_LINE INDENT n = len ( ary ) NEW_LINE l = - 1 NEW_LINE r = n NEW_LINE while r - l > 1 : NEW_LINE INDENT mid = ( l + r ) // 2 NEW_LINE if ary [ mid ] >= val : NEW_LINE INDENT r = mid NEW_LINE DEDENT else : NEW_LINE INDENT l = mid NEW_LINE DEDENT DEDENT if l == - 1 : NEW_LINE INDENT return [ ary [ 0 ] ] NEW_LINE DEDENT if r == n : NEW_LINE INDENT return [ ary [ n - 1 ] ] NEW_LINE DEDENT return [ ary [ l ] , ary [ r ] ] NEW_LINE DEDENT for q in x : NEW_LINE INDENT ret = float ( ' inf ' ) NEW_LINE a_pos = binary_search ( s , q ) NEW_LINE b_pos = binary_search ( t , q ) NEW_LINE for a in a_pos : NEW_LINE INDENT for b in b_pos : NEW_LINE INDENT ret = min ( ret , abs ( a - q ) + abs ( b - a ) ) NEW_LINE ret = min ( ret , abs ( b - q ) + abs ( a - b ) ) NEW_LINE DEDENT DEDENT print ( ret ) NEW_LINE DEDENT return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE Q = int ( next ( tokens ) ) NEW_LINE s = [ int ( next ( tokens ) ) for _ in range ( A ) ] NEW_LINE t = [ int ( next ( tokens ) ) for _ in range ( B ) ] NEW_LINE x = [ int ( next ( tokens ) ) for _ in range ( Q ) ] NEW_LINE solve ( A , B , Q , s , t , x ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "from bisect import bisect_left NEW_LINE def solve ( string ) : NEW_LINE INDENT a , b , q , * stx = map ( int , string . split ( ) ) NEW_LINE s = [ - 10 ** 10 ] + stx [ : a ] + [ 2 * 10 ** 10 ] NEW_LINE t = [ - 10 ** 10 ] + stx [ a : a + b ] + [ 2 * 10 ** 10 ] NEW_LINE x = dict ( [ ] ) NEW_LINE ans = [ ] NEW_LINE i_s = 0 NEW_LINE i_t = 0 NEW_LINE for _x in sorted ( stx [ - q : ] ) : NEW_LINE INDENT while s [ i_s ] < _x : NEW_LINE INDENT i_s += 1 NEW_LINE DEDENT while t [ i_t ] < _x : NEW_LINE INDENT i_t += 1 NEW_LINE DEDENT ls , rs = _x - s [ i_s - 1 ] , s [ i_s ] - _x NEW_LINE lt , rt = _x - t [ i_t - 1 ] , t [ i_t ] - _x NEW_LINE r_max = rs if rs > rt else rt NEW_LINE l_max = ls if ls > lt else lt NEW_LINE x [ _x ] = str ( min ( r_max , l_max , rt + ls + ( rt if rt < ls else ls ) , rs + lt + ( rs if rs < lt else lt ) ) ) NEW_LINE DEDENT return \" \\n \" . join ( [ x [ _x ] for _x in stx [ - q : ] ] ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n , m , l = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( ' { } ▁ { } ▁ { } \\n ' . format ( n , m , l ) + ' \\n ' . join ( [ input ( ) for _ in range ( n + m + l ) ] ) ) ) NEW_LINE DEDENT", "import itertools NEW_LINE A , B , Q = [ int ( _ ) for _ in input ( ) . split ( \" ▁ \" ) ] NEW_LINE s_array = [ int ( input ( ) ) for _ in range ( A ) ] NEW_LINE t_array = [ int ( input ( ) ) for _ in range ( B ) ] NEW_LINE x = [ int ( input ( ) ) for _ in range ( Q ) ] NEW_LINE def binary_search ( arr , point , start , end ) : NEW_LINE INDENT pivot = ( start + end ) // 2 NEW_LINE if end - start > 1 : NEW_LINE INDENT if arr [ pivot ] < point : NEW_LINE INDENT return binary_search ( arr , point , pivot , end ) NEW_LINE DEDENT else : NEW_LINE INDENT return binary_search ( arr , point , start , pivot ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return start NEW_LINE DEDENT DEDENT def find_closest_path ( s_1 , s_2 , t_1 , t_2 , point ) : NEW_LINE INDENT shortest = 10 ** 11 NEW_LINE for s , t in itertools . product ( [ s_1 , s_2 ] , [ t_1 , t_2 ] ) : NEW_LINE INDENT length = min ( abs ( point - t ) , abs ( point - s ) ) + abs ( s - t ) NEW_LINE if length < shortest : NEW_LINE INDENT shortest = length NEW_LINE DEDENT DEDENT return shortest NEW_LINE DEDENT for i in range ( Q ) : NEW_LINE INDENT s_idx = binary_search ( s_array , x [ i ] , 0 , len ( s_array ) - 1 ) NEW_LINE t_idx = binary_search ( t_array , x [ i ] , 0 , len ( t_array ) - 1 ) NEW_LINE if len ( s_array ) > 1 : NEW_LINE INDENT s_1 , s_2 = s_array [ s_idx ] , s_array [ s_idx + 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT s_1 , s_2 = s_array [ 0 ] , s_array [ 0 ] NEW_LINE DEDENT if len ( t_array ) > 1 : NEW_LINE INDENT t_1 , t_2 = t_array [ t_idx ] , t_array [ t_idx + 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT t_1 , t_2 = t_array [ 0 ] , t_array [ 0 ] NEW_LINE DEDENT answer = find_closest_path ( s_1 , s_2 , t_1 , t_2 , x [ i ] ) NEW_LINE print ( answer ) NEW_LINE DEDENT" ]
atcoder_abc030_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] st = sc . nextLine ( ) . split ( \" ▁ \" ) ; sc . close ( ) ; int n = Integer . parseInt ( st [ 0 ] ) ; int m = Integer . parseInt ( st [ 1 ] ) ; n = n >= 12 ? n - 12 : n ; double shortHand = ( n * 30 ) + ( m * 0.5 ) ; double longHand = m * 6 ; double ans = Math . abs ( shortHand - longHand ) ; ans = ans > 180 ? Math . abs ( 360 - ans ) : ans ; System . out . println ( ans ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { double a = ( in . nextDouble ( ) % 12 ) * 30.0 ; double b = in . nextDouble ( ) * 6.0 ; a += ( 30.0 * ( b / 360.0 ) ) ; double d = Math . abs ( a - b ) ; out . println ( Math . min ( d , 360.0 - d ) ) ; } } 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 . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] line = scanner . nextLine ( ) . split ( \" ▁ \" , 2 ) ; int n = Integer . parseInt ( line [ 0 ] ) ; int m = Integer . parseInt ( line [ 1 ] ) ; double n60 = ( ( double ) ( n % 12 ) + ( ( double ) m / 60.0 ) ) * 5.0 ; double diff = Math . abs ( n60 - ( double ) m ) ; if ( diff > 30.0 ) { diff = 60.0 - diff ; } System . out . println ( 6.0 * diff ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { double n = in . ints ( ) % 12 * 30 , m = in . ints ( ) * 6 ; n += m / 12 ; out . println ( Math . min ( ( n - m + 360 ) % 360 , ( m - n + 360 ) % 360 ) ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; double rad = Math . abs ( ( double ) ( sc . nextInt ( ) % 12 ) * 30 - ( double ) sc . nextInt ( ) * ( 11.0 / 2 ) ) ; System . out . println ( Math . min ( rad , 360.0 - rad ) ) ; } }" ]
[ "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE n = n % 12 NEW_LINE n_angle = n * 30 + m * 0.5 NEW_LINE m_angle = m * 6 NEW_LINE print ( min ( abs ( n_angle - m_angle ) , 360 - abs ( n_angle - m_angle ) ) ) NEW_LINE", "def watch ( n : int , m : int ) -> float : NEW_LINE INDENT long_angle = ( n % 12 ) * ( 360 // 12 ) + m * ( 360 // 12 ) / 60 NEW_LINE shor_angle = m * 360 // 60 NEW_LINE angle_diff = abs ( long_angle - shor_angle ) NEW_LINE return min ( angle_diff , 360 - angle_diff ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE ans = watch ( n , m ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "n , m = map ( int , input ( ) . split ( ) ) NEW_LINE if abs ( ( 30 * n + 0.5 * m ) - 6 * m ) % 360 == 180 : NEW_LINE INDENT print ( 180 ) NEW_LINE exit ( ) NEW_LINE DEDENT if abs ( ( 30 * n + 0.5 * m ) - 6 * m ) % 360 == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT if abs ( ( 30 * n + 0.5 * m ) - 6 * m ) % 360 < 180 : NEW_LINE INDENT print ( abs ( ( 30 * n + 0.5 * m ) - 6 * m ) % 360 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 360 - abs ( ( 30 * n + 0.5 * m ) - 6 * m ) % 360 ) NEW_LINE DEDENT", "n , m = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE a = ( n % 12 / 12 ) * 360 + ( m / 60 ) * 30 NEW_LINE b = ( m / 60 ) * 360 NEW_LINE x = abs ( a - b ) NEW_LINE print ( min ( x , 360 - x ) ) NEW_LINE", "ji , fun = map ( int , input ( ) . split ( ) ) NEW_LINE if ( ji >= 12 ) : NEW_LINE INDENT ji -= 12 NEW_LINE DEDENT tanshin = 6 * fun NEW_LINE tyoushin = 30 * ji + 0.5 * fun NEW_LINE kakudo = abs ( tyoushin - tanshin ) NEW_LINE if ( kakudo >= 180 ) : NEW_LINE INDENT print ( 360 - kakudo ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( kakudo ) NEW_LINE DEDENT" ]
atcoder_abc015_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 ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] [ ] t = new int [ n ] [ k ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { t [ i ] [ j ] = sc . nextInt ( ) ; } } Queue < Integer > rank = new ArrayDeque < > ( ) ; Queue < Integer > q = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < k ; i ++ ) { q . add ( t [ 0 ] [ i ] ) ; rank . add ( 0 ) ; } while ( ! q . isEmpty ( ) ) { int p = q . poll ( ) ; int row = rank . poll ( ) ; if ( p == 0 ) { out . println ( \" Found \" ) ; exit ( 0 ) ; } for ( int i = 0 ; i < k && row < n - 1 ; i ++ ) { q . add ( p ^ t [ row + 1 ] [ i ] ) ; rank . add ( row + 1 ) ; } } out . println ( \" Nothing \" ) ; } }", "import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; static int n , k , a [ ] [ ] ; public static void main ( String [ ] $ ) { n = scanner . nextInt ( ) ; k = scanner . nextInt ( ) ; a = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , k ) . map ( j -> scanner . nextInt ( ) ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; System . out . println ( dfs ( 0 , 0 ) ? \" Found \" : \" Nothing \" ) ; } private static boolean dfs ( int d , int x ) { return d == n ? x == 0 : IntStream . range ( 0 , k ) . anyMatch ( i -> dfs ( d + 1 , x ^ a [ d ] [ i ] ) ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public boolean solve ( int n , int k , int [ ] [ ] ts ) { int [ ] selects = new int [ n ] ; Arrays . fill ( selects , 0 ) ; while ( true ) { int xor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { xor = xor ^ ts [ i ] [ selects [ i ] ] ; } if ( xor == 0 ) { return true ; } selects [ 0 ] ++ ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( selects [ i ] >= k ) { selects [ i ] = 0 ; selects [ i + 1 ] ++ ; } else { break ; } } if ( selects [ n - 1 ] >= k ) { break ; } } return false ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int ts [ ] [ ] = new int [ n ] [ k ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { ts [ i ] [ j ] = in . nextInt ( ) ; } } in . close ( ) ; Main main = new Main ( ) ; boolean ret = main . solve ( n , k , ts ) ; if ( ret ) { System . out . println ( \" Found \" ) ; } else { System . out . println ( \" Nothing \" ) ; } } }", "import java . util . Scanner ; public class Main { public static int N ; public static int K ; public static int [ ] [ ] T ; public static void main ( String [ ] args ) { readInput ( ) ; boolean hasBug = xor ( 0 , 0 , 0 ) ; if ( hasBug ) { System . out . println ( \" Found \" ) ; } else { System . out . println ( \" Nothing \" ) ; } } public static void readInput ( ) { try ( Scanner sc = new Scanner ( System . in ) ) { N = sc . nextInt ( ) ; K = sc . nextInt ( ) ; T = new int [ N + 1 ] [ K + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { T [ i ] [ j ] = sc . nextInt ( ) ; } } } } public static boolean xor ( int i , int j , int sum ) { if ( i > N ) { if ( sum == 0 ) { return true ; } else { return false ; } } sum ^= T [ i ] [ j ] ; boolean hasBug = false ; for ( int k = 1 ; k <= K ; k ++ ) { hasBug = hasBug || xor ( i + 1 , k , sum ) ; } return hasBug ; } }", "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 K = sc . nextInt ( ) ; int [ ] [ ] T = new int [ N ] [ K ] ; for ( int n = 0 ; n < N ; n ++ ) { for ( int k = 0 ; k < K ; k ++ ) { T [ n ] [ k ] = sc . nextInt ( ) ; } } if ( dfs ( T , N , K , 0 , - 1 ) ) { out . println ( \" Found \" ) ; } else { out . println ( \" Nothing \" ) ; } } public static boolean dfs ( int [ ] [ ] T , int N , int K , int n , int num ) { if ( n == 0 ) { for ( int k = 0 ; k < K ; k ++ ) { if ( dfs ( T , N , K , n + 1 , T [ n ] [ k ] ) ) { return true ; } } } else if ( n < N ) { for ( int k = 0 ; k < K ; k ++ ) { if ( dfs ( T , N , K , n + 1 , num ^ T [ n ] [ k ] ) ) { return true ; } } } else { if ( num == 0 ) { return true ; } } return false ; } }" ]
[ "from itertools import product NEW_LINE from functools import reduce NEW_LINE from operator import xor NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE T = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for _ in range ( N ) ] NEW_LINE flag = False NEW_LINE for i in product ( * T ) : NEW_LINE INDENT if reduce ( xor , i ) == 0 : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT print ( \" Found \" if flag else \" Nothing \" ) NEW_LINE", "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 T = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT row = inpl ( ) NEW_LINE T . append ( row ) NEW_LINE DEDENT flag = True NEW_LINE for row in product ( * T ) : NEW_LINE INDENT tmp = None NEW_LINE for i in row : NEW_LINE INDENT if tmp is None : NEW_LINE INDENT tmp = i NEW_LINE DEDENT else : NEW_LINE INDENT tmp = tmp ^ i NEW_LINE DEDENT DEDENT if tmp == 0 : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT print ( \" Nothing \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Found \" ) NEW_LINE DEDENT", "n , k = map ( int , input ( ) . split ( ) ) NEW_LINE tAll = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT tmp = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE tAll . append ( tmp ) NEW_LINE DEDENT for i in range ( 5 - n ) : NEW_LINE INDENT tAll . append ( [ 0 ] * k ) NEW_LINE DEDENT ans = \" Nothing \" NEW_LINE for a in range ( k ) : NEW_LINE INDENT for b in range ( k ) : NEW_LINE INDENT for c in range ( k ) : NEW_LINE INDENT for d in range ( k ) : NEW_LINE INDENT for e in range ( k ) : NEW_LINE INDENT if tAll [ 0 ] [ a ] ^ tAll [ 1 ] [ b ] ^ tAll [ 2 ] [ c ] ^ tAll [ 3 ] [ d ] ^ tAll [ 4 ] [ e ] == 0 : NEW_LINE INDENT ans = \" Found \" NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE t = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE def dfs ( q , x ) : NEW_LINE INDENT if q == n : NEW_LINE INDENT if x == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT for i in range ( k ) : NEW_LINE INDENT if dfs ( q + 1 , x ^ t [ q ] [ i ] ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT if dfs ( 0 , 0 ) : NEW_LINE INDENT print ( \" Found \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Nothing \" ) NEW_LINE DEDENT", "def tobi ( string ) : NEW_LINE INDENT return format ( int ( string ) , \"07b \" ) NEW_LINE DEDENT n , k = map ( int , input ( ) . split ( ) ) NEW_LINE T = [ list ( map ( tobi , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE flag = True NEW_LINE def bi5 ( inte , a , b ) : NEW_LINE INDENT ans = [ 0 ] * b NEW_LINE for i in range ( b - 1 , - 1 , - 1 ) : NEW_LINE INDENT if inte >= a ** i : NEW_LINE INDENT ans [ i ] = int ( inte / ( a ** i ) ) NEW_LINE inte = inte % a ** i NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT for i in range ( k ** n ) : NEW_LINE INDENT temp = [ 0 ] * 7 NEW_LINE for p , l in zip ( bi5 ( i , k , n ) , range ( n ) ) : NEW_LINE INDENT for t , m in zip ( T [ l ] [ p ] , range ( 7 ) ) : NEW_LINE INDENT temp [ m ] += int ( t ) NEW_LINE DEDENT DEDENT for j in range ( 7 ) : NEW_LINE INDENT temp [ j ] = temp [ j ] % 2 NEW_LINE DEDENT if sum ( temp ) == 0 : NEW_LINE INDENT print ( \" Found \" ) NEW_LINE flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT print ( \" Nothing \" ) NEW_LINE DEDENT" ]
atcoder_abc035_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int x = 0 ; int y = 0 ; int uk = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { switch ( s . substring ( i , i + 1 ) ) { case \" R \" : x ++ ; break ; case \" L \" : x -- ; break ; case \" D \" : y -- ; break ; case \" U \" : y ++ ; break ; case \" ? \" : uk ++ ; break ; } } int ans = Math . abs ( x ) + Math . abs ( y ) ; int t = sc . nextInt ( ) ; if ( t == 1 ) System . out . println ( ans + uk ) ; else { if ( ans >= uk ) System . out . println ( ans - uk ) ; else System . out . println ( ( uk - ans ) % 2 ) ; } } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String s = in . string ( ) ; int p = 0 ; int x = 0 , y = 0 ; for ( char c : s . toCharArray ( ) ) { switch ( c ) { case ' L ' : x -- ; break ; case ' R ' : x ++ ; break ; case ' U ' : y ++ ; break ; case ' D ' : y -- ; break ; case ' ? ' : p ++ ; break ; } } int t = in . ints ( ) ; int total = Math . abs ( x ) + Math . abs ( y ) ; if ( t == 2 ) { if ( total > p ) { out . println ( total - p ) ; } else { out . println ( ( p - total ) % 2 ) ; } } else { out . println ( total + p ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }", "import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int T = scanner . nextInt ( ) ; int x = 0 ; int y = 0 ; int count = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == ' L ' ) { x += - 1 ; } if ( S . charAt ( i ) == ' R ' ) { x += 1 ; } if ( S . charAt ( i ) == ' U ' ) { y += 1 ; } if ( S . charAt ( i ) == ' D ' ) { y += - 1 ; } if ( S . charAt ( i ) == ' ? ' ) { count ++ ; } } if ( T == 1 ) { System . out . println ( Math . abs ( x ) + Math . abs ( y ) + count ) ; } if ( T == 2 ) { if ( Math . abs ( x ) + Math . abs ( y ) - count >= 0 ) { System . out . println ( Math . abs ( x ) + Math . abs ( y ) - count ) ; } else if ( Math . abs ( x ) + Math . abs ( y ) - count < 0 && ( Math . abs ( x ) + Math . abs ( y ) ) % 2 == count % 2 ) { System . out . println ( 0 ) ; } else { System . out . println ( 1 ) ; } } } }", "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 t = sc . nextInt ( ) ; int lr = 0 ; int ud = 0 ; int qc = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' L ' ) { lr -- ; } else if ( s . charAt ( i ) == ' R ' ) { lr ++ ; } else if ( s . charAt ( i ) == ' D ' ) { ud -- ; } else if ( s . charAt ( i ) == ' U ' ) { ud ++ ; } else { qc ++ ; } } if ( lr < 0 ) { lr = lr * ( - 1 ) ; } if ( ud < 0 ) { ud = ud * ( - 1 ) ; } if ( t == 1 ) { System . out . println ( lr + ud + qc ) ; } else { if ( qc >= lr + ud ) { System . out . println ( ( qc - ( lr + ud ) ) % 2 ) ; } else { System . out . println ( lr + ud - qc ) ; } } sc . close ( ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String po = sc . nextLine ( ) ; int n = sc . nextInt ( ) ; int count = 0 ; int x = 0 , y = 0 ; String s [ ] = po . split ( \" \" , 0 ) ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] . equals ( \" U \" ) ) y -- ; else if ( s [ i ] . equals ( \" D \" ) ) y ++ ; else if ( s [ i ] . equals ( \" R \" ) ) x ++ ; else if ( s [ i ] . equals ( \" L \" ) ) x -- ; else count ++ ; } int h = Math . abs ( x ) + Math . abs ( y ) ; System . out . println ( ( n == 1 ) ? h + count : ( h < count ) ? ( ( h - count ) % 2 == 0 ) ? 0 : 1 : h - count ) ; } }" ]
[ "import math 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 zeros2 ( n , m ) : return [ zeros ( m ) for i in range ( n ) ] NEW_LINE class Debug ( ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . debug = True NEW_LINE DEDENT def off ( self ) : NEW_LINE INDENT self . debug = False NEW_LINE DEDENT def dmp ( self , x , cmt = ' ' ) : NEW_LINE INDENT if self . debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT 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 d . dmp ( ( S ) , ' S ' ) NEW_LINE T = getInt ( ) NEW_LINE d . dmp ( ( T ) , ' T ' ) NEW_LINE x , y , q = 0 , 0 , 0 NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i ] == ' R ' : NEW_LINE INDENT x += 1 NEW_LINE DEDENT elif S [ i ] == ' L ' : NEW_LINE INDENT x -= 1 NEW_LINE DEDENT elif S [ i ] == ' U ' : NEW_LINE INDENT y += 1 NEW_LINE DEDENT elif S [ i ] == ' D ' : NEW_LINE INDENT y -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT q += 1 NEW_LINE DEDENT DEDENT val = abs ( x ) + abs ( y ) NEW_LINE if T == 1 : NEW_LINE INDENT val += q NEW_LINE DEDENT else : NEW_LINE INDENT if val >= q : NEW_LINE INDENT val -= q NEW_LINE DEDENT else : NEW_LINE INDENT val = ( q - val ) % 2 NEW_LINE DEDENT DEDENT return val NEW_LINE DEDENT ans = prob ( ) NEW_LINE print ( ans ) NEW_LINE", "s = input ( ) NEW_LINE x = abs ( s . count ( ' R ' ) - s . count ( ' L ' ) ) + abs ( s . count ( ' U ' ) - s . count ( ' D ' ) ) NEW_LINE c = s . count ( ' ? ' ) NEW_LINE if int ( input ( ) ) == 1 : NEW_LINE INDENT print ( x + c ) NEW_LINE DEDENT elif c <= x : NEW_LINE INDENT print ( x - c ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( x + c ) % 2 ) NEW_LINE DEDENT", "s = list ( input ( ) ) NEW_LINE t = int ( input ( ) ) NEW_LINE x = 0 NEW_LINE y = 0 NEW_LINE d = 0 NEW_LINE count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' L ' : NEW_LINE INDENT x -= 1 NEW_LINE DEDENT elif s [ i ] == ' R ' : NEW_LINE INDENT x += 1 NEW_LINE DEDENT elif s [ i ] == ' U ' : NEW_LINE INDENT y += 1 NEW_LINE DEDENT elif s [ i ] == ' D ' : NEW_LINE INDENT y -= 1 NEW_LINE DEDENT elif s [ i ] == ' ? ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if t == 1 : NEW_LINE INDENT print ( max ( abs ( x + count ) + abs ( y ) , abs ( x ) + abs ( y + count ) , abs ( x - count ) + abs ( y ) , abs ( x ) + abs ( y - count ) ) ) NEW_LINE DEDENT elif t == 2 : NEW_LINE INDENT d = abs ( x ) + abs ( y ) NEW_LINE if d > count : NEW_LINE INDENT print ( d - count ) NEW_LINE DEDENT else : NEW_LINE INDENT if ( d - count ) % 2 == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT DEDENT DEDENT", "def drone ( S : int , T : int ) -> int : NEW_LINE INDENT d = { ' L ' : 0 , ' R ' : 0 , ' U ' : 0 , ' D ' : 0 , ' ? ' : 0 } NEW_LINE for c in S : NEW_LINE INDENT d [ c ] += 1 NEW_LINE DEDENT dx = abs ( d [ ' L ' ] - d [ ' R ' ] ) NEW_LINE dy = abs ( d [ ' U ' ] - d [ ' D ' ] ) NEW_LINE if T == 1 : NEW_LINE INDENT return dx + dy + d [ ' ? ' ] NEW_LINE DEDENT min_d = dx + dy - d [ ' ? ' ] NEW_LINE if min_d >= 0 : NEW_LINE INDENT return min_d NEW_LINE DEDENT return ( - min_d ) % 2 NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT S = input ( ) NEW_LINE T = int ( input ( ) ) NEW_LINE ans = drone ( S , T ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "s = list ( input ( ) ) NEW_LINE t = int ( input ( ) ) NEW_LINE c = [ 0 , 0 ] NEW_LINE for s_ in s : NEW_LINE INDENT if s_ == \" L \" : NEW_LINE INDENT c [ 0 ] += - 1 NEW_LINE DEDENT elif s_ == \" R \" : NEW_LINE INDENT c [ 0 ] += 1 NEW_LINE DEDENT elif s_ == \" U \" : NEW_LINE INDENT c [ 1 ] += 1 NEW_LINE DEDENT elif s_ == \" D \" : NEW_LINE INDENT c [ 1 ] += - 1 NEW_LINE DEDENT DEDENT ques = s . count ( \" ? \" ) NEW_LINE ans = abs ( c [ 0 ] ) + abs ( c [ 1 ] ) NEW_LINE if t == 1 : NEW_LINE INDENT ans += ques NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( ques ) : NEW_LINE INDENT if ans > 0 : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT elif ans == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_agc028_B
[ "import java . io . * ; import java . util . * ; public class Main { static final Reader in = new Reader ( ) ; static final long M = ( long ) 1e9 + 7 ; public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; long [ ] ps = new long [ n + 1 ] ; long nf = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { ps [ i ] = ( ps [ i - 1 ] + in . nextInt ( ) ) % M ; nf = nf * i % M ; } long ans = nf * ps [ n ] % M , s = 0 ; for ( int i = 1 ; i <= n - 1 ; ++ i ) { s = ( s + ps [ n - i ] - ps [ i ] + M ) % M ; ans = ( ans + nf * modI ( ( long ) ( i + 1 ) * ( i >= n - 1 ? 1 : i + 2 ) , M ) % M * 2 * s + nf * modI ( i + 1 , M ) % M * ( ps [ i ] + ps [ n ] - ps [ n - i ] + M ) ) % M ; } System . out . println ( ans ) ; } static long modI ( long a , long m ) { return ( a %= m ) <= 1 ? 1 : ( 1 - modI ( m % a , a ) * m ) / a + m ; } static class Reader { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int mod = ( ( int ) 1e9 ) + 7 ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } long k = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { k *= i ; k %= mod ; } long [ ] r = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { r [ i ] = ( r [ i - 1 ] + mod_pow ( i , mod - 2 , mod ) ) % mod ; } long res = 0L ; for ( int i = 0 ; i < n ; i ++ ) { res += ( r [ i + 1 ] + r [ n - i ] - r [ 1 ] ) * a [ i ] ; res %= mod ; } System . out . println ( res * k % mod ) ; } public static long mod_pow ( long x , long p , long m ) { long a = 1 ; while ( p > 0 ) { if ( p % 2 == 1 ) { a = a * x % m ; } x = x * x % m ; p /= 2 ; } return a ; } }", "import java . util . * ; class Main { static long mod = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long [ ] b = new long [ n + 1 ] ; b [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { b [ i ] = ( b [ i - 1 ] + pow ( i , mod - 2 ) ) % mod ; } long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += a [ i ] * ( b [ i + 1 ] + b [ n - i ] - 1 ) ; ans %= mod ; } for ( int i = 1 ; i <= n ; i ++ ) { ans *= i ; ans %= mod ; } System . out . println ( ans ) ; } static long pow ( long a , long p ) { if ( p == 0 ) return 1 ; else if ( p % 2 == 0 ) { long d = pow ( a , p / 2 ) ; return d * d % mod ; } else return pow ( a , p - 1 ) * a % mod ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { final long DIV = 1000000007 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } sc . close ( ) ; long [ ] p = new long [ n ] ; long [ ] sump = new long [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ i ] = inverseElement ( i + 1 , DIV ) ; sump [ i + 1 ] = sump [ i ] + p [ i ] ; sump [ i + 1 ] %= DIV ; } long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += a [ i ] * ( sump [ i - 0 + 1 ] + sump [ n - i ] - p [ 0 ] ) ; if ( ans < 0 ) ans += DIV * DIV ; if ( ans > 0 ) ans %= DIV ; } for ( int i = 0 ; i < n ; i ++ ) { ans *= ( i + 1 ) ; ans %= DIV ; } System . out . println ( ans ) ; } public static long inverseElement ( long a , long n ) { long b = n , u = 1 , v = 0 ; while ( b > 0 ) { long t = a / b ; a -= t * b ; u -= t * v ; t = a ; a = b ; b = t ; t = u ; u = v ; v = t ; } u = u % n ; if ( u < 0 ) u += n ; return u ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE F = 1 NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT F = F * i % mod NEW_LINE DEDENT D = [ 0 ] NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT D . append ( D [ - 1 ] + pow ( i , mod - 2 , mod ) ) NEW_LINE DEDENT L = [ 0 ] * N NEW_LINE for i in range ( N // 2 + N % 2 ) : NEW_LINE INDENT t = round ( F * ( D [ - 1 - i ] + D [ i ] + 1 ) ) % mod NEW_LINE L [ i ] = t NEW_LINE L [ - 1 - i ] = t NEW_LINE DEDENT Ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT Ans += L [ i ] * A [ i ] % mod NEW_LINE DEDENT print ( Ans % mod ) NEW_LINE", "import sys NEW_LINE fin = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 200000 ) NEW_LINE def factorial ( n , mod ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return n * factorial ( n - 1 , mod ) % mod NEW_LINE DEDENT DEDENT MOD = 10 ** 9 + 7 NEW_LINE N = int ( fin ( ) ) NEW_LINE A_list = [ int ( elem ) for elem in fin ( ) . split ( ) ] NEW_LINE fac_N = factorial ( N , MOD ) NEW_LINE inv_nums = [ fac_N * pow ( i , MOD - 2 , MOD ) % MOD for i in range ( 1 , N + 1 ) ] NEW_LINE cuml_inv_nums = [ inv_nums [ 0 ] ] NEW_LINE for inv_num in inv_nums [ 1 : ] : NEW_LINE INDENT cuml_inv_nums . append ( ( cuml_inv_nums [ - 1 ] + inv_num ) % MOD ) NEW_LINE DEDENT ans = 0 NEW_LINE for i , A in enumerate ( A_list ) : NEW_LINE INDENT ans += A * ( cuml_inv_nums [ i ] + cuml_inv_nums [ N - 1 - i ] - cuml_inv_nums [ 0 ] ) % MOD NEW_LINE ans %= MOD NEW_LINE DEDENT print ( ans ) NEW_LINE", "def power ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif b == 1 : NEW_LINE INDENT return a % 1000000007 NEW_LINE DEDENT elif b % 2 == 0 : NEW_LINE INDENT return ( power ( a , b // 2 ) ** 2 ) % 1000000007 NEW_LINE DEDENT else : NEW_LINE INDENT return ( power ( a , b // 2 ) ** 2 * a ) % 1000000007 NEW_LINE DEDENT DEDENT def divide ( a , b ) : NEW_LINE INDENT return ( a * power ( b , 1000000005 ) ) % 1000000007 NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE fac_lim = N NEW_LINE fac = [ None ] * ( fac_lim + 1 ) NEW_LINE fac [ 0 ] = 1 NEW_LINE for i in range ( fac_lim ) : NEW_LINE INDENT fac [ i + 1 ] = fac [ i ] * ( i + 1 ) NEW_LINE fac [ i + 1 ] = fac [ i + 1 ] % 1000000007 NEW_LINE DEDENT fs = [ 0 ] * ( N + 1 ) NEW_LINE fs [ 1 ] = fac [ N ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT fs [ i + 1 ] = fs [ i ] + divide ( fs [ 1 ] , i + 1 ) NEW_LINE fs [ i + 1 ] %= 1000000007 NEW_LINE DEDENT A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans += ( fs [ i + 1 ] + fs [ N - i ] - fs [ 1 ] ) * A [ i ] NEW_LINE ans %= 1000000007 NEW_LINE DEDENT print ( ans ) NEW_LINE", "def extgcd ( a , b ) : NEW_LINE INDENT r = [ 1 , 0 , a ] NEW_LINE w = [ 0 , 1 , b ] NEW_LINE while w [ 2 ] != 1 : NEW_LINE INDENT q = r [ 2 ] // w [ 2 ] NEW_LINE r2 = w NEW_LINE w2 = [ r [ 0 ] - q * w [ 0 ] , r [ 1 ] - q * w [ 1 ] , r [ 2 ] - q * w [ 2 ] ] NEW_LINE r = r2 NEW_LINE w = w2 NEW_LINE DEDENT return [ w [ 0 ] , w [ 1 ] ] NEW_LINE DEDENT def mod_inv ( a , m ) : NEW_LINE INDENT x = extgcd ( a , m ) [ 0 ] NEW_LINE return ( m + x % m ) % m NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE m = 10 ** 9 + 7 NEW_LINE r = [ 0 ] NEW_LINE w = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT w = ( w + mod_inv ( i , m ) ) % m NEW_LINE r . append ( w ) NEW_LINE DEDENT fact = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT fact = fact * i % m NEW_LINE DEDENT res = 0 NEW_LINE for j in range ( 1 , n + 1 ) : NEW_LINE INDENT sum_p = ( r [ j ] + r [ n - j + 1 ] - 1 ) % m NEW_LINE res = ( res + a [ j - 1 ] * sum_p * fact ) % m NEW_LINE DEDENT print ( res % m ) NEW_LINE", "from math import factorial NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE invsum = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT invsum [ i ] = ( invsum [ i - 1 ] + pow ( i , MOD - 2 , MOD ) ) % MOD NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT ans += ( A [ i - 1 ] * ( invsum [ i ] + invsum [ N - i + 1 ] - 1 ) ) % MOD NEW_LINE DEDENT ans *= factorial ( N ) NEW_LINE print ( ans % MOD ) NEW_LINE" ]
atcoder_abc021_C
[ "import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; private static int mod = 1000000007 ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , a = scanner . nextInt ( ) - 1 , b = scanner . nextInt ( ) - 1 , m = scanner . nextInt ( ) , aa [ ] [ ] = new int [ n ] [ n ] , ba [ ] [ ] = new int [ n ] [ n ] , ca [ ] [ ] = new int [ n ] [ n ] ; for ( int i = 0 , l , r ; i < m ; i ++ ) aa [ l = scanner . nextInt ( ) - 1 ] [ r = scanner . nextInt ( ) - 1 ] = aa [ r ] [ l ] = ba [ l ] [ r ] = ba [ r ] [ l ] = 1 ; System . out . println ( IntStream . range ( 0 , n ) . reduce ( 0 , ( a1 , b1 ) -> { if ( ba [ a ] [ b ] != 0 ) return ba [ a ] [ b ] ; IntStream . range ( 0 , n ) . forEach ( i -> IntStream . range ( 0 , n ) . forEach ( j -> ca [ i ] [ j ] = IntStream . range ( 0 , n ) . map ( k -> ba [ i ] [ k ] * aa [ k ] [ j ] ) . sum ( ) % mod ) ) ; IntStream . range ( 0 , n ) . forEach ( i -> IntStream . range ( 0 , n ) . forEach ( j -> ba [ i ] [ j ] = ca [ i ] [ j ] ) ) ; return ba [ a ] [ b ] ; } ) ) ; } }", "import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int N = sc . nextInt ( ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int mod = 1000000007 ; int [ ] min = new int [ N + 1 ] ; min [ a ] = 0 ; long [ ] count = new long [ N + 1 ] ; count [ a ] = 1 ; ArrayList < Integer > [ ] edge = new ArrayList [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) edge [ i ] = new ArrayList < > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; edge [ x ] . add ( y ) ; edge [ y ] . add ( x ) ; } Queue < Integer > q = new ArrayDeque < > ( ) ; q . add ( a ) ; Queue < Integer > dist = new ArrayDeque < > ( ) ; dist . add ( 0 ) ; while ( ! q . isEmpty ( ) ) { int vertex = q . poll ( ) ; int d = dist . poll ( ) ; for ( Integer child : edge [ vertex ] ) { if ( min [ child ] == 0 ) { q . add ( child ) ; dist . add ( d + 1 ) ; min [ child ] = d + 1 ; count [ child ] = count [ vertex ] ; } else if ( min [ child ] > d + 1 ) { min [ child ] = d + 1 ; count [ child ] = count [ vertex ] ; } else if ( min [ child ] == d + 1 ) { count [ child ] = ( count [ child ] + count [ vertex ] ) % mod ; } } } out . println ( count [ b ] ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int N = sc . nextInt ( ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int mod = 1000000007 ; int [ ] node = new int [ N + 1 ] ; node [ a ] = 1 ; long [ ] count = new long [ N + 1 ] ; count [ a ] = 1 ; ArrayList < Integer > [ ] edge = new ArrayList [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) edge [ i ] = new ArrayList < > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; edge [ x ] . add ( y ) ; edge [ y ] . add ( x ) ; } Queue < Integer > q = new ArrayDeque < > ( ) ; q . add ( a ) ; Queue < Integer > dist = new ArrayDeque < > ( ) ; dist . add ( 0 ) ; while ( ! q . isEmpty ( ) ) { int vertex = q . poll ( ) ; int d = dist . poll ( ) ; for ( Integer child : edge [ vertex ] ) { if ( node [ child ] == 0 ) { q . add ( child ) ; dist . add ( d + 1 ) ; node [ child ] = d + 1 ; } if ( node [ child ] == d + 1 ) count [ child ] = ( count [ child ] + count [ vertex ] ) % mod ; } } out . println ( count [ b ] ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .", "import java . util . Scanner ; public class Main { static int N ; static int a ; static int b ; static int q = 1000000007 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; a = scan . nextInt ( ) - 1 ; b = scan . nextInt ( ) - 1 ; int M = scan . nextInt ( ) ; int [ ] [ ] A = new int [ N ] [ N ] ; int [ ] [ ] B = new int [ N ] [ N ] ; for ( int i = 0 ; i < M ; i ++ ) { int x = scan . nextInt ( ) - 1 ; int y = scan . nextInt ( ) - 1 ; A [ x ] [ y ] = 1 ; A [ y ] [ x ] = 1 ; B [ x ] [ y ] = 1 ; B [ y ] [ x ] = 1 ; } scan . close ( ) ; int [ ] [ ] C = new int [ N ] [ N ] ; for ( int l = 0 ; l < N ; l ++ ) { if ( B [ a ] [ b ] != 0 ) { System . out . println ( B [ a ] [ b ] ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { int t = 0 ; for ( int k = 0 ; k < N ; k ++ ) { t += B [ i ] [ k ] * A [ k ] [ j ] ; } t = t % q ; C [ i ] [ j ] = t ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { B [ i ] [ j ] = C [ i ] [ j ] ; } } } } }", "import java . util . * ; public class Main { static int N ; static int M ; static int a , b ; static ArrayList < Integer > [ ] E ; static int INF = 1 << 30 ; static int MODP = 1000000007 ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; N = Integer . parseInt ( in . next ( ) ) ; a = Integer . parseInt ( in . next ( ) ) - 1 ; b = Integer . parseInt ( in . next ( ) ) - 1 ; M = Integer . parseInt ( in . next ( ) ) ; E = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { E [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { int x = Integer . parseInt ( in . next ( ) ) - 1 ; int y = Integer . parseInt ( in . next ( ) ) - 1 ; E [ x ] . add ( y ) ; E [ y ] . add ( x ) ; } long [ ] cost = new long [ N ] ; long [ ] count = new long [ N ] ; boolean [ ] visited = new boolean [ N ] ; Arrays . fill ( cost , INF ) ; Queue < Integer > q = new ArrayDeque < > ( ) ; q . add ( a ) ; cost [ a ] = 0 ; count [ a ] = 1 ; visited [ a ] = true ; while ( ! q . isEmpty ( ) ) { int st = q . remove ( ) ; for ( int adj : E [ st ] ) { if ( cost [ st ] + 1 <= cost [ adj ] ) { cost [ adj ] = cost [ st ] + 1 ; count [ adj ] += count [ st ] ; if ( ! visited [ adj ] ) { q . add ( adj ) ; } visited [ adj ] = true ; } } } System . out . println ( count [ b ] % MODP ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "from collections import deque NEW_LINE def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE a -= 1 NEW_LINE b -= 1 NEW_LINE m = int ( input ( ) ) NEW_LINE adj_mat = [ [ False for j in range ( n ) ] for i in range ( n ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE adj_mat [ x - 1 ] [ y - 1 ] = True NEW_LINE adj_mat [ y - 1 ] [ x - 1 ] = True NEW_LINE DEDENT queued = [ False for i in range ( n ) ] NEW_LINE shortest_paths = [ 0 for i in range ( n ) ] NEW_LINE shortest_dist = [ 10 ** 9 for i in range ( n ) ] NEW_LINE q = deque ( [ a ] ) NEW_LINE queued [ a ] = True NEW_LINE shortest_paths [ a ] = 1 NEW_LINE shortest_dist [ a ] = 0 NEW_LINE while q : NEW_LINE INDENT st = q . popleft ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if adj_mat [ st ] [ i ] : NEW_LINE INDENT if not queued [ i ] : NEW_LINE INDENT q . append ( i ) NEW_LINE queued [ i ] = True NEW_LINE DEDENT shortest_dist [ i ] = min ( shortest_dist [ i ] , shortest_dist [ st ] + 1 ) NEW_LINE if shortest_dist [ i ] == shortest_dist [ st ] + 1 : NEW_LINE INDENT shortest_paths [ i ] += shortest_paths [ st ] NEW_LINE shortest_paths [ i ] %= 10 ** 9 + 7 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( shortest_paths [ b ] ) NEW_LINE DEDENT main ( ) NEW_LINE", "import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE M = int ( input ( ) ) NEW_LINE Adjacency = np . zeros ( [ N , N ] ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE Adjacency [ x - 1 , y - 1 ] = Adjacency [ y - 1 , x - 1 ] = 1 NEW_LINE DEDENT a , b = a - 1 , b - 1 NEW_LINE walk = np . zeros ( [ N , 1 ] ) NEW_LINE walk [ a ] = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT walk = np . dot ( Adjacency , walk ) NEW_LINE if ( walk [ b ] != 0 ) : NEW_LINE INDENT print ( int ( walk [ b ] [ 0 ] % ( 1e9 + 7 ) ) ) NEW_LINE break NEW_LINE DEDENT DEDENT", "import heapq NEW_LINE def dijkstra_heap ( s ) : NEW_LINE INDENT d = [ float ( \" inf \" ) ] * n NEW_LINE used = [ True ] * n NEW_LINE d [ s ] = 0 NEW_LINE used [ s ] = False NEW_LINE edgelist = [ ] NEW_LINE for e in edge [ s ] : NEW_LINE INDENT heapq . heappush ( edgelist , e ) NEW_LINE DEDENT while len ( edgelist ) : NEW_LINE INDENT minedge = heapq . heappop ( edgelist ) NEW_LINE if not used [ minedge [ 1 ] ] : NEW_LINE INDENT continue NEW_LINE DEDENT v = minedge [ 1 ] NEW_LINE d [ v ] = minedge [ 0 ] NEW_LINE used [ v ] = False NEW_LINE for e in edge [ v ] : NEW_LINE INDENT if used [ e [ 1 ] ] : NEW_LINE INDENT heapq . heappush ( edgelist , [ e [ 0 ] + d [ v ] , e [ 1 ] ] ) NEW_LINE DEDENT DEDENT DEDENT return d NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE M = int ( input ( ) ) NEW_LINE edge = [ [ ] for i in range ( n ) ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE edge [ x - 1 ] . append ( [ 1 , y - 1 ] ) NEW_LINE edge [ y - 1 ] . append ( [ 1 , x - 1 ] ) NEW_LINE DEDENT L = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT D = dijkstra_heap ( i ) NEW_LINE L . append ( D ) NEW_LINE DEDENT dp = [ 0 ] * n NEW_LINE dp [ a - 1 ] = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if L [ a - 1 ] [ j ] != i : NEW_LINE INDENT continue NEW_LINE DEDENT for k in range ( n ) : NEW_LINE INDENT if L [ a - 1 ] [ k ] == i + 1 and L [ j ] [ k ] == 1 : NEW_LINE INDENT dp [ k ] = ( dp [ k ] + dp [ j ] ) % ( 10 ** 9 + 7 ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( dp [ b - 1 ] ) NEW_LINE", "import sys NEW_LINE import heapq NEW_LINE input = sys . stdin . readline NEW_LINE inf = 10 ** 18 NEW_LINE N = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE M = int ( input ( ) ) NEW_LINE xy = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( M ) ] NEW_LINE tab = [ [ ] for i in range ( N ) ] NEW_LINE for xi , yi in xy : NEW_LINE INDENT tab [ xi - 1 ] . append ( yi ) NEW_LINE tab [ yi - 1 ] . append ( xi ) NEW_LINE DEDENT d = [ ( 0 if i == a - 1 else inf ) for i in range ( N ) ] NEW_LINE prev = [ False ] * N NEW_LINE cnt = [ 0 ] * N NEW_LINE q = [ ] NEW_LINE heapq . heappush ( q , ( 0 , a ) ) NEW_LINE while len ( q ) > 0 : NEW_LINE INDENT cost , hi = heapq . heappop ( q ) NEW_LINE if cost >= d [ b - 1 ] : continue NEW_LINE for hj in tab [ hi - 1 ] : NEW_LINE INDENT if hj == prev [ hi - 1 ] : continue NEW_LINE alt = d [ hi - 1 ] + 1 NEW_LINE if alt < d [ hj - 1 ] : NEW_LINE INDENT d [ hj - 1 ] = alt NEW_LINE prev [ hj - 1 ] = hi NEW_LINE heapq . heappush ( q , ( alt , hj ) ) NEW_LINE DEDENT DEDENT DEDENT memo = [ [ None ] * ( d [ b - 1 ] + 1 ) for i in range ( N ) ] NEW_LINE def back ( pos , turn ) : NEW_LINE INDENT if pos == a : return 1 NEW_LINE if memo [ pos - 1 ] [ turn ] != None : return memo [ pos - 1 ] [ turn ] NEW_LINE ret = 0 NEW_LINE for src in tab [ pos - 1 ] : NEW_LINE INDENT if d [ src - 1 ] > turn - 1 : continue NEW_LINE ret += back ( src , turn - 1 ) NEW_LINE DEDENT ret = ret % ( 10 ** 9 + 7 ) NEW_LINE memo [ pos - 1 ] [ turn ] = ret NEW_LINE return ret NEW_LINE DEDENT print ( back ( b , d [ b - 1 ] ) ) NEW_LINE", "from collections import deque NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE a , b = map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) NEW_LINE M = int ( input ( ) ) NEW_LINE edges = [ [ ] for _ in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT x , y = map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) NEW_LINE edges [ x ] . append ( y ) NEW_LINE edges [ y ] . append ( x ) NEW_LINE DEDENT q = deque ( [ a ] ) NEW_LINE visited = [ False ] * N NEW_LINE visited [ a ] = True NEW_LINE depth = [ - 1 ] * N NEW_LINE depth [ a ] = 1 NEW_LINE cnts = [ 0 ] * N NEW_LINE cnts [ a ] = 1 NEW_LINE while q : NEW_LINE INDENT cur = q . popleft ( ) NEW_LINE for nex in edges [ cur ] : NEW_LINE INDENT if not visited [ nex ] : NEW_LINE INDENT q . append ( nex ) NEW_LINE visited [ nex ] = True NEW_LINE DEDENT if depth [ nex ] < 0 : NEW_LINE INDENT depth [ nex ] = depth [ cur ] + 1 NEW_LINE DEDENT if depth [ nex ] == depth [ cur ] + 1 : NEW_LINE INDENT cnts [ nex ] += cnts [ cur ] NEW_LINE cnts [ nex ] %= MOD NEW_LINE DEDENT DEDENT DEDENT print ( cnts [ b ] ) NEW_LINE NEW_LINE" ]
atcoder_arc082_C
[ "import java . util . * ; public class Main { static long mod = 998244353 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] x = new long [ n ] , y = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; } long res = modPow ( 2 , n , mod ) - 1 - n ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int count = 0 ; for ( int k = 0 ; k < n ; k ++ ) { if ( ( ( x [ i ] - x [ k ] ) * ( y [ j ] - y [ k ] ) ) == ( ( x [ j ] - x [ k ] ) * ( y [ i ] - y [ k ] ) ) ) count ++ ; } long kumi = modPow ( 2 , count , mod ) - 1 - count ; kumi = kumi * inv ( count * ( count - 1 ) / 2 , mod ) % mod ; res = ( res - kumi + mod ) % mod ; } } System . out . println ( res ) ; } static long modPow ( long a , long b , long mod ) { long res = 1 ; long c = a ; while ( b > 0 ) { if ( b % 2 == 1 ) res = res * c % mod ; c = c * c % mod ; b /= 2 ; } return res ; } static long inv ( long a , long mod ) { long b = mod ; long p = 1 , q = 0 ; while ( b > 0 ) { long c = a / b ; long d = a ; a = b ; b = d % b ; d = p ; p = q ; q = d - c * q ; } return ( mod + p ) % mod ; } }" ]
[ "def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT return gcd ( b , a % b ) NEW_LINE DEDENT def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE from collections import defaultdict NEW_LINE H = defaultdict ( lambda : 0 ) NEW_LINE N = int ( input ( ) ) NEW_LINE dot = [ ( ) ] * N NEW_LINE mod = 998244353 NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y = inpl ( ) NEW_LINE dot [ i ] = ( x , y ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT x1 , y1 = dot [ i ] NEW_LINE x2 , y2 = dot [ j ] NEW_LINE A = y1 - y2 NEW_LINE B = x2 - x1 NEW_LINE C = y1 * x2 - x1 * y2 NEW_LINE if A < 0 : NEW_LINE INDENT A *= - 1 NEW_LINE B *= - 1 NEW_LINE C *= - 1 NEW_LINE DEDENT gcdabc = gcd ( gcd ( A , B ) , C ) NEW_LINE A //= gcdabc NEW_LINE B //= gcdabc NEW_LINE C //= gcdabc NEW_LINE H [ ( A , B , C ) ] += 1 NEW_LINE DEDENT DEDENT ans = ( 2 ** N - N - 1 ) % mod NEW_LINE for i in H . values ( ) : NEW_LINE INDENT i = int ( ( 1 + ( 1 + 8 * i ) ** ( 1 / 2 ) ) / 2 ) NEW_LINE ans -= ( 2 ** i - i - 1 ) % mod NEW_LINE DEDENT print ( ans % mod ) NEW_LINE", "def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE points = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT points . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT x = [ p [ 0 ] for p in points ] NEW_LINE y = [ p [ 1 ] for p in points ] NEW_LINE M = 998244353 NEW_LINE c = 1 + N + N * ( N - 1 ) // 2 NEW_LINE for i in range ( N ) : NEW_LINE INDENT xi = x [ i ] NEW_LINE yi = y [ i ] NEW_LINE dx = [ xj - xi for xj in x ] NEW_LINE dy = [ yj - yi for yj in y ] NEW_LINE for j in range ( i + 1 , N ) : NEW_LINE INDENT xj = dx [ j ] NEW_LINE yj = dy [ j ] NEW_LINE cc = 1 NEW_LINE for k in range ( j + 1 , N ) : NEW_LINE INDENT if xj * dy [ k ] - dx [ k ] * yj == 0 : NEW_LINE INDENT cc *= 2 NEW_LINE cc %= M NEW_LINE DEDENT DEDENT c += cc - 1 NEW_LINE DEDENT DEDENT r = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT r *= 2 NEW_LINE r %= M NEW_LINE DEDENT r -= c NEW_LINE r %= M NEW_LINE print ( r ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "from collections import Counter NEW_LINE from fractions import gcd NEW_LINE n = int ( input ( ) ) NEW_LINE xys = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE MOD = 998244353 NEW_LINE excludes = 0 NEW_LINE for i , ( x1 , y1 ) in enumerate ( xys ) : NEW_LINE INDENT slopes = [ ] NEW_LINE for x2 , y2 in xys [ i + 1 : ] : NEW_LINE INDENT dx , dy = x2 - x1 , y2 - y1 NEW_LINE if dx == 0 : NEW_LINE INDENT slopes . append ( 1j ) NEW_LINE DEDENT elif dy == 0 : NEW_LINE INDENT slopes . append ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT m = gcd ( dx , dy ) NEW_LINE slopes . append ( dx // m + dy // m * 1j ) NEW_LINE DEDENT DEDENT for c in Counter ( slopes ) . values ( ) : NEW_LINE INDENT if c > 1 : NEW_LINE INDENT excludes += 2 ** c - c - 1 NEW_LINE DEDENT DEDENT excludes %= MOD NEW_LINE DEDENT print ( ( pow ( 2 , n , MOD ) - excludes - ( n * ( n - 1 ) // 2 ) - n - 1 ) % MOD ) NEW_LINE", "from collections import Counter NEW_LINE if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE xy_list = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE modulo_num = 998244353 NEW_LINE duplicate_list = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT xi , yi = xy_list [ i ] NEW_LINE gradient_list = [ ] NEW_LINE for j in range ( N ) : NEW_LINE INDENT xj , yj = xy_list [ j ] NEW_LINE if xi != xj : NEW_LINE INDENT gradient_list . append ( ( yj - yi ) / ( xj - xi ) ) NEW_LINE DEDENT elif yi != yj : NEW_LINE INDENT gradient_list . append ( 100000 ) NEW_LINE DEDENT DEDENT counter = Counter ( gradient_list ) NEW_LINE for k in counter . values ( ) : NEW_LINE INDENT duplicate_list [ k + 1 ] += 1 NEW_LINE DEDENT DEDENT ans = pow ( 2 , N , modulo_num ) NEW_LINE ans -= 1 NEW_LINE ans -= N NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT cnt = duplicate_list [ i ] // i NEW_LINE ans -= cnt * ( pow ( 2 , i , modulo_num ) - i - 1 ) NEW_LINE DEDENT ans = ans % modulo_num NEW_LINE print ( ans ) NEW_LINE DEDENT", "N = int ( input ( ) ) NEW_LINE P = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE MOD = 998244353 NEW_LINE ans = pow ( 2 , N , MOD ) - 1 - N NEW_LINE u = set ( ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT xi , yi = P [ i ] NEW_LINE for j in range ( i + 1 , N ) : NEW_LINE INDENT xj , yj = P [ j ] NEW_LINE if ( i , j ) in u : NEW_LINE INDENT continue NEW_LINE DEDENT cnt = 0 NEW_LINE Q = { i , j } NEW_LINE for k in range ( N ) : NEW_LINE INDENT xk , yk = P [ k ] NEW_LINE if ( xj - xi ) * ( yk - yi ) == ( xk - xi ) * ( yj - yi ) : NEW_LINE INDENT cnt += 1 NEW_LINE Q . add ( k ) NEW_LINE DEDENT DEDENT for p in Q : NEW_LINE INDENT for q in Q : NEW_LINE INDENT u . add ( ( p , q ) ) NEW_LINE DEDENT DEDENT ans -= pow ( 2 , cnt , MOD ) - cnt - 1 NEW_LINE DEDENT DEDENT print ( ans % MOD ) NEW_LINE" ]
atcoder_abc017_B
[ "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String X = sc . next ( ) ; int ngs = X . length ( ) ; if ( ngs == 0 ) { System . out . println ( \" YES \" ) ; System . exit ( 0 ) ; } int cnt = 0 ; for ( cnt = 0 ; cnt < ngs ; cnt ++ ) { if ( X . charAt ( cnt ) == ' o ' || X . charAt ( cnt ) == ' k ' || X . charAt ( cnt ) == ' u ' ) { } else if ( X . charAt ( cnt ) == ' c ' ) { if ( X . charAt ( cnt + 1 ) == ' h ' ) { cnt ++ ; } else { System . out . println ( \" NO \" ) ; System . exit ( 0 ) ; } } else { System . out . println ( \" NO \" ) ; System . exit ( 0 ) ; } } System . out . println ( \" YES \" ) ; } }", "import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String s = reader . readLine ( ) ; int prelen = s . length ( ) ; boolean flg = true ; while ( 0 < s . length ( ) ) { s = s . replaceAll ( \" ch $ \" , \" \" ) ; s = s . replaceAll ( \" o $ \" , \" \" ) ; s = s . replaceAll ( \" k $ \" , \" \" ) ; s = s . replaceAll ( \" u $ \" , \" \" ) ; if ( prelen == s . length ( ) ) { flg = false ; break ; } prelen = s . length ( ) ; } System . out . println ( flg ? \" YES \" : \" 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 ) { String s = in . next ( ) ; boolean isChoku = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char cc = s . charAt ( i ) ; if ( cc == ' c ' && ++ i < s . length ( ) && s . charAt ( i ) == ' h ' ) continue ; if ( cc == ' o ' || cc == ' k ' || cc == ' u ' ) continue ; isChoku = false ; break ; } out . println ( isChoku ? \" YES \" : \" NO \" ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . 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 X = in . next ( ) ; String ans = \" YES \" ; for ( int i = 0 ; i < X . length ( ) ; i ++ ) { char tmp = X . charAt ( i ) ; if ( i != X . length ( ) - 1 && ( tmp == ' c ' && X . charAt ( i + 1 ) == ' h ' ) ) { } else if ( i != 0 && ( tmp == ' h ' && X . charAt ( i - 1 ) == ' c ' ) ) { } else if ( tmp == ' o ' || tmp == ' k ' || tmp == ' u ' ) { } else { 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 long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . Scanner ; import java . util . ArrayList ; import java . util . List ; public class Main { public static boolean isChokugo ( String s ) { boolean res = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' c ' && s . charAt ( i + 1 ) == ' h ' ) { i ++ ; } else if ( s . charAt ( i ) != ' o ' && s . charAt ( i ) != ' k ' && s . charAt ( i ) != ' u ' ) { res = false ; break ; } } return res ; } public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String x = scan . nextLine ( ) ; String ans = ( isChokugo ( x ) ) ? \" YES \" : \" NO \" ; System . out . println ( ans ) ; } }" ]
[ "X = input ( ) NEW_LINE X1 = X . split ( \" ch \" ) NEW_LINE X2 = \" \" . join ( X1 ) . split ( \" o \" ) NEW_LINE X3 = \" \" . join ( X2 ) . split ( \" k \" ) NEW_LINE X4 = \" \" . join ( X3 ) . split ( \" u \" ) NEW_LINE if len ( \" \" . join ( X4 ) ) == 0 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT", "hoge = list ( input ( ) ) NEW_LINE flag = 0 NEW_LINE while 1 : NEW_LINE INDENT if ( len ( hoge ) == 0 and flag == 0 ) : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE break NEW_LINE DEDENT elif ( len ( hoge ) == 0 and flag == 1 ) : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE break NEW_LINE DEDENT elif ( hoge [ 0 ] == \" o \" or hoge [ 0 ] == \" k \" or hoge [ 0 ] == \" u \" ) : NEW_LINE INDENT hoge = hoge [ 1 : ] NEW_LINE DEDENT elif ( len ( hoge ) >= 2 ) : NEW_LINE INDENT if ( hoge [ 0 ] == \" c \" and hoge [ 1 ] == \" h \" ) : NEW_LINE INDENT hoge = hoge [ 2 : ] NEW_LINE DEDENT else : NEW_LINE INDENT flag = 1 NEW_LINE hoge = [ ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT flag = 1 NEW_LINE hoge = [ ] NEW_LINE DEDENT DEDENT", "def judge_choku ( str ) : NEW_LINE INDENT isChoku = 1 NEW_LINE while isChoku : NEW_LINE INDENT if ( str == \" \" ) : NEW_LINE INDENT break NEW_LINE DEDENT elif ( str [ 0 ] == \" o \" or str [ 0 ] == \" k \" or str [ 0 ] == \" u \" ) : NEW_LINE INDENT str = str [ 1 : ] NEW_LINE judge_choku ( str ) NEW_LINE DEDENT elif ( str [ : 2 ] == \" ch \" ) : NEW_LINE INDENT str = str [ 2 : ] NEW_LINE judge_choku ( str ) NEW_LINE DEDENT else : NEW_LINE INDENT isChoku = 0 NEW_LINE DEDENT DEDENT return isChoku NEW_LINE DEDENT s = input ( ) NEW_LINE print ( \" YES \" if judge_choku ( s ) == 1 else \" NO \" ) NEW_LINE", "print ( ' YES ' if input ( ) . replace ( ' ch ' , ' ' ) . replace ( ' o ' , ' ' ) . replace ( ' k ' , ' ' ) . replace ( ' u ' , ' ' ) == ' ' else ' NO ' ) NEW_LINE", "choku = [ ' ch ' , ' o ' , ' k ' , ' u ' ] NEW_LINE s = input ( ) NEW_LINE def f ( i ) : NEW_LINE INDENT if i == len ( s ) : NEW_LINE INDENT return True NEW_LINE DEDENT elif s [ i ] in choku : NEW_LINE INDENT return f ( i + 1 ) NEW_LINE DEDENT elif s [ i : i + 2 ] in choku : NEW_LINE INDENT return f ( i + 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT print ( ' YES ' if f ( 0 ) else ' NO ' ) NEW_LINE" ]
atcoder_abc065_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 input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; int [ ] positions = new int [ n + 1 ] ; int currentIndex = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { positions [ i ] = Integer . parseInt ( input . readLine ( ) ) ; } int count = 0 ; while ( currentIndex != 2 && positions [ currentIndex ] > 0 ) { int copyCurrentIndex = currentIndex ; currentIndex = positions [ currentIndex ] ; positions [ copyCurrentIndex ] = - 1 ; count ++ ; } System . out . println ( currentIndex == 2 ? count : - 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 N = in . nextInt ( ) ; int [ ] a = new int [ N + 1 ] ; for ( int i = 1 ; i < a . length ; i ++ ) { a [ i ] = in . nextInt ( ) ; } int tmp = 1 ; int count = 0 ; while ( count < N ) { tmp = a [ tmp ] ; count ++ ; if ( tmp == 2 ) { break ; } } if ( count == N ) { count = - 1 ; } 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 char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; Button [ ] buttons = new Button [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { buttons [ i ] = new Button ( sc . nextInt ( ) - 1 , false ) ; } buttons [ 0 ] . light = true ; int ans = - 1 ; int nowLight = 0 ; for ( int i = 0 ; i < n ; i ++ ) { buttons [ nowLight ] . light = false ; nowLight = buttons [ nowLight ] . Push ( ) ; buttons [ nowLight ] . light = true ; if ( nowLight == 1 ) { ans = i + 1 ; break ; } } System . out . println ( ans ) ; } } class Button { int num ; boolean light ; Button ( int n , boolean l ) { num = n ; light = l ; } int Push ( ) { return num ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int totalButton = scanner . nextInt ( ) ; Integer [ ] buttonList = new Integer [ totalButton + 1 ] ; for ( int buttonNum = 0 ; buttonNum < totalButton ; buttonNum ++ ) { int temp = scanner . nextInt ( ) ; buttonList [ buttonNum + 1 ] = temp ; } int nowButton = 1 ; boolean flag = false ; int num ; for ( num = 0 ; num < totalButton ; num ++ ) { int temp = buttonList [ nowButton ] ; nowButton = temp ; if ( nowButton == 2 ) { flag = true ; num ++ ; break ; } } if ( flag == true ) { System . out . println ( num ) ; } else { System . out . println ( \" - 1\" ) ; } } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean [ ] n = new boolean [ N + 1 ] ; boolean isEnd = false ; for ( int i = 1 ; i <= N ; i ++ ) { n [ i ] = false ; } int [ ] a = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int count = 0 ; int i = 1 ; while ( true ) { if ( n [ i ] == false ) { n [ i ] = true ; count ++ ; if ( a [ i ] == 2 ) { break ; } i = a [ i ] ; } else { count = - 1 ; break ; } } System . out . println ( count ) ; ; } }" ]
[ "n , * a = map ( int , open ( 0 ) ) ; c , s = 1 , a [ 0 ] NEW_LINE while s != 2 and c < n : c += 1 ; s = a [ s - 1 ] NEW_LINE print ( c * ( c < n ) or - 1 ) NEW_LINE", "import sys NEW_LINE from collections import deque NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ 0 ] + [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE cnt = 1 NEW_LINE pushed = set ( [ 1 ] ) NEW_LINE q = deque ( ) NEW_LINE q . append ( 1 ) NEW_LINE while len ( q ) > 0 : NEW_LINE INDENT a = q . popleft ( ) NEW_LINE b = A [ a ] NEW_LINE if b == 2 : NEW_LINE INDENT return cnt NEW_LINE DEDENT elif b in pushed : NEW_LINE INDENT return - 1 NEW_LINE DEDENT else : NEW_LINE INDENT pushed . add ( b ) NEW_LINE cnt += 1 NEW_LINE q . append ( b ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE a = [ int ( input ( ) ) for _ in range ( n ) ] NEW_LINE count = 0 NEW_LINE i = 0 NEW_LINE while count <= 10e+5 : NEW_LINE INDENT count += 1 NEW_LINE if a [ i ] == 2 : NEW_LINE INDENT print ( count ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT i = a [ i ] - 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT", "import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = [ ni ( ) for _ in range ( n ) ] NEW_LINE count = 0 NEW_LINE nexti = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if nexti == 1 : NEW_LINE INDENT print ( count ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT nexti = a [ nexti ] - 1 NEW_LINE count += 1 NEW_LINE DEDENT DEDENT print ( - 1 ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = [ int ( input ( ) ) - 1 for _ in range ( N ) ] NEW_LINE result = [ False ] * N NEW_LINE k = 0 NEW_LINE while 1 : NEW_LINE INDENT newlight = A [ k ] NEW_LINE if k == 1 : NEW_LINE INDENT ans = 0 NEW_LINE break NEW_LINE DEDENT elif result [ k ] : NEW_LINE INDENT ans = 1 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT result [ k ] = True NEW_LINE k = newlight NEW_LINE DEDENT DEDENT if ans : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : print ( sum ( result ) ) NEW_LINE" ]
atcoder_agc017_B
[ "import java . util . * ; public class Main { int INF = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextInt ( ) ; long A = sc . nextInt ( ) ; long B = sc . nextInt ( ) ; long C = sc . nextInt ( ) ; long D = sc . nextInt ( ) ; for ( int k = 0 ; k <= N ; k ++ ) { if ( ( ( k * C - ( N - 1 - k ) * D ) <= ( B - A ) ) && ( ( B - A ) <= ( k * D - ( N - 1 - k ) * C ) ) ) { System . out . println ( \" YES \" ) ; return ; } } System . out . println ( \" NO \" ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . 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 ) ; BModerateDifferences solver = new BModerateDifferences ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BModerateDifferences { private static final String YES = \" YES \" ; private static final String NO = \" NO \" ; public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; long a = in . longs ( ) , b = in . longs ( ) , c = in . longs ( ) , d = in . longs ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long max = a + d * i - c * ( n - 1 - i ) ; long min = a + c * i - d * ( n - 1 - i ) ; if ( min <= b && b <= max ) { out . println ( YES ) ; return ; } } out . println ( NO ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } public long longs ( ) { return Long . parseLong ( string ( ) ) ; } } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { long n = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long dur = a - b ; for ( int up = 0 ; up < n - 1 ; up ++ ) { long max = d * up - c * ( n - 1 - up ) ; long min = c * up - d * ( n - 1 - up ) ; if ( min <= dur && dur <= max ) { System . out . println ( \" YES \" ) ; return ; } } System . out . println ( \" NO \" ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; boolean bl = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( a + c * i - d * ( n - i - 1 ) <= b && b <= a + d * i - c * ( n - i - 1 ) ) { bl = true ; } } String ans = ( bl == true ) ? \" YES \" : \" NO \" ; System . out . println ( ans ) ; } }", "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; for ( int plus = 0 ; plus < N ; plus ++ ) { int minus = ( N - 1 ) - plus ; long max = A + D * plus - C * minus ; long min = A + C * plus - D * minus ; if ( min <= B && B <= max ) { System . out . println ( \" YES \" ) ; return ; } } System . out . println ( \" NO \" ) ; } }" ]
[ "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 , a , b , c , d = li ( ) NEW_LINE exist = False NEW_LINE for m in range ( n - 1 ) : NEW_LINE INDENT if - d * m + c * ( n - 1 - m ) <= b - a <= - c * m + d * ( n - 1 - m ) : NEW_LINE INDENT exist = True NEW_LINE DEDENT DEDENT if exist : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT", "import sys , collections , itertools NEW_LINE def solve ( ) : NEW_LINE INDENT N , A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE chkL = [ B + D , B + C , B - C , B - D ] NEW_LINE for i in range ( N - 2 ) : NEW_LINE INDENT min_v = C * ( N - 2 - i ) - D * i + A NEW_LINE max_v = D * ( N - 2 - i ) - C * i + A NEW_LINE for v in chkL : NEW_LINE INDENT if ( min_v <= v and v <= max_v ) : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT print ( \" NO \" ) NEW_LINE DEDENT solve ( ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N , A , B , C , D = inpl ( ) NEW_LINE for k in range ( N + 1 ) : NEW_LINE INDENT j = N - 1 - k NEW_LINE if D * k - C * j >= B - A >= C * k - D * j : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT", "n , a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE diff_ab = abs ( b - a ) NEW_LINE diff_cd = d - c NEW_LINE mod = c + d NEW_LINE mod_ab = diff_ab % mod NEW_LINE MAX = d * ( n - 1 ) NEW_LINE MAX_mod = MAX % mod NEW_LINE MIN_mod = ( c * ( n - 1 ) ) % mod NEW_LINE if MAX >= diff_ab : NEW_LINE INDENT if diff_cd * ( n - 1 ) + 1 >= mod : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT if MAX_mod >= MIN_mod : NEW_LINE INDENT if mod_ab <= MAX_mod and mod_ab >= MIN_mod : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if mod_ab >= MIN_mod or mod_ab <= MAX_mod : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT", "import math NEW_LINE def solve ( ) : NEW_LINE INDENT n , a , b , c , d = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE if a > b : a , b = b , a NEW_LINE ans = ' NO ' NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a + i * c - ( n - i - 1 ) * d <= b <= a + i * d - ( n - i - 1 ) * c : NEW_LINE INDENT ans = ' YES ' NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( ) ) NEW_LINE DEDENT" ]
atcoder_abc007_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; System . out . println ( n - 1 ) ; } }", "import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { out . println ( nextInt ( ) - 1 ) ; } }", "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 ( ) ) ; System . out . println ( n - 1 ) ; } catch ( Exception e ) { System . out . println ( \" out \" ) ; } } }", "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 N = scanner . nextInt ( ) ; System . out . println ( N - 1 ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . nextLine ( ) ; int ans = Integer . parseInt ( Integer . toBinaryString ( Integer . parseInt ( a ) ) , 2 ) - 1 ; System . out . println ( \" \" + \" \" + \" \" + \" \" + \" \" + \" \" + \" \" + \" \" + ans ) ; } }" ]
[ "print ( int ( input ( ) ) - 1 ) NEW_LINE", "import numpy as np NEW_LINE class Calculator : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT pass NEW_LINE DEDENT def set_num ( self , N ) : NEW_LINE INDENT self . num = 0 NEW_LINE self . N = N NEW_LINE DEDENT def calc ( self ) : NEW_LINE INDENT self . num = self . N - 1 ; NEW_LINE DEDENT def get_num ( self ) : NEW_LINE INDENT return self . num NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N , = map ( int , input ( ) . split ( ) ) NEW_LINE c = Calculator ( ) NEW_LINE c . set_num ( N ) NEW_LINE c . calc ( ) NEW_LINE ans = c . get_num ( ) NEW_LINE print ( ans ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE print ( n - 1 ) if n != 0 else print ( 0 ) NEW_LINE", "from sys import stdin NEW_LINE print ( int ( stdin . readline ( ) . rstrip ( ) ) - 1 ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE print ( N - 1 ) NEW_LINE" ]
atcoder_abc012_D
[ "import java . util . * ; public class Main { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] times = new int [ n ] [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; times [ a - 1 ] [ b - 1 ] = t ; times [ b - 1 ] [ a - 1 ] = t ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i != j && times [ i ] [ j ] == 0 ) { times [ i ] [ j ] = 1000000 ; times [ j ] [ i ] = 1000000 ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { times [ j ] [ k ] = Math . min ( times [ j ] [ k ] , times [ j ] [ i ] + times [ i ] [ k ] ) ; times [ k ] [ j ] = times [ j ] [ k ] ; } } } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int tmpmin = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( i != j ) tmpmin = Math . max ( tmpmin , times [ i ] [ j ] ) ; } min = Math . min ( tmpmin , min ) ; } System . out . println ( min ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] dist = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { Arrays . fill ( dist [ i ] , Integer . MAX_VALUE / 3 ) ; dist [ i ] [ i ] = 0 ; } int m = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; dist [ a - 1 ] [ b - 1 ] = t ; dist [ b - 1 ] [ a - 1 ] = t ; } for ( int k = 0 ; k < n ; k ++ ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { dist [ i ] [ j ] = Math . min ( dist [ i ] [ j ] , dist [ i ] [ k ] + dist [ k ] [ j ] ) ; dist [ j ] [ i ] = dist [ i ] [ j ] ; } } } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int max = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( max < dist [ i ] [ j ] ) { max = dist [ i ] [ j ] ; } } if ( min > max ) { min = max ; } } System . out . println ( min ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . util . Arrays ; import java . util . Scanner ; import java . util . OptionalInt ; 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 ( ) , m = in . nextInt ( ) ; int [ ] [ ] dist = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { Arrays . fill ( dist [ i ] , 1000000000 ) ; dist [ i ] [ i ] = 0 ; } for ( int i = 0 ; i < m ; i ++ ) { int a = in . nextInt ( ) - 1 , b = in . nextInt ( ) - 1 , t = in . nextInt ( ) ; dist [ a ] [ b ] = t ; dist [ b ] [ a ] = t ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { dist [ j ] [ k ] = Math . min ( dist [ j ] [ k ] , dist [ j ] [ i ] + dist [ i ] [ k ] ) ; } } } int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . min ( ans , IntStream . of ( dist [ i ] ) . max ( ) . orElse ( Integer . MAX_VALUE ) ) ; } out . println ( ans ) ; } } }", "import java . util . Scanner ; public class Main { static int [ ] [ ] map ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; map = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i != j ) { map [ i ] [ j ] = 1 << 29 ; } } } for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; int t = sc . nextInt ( ) ; map [ a ] [ b ] = t ; map [ b ] [ a ] = t ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { int a = Math . min ( map [ j ] [ k ] , map [ j ] [ i ] + map [ i ] [ k ] ) ; map [ j ] [ k ] = a ; map [ k ] [ j ] = a ; } } } int min = 1 << 29 ; for ( int i = 0 ; i < n ; i ++ ) { int max = 0 ; for ( int j = 0 ; j < n ; j ++ ) { max = Math . max ( max , map [ i ] [ j ] ) ; } if ( min > max ) { min = max ; } } System . out . println ( min ) ; } }", "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 ( ) ; final int INF = 1_000_000_000 ; int [ ] [ ] d = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i != j ) { d [ i ] [ j ] = INF ; } } } for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; d [ a - 1 ] [ b - 1 ] = t ; d [ b - 1 ] [ a - 1 ] = t ; } for ( int k = 0 ; k < n ; k ++ ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( d [ i ] [ j ] > d [ i ] [ k ] + d [ k ] [ j ] ) { d [ i ] [ j ] = d [ i ] [ k ] + d [ k ] [ j ] ; } } } } int ans = INF ; for ( int i = 0 ; i < n ; i ++ ) { int max = 0 ; for ( int j = 0 ; j < n ; j ++ ) { max = Math . max ( max , d [ i ] [ j ] ) ; } ans = Math . min ( ans , max ) ; } System . out . println ( ans ) ; } }" ]
[ "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 import numpy as np NEW_LINE from scipy . sparse . csgraph import floyd_warshall NEW_LINE n , m = li ( ) NEW_LINE graph = np . inf * np . ones ( ( n , n ) ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b , t = li ( ) NEW_LINE graph [ a - 1 ] [ b - 1 ] = t NEW_LINE graph [ b - 1 ] [ a - 1 ] = t NEW_LINE DEDENT dist = floyd_warshall ( graph , directed = False ) NEW_LINE ans = 10 ** 18 NEW_LINE for i in range ( n ) : NEW_LINE INDENT ans = min ( ans , max ( dist [ i ] ) ) NEW_LINE DEDENT print ( int ( ans ) ) NEW_LINE", "from scipy . sparse import * ; f = lambda * z : map ( int , input ( ) . split ( ) ) ; N , M = f ( ) ; a , b , c = zip ( * map ( f , [ 0 ] * M ) ) ; l = csgraph . dijkstra ( csr_matrix ( ( c , ( a , b ) ) , [ N + 1 ] * 2 ) , 0 ) ; print ( int ( min ( max ( i [ 1 : ] ) for i in l ) ) ) NEW_LINE", "import sys NEW_LINE def ? ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N , M = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE aB = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( M ) ] NEW_LINE dT = { } NEW_LINE def addData ( dT : dict , a : int , b : int , t : int ) : NEW_LINE INDENT if a in dT : NEW_LINE INDENT dT [ a ] [ b ] = t NEW_LINE DEDENT else : NEW_LINE INDENT dT [ a ] = { b : t } NEW_LINE DEDENT DEDENT for a , b , t in aB : NEW_LINE INDENT addData ( dT , a , b , t ) NEW_LINE addData ( dT , b , a , t ) NEW_LINE DEDENT for k in range ( 1 , N + 1 ) : NEW_LINE INDENT aK = dT [ k ] . keys ( ) NEW_LINE for i in aK : NEW_LINE INDENT dI = dT [ i ] NEW_LINE dK = dT [ k ] NEW_LINE iRK = dI [ k ] NEW_LINE for j in aK : NEW_LINE INDENT iR = iRK + dK [ j ] NEW_LINE if j in dI : NEW_LINE INDENT if dI [ j ] > iR : NEW_LINE INDENT dI [ j ] = iR NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT dI [ j ] = iR NEW_LINE DEDENT DEDENT DEDENT DEDENT iAns = float ( \" inf \" ) NEW_LINE for i , dD in dT . items ( ) : NEW_LINE INDENT iD = 0 NEW_LINE for j , v in dD . items ( ) : NEW_LINE INDENT if i == j : NEW_LINE INDENT continue NEW_LINE DEDENT if v > iD : NEW_LINE INDENT iD = v NEW_LINE DEDENT DEDENT if iAns > iD : NEW_LINE INDENT iAns = iD NEW_LINE DEDENT DEDENT print ( iAns ) NEW_LINE DEDENT ? ( ) NEW_LINE", "def warshall_floyd ( v_count : int , matrix : list ) -> list : NEW_LINE INDENT for i in range ( v_count ) : NEW_LINE INDENT for j , c2 in enumerate ( row [ i ] for row in matrix ) : NEW_LINE INDENT for k , ( c1 , c3 ) in enumerate ( zip ( matrix [ j ] , matrix [ i ] ) ) : NEW_LINE INDENT if c1 > c2 + c3 : NEW_LINE INDENT matrix [ j ] [ k ] = c2 + c3 NEW_LINE DEDENT DEDENT DEDENT DEDENT return matrix NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT import sys NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE inf = float ( \" inf \" ) NEW_LINE matrix = [ [ inf ] * N for _ in [ 0 ] * N ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT matrix [ i ] [ i ] = 0 NEW_LINE DEDENT for a , b , t in ( map ( int , l . split ( ) ) for l in sys . stdin ) : NEW_LINE INDENT matrix [ a - 1 ] [ b - 1 ] = matrix [ b - 1 ] [ a - 1 ] = t NEW_LINE DEDENT matrix = warshall_floyd ( N , matrix ) NEW_LINE print ( min ( max ( row ) for row in matrix ) ) NEW_LINE DEDENT", "from scipy . sparse . csgraph import floyd_warshall NEW_LINE from scipy . sparse . csgraph import dijkstra NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE dis = [ [ float ( ' inf ' ) for i in range ( n ) ] for j in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT dis [ i ] [ i ] = 0 NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT a , b , t = map ( int , input ( ) . split ( ) ) NEW_LINE dis [ a - 1 ] [ b - 1 ] = t NEW_LINE dis [ b - 1 ] [ a - 1 ] = t NEW_LINE DEDENT cost = dijkstra ( dis ) NEW_LINE ans = [ max ( cost [ i ] ) for i in range ( n ) ] NEW_LINE print ( int ( min ( ans ) ) ) NEW_LINE" ]
atcoder_agc004_C
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) , w = sc . nextInt ( ) ; char [ ] [ ] map = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { map [ i ] = sc . next ( ) . toCharArray ( ) ; } char [ ] [ ] red = new char [ h ] [ w ] ; char [ ] [ ] blue = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( map [ i ] [ j ] == ' # ' ) { red [ i ] [ j ] = blue [ i ] [ j ] = ' # ' ; continue ; } if ( ( i % 2 == 0 && j != w - 1 ) || ( i % 2 == 1 && j == 0 ) ) { red [ i ] [ j ] = ' # ' ; blue [ i ] [ j ] = ' . ' ; } else { red [ i ] [ j ] = ' . ' ; blue [ i ] [ j ] = ' # ' ; } } } printArr ( red ) ; System . out . println ( ) ; printArr ( blue ) ; } static void printArr ( char [ ] [ ] arr ) { for ( char [ ] chars : arr ) { for ( char c : chars ) { System . out . print ( c ) ; } System . out . println ( ) ; } } }", "import java . util . * ; class Main { public static void puts ( char [ ] [ ] str ) { for ( int i = 0 ; i < str . length ; i ++ ) { for ( int j = 0 ; j < str [ i ] . length ; j ++ ) { System . out . print ( str [ i ] [ j ] ) ; } System . out . print ( ' \\n ' ) ; } return ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; char [ ] [ ] a = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { a [ i ] = ( sc . next ( ) ) . toCharArray ( ) ; } char [ ] [ ] b = new char [ h ] [ w ] ; char [ ] [ ] r = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( j == 0 ) { b [ i ] [ j ] = ' # ' ; r [ i ] [ j ] = ' . ' ; } else if ( j == w - 1 ) { b [ i ] [ j ] = ' . ' ; r [ i ] [ j ] = ' # ' ; } else { if ( i % 2 == 0 ) { b [ i ] [ j ] = ' . ' ; r [ i ] [ j ] = ' # ' ; } else { b [ i ] [ j ] = ' # ' ; r [ i ] [ j ] = ' . ' ; } } } } for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( a [ i ] [ j ] == ' # ' ) { r [ i ] [ j ] = ' # ' ; b [ i ] [ j ] = ' # ' ; } } } puts ( b ) ; puts ( r ) ; return ; } }", "import java . util . * ; public class Main { int H , W ; boolean [ ] [ ] rg , bg , pg ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; H = sc . nextInt ( ) ; W = sc . nextInt ( ) ; rg = new boolean [ H ] [ W ] ; bg = new boolean [ H ] [ W ] ; pg = new boolean [ H ] [ W ] ; for ( int h = 0 ; h < H ; h ++ ) { if ( h % 2 == 0 ) { for ( int w = 0 ; w < W ; w ++ ) rg [ h ] [ w ] = true ; } else { for ( int w = 0 ; w < W ; w ++ ) bg [ h ] [ w ] = true ; } bg [ h ] [ W - 1 ] = rg [ h ] [ 0 ] = true ; rg [ h ] [ W - 1 ] = bg [ h ] [ 0 ] = false ; } for ( int h = 0 ; h < H ; h ++ ) { String l = sc . next ( ) ; for ( int w = 0 ; w < W ; w ++ ) { if ( l . charAt ( w ) == ' # ' ) bg [ h ] [ w ] = rg [ h ] [ w ] = true ; pg [ h ] [ w ] = bg [ h ] [ w ] & rg [ h ] [ w ] ; } } printBoard ( rg ) ; System . out . println ( ) ; printBoard ( bg ) ; } void printBoard ( boolean [ ] [ ] b ) { for ( int h = 0 ; h < H ; h ++ ) { for ( int w = 0 ; w < W ; w ++ ) System . out . print ( b [ h ] [ w ] ? ' # ' : ' . ' ) ; System . out . println ( ) ; } } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { new Main ( ) . solve ( in ) ; } } private void solve ( Scanner in ) { int H = in . nextInt ( ) , W = in . nextInt ( ) ; char [ ] [ ] a = new char [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { a [ i ] = in . next ( ) . toCharArray ( ) ; } char [ ] [ ] r = new char [ H ] [ W ] ; char [ ] [ ] b = new char [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { Arrays . fill ( r [ i ] , DOT ) ; Arrays . fill ( b [ i ] , DOT ) ; r [ i ] [ 0 ] = SHA ; b [ i ] [ W - 1 ] = SHA ; for ( int j = 1 ; j < W - 1 ; j ++ ) { r [ i ] [ j ] = ( i % 2 == 0 ) ? SHA : DOT ; b [ i ] [ j ] = ( i % 2 == 1 ) ? SHA : DOT ; } } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( a [ i ] [ j ] == SHA ) { r [ i ] [ j ] = SHA ; b [ i ] [ j ] = SHA ; } } } show ( r ) ; System . out . println ( ) ; show ( b ) ; } private static final char DOT = ' . ' , SHA = ' # ' ; private void show ( char [ ] [ ] cs ) { for ( int i = 0 ; i < cs . length ; i ++ ) { System . out . println ( new String ( cs [ i ] ) ) ; } } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; char [ ] [ ] a = new char [ H ] [ W ] ; for ( int i = 0 ; i < H ; ++ i ) { a [ i ] = sc . next ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < H ; ++ i ) { for ( int j = 0 ; j < W ; ++ j ) { if ( j != W - 1 && ( j == 0 || a [ i ] [ j ] == ' # ' || i % 2 == 0 ) ) { System . out . print ( ' # ' ) ; } else { System . out . print ( ' . ' ) ; } } System . out . println ( ) ; } System . out . println ( ) ; for ( int i = 0 ; i < H ; ++ i ) { for ( int j = 0 ; j < W ; ++ j ) { if ( j != 0 && ( j == W - 1 || a [ i ] [ j ] == ' # ' || i % 2 == 1 ) ) { System . out . print ( ' # ' ) ; } else { System . out . print ( ' . ' ) ; } } System . out . println ( ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }" ]
[ "h , w = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE a = [ input ( ) for i in range ( h ) ] NEW_LINE r , b = [ [ \" # \" ] for i in range ( h ) ] , [ [ \" . \" ] for i in range ( h ) ] NEW_LINE x = [ \" # \" , \" . \" ] NEW_LINE for i in range ( h ) : NEW_LINE INDENT for j in range ( 1 , w - 1 ) : NEW_LINE INDENT if a [ i ] [ j ] == \" # \" : NEW_LINE INDENT r [ i ] . append ( \" # \" ) NEW_LINE b [ i ] . append ( \" # \" ) NEW_LINE DEDENT else : NEW_LINE INDENT r [ i ] . append ( x [ i % 2 ] ) NEW_LINE b [ i ] . append ( x [ 1 - i % 2 ] ) NEW_LINE DEDENT DEDENT r [ i ] . append ( \" . \" ) NEW_LINE b [ i ] . append ( \" # \" ) NEW_LINE DEDENT for i in range ( h ) : print ( \" \" . join ( r [ i ] ) ) NEW_LINE print ( ) NEW_LINE for i in range ( h ) : print ( \" \" . join ( b [ i ] ) ) NEW_LINE", "from collections import defaultdict , Counter NEW_LINE from itertools import product , groupby , count , permutations , combinations NEW_LINE from math import pi , sqrt NEW_LINE from collections import deque NEW_LINE from bisect import bisect , bisect_left , bisect_right NEW_LINE INF = 10 ** 10 NEW_LINE def check ( ans1 , ans2 , field ) : NEW_LINE INDENT h , w = len ( ans1 ) , len ( ans1 [ 0 ] ) NEW_LINE ans = [ [ 0 ] * w for _ in range ( h ) ] NEW_LINE for y in range ( h ) : NEW_LINE INDENT for x in range ( w ) : NEW_LINE INDENT c = \" # \" if ans1 [ y ] [ x ] == ans2 [ y ] [ x ] == \" # \" else \" . \" NEW_LINE if field [ y ] [ x ] != c : NEW_LINE INDENT print ( y , x ) NEW_LINE DEDENT DEDENT DEDENT DEDENT def main ( ) : NEW_LINE INDENT H , W = map ( int , input ( ) . split ( ) ) NEW_LINE field = [ ] NEW_LINE for _ in range ( H ) : NEW_LINE INDENT field . append ( input ( ) ) NEW_LINE DEDENT ans1 , ans2 = [ [ \" . \" ] * W for _ in range ( H ) ] , [ [ \" . \" ] * W for _ in range ( H ) ] NEW_LINE for i in range ( H ) : NEW_LINE INDENT ans1 [ i ] [ 0 ] = \" # \" NEW_LINE ans2 [ i ] [ - 1 ] = \" # \" NEW_LINE if i % 2 == 0 : NEW_LINE INDENT ans1 [ i ] = [ \" # \" ] * ( W - 1 ) + [ \" . \" ] NEW_LINE DEDENT else : NEW_LINE INDENT ans2 [ i ] = [ \" . \" ] + [ \" # \" ] * ( W - 1 ) NEW_LINE DEDENT DEDENT for y in range ( H ) : NEW_LINE INDENT for x in range ( W ) : NEW_LINE INDENT if field [ y ] [ x ] == \" # \" : NEW_LINE INDENT if y % 2 == 0 : NEW_LINE INDENT ans2 [ y ] [ x ] = \" # \" NEW_LINE DEDENT else : NEW_LINE INDENT ans1 [ y ] [ x ] = \" # \" NEW_LINE DEDENT DEDENT DEDENT DEDENT for line in ans1 : NEW_LINE INDENT print ( \" \" . join ( line ) ) NEW_LINE DEDENT print ( ) NEW_LINE for line in ans2 : NEW_LINE INDENT print ( \" \" . join ( line ) ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) 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 eps = 1.0 / 10 ** 10 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 h , w = LI ( ) NEW_LINE a = [ [ c == ' # ' for c in S ( ) ] for _ in range ( h ) ] NEW_LINE r = [ ' # ' * w ] NEW_LINE for c in a [ 1 : - 1 ] : NEW_LINE INDENT t = ' ' NEW_LINE for i in range ( w ) : NEW_LINE INDENT ci = c [ i ] NEW_LINE if ci or i % 2 == 0 : NEW_LINE INDENT t += ' # ' NEW_LINE DEDENT else : NEW_LINE INDENT t += ' . ' NEW_LINE DEDENT DEDENT r . append ( t ) NEW_LINE DEDENT r . append ( ' . ' * w ) NEW_LINE r . append ( ' ' ) NEW_LINE r . append ( ' . ' * w ) NEW_LINE for c in a [ 1 : - 1 ] : NEW_LINE INDENT t = ' ' NEW_LINE for i in range ( w ) : NEW_LINE INDENT ci = c [ i ] NEW_LINE if ci or i % 2 == 1 : NEW_LINE INDENT t += ' # ' NEW_LINE DEDENT else : NEW_LINE INDENT t += ' . ' NEW_LINE DEDENT DEDENT r . append ( t ) NEW_LINE DEDENT r . append ( ' # ' * w ) NEW_LINE return ' \\n ' . join ( r ) NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "import itertools NEW_LINE import random NEW_LINE def genrandom ( h , w ) : NEW_LINE INDENT g = [ [ 0 ] * w for _ in range ( h ) ] NEW_LINE for i in range ( 1 , h - 1 ) : NEW_LINE INDENT for j in range ( 1 , w - 1 ) : NEW_LINE INDENT if random . randint ( 0 , 1 ) : NEW_LINE INDENT g [ i ] [ j ] = 1 NEW_LINE DEDENT DEDENT DEDENT return g NEW_LINE DEDENT def display ( g ) : NEW_LINE INDENT for i in range ( len ( g ) ) : NEW_LINE INDENT print ( ' ' . join ( ' # ' if b else ' . ' for b in g [ i ] ) ) NEW_LINE DEDENT DEDENT h , w = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE g = [ [ 0 ] * w for _ in range ( h ) ] NEW_LINE for i in range ( h ) : NEW_LINE INDENT s = input ( ) NEW_LINE for ( j , c ) in enumerate ( s ) : NEW_LINE INDENT if c == ' # ' : NEW_LINE INDENT g [ i ] [ j ] = 1 NEW_LINE DEDENT DEDENT DEDENT red = [ list ( g [ i ] ) for i in range ( h ) ] NEW_LINE blue = [ list ( g [ i ] ) for i in range ( h ) ] NEW_LINE for i in range ( h ) : NEW_LINE INDENT red [ i ] [ - 1 ] = 1 NEW_LINE blue [ i ] [ 0 ] = 1 NEW_LINE if i % 2 == 0 : NEW_LINE INDENT for j in range ( 1 , w - 1 ) : NEW_LINE INDENT red [ i ] [ j ] = 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for j in range ( 1 , w - 1 ) : NEW_LINE INDENT blue [ i ] [ j ] = 1 NEW_LINE DEDENT DEDENT DEDENT display ( red ) NEW_LINE print ( ) NEW_LINE display ( blue ) NEW_LINE NEW_LINE", "import sys NEW_LINE stdin = sys . stdin NEW_LINE readline = sys . stdin . readline NEW_LINE H , W = map ( int , readline ( ) . split ( ) ) NEW_LINE red , blue = [ ] , [ ] NEW_LINE r_append , b_append = red . append , blue . append NEW_LINE for _ in [ None ] * ( H // 2 ) : NEW_LINE INDENT r_append ( list ( \" # \" * ( W - 1 ) + \" . \" ) ) NEW_LINE r_append ( list ( \" # \" + \" . \" * ( W - 1 ) ) ) NEW_LINE b_append ( list ( \" . \" * ( W - 1 ) + \" # \" ) ) NEW_LINE b_append ( list ( \" . \" + \" # \" * ( W - 1 ) ) ) NEW_LINE DEDENT if H % 2 : NEW_LINE INDENT r_append ( list ( \" # \" * ( W - 1 ) + \" . \" ) ) NEW_LINE b_append ( list ( \" . \" * ( W - 1 ) + \" # \" ) ) NEW_LINE DEDENT for y in range ( H ) : NEW_LINE INDENT for x , c in enumerate ( readline ( ) ) : NEW_LINE INDENT if c == \" # \" : NEW_LINE INDENT if red [ y ] [ x ] == \" . \" : NEW_LINE INDENT red [ y ] [ x ] = \" # \" NEW_LINE DEDENT else : NEW_LINE INDENT blue [ y ] [ x ] = \" # \" NEW_LINE DEDENT DEDENT DEDENT DEDENT join = \" \" . join NEW_LINE for line in red : NEW_LINE INDENT print ( join ( line ) ) NEW_LINE DEDENT print ( ) NEW_LINE for line in blue : NEW_LINE INDENT print ( join ( line ) ) NEW_LINE DEDENT" ]
atcoder_arc082_B
[ "import java . util . * ; public class Main { private static int solve ( Scanner scanner ) { int N = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] nums = lineToIntNums ( scanner . nextLine ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { nums [ i ] -- ; } int ret = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( nums [ i ] == i ) { if ( i == N - 1 ) { swap ( i - 1 , i , nums ) ; } else { swap ( i , i + 1 , nums ) ; } ret ++ ; } } return ret ; } private static void swap ( int i , int j , int [ ] nums ) { int tmp = nums [ i ] ; nums [ i ] = nums [ j ] ; nums [ j ] = tmp ; } private static final String ex1 = \"5 \\n \" + \"1 ▁ 4 ▁ 3 ▁ 5 ▁ 2\" ; private static final String ex2 = \"2 \\n \" + \"1 ▁ 2\" ; private static final String ex3 = \"2 \\n \" + \"2 ▁ 1\" ; private static final String ex4 = \"9 \\n \" + \"1 ▁ 2 ▁ 4 ▁ 9 ▁ 5 ▁ 8 ▁ 7 ▁ 3 ▁ 6\" ; 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 . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . function . Consumer ; import java . util . stream . IntStream ; import static java . util . stream . Collectors . toList ; public class Main { private static final Scanner scanner = new Scanner ( System . in ) ; private static final Consumer < List < String > > consumer = solve ( ) ; public static void main ( String [ ] args ) { consumer . accept ( readInput ( ) ) ; } private static List < String > readInput ( ) { final List < String > lineList = new ArrayList < > ( ) ; while ( scanner . hasNextLine ( ) ) { lineList . add ( scanner . nextLine ( ) ) ; } return lineList ; } private static Consumer < List < String > > solve ( ) { return args -> { final List < Integer > numList = Arrays . stream ( args . get ( 1 ) . split ( \" ▁ \" ) ) . map ( Integer :: valueOf ) . collect ( toList ( ) ) ; final List < Integer > matchedIndexList = IntStream . range ( 0 , numList . size ( ) ) . filter ( x -> numList . get ( x ) . equals ( x + 1 ) ) . boxed ( ) . collect ( toList ( ) ) ; Integer curr = - 1 ; Integer cnt = 0 ; Integer ans = 0 ; for ( final Integer index : matchedIndexList ) { if ( curr == - 1 || curr + 1 == index ) { cnt ++ ; curr = index ; continue ; } ans += Double . valueOf ( Math . ceil ( cnt . doubleValue ( ) / 2 ) ) . intValue ( ) ; cnt = 1 ; curr = index ; } ans += Double . valueOf ( Math . ceil ( cnt . doubleValue ( ) / 2 ) ) . intValue ( ) ; System . out . println ( ans ) ; } ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; int [ ] ps ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; ps = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { ps [ i ] = sc . nextInt ( ) ; } solve ( ) ; } void solve ( ) { boolean [ ] bads = new boolean [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ps [ i ] == i ) { bads [ i ] = true ; } } int count = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( ps [ i ] == i ) { swap ( ps , i , i + 1 ) ; count ++ ; } } if ( ps [ n ] == n ) { count ++ ; } System . out . println ( count ) ; } void swap ( int [ ] ps , int i , int j ) { int temp = ps [ i ] ; ps [ i ] = ps [ j ] ; ps [ j ] = temp ; } 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 . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = sc . nextInt ( ) - 1 ; } int pos = 0 ; int ans = 0 ; while ( pos < N ) { if ( pos == p [ pos ] ) { if ( pos != N - 1 ) { if ( pos + 1 == p [ pos + 1 ] ) { ans ++ ; pos += 2 ; } else { ans ++ ; pos ++ ; } } else { ans ++ ; pos ++ ; } } else { pos ++ ; } } System . out . println ( ans ) ; } }", "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 [ ] num = new int [ n + 1 ] ; int ans = 0 ; int tmp ; num [ 0 ] = 10000000 ; for ( int i = 1 ; i <= n ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( i == n ) { if ( num [ i ] == i ) { tmp = num [ i ] ; num [ i ] = num [ i - 1 ] ; num [ i - 1 ] = tmp ; ans ++ ; } } else { if ( num [ i ] == i ) { tmp = num [ i ] ; num [ i ] = num [ i + 1 ] ; num [ i + 1 ] = tmp ; ans ++ ; } } } System . out . println ( ans ) ; sc . close ( ) ; } }" ]
[ "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT A [ i - 1 ] -= i NEW_LINE DEDENT ans = 0 NEW_LINE if all ( a != 0 for a in A ) : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT seq = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if A [ i ] == 0 : NEW_LINE INDENT seq += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( seq + 1 ) // 2 NEW_LINE seq = 0 NEW_LINE DEDENT DEDENT ans += ( seq + 1 ) // 2 NEW_LINE DEDENT print ( ans ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE p = inpl ( ) NEW_LINE H = ' ' NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if i != p [ i - 1 ] : NEW_LINE INDENT H += '1' NEW_LINE DEDENT else : NEW_LINE INDENT H += '0' NEW_LINE DEDENT DEDENT H = H . replace ( '00' , '1' ) NEW_LINE ans = N - len ( H ) NEW_LINE ans += H . count ( '0' ) NEW_LINE print ( ans ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE plist = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE prevp = plist [ 0 ] NEW_LINE swap = 0 NEW_LINE is_swap = False NEW_LINE for i , p in enumerate ( plist [ 1 : ] ) : NEW_LINE INDENT if is_swap : NEW_LINE INDENT is_swap = False NEW_LINE DEDENT elif i + 1 == prevp : NEW_LINE INDENT is_swap = True NEW_LINE swap += 1 NEW_LINE DEDENT prevp = p NEW_LINE DEDENT print ( swap + ( 1 if not is_swap and plist [ - 1 ] == len ( plist ) else 0 ) ) NEW_LINE", "from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" YES \" ) NEW_LINE else : print ( \" NO \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT n = ip ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE prev = 0 NEW_LINE s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] == i + 1 : NEW_LINE INDENT s += 1 NEW_LINE if prev : NEW_LINE INDENT s -= 1 NEW_LINE prev = 0 NEW_LINE DEDENT else : prev = 1 NEW_LINE DEDENT else : prev = 0 NEW_LINE DEDENT print ( s ) NEW_LINE", "def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE p = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE r = 0 NEW_LINE i = 0 NEW_LINE while i < N : NEW_LINE INDENT if p [ i ] == i + 1 : NEW_LINE INDENT r += 1 NEW_LINE i += 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print ( r ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_agc010_B
[ "import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } long nn = n ; long consume = nn * ( nn + 1 ) / 2 ; if ( sum % consume != 0 ) { System . out . println ( \" NO \" ) ; return ; } long sump = sum / consume ; long cnt = 0 ; boolean isok = true ; for ( int i = 0 ; i < n ; i ++ ) { long chil = ( a [ ( i - 1 + n ) % n ] + sump - a [ i ] ) ; if ( chil < 0 || chil % n != 0 ) isok = false ; long p = chil / n ; if ( a [ ( i - 1 + n ) % n ] + ( sump - p ) != a [ i ] + ( n - 1 ) * p ) isok = false ; if ( p < 0 ) isok = false ; cnt += p ; } if ( isok && sump == cnt ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } return ; } }", "import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Main { private void solve ( Scanner in , PrintWriter out ) { int N = in . nextInt ( ) ; long [ ] a = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = in . nextInt ( ) ; } long [ ] d = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { d [ i ] = a [ ( i + 1 ) % N ] - a [ i ] ; } long sum = Arrays . stream ( a ) . sum ( ) ; if ( sum % ( ( long ) N * ( ( long ) N + 1 ) / 2 ) != 0 ) { out . println ( \" NO \" ) ; return ; } long k = sum / ( ( long ) N * ( ( long ) N + 1 ) / 2 ) ; long count = 0 ; for ( long e : d ) { e -= k ; if ( e > 0 || ( - e ) % ( long ) N != 0 ) { out . println ( \" NO \" ) ; return ; } else { count += ( - e ) / ( long ) N ; } } if ( count != k ) { out . println ( \" NO \" ) ; } else { out . println ( \" YES \" ) ; } } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( in , out ) ; in . close ( ) ; out . close ( ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Main { public static void main ( String args [ ] ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Solver solver = new Solver ( ) ; solver . init ( ) ; solver . readHead ( in . readLine ( ) ) ; for ( ; solver . hasNext ( ) ; ) { solver . readBody ( in . readLine ( ) ) ; } } } class Solver { int N ; int cnt ; public void init ( ) { N = 0 ; cnt = 0 ; } public void readHead ( String str ) { String [ ] strArr = str . split ( \" ▁ \" ) ; N = Integer . parseInt ( strArr [ 0 ] ) ; } public boolean hasNext ( ) { return cnt < 1 ; } public void readBody ( String str ) { cnt ++ ; String [ ] strArr = str . split ( \" ▁ \" ) ; long sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += Long . parseLong ( strArr [ i ] ) ; } if ( sum % ( ( long ) N * ( ( long ) N + 1 ) / 2 ) != 0 ) { System . out . println ( \" NO \" ) ; return ; } long k = sum / ( ( long ) N * ( ( long ) N + 1 ) / 2 ) ; boolean able = true ; long edge = 0 ; for ( int i = 0 ; i < N ; i ++ ) { long d = - Long . parseLong ( strArr [ i ] ) - k ; if ( i == N - 1 ) d += Long . parseLong ( strArr [ 0 ] ) ; else d += Long . parseLong ( strArr [ i + 1 ] ) ; if ( d > 0 ) { able = false ; break ; } if ( d < 0 ) { if ( d % N != 0 ) { able = false ; break ; } edge -= d ; } } if ( able ) { able = ( edge == N * k ) ; } if ( able ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } }", "import java . util . * ; 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 ( ) ; String ans = help ( n , A ) ; System . out . println ( ans ) ; } static String help ( int n , long [ ] A ) { if ( n == 1 ) return \" YES \" ; long sum = A [ 1 ] ; for ( int i = 2 ; i <= n ; i ++ ) sum += A [ i ] ; long temp = ( ( long ) n ) * ( ( long ) n + 1 ) / 2 ; if ( sum % temp != 0 ) return \" NO \" ; long K = sum / temp ; long [ ] x = new long [ n + 1 ] ; long sumx = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { long dif = i == n ? ( A [ 1 ] - A [ i ] ) : ( A [ i + 1 ] - A [ i ] ) ; if ( K == dif ) continue ; if ( ( K - dif ) % n != 0 || K < dif ) return \" NO \" ; x [ i ] = ( K - dif ) / n ; sumx += x [ i ] ; } if ( sumx != K ) return \" NO \" ; else return \" YES \" ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } System . out . println ( check ( a ) ? \" YES \" : \" NO \" ) ; } static boolean check ( long [ ] a ) { int n = a . length ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } if ( sum % ( ( long ) n * ( n + 1 ) / 2 ) != 0 ) { return false ; } else { long step = sum / ( ( long ) n * ( n + 1 ) / 2 ) ; long count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( ( a [ i ] - a [ i + 1 ] + step ) % n != 0 || a [ i ] - a [ i + 1 ] + step < 0 ) { return false ; } count += ( a [ i ] - a [ i + 1 ] + step ) / n ; } if ( ( a [ n - 1 ] - a [ 0 ] + step ) % n != 0 || a [ n - 1 ] - a [ 0 ] + step < 0 ) { return false ; } else { count += ( a [ n - 1 ] - a [ 0 ] + step ) / n ; } return count == step ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE s = sum ( A ) NEW_LINE K = s // ( N * ( N + 1 ) // 2 ) NEW_LINE if N == 1 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE exit ( ) NEW_LINE DEDENT if s % ( N * ( N + 1 ) // 2 ) != 0 : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE exit ( ) NEW_LINE DEDENT d = [ 0 ] * ( N - 1 ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT d [ i ] = A [ i + 1 ] - A [ i ] - K NEW_LINE DEDENT for i in range ( N - 1 ) : NEW_LINE INDENT if d [ i ] > 0 or abs ( d [ i ] ) % N != 0 : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( \" YES \" ) NEW_LINE", "def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT ret_ng = ' NO ' NEW_LINE ret_ok = ' YES ' NEW_LINE n = int ( io ( ) ) NEW_LINE l = list ( map ( int , io ( ) . split ( ) ) ) NEW_LINE v_one_act = n * ( n + 1 ) / 2 NEW_LINE if sum ( l ) % v_one_act != 0 : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT act_num = sum ( l ) // v_one_act NEW_LINE st_num = 0 NEW_LINE for a , b in zip ( l , l [ 1 : ] + l ) : NEW_LINE INDENT diff = b - a NEW_LINE if ( act_num - diff ) % ( n ) != 0 : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT if ( act_num - diff ) < 0 : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT st = ( act_num - diff ) // ( n ) NEW_LINE st_num += st NEW_LINE DEDENT if act_num != st_num : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT return ret_ok NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE print ( main ( io ) ) NEW_LINE DEDENT", "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 n = II ( ) NEW_LINE A = LI ( ) NEW_LINE k , mod = divmod ( sum ( A ) , ( n * ( n + 1 ) // 2 ) ) NEW_LINE if mod : NEW_LINE INDENT return ' NO ' NEW_LINE DEDENT A . append ( A [ 0 ] ) NEW_LINE diff = [ ] NEW_LINE for a1 , a2 in zip ( A [ : - 1 ] , A [ 1 : ] ) : NEW_LINE INDENT diff . append ( a2 - a1 ) NEW_LINE DEDENT return ' YES ' if not any ( [ ( d - k ) % n or d > k for d in diff ] ) else ' NO ' NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE one2n = sum ( [ i for i in range ( 1 , n + 1 ) ] ) NEW_LINE ok = True NEW_LINE if sum ( a ) % one2n > 0 : NEW_LINE INDENT ok = False NEW_LINE DEDENT if ok : NEW_LINE INDENT b = a + [ a [ 0 ] ] NEW_LINE end = 0 NEW_LINE kire = sum ( a ) // one2n NEW_LINE for idx in range ( n ) : NEW_LINE INDENT dif = b [ idx + 1 ] - b [ idx ] NEW_LINE if ( kire - dif ) % n > 0 : NEW_LINE INDENT ok = False NEW_LINE break NEW_LINE DEDENT elif ( kire - dif ) // n < 0 : NEW_LINE INDENT ok = False NEW_LINE break NEW_LINE DEDENT end += ( kire - dif ) // n NEW_LINE DEDENT if end != kire : NEW_LINE INDENT ok = False NEW_LINE DEDENT DEDENT print ( \" YES \" ) if ok else print ( \" NO \" ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = [ int ( a ) for a in input ( ) . split ( ) ] NEW_LINE RejectStones = N * ( N + 1 ) // 2 NEW_LINE if sum ( A ) % RejectStones != 0 : print ( \" NO \" ) NEW_LINE else : NEW_LINE INDENT TotalOperation = sum ( A ) // RejectStones NEW_LINE sumcheck = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if ( TotalOperation - A [ i + 1 ] + A [ i ] ) % N != 0 or TotalOperation < A [ i + 1 ] - A [ i ] : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT sumcheck += ( TotalOperation - A [ i + 1 ] + A [ i ] ) // N NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( TotalOperation - A [ 0 ] + A [ - 1 ] ) % N != 0 or TotalOperation < A [ 0 ] - A [ - 1 ] : print ( \" NO \" ) NEW_LINE else : NEW_LINE INDENT sumcheck += ( TotalOperation - A [ 0 ] + A [ - 1 ] ) // N NEW_LINE if sumcheck == TotalOperation : print ( \" YES \" ) NEW_LINE else : print ( \" NO \" ) NEW_LINE DEDENT DEDENT DEDENT" ]
atcoder_agc011_B
[ "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 ( ) ; long [ ] ball = new long [ n ] ; long [ ] ruisekiball = new long [ n ] ; int ans = 1 ; int ite = n - 1 ; for ( int i = 0 ; i < n ; i ++ ) { ball [ i ] = sc . nextInt ( ) ; } Arrays . sort ( ball ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { ruisekiball [ i ] = ball [ i ] ; } else { ruisekiball [ i ] = ruisekiball [ i - 1 ] + ball [ i ] ; } } while ( true ) { ite -- ; if ( ruisekiball [ ite ] * 2 >= ball [ ite + 1 ] ) { ans ++ ; } else { break ; } if ( ite == 0 ) { break ; } } System . out . println ( ans ) ; sc . close ( ) ; } }", "import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { long pos = - 1 ; long n = in . nextLong ( ) ; long [ ] a = new long [ ( int ) n ] ; for ( int i = 0 ; i < n ; ++ i ) a [ i ] = in . nextLong ( ) ; Arrays . sort ( a ) ; for ( int i = 0 ; i < n - 1 ; ++ i ) { a [ i + 1 ] += a [ i ] ; if ( a [ i ] * 3 < a [ i + 1 ] ) { pos = i ; } } System . out . println ( n - pos - 1 ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { String line = null ; long sum = 0 ; int answer = 0 ; ArrayList < Integer > aList = new ArrayList < Integer > ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; line = br . readLine ( ) ; line = br . readLine ( ) ; String data [ ] = line . split ( \" ▁ \" ) ; for ( int i = 0 ; i < data . length ; i ++ ) { int num = Integer . parseInt ( data [ i ] ) ; aList . add ( num ) ; } Collections . sort ( aList ) ; for ( int i = 0 ; i < aList . size ( ) ; i ++ ) { int num = aList . get ( i ) ; if ( 2 * sum >= num ) { answer = answer + 1 ; } else { answer = 0 ; } sum = sum + num ; } answer = answer + 1 ; System . out . println ( answer ) ; } }", "import java . util . Arrays ; 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 = sc . nextInt ( ) ; long [ ] A = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) A [ i ] = sc . nextLong ( ) ; Arrays . sort ( A ) ; sc . close ( ) ; long [ ] sum = new long [ n ] ; sum [ 0 ] = A [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) sum [ i ] = sum [ i - 1 ] + A [ i ] ; int res = 1 ; for ( int i = n - 1 ; i >= 1 ; i -- ) { if ( A [ i ] <= 2 * sum [ i - 1 ] ) res ++ ; else break ; } System . out . println ( res ) ; } }", "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 ( ) ; long [ ] a1 = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { long a = sc . nextLong ( ) ; a1 [ i ] = a ; } Arrays . sort ( a1 ) ; long ans = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a1 [ i ] * 2 >= a1 [ i + 1 ] ) { ans ++ ; } else { ans = 1 ; } a1 [ i + 1 ] += a1 [ i ] ; } System . out . println ( ans ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A . sort ( ) NEW_LINE c = 0 NEW_LINE kind = N NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if c * 2 < a : NEW_LINE INDENT kind = N - i NEW_LINE DEDENT c += a NEW_LINE DEDENT print ( kind ) NEW_LINE", "import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE from itertools import accumulate NEW_LINE n = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE a . sort ( ) NEW_LINE acc = list ( accumulate ( a ) ) NEW_LINE ans = 0 NEW_LINE for ai , acci in zip ( a [ - 1 : 0 : - 1 ] , acc [ - 2 : : - 1 ] ) : NEW_LINE INDENT if 2 * acci >= ai : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans + 1 ) NEW_LINE", "import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE A = LI ( ) NEW_LINE A . sort ( ) NEW_LINE C = [ 0 ] NEW_LINE for a in A : NEW_LINE INDENT C . append ( C [ - 1 ] + a ) NEW_LINE DEDENT t = 0 NEW_LINE for i , ( a , c ) in enumerate ( zip ( A [ 1 : ] , C [ 1 : - 1 ] ) ) : NEW_LINE INDENT if a > 2 * c : NEW_LINE INDENT t = i + 1 NEW_LINE DEDENT DEDENT return n - t NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "from itertools import accumulate NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = sorted ( A ) NEW_LINE a_acc = list ( accumulate ( A ) ) NEW_LINE ans = N NEW_LINE seq = 1 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if a_acc [ i ] * 2 >= A [ i + 1 ] : NEW_LINE INDENT seq += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans -= seq NEW_LINE seq = 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT a = int ( io ( ) ) NEW_LINE l = list ( map ( int , io ( ) . split ( ) ) ) NEW_LINE l . sort ( reverse = True ) NEW_LINE m = sum ( l [ 1 : ] ) NEW_LINE pre = l [ 0 ] NEW_LINE num = 1 NEW_LINE for val in l [ 1 : ] : NEW_LINE INDENT if pre > m * 2 : NEW_LINE INDENT break NEW_LINE DEDENT else : NEW_LINE INDENT num += 1 NEW_LINE pre = val NEW_LINE m = m - val NEW_LINE DEDENT DEDENT return num NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE print ( main ( io ) ) NEW_LINE DEDENT" ]
atcoder_agc031_A
[ "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 ( ) ; long mod = 1000000007 ; long [ ] cnt = new long [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { cnt [ S . charAt ( i ) - ' a ' ] ++ ; } long ans = 1 ; for ( long i : cnt ) { ans = ( i + 1 ) * ans % mod ; } ans -= 1 ; System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int MOD = ( int ) 1e9 + 7 ; void solve ( ) { int n = in . nextInt ( ) ; char [ ] s = in . nextToken ( ) . toCharArray ( ) ; int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; } long ans = 1 ; for ( int i = 0 ; i < 26 ; i ++ ) { ans = ans * ( cnt [ i ] + 1 ) % MOD ; } ans = ( ans - 1 + MOD ) % MOD ; out . println ( ans ) ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }", "import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . nextLine ( ) ; String s = sc . nextLine ( ) ; HashMap < String , String > alpha = new HashMap < String , String > ( ) ; long count = 1 ; for ( int i = 0 ; i < Integer . parseInt ( n ) ; i ++ ) { char mark = s . charAt ( i ) ; if ( alpha . containsKey ( String . valueOf ( mark ) ) ) { } else { alpha . put ( String . valueOf ( mark ) , \" \" ) ; int sum = 0 ; for ( int j = i ; j < Integer . parseInt ( n ) ; j ++ ) { if ( s . charAt ( j ) == mark ) { sum ++ ; } } count = count % 1000000007 ; count *= sum + 1 ; } } System . out . println ( ( count - 1 ) % 1000000007 ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { static final long MOD = 1000000007 ; public static void main ( String [ ] args ) throws IOException { MyScanner sc = new MyScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; char [ ] vals = sc . next ( ) . toCharArray ( ) ; long [ ] cant = new long [ 26 ] ; for ( int i = 0 ; i < vals . length ; i ++ ) { cant [ vals [ i ] - ' a ' ] ++ ; } long ans = 1 ; for ( int i = 0 ; i < cant . length ; i ++ ) { ans *= 1 + cant [ i ] ; ans %= MOD ; } ans += MOD - 1 ; ans %= MOD ; out . println ( ans ) ; out . flush ( ) ; } static class MyScanner { private BufferedReader br ; private StringTokenizer tokenizer ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }", "import java . util . HashMap ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String t = s . substring ( i , i + 1 ) ; if ( map . containsKey ( t ) ) { map . put ( t , map . get ( t ) + 1 ) ; } else { map . put ( t , 1 ) ; } } long mod = 1000000007 ; long sum = 1l ; for ( Entry < String , Integer > entry : map . entrySet ( ) ) { long c = entry . getValue ( ) ; sum *= ( long ) ( c + 1 ) % mod ; sum %= ( long ) mod ; } System . out . println ( sum - 1 ) ; } }" ]
[ "import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE from collections import Counter NEW_LINE n = ni ( ) NEW_LINE s = ns ( ) NEW_LINE cnt = Counter ( s ) NEW_LINE ans = 1 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE for k , v in cnt . items ( ) : NEW_LINE INDENT ans *= ( v + 1 ) NEW_LINE ans %= mod NEW_LINE DEDENT ans -= 1 NEW_LINE if ans < 0 : NEW_LINE INDENT ans += mod NEW_LINE DEDENT print ( ans ) NEW_LINE", "_ , s = open ( 0 ) ; a = 1 NEW_LINE for i in set ( s ) : a *= s . count ( i ) + 1 NEW_LINE print ( a // 2 % ( 10 ** 9 + 7 ) - 1 ) NEW_LINE", "import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE eps = 1.0 / 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE dd = [ ( - 1 , 0 ) , ( 0 , 1 ) , ( 1 , 0 ) , ( 0 , - 1 ) ] NEW_LINE ddn = [ ( - 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) , ( 1 , 1 ) , ( 1 , 0 ) , ( 1 , - 1 ) , ( 0 , - 1 ) , ( - 1 , - 1 ) ] NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def pf ( s ) : return print ( s , flush = True ) NEW_LINE def main ( ) : NEW_LINE INDENT n = I ( ) NEW_LINE s = S ( ) NEW_LINE c = collections . Counter ( s ) NEW_LINE r = 1 NEW_LINE for k , v in c . items ( ) : NEW_LINE INDENT r *= v + 1 NEW_LINE r %= mod NEW_LINE DEDENT return ( r - 1 ) % mod NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE memo = [ 1 ] * 26 NEW_LINE for i in range ( N ) : NEW_LINE INDENT k = ord ( s [ i ] ) - ord ( ' a ' ) NEW_LINE memo [ k ] += 1 NEW_LINE DEDENT ans = 1 NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT ans = ans * memo [ i ] % ( 1000000007 ) NEW_LINE DEDENT print ( ans - 1 ) NEW_LINE", "import sys NEW_LINE from collections import Counter NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def list2d ( a , b , c ) : return [ [ c ] * b for i in range ( a ) ] NEW_LINE def list3d ( a , b , c , d ) : return [ [ [ d ] * c for j in range ( b ) ] for i in range ( a ) ] NEW_LINE def ceil ( x , y = 1 ) : return int ( - ( - x // y ) ) 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 def Yes ( ) : print ( ' Yes ' ) NEW_LINE def No ( ) : print ( ' No ' ) NEW_LINE def YES ( ) : print ( ' YES ' ) NEW_LINE def NO ( ) : print ( ' NO ' ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE N = INT ( ) NEW_LINE S = input ( ) NEW_LINE C = Counter ( S ) NEW_LINE ans = 1 NEW_LINE for v in C . values ( ) : NEW_LINE INDENT ans *= v + 1 NEW_LINE ans %= MOD NEW_LINE DEDENT ans -= 1 NEW_LINE print ( ans ) NEW_LINE" ]
atcoder_agc025_B
[ "import java . util . Scanner ; public class Main { static final long M = 998244353L ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; long K = scanner . nextLong ( ) ; System . out . println ( solve ( N , A , B , K ) ) ; } private static long solve ( int N , long A , long B , long K ) { if ( A > B ) return solve ( N , B , A , K ) ; long [ ] fact = new long [ N + 1 ] ; fact [ 0 ] = 1 ; for ( int i = 0 ; i < N ; i ++ ) { fact [ i + 1 ] = fact [ i ] * ( N - i ) % M ; } long [ ] factinv = new long [ N + 1 ] ; factinv [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { factinv [ i ] = factinv [ i - 1 ] * inverse ( i , M ) % M ; } long res = 0 ; for ( int i = 0 ; i <= Math . min ( N , K / B ) ; i ++ ) { if ( ( K - B * i ) % A == 0 ) { long j = ( K - B * i ) / A ; if ( j > N ) continue ; int jj = ( int ) j ; long c = fact [ i ] * factinv [ i ] % M ; c *= fact [ jj ] * factinv [ jj ] % M ; res += c % M ; res %= M ; } } return res ; } public static long inverse ( long a , long mod ) { return modpow ( a , mod - 2 , mod ) ; } public static long modpow ( long a , long n , long mod ) { long res = 1 ; while ( n > 0 ) { if ( n % 2 == 1 ) res = ( res * a ) % mod ; a = ( a * a ) % mod ; n >>= 1 ; } return res % mod ; } }", "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 = Long . parseLong ( sc . next ( ) ) ; long B = Long . parseLong ( sc . next ( ) ) ; long K = Long . parseLong ( sc . next ( ) ) ; final long p = 998244353 ; combination nC = new combination ( N , p ) ; long ans = 0 ; long b = 0 ; for ( int a = 0 ; a <= N ; a ++ ) { b = ( K - A * a ) / B ; if ( A * a > K ) { break ; } else if ( ( K - A * a ) % B != 0 || b > ( long ) N ) { continue ; } else { ans += ( nC . C ( a , p ) * nC . C ( ( int ) b , p ) ) % p ; } } System . out . println ( ans % p ) ; } static class combination { public int n ; public long nfact ; public long reverceTable [ ] ; public combination ( int n , long p ) { this . n = n ; reverceTable = new long [ n + 1 ] ; reverceTable [ 0 ] = 1 ; nfact = 1 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { nfact = nfact * i % p ; } long sum = 1 ; long x = nfact ; long m = p - 2 ; while ( m > 0 ) { if ( ( m & 1 ) == 1 ) { sum = sum * x % p ; } x = x * x % p ; m >>= 1 ; } reverceTable [ n ] = sum ; for ( int i = n - 1 ; i > 0 ; i -- ) { reverceTable [ i ] = reverceTable [ i + 1 ] * ( i + 1 ) % p ; } } public long C ( int r , long p ) { if ( r < 0 || r > n ) { return 0 ; } else { return ( nfact * reverceTable [ r ] % p ) * reverceTable [ n - r ] % p ; } } } }", "import java . util . * ; import java . io . * ; import java . math . BigInteger ; class Main { public static long comb ( long a , long b , long mod , long [ ] pw , long [ ] ipw ) { return ( ( ( pw [ ( int ) a ] * ipw [ ( int ) a - ( int ) b ] ) % mod ) * ipw [ ( int ) b ] ) % mod ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int max = 400000 ; int mod = 998244353 ; long [ ] pw = new long [ max ] ; pw [ 0 ] = 1 ; long [ ] ipw = new long [ max ] ; BigInteger modb = new BigInteger ( String . valueOf ( mod ) ) ; for ( int i = 1 ; i < max ; i ++ ) { pw [ i ] = ( i * pw [ i - 1 ] ) % mod ; } for ( int i = 0 ; i < max ; i ++ ) { ipw [ i ] = new BigInteger ( String . valueOf ( pw [ i ] ) ) . modInverse ( modb ) . longValue ( ) ; } long n = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long ans = 0 ; for ( int A = 0 ; A <= n ; A ++ ) { if ( ( k - A * a ) % b != 0 ) continue ; long B = ( k - A * a ) / b ; if ( B > n || B < 0 ) continue ; ans += ( comb ( n , A , mod , pw , ipw ) * comb ( n , B , mod , pw , ipw ) ) % mod ; ans %= mod ; } System . out . println ( ans ) ; } }", "import java . util . * ; class Main { static int MOD = 998244353 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long ans = 0 ; long [ ] comb = new long [ n + 1 ] ; comb [ 0 ] = 1 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { comb [ i ] = comb [ i - 1 ] * ( n - i + 1 ) % MOD * pow ( i , MOD - 2 ) % MOD ; } long q = K + A ; for ( int x = 0 ; x <= n ; x ++ ) { q -= A ; if ( q % B == 0 ) { long y = q / B ; if ( y > n ) continue ; if ( y < 0 ) break ; ans = ( ans + comb [ x ] * comb [ ( int ) y ] % MOD ) % MOD ; } } System . out . println ( ans ) ; } static long calc ( int n , long a ) { long MulSumN = 1 ; long MulSumA = 1 ; for ( int i = 1 ; i <= a ; i ++ ) { MulSumN *= n - i + 1 ; MulSumN %= MOD ; MulSumA *= i ; MulSumA %= MOD ; } return MulSumN * pow ( MulSumA , MOD - 2 ) % MOD ; } public static long pow ( long a , int b ) { if ( b == 1 ) return a ; if ( b % 2 == 0 ) { long d = pow ( a , b / 2 ) ; return d * d % MOD ; } return a * pow ( a , b - 1 ) % MOD ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; long a = Integer . parseInt ( sc . next ( ) ) ; long b = Integer . parseInt ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; int mod = 998244353 ; int max = 300_003 ; Mod_nCr mn = new Mod_nCr ( mod , max ) ; long ans = 0 ; for ( int red = 0 ; red <= n ; red ++ ) { int blue = ( int ) ( ( k - red * a ) / b ) ; if ( red * a + blue * b == k && 0 <= blue ) { ans += mn . nCr ( n , red ) * mn . nCr ( n , blue ) ; ans %= mod ; } } System . out . println ( ans ) ; } } class Mod_nCr { int mod ; long [ ] fact ; long [ ] rfact ; public Mod_nCr ( int mod , int max ) { this . mod = mod ; fact = new long [ max ] ; rfact = new long [ max ] ; fact [ 0 ] = 1 ; rfact [ 0 ] = 1 ; for ( int i = 1 ; i < max ; i ++ ) { fact [ i ] = ( fact [ i - 1 ] * i ) % mod ; rfact [ i ] = mod_inverse ( fact [ i ] , mod ) ; } } private long mod_pow ( long x , long p , long m ) { long a = 1 ; while ( p > 0 ) { if ( p % 2 == 1 ) { a = a * x % m ; } x = x * x % m ; p /= 2 ; } return a ; } private long mod_inverse ( long a , long m ) { return mod_pow ( a , m - 2 , m ) ; } public long nCr ( int n , int r ) { if ( n < r ) return 0 ; return fact [ n ] * rfact [ r ] % mod * rfact [ n - r ] % mod ; } }" ]
[ "n , a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE m = 998244353 NEW_LINE I = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT I [ i ] = pow ( i + 1 , m - 2 , m ) NEW_LINE DEDENT c = [ 0 ] * ( n + 1 ) NEW_LINE c [ 0 ] = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT c [ i ] = ( c [ i - 1 ] * ( n - i + 1 ) * I [ i - 1 ] ) % m NEW_LINE DEDENT q = 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT j = ( k - i * a ) // b NEW_LINE if ( k - i * a ) % b or j < 0 or j > n : continue NEW_LINE q = ( q + c [ i ] * c [ j ] ) % m NEW_LINE DEDENT print ( q % m ) NEW_LINE", "import sys NEW_LINE MOD = 998244353 NEW_LINE def solve ( N : int , A : int , B : int , K : int ) : NEW_LINE INDENT N_max = 3 * 10 ** 5 NEW_LINE g1 = [ 1 , 1 ] NEW_LINE g2 = [ 1 , 1 ] NEW_LINE inv = [ 0 , 1 ] NEW_LINE for i in range ( 2 , N_max + 1 ) : NEW_LINE INDENT g1 . append ( ( g1 [ - 1 ] * i ) % MOD ) NEW_LINE inv . append ( ( - inv [ MOD % i ] * ( MOD // i ) ) % MOD ) NEW_LINE g2 . append ( ( g2 [ - 1 ] * inv [ - 1 ] ) % MOD ) NEW_LINE DEDENT ans = 0 NEW_LINE for x in range ( N + 1 ) : NEW_LINE INDENT if ( K - A * x ) % B == 0 : NEW_LINE INDENT y = ( K - A * x ) // B NEW_LINE if y < 0 or y > N : NEW_LINE INDENT continue NEW_LINE DEDENT ans += g1 [ N ] * g2 [ x ] * g2 [ N - x ] * g1 [ N ] * g2 [ y ] * g2 [ N - y ] NEW_LINE ans %= MOD NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE K = int ( next ( tokens ) ) NEW_LINE solve ( N , A , B , K ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "N , A , B , K = map ( int , input ( ) . split ( ) ) NEW_LINE P = 998244353 NEW_LINE def egcd ( a , b ) : NEW_LINE INDENT ( x , lastx ) = ( 0 , 1 ) NEW_LINE ( y , lasty ) = ( 1 , 0 ) NEW_LINE while b != 0 : NEW_LINE INDENT q = a // b NEW_LINE ( a , b ) = ( b , a % b ) NEW_LINE ( x , lastx ) = ( lastx - q * x , x ) NEW_LINE ( y , lasty ) = ( lasty - q * y , y ) NEW_LINE DEDENT return ( lastx , lasty , a ) NEW_LINE DEDENT def inv ( x ) : NEW_LINE INDENT return egcd ( x , P ) [ 0 ] NEW_LINE DEDENT Fact = [ 0 for i in range ( N + 1 ) ] NEW_LINE Finv = [ 0 for i in range ( N + 1 ) ] NEW_LINE Fact [ 0 ] = 1 NEW_LINE Finv [ 0 ] = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT Fact [ i ] = ( i * Fact [ i - 1 ] ) % P NEW_LINE Finv [ i ] = ( Finv [ i - 1 ] * inv ( i ) ) % P NEW_LINE DEDENT ans = 0 NEW_LINE def NC ( k ) : NEW_LINE INDENT tmp = ( Finv [ k ] * Finv [ N - k ] ) % P NEW_LINE return ( Fact [ N ] * tmp ) % P NEW_LINE DEDENT for x in range ( N + 1 ) : NEW_LINE INDENT y = ( K - x * A ) // B NEW_LINE if x * A + y * B == K and 0 <= y <= N : NEW_LINE INDENT ans += ( NC ( x ) * NC ( y ) ) % P NEW_LINE DEDENT DEDENT print ( ans % P ) 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 from itertools import accumulate NEW_LINE self . mod = mod NEW_LINE self . factorial = [ 1 ] + list ( accumulate ( range ( 1 , max_n + 1 ) , lambda x , y : x * y % mod ) ) NEW_LINE max_inv , x = 1 , self . factorial [ - 1 ] NEW_LINE for bit in bin ( mod - 2 ) [ : 1 : - 1 ] : NEW_LINE INDENT if bit == \"1\" : NEW_LINE INDENT max_inv = max_inv * x % mod NEW_LINE DEDENT x = x * x % mod NEW_LINE DEDENT self . inverse = ( list ( accumulate ( [ max_inv ] + list ( range ( max_n , 0 , - 1 ) ) , lambda x , y : x * y % mod ) ) ) [ : : - 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 N , A , B , K = map ( int , input ( ) . split ( ) ) NEW_LINE mod = 998244353 NEW_LINE big_comb = BigCombination ( mod , N ) NEW_LINE get_comb = big_comb . get_combination NEW_LINE answer = 0 NEW_LINE for a_count in range ( N + 1 ) : NEW_LINE INDENT if ( K - a_count * A ) % B == 0 and 0 <= ( K - a_count * A ) // B <= N : NEW_LINE INDENT b_count = ( K - a_count * A ) // B NEW_LINE answer = ( answer + get_comb ( N , a_count ) * get_comb ( N , b_count ) ) % mod NEW_LINE DEDENT DEDENT print ( answer ) NEW_LINE DEDENT", "p = 998244353 NEW_LINE def getinv ( n ) : NEW_LINE INDENT inv = [ 0 ] * ( n + 1 ) NEW_LINE inv [ 1 ] = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT inv [ i ] = ( - ( p // i ) * inv [ p % i ] ) % p NEW_LINE DEDENT return inv NEW_LINE DEDENT def getCmb ( n ) : NEW_LINE INDENT inv = getinv ( n ) NEW_LINE nCr = [ 0 ] * ( n + 1 ) NEW_LINE nCr [ 0 ] = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT nCr [ i ] = ( nCr [ i - 1 ] * ( n - i + 1 ) * inv [ i ] ) % p NEW_LINE DEDENT return nCr NEW_LINE DEDENT def solve ( n , a , b , k ) : NEW_LINE INDENT nCr = getCmb ( n ) NEW_LINE ans = 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT j = ( k - a * i ) // b NEW_LINE if a * i + b * j == k and 0 <= j <= n : NEW_LINE INDENT ans += ( nCr [ i ] * nCr [ j ] ) % p NEW_LINE ans %= p NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n , a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( n , a , b , k ) ) NEW_LINE" ]