id
stringlengths
13
20
java
sequence
python
sequence
atcoder_arc044_B
[ "import java . io . * ; import java . util . * ; import static java . lang . System . in ; class Main { static long mod = 1000000000 + 7 ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; long ans = help ( a ) ; System . out . println ( ans ) ; } static long help ( int [ ] a ) { if ( a [ 0 ] != 0 ) return 0 ; int maxDist = 0 ; for ( int w : a ) maxDist = Math . max ( maxDist , w ) ; int [ ] rec = new int [ maxDist + 1 ] ; for ( int w : a ) rec [ w ] ++ ; if ( rec [ 0 ] != 1 ) return 0 ; for ( int i = 1 ; i <= maxDist ; i ++ ) { if ( rec [ i ] < 1 ) return 0 ; } long [ ] dp = new long [ maxDist + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= maxDist ; i ++ ) { long base = power ( 2 , rec [ i - 1 ] ) - 1 ; dp [ i ] = power ( base , rec [ i ] ) * dp [ i - 1 ] % mod ; long sameLayer = ( ( long ) rec [ i ] ) * ( ( long ) rec [ i ] - 1 ) / 2 ; dp [ i ] = dp [ i ] * power ( 2 , sameLayer ) % mod ; } return dp [ maxDist ] ; } static long power ( long base , long p ) { long ans = 1 ; while ( p > 0 ) { if ( p % 2 == 1 ) ans = ans * base % mod ; base = base * base % mod ; p /= 2 ; } return ans ; } }", "import java . util . * ; public class Main { static final int MOD = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] d = new int [ n ] ; int dmax = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; d [ a [ i ] ] ++ ; dmax = Math . max ( a [ i ] , dmax ) ; } if ( a [ 0 ] != 0 || d [ 0 ] != 1 ) { System . out . println ( 0 ) ; return ; } for ( int i = 0 ; i <= dmax ; i ++ ) { if ( d [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } long ans = 1L ; for ( int i = 1 ; i <= dmax ; i ++ ) { long tmp = pow ( 2 , d [ i - 1 ] ) ; tmp = ( tmp + MOD - 1 ) % MOD ; ans = ( ans * pow ( tmp , d [ i ] ) ) % MOD ; ans = ( ans * pow ( 2 , ( long ) ( d [ i ] - 1 ) * d [ i ] / 2 ) ) % MOD ; } System . out . println ( ans ) ; } public static long pow ( long a , long n ) { long x = 1 ; while ( n > 0 ) { if ( n % 2 == 1 ) { x = x * a % MOD ; } a = a * a % MOD ; n >>= 1 ; } return x ; } }" ]
[ "def main ( ) : NEW_LINE INDENT R = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( \" ▁ \" ) ) ) NEW_LINE if a [ 0 ] != 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT amax = max ( a ) NEW_LINE h = [ 0 ] * ( amax + 1 ) NEW_LINE for i in a : NEW_LINE INDENT h [ i ] += 1 NEW_LINE DEDENT if h [ 0 ] != 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT for i in h : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE b = 1 NEW_LINE for i in h [ 1 : ] : NEW_LINE INDENT if i > 1 : NEW_LINE INDENT ans *= pow ( 2 , i * ( i - 1 ) // 2 , R ) NEW_LINE ans %= R NEW_LINE DEDENT ans *= pow ( pow ( 2 , b , R ) - 1 , i , R ) NEW_LINE ans %= R NEW_LINE b = i NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "def powmod ( a , b , P ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT stk = [ ] NEW_LINE while b > 1 : NEW_LINE INDENT stk . append ( b % 2 ) NEW_LINE b //= 2 NEW_LINE DEDENT c = a % P NEW_LINE while len ( stk ) > 0 : NEW_LINE INDENT t = stk . pop ( ) NEW_LINE c = ( c * c ) % P NEW_LINE if t == 1 : NEW_LINE INDENT c = ( c * a ) % P NEW_LINE DEDENT DEDENT return c NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE P = 10 ** 9 + 7 NEW_LINE def count ( A ) : NEW_LINE INDENT S = [ 0 for _ in range ( max ( A ) + 1 ) ] NEW_LINE for a in A : NEW_LINE INDENT S [ a ] += 1 NEW_LINE DEDENT if A [ 0 ] != 0 or S [ 0 ] != 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT cnt = 1 NEW_LINE for i in range ( 1 , len ( S ) ) : NEW_LINE INDENT if S [ i ] == 0 : return 0 NEW_LINE path1 = powmod ( ( powmod ( 2 , S [ i - 1 ] , P ) - 1 ) % P , S [ i ] , P ) NEW_LINE path2 = powmod ( 2 , S [ i ] * ( S [ i ] - 1 ) // 2 , P ) % P NEW_LINE cnt = cnt * path1 * path2 % P NEW_LINE DEDENT return cnt NEW_LINE DEDENT print ( count ( A ) ) NEW_LINE", "from collections import defaultdict NEW_LINE def mod_pow ( x , n , mod ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT res = mod_pow ( x * x % mod , n // 2 , mod ) NEW_LINE if n & 1 : NEW_LINE INDENT res = res * x % mod NEW_LINE DEDENT return res NEW_LINE DEDENT MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ok = True NEW_LINE zeros = 0 NEW_LINE cnt = defaultdict ( int ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT if A [ i ] != 0 : NEW_LINE INDENT ok = False NEW_LINE DEDENT DEDENT if A [ i ] == 0 : NEW_LINE INDENT zeros += 1 NEW_LINE DEDENT cnt [ A [ i ] ] += 1 NEW_LINE DEDENT maxn = max ( cnt . keys ( ) ) NEW_LINE if zeros != 1 : NEW_LINE INDENT ok = False NEW_LINE DEDENT res = 1 NEW_LINE if ok == True : NEW_LINE INDENT for i in range ( 0 , maxn + 1 ) : NEW_LINE INDENT if i != 0 and cnt [ i ] == 0 : NEW_LINE INDENT ok = False ; NEW_LINE break NEW_LINE DEDENT K = cnt [ i ] NEW_LINE res = ( res * mod_pow ( 2 , K * ( K - 1 ) // 2 , MOD ) ) % MOD NEW_LINE if i != 0 : NEW_LINE INDENT t = cnt [ i - 1 ] NEW_LINE curr = mod_pow ( 2 , t , MOD ) NEW_LINE s = cnt [ i ] NEW_LINE curr2 = mod_pow ( curr - 1 + MOD , s , MOD ) NEW_LINE res = ( res * curr2 ) % MOD NEW_LINE DEDENT DEDENT DEDENT print ( res if ok == True else 0 ) NEW_LINE", "import collections NEW_LINE MAX_N = 10 ** 5 + 1 NEW_LINE MOD = 1000000007 NEW_LINE same_dist = [ 0 ] * ( MAX_N + 1 ) NEW_LINE same_dist [ 1 ] = 1 NEW_LINE for i in range ( 2 , MAX_N + 1 ) : NEW_LINE INDENT same_dist [ i ] = same_dist [ i - 1 ] * pow ( 2 , i - 1 , MOD ) NEW_LINE same_dist [ i ] %= MOD NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cnt_num = collections . Counter ( a ) NEW_LINE if not ( cnt_num [ 0 ] == 1 and a [ 0 ] == 0 ) : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT if len ( a ) == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT ans = 1 NEW_LINE cnt = 1 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if cnt_num [ i ] == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT ans *= same_dist [ cnt_num [ i ] ] NEW_LINE ans %= MOD NEW_LINE ans *= pow ( ( 2 ** cnt_num [ i - 1 ] - 1 ) , cnt_num [ i ] , MOD ) NEW_LINE ans %= MOD NEW_LINE DEDENT cnt += cnt_num [ i ] NEW_LINE if cnt == len ( a ) : NEW_LINE INDENT print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT", "from collections import Counter NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def power ( n , k ) : NEW_LINE INDENT if k == 0 : return 1 NEW_LINE elif k == 1 : return n NEW_LINE elif k % 2 == 0 : return power ( ( n ** 2 ) % mod , k // 2 ) NEW_LINE else : return ( n * power ( n , k - 1 ) ) % mod NEW_LINE DEDENT if a [ 0 ] != 0 or a . count ( 0 ) != 1 : print ( 0 ) NEW_LINE else : NEW_LINE INDENT c , ans , num , mod = Counter ( a ) , 1 , 1 , 10 ** 9 + 7 NEW_LINE for i in range ( 1 , max ( a ) + 1 ) : NEW_LINE INDENT if c [ i ] == 0 : NEW_LINE INDENT ans = 0 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( ans * power ( ( power ( 2 , num ) - 1 ) , c [ i ] ) * power ( 2 , c [ i ] * ( c [ i ] - 1 ) // 2 ) ) % mod NEW_LINE num = c [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT" ]
atcoder_arc032_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; UnionFind uf = new UnionFind ( N ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; uf . union ( a , b ) ; } System . out . println ( uf . count ( N ) - 1 ) ; } private static class UnionFind { int parent [ ] ; int rank [ ] ; public UnionFind ( int n ) { parent = new int [ n ] ; rank = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { parent [ i ] = i ; rank [ i ] = 0 ; } } boolean same ( int x , int y ) { return find ( x ) == find ( y ) ; } public int find ( int x ) { if ( parent [ x ] == x ) return x ; else return parent [ x ] = find ( parent [ x ] ) ; } public void union ( int x , int y ) { x = find ( x ) ; y = find ( y ) ; if ( x != y ) { if ( rank [ x ] > rank [ y ] ) { parent [ y ] = x ; } else { parent [ x ] = y ; if ( rank [ x ] == rank [ y ] ) { rank [ y ] ++ ; } } } return ; } public int count ( int n ) { int ret = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == find ( i ) ) ret ++ ; } return ret ; } } }", "import java . util . * ; public class Main { public static class Node { ArrayList < Integer > to ; boolean visit ; Node ( ) { to = new ArrayList < Integer > ( ) ; visit = false ; } } static Scanner sc = new Scanner ( System . in ) ; static int N = sc . nextInt ( ) ; static int M = sc . nextInt ( ) ; static Node [ ] node = new Node [ 100000 ] ; public static void main ( String [ ] args ) { for ( int i = 0 ; i < N ; i ++ ) node [ i ] = new Node ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; node [ a - 1 ] . to . add ( b - 1 ) ; node [ b - 1 ] . to . add ( a - 1 ) ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( node [ i ] . visit ) continue ; node [ i ] . visit = true ; solve ( node [ i ] ) ; count ++ ; } System . out . println ( count - 1 ) ; } public static void solve ( Node n ) { for ( int i = 0 ; i < n . to . size ( ) ; i ++ ) { int next = n . to . get ( i ) ; if ( node [ next ] . visit ) continue ; node [ next ] . visit = true ; solve ( node [ next ] ) ; } } }", "import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; UnionFind uf = new UnionFind ( N ) ; uf . init ( N ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; uf . unite ( a , b ) ; } for ( int i = 0 ; i < N ; i ++ ) { uf . find ( i ) ; } boolean [ ] used = new boolean [ N ] ; int ans = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! used [ uf . parent [ i ] ] ) { used [ uf . parent [ i ] ] = true ; ans ++ ; } } System . out . println ( ans ) ; } } class UnionFind { public int [ ] parent ; public int [ ] rank ; public UnionFind ( int MAX_SIZE ) { parent = new int [ MAX_SIZE ] ; rank = new int [ MAX_SIZE ] ; } public void init ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { parent [ i ] = i ; rank [ i ] = 0 ; } } public int find ( int x ) { if ( parent [ x ] == x ) { return x ; } else { return parent [ x ] = find ( parent [ x ] ) ; } } public void unite ( int x , int y ) { x = find ( x ) ; y = find ( y ) ; if ( x == y ) return ; if ( rank [ x ] < rank [ y ] ) parent [ x ] = y ; else parent [ y ] = x ; if ( rank [ x ] == rank [ y ] ) rank [ x ] ++ ; } public boolean same ( int x , int y ) { return find ( x ) == find ( y ) ; } }", "import java . util . * ; public class Main { public static class Node { ArrayList < Integer > to ; boolean visit ; Node ( ) { to = new ArrayList < Integer > ( ) ; visit = false ; } } static Node [ ] node = new Node [ 100000 ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) node [ i ] = new Node ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; node [ a - 1 ] . to . add ( b - 1 ) ; node [ b - 1 ] . to . add ( a - 1 ) ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( node [ i ] . visit ) continue ; node [ i ] . visit = true ; solve ( node [ i ] ) ; count ++ ; } System . out . println ( count - 1 ) ; } public static void solve ( Node n ) { for ( int i = 0 ; i < n . to . size ( ) ; i ++ ) { int next = n . to . get ( i ) ; if ( node [ next ] . visit ) continue ; node [ next ] . visit = true ; solve ( node [ next ] ) ; } } }", "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 ( ) ; UnionFindTree uft = new UnionFindTree ( n ) ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; uft . union ( a - 1 , b - 1 ) ; } System . out . println ( uft . countBlock ( ) - 1 ) ; } static class UnionFindTree { int [ ] parent ; int [ ] rank ; public UnionFindTree ( int size ) { parent = new int [ size ] ; rank = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { parent [ i ] = i ; } } public int find ( int x ) { if ( parent [ x ] == x ) { return x ; } else { int v = find ( parent [ x ] ) ; parent [ x ] = v ; return v ; } } public boolean same ( int x , int y ) { return find ( x ) == find ( y ) ; } public void union ( int x , int y ) { int rootX = find ( x ) ; int rootY = find ( y ) ; if ( rank [ rootX ] > rank [ rootY ] ) { parent [ rootY ] = rootX ; } else if ( rank [ rootX ] < rank [ rootY ] ) { parent [ rootX ] = rootY ; } else if ( rootX != rootY ) { parent [ rootX ] = rootY ; rank [ rootX ] ++ ; } } public int countBlock ( ) { int count = 0 ; for ( int i = 0 ; i < parent . length ; i ++ ) { if ( parent [ i ] == i ) { count ++ ; } } return count ; } } }" ]
[ "import sys NEW_LINE input = sys . stdin . readline NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE par = [ ] NEW_LINE rank = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT par . append ( i ) NEW_LINE rank . append ( 0 ) NEW_LINE DEDENT def find ( x , par ) : NEW_LINE INDENT if par [ x ] == x : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return find ( par [ x ] , par ) NEW_LINE DEDENT DEDENT def unite ( x , y , par , rank ) : NEW_LINE INDENT x = find ( x , par ) NEW_LINE y = find ( y , par ) NEW_LINE if x != y : NEW_LINE INDENT if rank [ x ] < rank [ y ] : NEW_LINE INDENT par [ x ] = y NEW_LINE DEDENT else : NEW_LINE INDENT par [ y ] = x NEW_LINE if rank [ x ] == rank [ y ] : NEW_LINE INDENT rank [ x ] += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT def same ( x , y , par ) : NEW_LINE INDENT return find ( x , par ) == find ( y , par ) NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT a , b = map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) NEW_LINE unite ( a , b , par , rank ) NEW_LINE DEDENT res = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if par [ i ] == i : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE", "class UnionFind ( ) : NEW_LINE INDENT def __init__ ( self , size ) : NEW_LINE INDENT self . table = [ - 1 ] * size NEW_LINE DEDENT def root ( self , x ) : NEW_LINE INDENT while self . table [ x ] >= 0 : NEW_LINE INDENT x = self . table [ x ] NEW_LINE DEDENT return x NEW_LINE DEDENT def unite ( self , x , y ) : NEW_LINE INDENT s1 = self . root ( x ) NEW_LINE s2 = self . root ( y ) NEW_LINE if s1 != s2 : NEW_LINE INDENT if self . table [ s1 ] > self . table [ s2 ] : NEW_LINE INDENT s1 , s2 = s2 , s1 NEW_LINE DEDENT self . table [ s1 ] += self . table [ s2 ] NEW_LINE self . table [ s2 ] = s1 NEW_LINE DEDENT return NEW_LINE DEDENT def same ( self , x , y ) : NEW_LINE INDENT return self . root ( x ) == self . root ( y ) NEW_LINE DEDENT def size ( self , x ) : NEW_LINE INDENT return - self . table [ self . root ( x ) ] NEW_LINE DEDENT DEDENT ( n , m ) , * e = [ map ( int , t . split ( ) ) for t in open ( 0 ) . readlines ( ) ] NEW_LINE u = UnionFind ( n ) NEW_LINE for x , y in e : NEW_LINE INDENT u . unite ( x - 1 , y - 1 ) NEW_LINE DEDENT print ( sum ( i < 0 for i in u . table ) - 1 ) NEW_LINE", "from collections import defaultdict NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( sys . getrecursionlimit ( ) * 10000 ) NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE g = defaultdict ( list ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE g [ a ] . append ( b ) NEW_LINE g [ b ] . append ( a ) NEW_LINE DEDENT visited = set ( ) NEW_LINE def dfs ( v ) : NEW_LINE INDENT visited . add ( v ) NEW_LINE for c in g [ v ] : NEW_LINE INDENT if not c in visited : NEW_LINE INDENT dfs ( c ) NEW_LINE DEDENT DEDENT DEDENT connected_component = 0 NEW_LINE for v in range ( 1 , N + 1 ) : NEW_LINE INDENT if not v in visited : NEW_LINE INDENT dfs ( v ) NEW_LINE connected_component += 1 NEW_LINE DEDENT DEDENT print ( connected_component - 1 ) NEW_LINE", "def b_construction ( N , M , Road ) : NEW_LINE INDENT class UnionFind ( object ) : NEW_LINE INDENT def __init__ ( self , N ) : NEW_LINE INDENT self . p = list ( range ( N ) ) NEW_LINE self . rank = [ 0 ] * N NEW_LINE self . size = [ 1 ] * N NEW_LINE DEDENT def union ( self , x , y ) : NEW_LINE INDENT u = self . find ( x ) NEW_LINE v = self . find ( y ) NEW_LINE if u == v : NEW_LINE INDENT return NEW_LINE DEDENT if self . rank [ u ] < self . rank [ v ] : NEW_LINE INDENT self . p [ u ] = v NEW_LINE self . size [ v ] += self . size [ u ] NEW_LINE self . size [ u ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT self . p [ v ] = u NEW_LINE self . size [ u ] += self . size [ v ] NEW_LINE self . size [ v ] = 0 NEW_LINE if self . rank [ u ] == self . rank [ v ] : NEW_LINE INDENT self . rank [ u ] += 1 NEW_LINE DEDENT DEDENT DEDENT def find ( self , x ) : NEW_LINE INDENT if self . p [ x ] != x : NEW_LINE INDENT self . p [ x ] = self . find ( self . p [ x ] ) NEW_LINE DEDENT return self . p [ x ] NEW_LINE DEDENT def __str__ ( self ) : NEW_LINE INDENT return ' [ { } ] ' . format ( ' , ▁ ' . join ( map ( str , self . p ) ) ) NEW_LINE DEDENT DEDENT uf = UnionFind ( N ) NEW_LINE for a , b in Road : NEW_LINE INDENT uf . union ( a - 1 , b - 1 ) NEW_LINE DEDENT ans = len ( [ 1 for v in range ( N ) if uf . find ( v ) == v ] ) - 1 NEW_LINE return ans NEW_LINE DEDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE Road = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( M ) ] NEW_LINE print ( b_construction ( N , M , Road ) ) NEW_LINE", "class DisjointSet : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . rank = { } NEW_LINE self . p = { } NEW_LINE DEDENT def makeSet ( self , x ) : NEW_LINE INDENT self . p [ x ] = x NEW_LINE self . rank [ x ] = 0 NEW_LINE DEDENT def same ( self , x , y ) : NEW_LINE INDENT return self . findSet ( x ) == self . findSet ( y ) NEW_LINE DEDENT def unite ( self , x , y ) : NEW_LINE INDENT self . link ( self . findSet ( x ) , self . findSet ( y ) ) NEW_LINE DEDENT def link ( self , x , y ) : NEW_LINE INDENT if x == y : NEW_LINE INDENT return NEW_LINE DEDENT if ( self . rank [ x ] > self . rank [ y ] ) : NEW_LINE INDENT self . p [ y ] = x NEW_LINE DEDENT else : NEW_LINE INDENT self . p [ x ] = y NEW_LINE if ( self . rank [ x ] == self . rank [ y ] ) : NEW_LINE INDENT self . rank [ y ] += 1 NEW_LINE DEDENT DEDENT DEDENT def findSet ( self , x ) : NEW_LINE INDENT if ( x != self . p [ x ] ) : NEW_LINE INDENT self . p [ x ] = self . findSet ( self . p [ x ] ) NEW_LINE DEDENT return self . p [ x ] NEW_LINE DEDENT DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE ds = DisjointSet ( ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT ds . makeSet ( i ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE ds . unite ( a , b ) NEW_LINE DEDENT connected_component = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if i == ds . findSet ( i ) : NEW_LINE INDENT connected_component += 1 NEW_LINE DEDENT DEDENT print ( connected_component - 1 ) NEW_LINE" ]
atcoder_abc015_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) , m = sc . next ( ) ; if ( n . length ( ) > m . length ( ) ) System . out . println ( n ) ; else System . out . println ( m ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; 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 ( ) ; String t = in . next ( ) ; out . println ( s . length ( ) > t . length ( ) ? s : t ) ; } } 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 ( ) ; String s = sc . next ( ) ; String s1 = sc . next ( ) ; int a = s . length ( ) ; int b = s1 . length ( ) ; System . out . println ( a > b ? s : s1 ) ; } 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 ) { String a = sc . next ( ) , b = sc . next ( ) ; out . println ( a . length ( ) > b . length ( ) ? a : b ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String A = in . next ( ) ; String B = in . next ( ) ; if ( A . length ( ) > B . length ( ) ) { out . println ( A ) ; } else { out . println ( B ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }" ]
[ "s1 = input ( ) NEW_LINE s2 = input ( ) NEW_LINE if len ( s1 ) > len ( s2 ) : NEW_LINE INDENT print ( s1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( s2 ) NEW_LINE DEDENT", "print ( max ( open ( 0 ) , key = len ) ) NEW_LINE", "a = input ( ) NEW_LINE b = input ( ) NEW_LINE print ( a if len ( a ) >= len ( b ) else b ) NEW_LINE", "A = input ( ) NEW_LINE B = input ( ) NEW_LINE if A . islower ( ) and B . islower ( ) : NEW_LINE INDENT C = len ( A ) NEW_LINE D = len ( B ) NEW_LINE if C > D : NEW_LINE INDENT print ( A ) NEW_LINE DEDENT elif D > C : NEW_LINE INDENT print ( B ) NEW_LINE DEDENT DEDENT", "print ( max ( input ( ) , input ( ) , key = len ) ) NEW_LINE" ]
atcoder_arc084_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; int [ ] c = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a ) ; Arrays . sort ( b ) ; Arrays . sort ( c ) ; long ans = 0 ; long [ ] cnum = new long [ n + 1 ] ; int pos = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( c [ pos ] <= b [ i ] ) { pos ++ ; if ( pos >= n ) { pos = n ; break ; } } if ( pos >= n ) break ; cnum [ i ] = n - pos ; } for ( int i = 1 ; i < n ; i ++ ) { cnum [ n - i - 1 ] = cnum [ n - i ] + cnum [ n - i - 1 ] ; } pos = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( b [ pos ] <= a [ i ] ) { pos ++ ; if ( pos >= n ) { pos = n ; break ; } } if ( pos >= n ) break ; ans += cnum [ pos ] ; } System . out . println ( ans ) ; } }", "import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; Integer [ ] A = new Integer [ n ] , B = new Integer [ n ] , C = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) B [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) C [ i ] = sc . nextInt ( ) ; Arrays . sort ( A ) ; Arrays . sort ( C ) ; long ans = 0L ; for ( int i = 0 ; i < n ; i ++ ) { long a = ~ Arrays . binarySearch ( A , B [ i ] , ( x , y ) -> x . compareTo ( y ) >= 0 ? 1 : - 1 ) ; long c = n - ~ Arrays . binarySearch ( C , B [ i ] , ( x , y ) -> x . compareTo ( y ) > 0 ? 1 : - 1 ) ; ans += a * c ; } System . out . println ( ans ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; import java . util . stream . IntStream ; class Main { static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { int n = gInt ( ) ; int [ ] a = in ( n ) , b = in ( n ) , c = in ( n ) ; long [ ] v1 = new long [ n ] , v2 = new long [ n ] ; { int v = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( ; v < n && a [ v ] < b [ i ] ; ++ v ) { } v1 [ i ] = v ; } } Arrays . parallelPrefix ( v1 , Long :: sum ) ; { int v = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( ; v < n && b [ v ] < c [ i ] ; ++ v ) { } v2 [ i ] = v == 0 ? 0 : v1 [ v - 1 ] ; } } System . out . println ( Arrays . stream ( v2 ) . sum ( ) ) ; } static int [ ] in ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> gInt ( ) ) . sorted ( ) . toArray ( ) ; } }", "import java . util . Scanner ; import java . util . Arrays ; 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 ( ) ) ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) b [ i ] = Integer . parseInt ( sc . next ( ) ) ; int [ ] c = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) c [ i ] = Integer . parseInt ( sc . next ( ) ) ; Arrays . sort ( a ) ; Arrays . sort ( b ) ; Arrays . sort ( c ) ; long ret = 0 ; int s = 0 , t = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { while ( s < n && c [ s ] <= b [ i ] ) s ++ ; while ( t < n - 1 && a [ t + 1 ] < b [ i ] ) t ++ ; ret += ( long ) ( n - s ) * ( t + 1 ) ; } System . out . println ( ret ) ; } }", "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 ( ) ; Integer [ ] as = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextInt ( ) ; } Arrays . sort ( as ) ; Integer [ ] bs = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { bs [ i ] = sc . nextInt ( ) ; } Integer [ ] cs = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { cs [ i ] = sc . nextInt ( ) ; } Arrays . sort ( cs ) ; long ans = 0 ; for ( Integer b : bs ) { long ai = Arrays . binarySearch ( as , b , ( x , y ) -> ( x . compareTo ( y ) >= 0 ) ? 1 : - 1 ) ; ai = ~ ai ; long ci = Arrays . binarySearch ( cs , b , ( x , y ) -> ( x . compareTo ( y ) > 0 ) ? 1 : - 1 ) ; ci = ~ ci ; ans += ai * ( cs . length - ci ) ; } System . out . println ( ans ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE c = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE sorted_a = sorted ( a ) NEW_LINE sorted_b = sorted ( b ) NEW_LINE sorted_c = sorted ( c ) NEW_LINE ans = 0 NEW_LINE before_a = 0 NEW_LINE before_c = 0 NEW_LINE count_a = 0 NEW_LINE count_c_rest = 0 NEW_LINE for each_b in sorted_b : NEW_LINE INDENT for ai in range ( before_a , len ( sorted_a ) ) : NEW_LINE INDENT if each_b > sorted_a [ ai ] : NEW_LINE INDENT count_a += 1 NEW_LINE before_a += 1 NEW_LINE DEDENT else : NEW_LINE INDENT before_a = ai NEW_LINE break NEW_LINE DEDENT DEDENT for ci in range ( before_c , len ( sorted_c ) ) : NEW_LINE INDENT if sorted_c [ ci ] <= each_b : NEW_LINE INDENT count_c_rest += 1 NEW_LINE before_c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT before_c = ci NEW_LINE break NEW_LINE DEDENT DEDENT ans += count_a * ( len ( sorted_c ) - count_c_rest ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE import bisect NEW_LINE N = int ( input ( ) ) NEW_LINE A = sorted ( inpl ( ) ) NEW_LINE B = inpl ( ) NEW_LINE C = sorted ( inpl ( ) ) NEW_LINE ans = 0 NEW_LINE for b in B : NEW_LINE INDENT ans += bisect . bisect_left ( A , b ) * ( N - bisect . bisect_right ( C , b ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE A , B , C = sorted ( list ( MI ( ) ) ) , sorted ( list ( MI ( ) ) ) , sorted ( list ( MI ( ) ) ) NEW_LINE s = [ i for i in range ( 1 , N + 1 ) ] NEW_LINE ia = N - 1 NEW_LINE ns = [ None ] * N NEW_LINE for ib in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT while ia >= 0 and A [ ia ] >= B [ ib ] : NEW_LINE INDENT ia -= 1 NEW_LINE DEDENT if ia >= 0 : NEW_LINE INDENT ns [ ib ] = s [ ia ] NEW_LINE DEDENT else : NEW_LINE INDENT ns [ ib ] = 0 NEW_LINE DEDENT DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT ns [ i ] += ns [ i - 1 ] NEW_LINE DEDENT s = ns NEW_LINE ib = N - 1 NEW_LINE ns = [ None ] * N NEW_LINE for ic in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT while ib >= 0 and B [ ib ] >= C [ ic ] : NEW_LINE INDENT ib -= 1 NEW_LINE DEDENT if ib >= 0 : NEW_LINE INDENT ns [ ic ] = s [ ib ] NEW_LINE DEDENT else : NEW_LINE INDENT ns [ ic ] = 0 NEW_LINE DEDENT DEDENT return sum ( ns ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT", "from itertools import accumulate NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE B = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE C = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = sorted ( A ) NEW_LINE B = sorted ( B ) NEW_LINE C = sorted ( C ) NEW_LINE acc_a = [ 0 ] * N NEW_LINE acc_c = [ 0 ] * N NEW_LINE i_a = 0 NEW_LINE i_c = N - 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT b = B [ i ] NEW_LINE while i_a < N and A [ i_a ] < b : NEW_LINE INDENT acc_a [ i ] += 1 NEW_LINE i_a += 1 NEW_LINE DEDENT DEDENT for i in reversed ( range ( N ) ) : NEW_LINE INDENT b = B [ i ] NEW_LINE while i_c >= 0 and C [ i_c ] > b : NEW_LINE INDENT acc_c [ i ] += 1 NEW_LINE i_c -= 1 NEW_LINE DEDENT DEDENT acc_a = list ( accumulate ( acc_a ) ) NEW_LINE acc_c = list ( accumulate ( acc_c [ : : - 1 ] ) ) NEW_LINE acc_c = acc_c [ : : - 1 ] NEW_LINE ans = 0 NEW_LINE for a , c in zip ( acc_a , acc_c ) : NEW_LINE INDENT ans += a * c NEW_LINE DEDENT print ( ans ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE A = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE B = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE C = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE A = sorted ( A ) NEW_LINE B = sorted ( B ) NEW_LINE C = sorted ( C ) NEW_LINE ans = 0 NEW_LINE midnum = [ ] NEW_LINE index = 0 NEW_LINE for i in B : NEW_LINE INDENT while True : NEW_LINE INDENT if index == N or A [ index ] >= i : NEW_LINE INDENT midnum . append ( index ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT index += 1 NEW_LINE DEDENT DEDENT DEDENT index = 0 NEW_LINE midCnum = [ ] NEW_LINE tmp = 0 NEW_LINE for i in midnum : NEW_LINE INDENT tmp += i NEW_LINE midCnum . append ( tmp ) NEW_LINE DEDENT for i in C : NEW_LINE INDENT while True : NEW_LINE INDENT if index == N : NEW_LINE INDENT ans += midCnum [ index - 1 ] NEW_LINE break NEW_LINE DEDENT elif i <= B [ index ] : NEW_LINE INDENT if index != 0 : NEW_LINE INDENT ans += midCnum [ index - 1 ] NEW_LINE DEDENT break NEW_LINE DEDENT else : NEW_LINE INDENT index += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE" ]
atcoder_arc007_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; System . out . println ( sc . next ( ) . replaceAll ( a , \" \" ) ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String c = in . next ( ) ; out . println ( in . next ( ) . replaceAll ( c , \" \" ) ) ; } } 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 s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! X . equals ( s . substring ( i , i + 1 ) ) ) { 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 . io . * ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 <= args . length ; debug2 = 2 <= args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; final String X = in . readLine ( ) ; System . out . println ( in . readLine ( ) . replaceAll ( X , \" \" ) ) ; } }", "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 ) ; char x = sc . next ( ) . charAt ( 0 ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != x ) out . print ( s . charAt ( i ) ) ; } out . println ( ) ; } }" ]
[ "X = input ( ) NEW_LINE s = input ( ) NEW_LINE result = \" \" . join ( [ c for c in s if c not in X ] ) NEW_LINE print ( result ) NEW_LINE", "x , c = input ( ) , input ( ) NEW_LINE ans = \" \" NEW_LINE for i in range ( len ( c ) ) : NEW_LINE INDENT if c [ i ] != x : ans += c [ i ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "s = input ( ) ; print ( input ( ) . replace ( s , \" \" ) ) NEW_LINE", "X = input ( ) NEW_LINE s = [ str ( _ ) for _ in input ( ) ] NEW_LINE Res = [ ] NEW_LINE for i in s : NEW_LINE INDENT if X == i : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT Res . append ( i ) NEW_LINE DEDENT DEDENT print ( \" \" . join ( Res ) ) NEW_LINE", "import sys NEW_LINE import copy NEW_LINE input = sys . stdin . readline NEW_LINE c = input ( ) . rstrip ( ) NEW_LINE s = input ( ) . rstrip ( ) NEW_LINE print ( s . replace ( c , \" \" ) ) NEW_LINE" ]
atcoder_abc059_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; String s = \" EQUAL \" ; if ( a . length ( ) > b . length ( ) ) { System . out . println ( \" GREATER \" ) ; System . exit ( 0 ) ; } if ( a . length ( ) < b . length ( ) ) { System . out . println ( \" LESS \" ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) > b . charAt ( i ) ) { s = \" GREATER \" ; break ; } if ( a . charAt ( i ) < b . charAt ( i ) ) { s = \" LESS \" ; break ; } } System . out . println ( s ) ; System . exit ( 0 ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . math . BigInteger ; 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 ) { BigInteger A = new BigInteger ( in . next ( ) ) ; BigInteger B = new BigInteger ( in . next ( ) ) ; out . println ( A . compareTo ( B ) > 0 ? \" GREATER \" : A . compareTo ( B ) == 0 ? \" EQUAL \" : \" LESS \" ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }", "import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter out = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; String a = input . readLine ( ) ; String b = input . readLine ( ) ; String s = null ; if ( a . length ( ) < b . length ( ) ) s = \" LESS \" ; else if ( a . length ( ) > b . length ( ) ) s = \" GREATER \" ; else { for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) > b . charAt ( i ) ) { s = \" GREATER \" ; break ; } else if ( a . charAt ( i ) < b . charAt ( i ) ) { s = \" LESS \" ; break ; } } } if ( s == null ) s = \" EQUAL \" ; out . write ( s ) ; out . write ( \" \\n \" ) ; out . close ( ) ; } }", "import java . math . BigInteger ; import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String a = sc . next ( ) , b = sc . next ( ) ; int comp = new BigInteger ( a ) . compareTo ( new BigInteger ( b ) ) ; if ( comp < 0 ) { System . out . println ( \" LESS \" ) ; } else if ( comp == 0 ) { System . out . println ( \" EQUAL \" ) ; } else { System . out . println ( \" GREATER \" ) ; } } }", "import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; String ans ; int la = a . length ( ) ; int lb = b . length ( ) ; if ( la > lb ) { ans = \" GREATER \" ; } else if ( la < lb ) { ans = \" LESS \" ; } else { if ( a . compareTo ( b ) < 0 ) { ans = \" LESS \" ; } else if ( a . compareTo ( b ) > 0 ) { ans = \" GREATER \" ; } else { ans = \" EQUAL \" ; } } System . out . println ( ans ) ; } 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 ; } } }" ]
[ "a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( \" GREATER \" if a > b else \" LESS \" if a < b else \" EQUAL \" ) NEW_LINE", "import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE a = list ( ns ( ) ) NEW_LINE b = list ( ns ( ) ) NEW_LINE if len ( a ) > len ( b ) : NEW_LINE INDENT print ( ' GREATER ' ) NEW_LINE DEDENT elif len ( a ) < len ( b ) : NEW_LINE INDENT print ( ' LESS ' ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( len ( a ) ) : NEW_LINE INDENT if a [ i ] > b [ i ] : NEW_LINE INDENT print ( ' GREATER ' ) NEW_LINE exit ( ) NEW_LINE DEDENT elif a [ i ] < b [ i ] : NEW_LINE INDENT print ( ' LESS ' ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( ' EQUAL ' ) NEW_LINE DEDENT", "a , b = map ( int , open ( 0 ) ) ; print ( [ ' ELQEUSASL ' [ a < b : : 2 ] , ' GREATER ' ] [ a > b ] ) NEW_LINE", "A , B = int ( input ( ) ) , int ( input ( ) ) NEW_LINE if A == B : NEW_LINE INDENT ans = ' EQUAL ' NEW_LINE DEDENT elif A < B : NEW_LINE INDENT ans = ' LESS ' NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' GREATER ' NEW_LINE DEDENT print ( ans ) NEW_LINE", "from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a = int ( input ( ) . rstrip ( ) ) NEW_LINE b = int ( input ( ) . rstrip ( ) ) NEW_LINE if a > b : NEW_LINE INDENT print ( ' GREATER ' ) NEW_LINE DEDENT elif b > a : NEW_LINE INDENT print ( ' LESS ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' EQUAL ' ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_abc089_B
[ "import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; String a [ ] = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . next ( ) ; } Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { set . add ( a [ i ] ) ; } if ( set . size ( ) == 4 ) { System . out . println ( \" Four \" ) ; } else { System . out . println ( \" Three \" ) ; } 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 ) ) ; stdin . readLine ( ) ; long cnt = Arrays . stream ( stdin . readLine ( ) . split ( \" ▁ \" ) ) . sorted ( ) . distinct ( ) . count ( ) ; String ans = cnt == 3 ? \" Three \" : \" Four \" ; System . out . println ( ans ) ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { boolean P = false ; boolean W = false ; boolean G = false ; boolean Y = false ; int n = sc . nextInt ( ) ; String s ; for ( int i = 0 ; i < n ; i ++ ) { s = sc . next ( ) ; if ( s . equals ( \" P \" ) ) { P = true ; } else if ( s . equals ( \" W \" ) ) { W = true ; } else if ( s . equals ( \" G \" ) ) { G = true ; } else { Y = true ; } } int count = 0 ; if ( P == true ) { count ++ ; } if ( W == true ) { count ++ ; } if ( G == true ) { count ++ ; } if ( Y == true ) { count ++ ; } out . println ( count == 4 ? \" Four \" : \" Three \" ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String ans = \" Three \" ; for ( int i = 0 ; i < N ; i ++ ) { char ch = reader . next ( ) . charAt ( 0 ) ; if ( ch == ' Y ' ) { ans = \" Four \" ; } } System . out . print ( ans ) ; reader . close ( ) ; } }", "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 n = Integer . parseInt ( input . readLine ( ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; String [ ] charac = { \" P \" , \" W \" , \" G \" , \" Y \" } ; boolean [ ] state = new boolean [ 4 ] ; String h ; for ( int i = 0 ; i < n ; i ++ ) { h = tokenizer . nextToken ( ) ; for ( int j = 0 ; j < 4 ; j ++ ) { if ( h . equals ( charac [ j ] ) ) { state [ j ] = true ; break ; } } } System . out . println ( state [ 3 ] ? \" Four \" : \" Three \" ) ; } }" ]
[ "N = int ( input ( ) ) NEW_LINE a = list ( input ( ) . split ( ) ) NEW_LINE if ( \" Y \" in a ) : NEW_LINE INDENT print ( \" Four \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Three \" ) NEW_LINE DEDENT", "input ( ) ; print ( ' TFhoruere ' [ ' Y ' in input ( ) : : 2 ] ) NEW_LINE", "n = int ( input ( ) ) NEW_LINE arr = list ( map ( str , input ( ) . split ( ) ) ) NEW_LINE count = 0 NEW_LINE if arr . count ( ' P ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if arr . count ( ' Y ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if arr . count ( ' W ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if arr . count ( ' G ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if count == 3 : NEW_LINE INDENT print ( ' Three ' ) NEW_LINE DEDENT if count == 4 : NEW_LINE INDENT print ( ' Four ' ) NEW_LINE DEDENT", "N = input ( ) NEW_LINE S = list ( set ( list ( input ( ) . split ( ) ) ) ) NEW_LINE ans = len ( S ) NEW_LINE if ( ans == 3 ) : NEW_LINE INDENT print ( \" Three \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Four \" ) NEW_LINE DEDENT", "n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE print ( ' Four ' if ' Y ' in s else ' Three ' ) NEW_LINE" ]
atcoder_abc105_D
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; int [ ] sum = new int [ n + 1 ] ; long ans = 0 ; sum [ 0 ] = 0 ; map . put ( 0 , 1 ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) { sum [ i ] = ( sum [ i - 1 ] + sc . nextInt ( ) ) % m ; if ( ! map . containsKey ( sum [ i ] ) ) { map . put ( sum [ i ] , 1 ) ; } else { map . put ( sum [ i ] , map . get ( sum [ i ] ) + 1 ) ; } ans += map . get ( sum [ i ] ) - 1 ; } System . out . println ( ans ) ; } }", "import java . util . HashMap ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long [ ] sum = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { sum [ i ] = a [ i ] + sum [ i - 1 ] ; } HashMap < Long , Integer > map = new HashMap < Long , Integer > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { map . put ( sum [ i ] % m , 0 ) ; } for ( int i = 1 ; i <= n ; i ++ ) { int x = map . get ( sum [ i ] % m ) ; map . put ( sum [ i ] % m , x + 1 ) ; } long ans = 0 ; if ( map . containsKey ( 0l ) ) { ans = map . get ( 0l ) ; } for ( long i : map . keySet ( ) ) { if ( map . get ( i ) >= 2 ) { for ( int j = map . get ( i ) ; j > 1 ; j -- ) { ans += j - 1 ; } } } System . out . println ( ans ) ; } } 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 . util . * ; import java . io . * ; class Main { public static void main ( String ... args ) { int N = IN . nextInt ( ) ; int M = IN . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = IN . nextInt ( ) ; } HashMap < Integer , Integer > B = new HashMap < > ( ) ; B . put ( 0 , 1 ) ; long ans = 0 ; int tot = 0 ; for ( int a : A ) { tot = ( tot + a ) % M ; int tmp = B . getOrDefault ( tot , 0 ) ; ans += ( long ) tmp ; B . put ( tot , tmp + 1 ) ; } puts ( ans ) ; flush ( ) ; } static final Scanner IN = new Scanner ( System . in ) ; static final PrintWriter OUT = new PrintWriter ( System . out ) ; static < T > void puts ( T arg ) { OUT . println ( arg ) ; } static void flush ( ) { OUT . flush ( ) ; } }", "import java . util . Scanner ; import java . util . HashMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long m = sc . nextLong ( ) ; long [ ] a = new long [ n ] ; HashMap < Long , Integer > map = new HashMap < > ( ) ; long ans = 0 ; a [ 0 ] = sc . nextLong ( ) ; for ( int i = 1 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) + a [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( map . containsKey ( a [ i ] % m ) ) { map . put ( a [ i ] % m , map . get ( a [ i ] % m ) + 1 ) ; } else { map . put ( a [ i ] % m , 1 ) ; } } for ( long i : map . keySet ( ) ) { long q = map . get ( i ) ; if ( i == 0 ) { ans += q ; } ans += ( q * ( q - 1 ) ) / 2 ; } System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; long sum [ ] = new long [ N + 1 ] ; int A [ ] = new int [ N + 1 ] ; A [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; sum [ 0 ] = 0 ; sum [ 1 ] = A [ 1 ] ; map . put ( ( int ) ( sum [ 1 ] % M ) , 1 ) ; for ( int i = 2 ; i <= N ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; sum [ i ] = sum [ i - 1 ] + A [ i ] ; int mod = ( int ) ( sum [ i ] % M ) ; if ( map . containsKey ( mod ) ) { map . put ( mod , map . get ( mod ) + 1 ) ; } else { map . put ( mod , 1 ) ; } } long ans = 0 ; Iterator < Map . Entry < Integer , Integer > > it = map . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Map . Entry < Integer , Integer > mapEntry = it . next ( ) ; long temp = 0 ; if ( mapEntry . getKey ( ) == 0 ) { for ( long i = mapEntry . getValue ( ) ; i > 0 ; i -- ) { temp += i ; } } else { for ( long i = mapEntry . getValue ( ) - 1 ; i > 0 ; i -- ) { temp += i ; } } if ( temp != 0 || mapEntry . getKey ( ) == 0 ) { ans += temp ; } } System . out . println ( ans ) ; } }" ]
[ "from itertools import accumulate as ac NEW_LINE from collections import Counter as c NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = 0 NEW_LINE for i in c ( [ i % m for i in [ 0 ] + list ( ac ( list ( map ( int , input ( ) . split ( ) ) ) ) ) ] ) . values ( ) : NEW_LINE INDENT a += i * ( i - 1 ) // 2 NEW_LINE DEDENT print ( a ) NEW_LINE", "import sys NEW_LINE import heapq NEW_LINE input = sys . stdin . readline NEW_LINE N , M = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE SUM = [ 0 ] NEW_LINE mp = { } NEW_LINE res = 0 NEW_LINE for i in range ( len ( A ) ) : NEW_LINE INDENT SUM . append ( A [ i ] + SUM [ i ] ) NEW_LINE DEDENT for i in range ( len ( SUM ) ) : NEW_LINE INDENT SUM [ i ] = SUM [ i ] % M NEW_LINE if not SUM [ i ] in mp : NEW_LINE INDENT mp . update ( { SUM [ i ] : 0 } ) NEW_LINE DEDENT else : NEW_LINE INDENT mp . update ( { SUM [ i ] : mp [ SUM [ i ] ] + 1 } ) NEW_LINE DEDENT res = res + mp [ SUM [ i ] ] NEW_LINE DEDENT print ( res ) 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 from operator import mul NEW_LINE from functools import reduce NEW_LINE def cmb ( n , r ) : NEW_LINE INDENT r = min ( n - r , r ) NEW_LINE if r == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT numer = reduce ( mul , range ( n , n - r , - 1 ) ) NEW_LINE denom = reduce ( mul , range ( 1 , r + 1 ) ) NEW_LINE return numer // denom NEW_LINE DEDENT def solve ( N : int , M : int , A : \" List [ int ] \" ) : NEW_LINE INDENT B = itertools . accumulate ( A ) NEW_LINE c = collections . Counter ( ) NEW_LINE for b in B : NEW_LINE INDENT c [ b % M ] += 1 NEW_LINE DEDENT print ( c [ 0 ] + sum ( [ cmb ( c [ k ] , 2 ) for k in c if c [ k ] > 1 ] ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE M = int ( next ( tokens ) ) NEW_LINE A = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , M , A ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def main ( ) : NEW_LINE INDENT N , M = [ int ( n ) for n in input ( ) . split ( ) ] NEW_LINE A = [ int ( n ) for n in input ( ) . split ( ) ] NEW_LINE B = [ 0 ] * ( N + 1 ) NEW_LINE B [ 0 ] = 0 NEW_LINE d = { } NEW_LINE accum = 0 NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT B [ i ] = accum NEW_LINE if i != N : NEW_LINE INDENT accum += A [ i ] NEW_LINE DEDENT DEDENT for i , b in enumerate ( B ) : NEW_LINE INDENT x = b % M NEW_LINE if x in d . keys ( ) : NEW_LINE INDENT d [ x ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT d [ x ] = 1 NEW_LINE DEDENT DEDENT print ( sum ( [ i * ( i - 1 ) // 2 for i in d . values ( ) ] ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "def d_candy_distribution ( N , M , A ) : NEW_LINE INDENT import itertools NEW_LINE import collections NEW_LINE remainders = collections . defaultdict ( int ) NEW_LINE for t in [ 0 ] + list ( itertools . accumulate ( A ) ) : NEW_LINE INDENT remainders [ t % M ] += 1 NEW_LINE DEDENT return sum ( [ v * ( v - 1 ) // 2 for v in remainders . values ( ) if v >= 2 ] ) NEW_LINE DEDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( d_candy_distribution ( N , M , A ) ) NEW_LINE" ]
atcoder_abc043_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int total = scanner . nextInt ( ) ; int sum = 0 ; for ( int ix = 1 ; ix <= total ; ix ++ ) { sum += ix ; } System . out . println ( sum ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int N = keyboard . nextInt ( ) ; int ame = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { ame += i ; } System . out . println ( ame ) ; keyboard . close ( ) ; } }", "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 + N ) / 2 ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; long res = 0 ; for ( int i = 1 ; i <= n ; i ++ ) res += i ; System . out . println ( res ) ; sc . close ( ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; System . out . println ( n * ( n + 1 ) / 2 ) ; } } }" ]
[ "N = int ( input ( ) ) NEW_LINE print ( int ( ( 1 + N ) * N / 2 ) ) NEW_LINE", "def children_and_candies ( N : int ) -> int : NEW_LINE INDENT return N * ( N + 1 ) // 2 NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = children_and_candies ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT", "from sys import stdin NEW_LINE n = int ( stdin . readline ( ) . rstrip ( ) ) NEW_LINE total = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT total += i NEW_LINE DEDENT print ( total ) NEW_LINE", "print ( sum ( [ n for n in range ( 1 , int ( input ( ) ) + 1 ) ] ) ) NEW_LINE", "n = input ( ) NEW_LINE n = int ( n ) NEW_LINE a = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT a = a + i NEW_LINE DEDENT print ( a ) NEW_LINE" ]
atcoder_abc114_D
[ "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] p = { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 } ; int [ ] pTotal = new int [ p . length ] ; for ( int i = 0 ; i < p . length ; i ++ ) pTotal [ i ] = legendre ( N , p [ i ] ) ; int ans = 0 ; for ( int i = 0 ; i < p . length ; i ++ ) { if ( pTotal [ i ] >= 74 ) ans ++ ; } for ( int i = 0 ; i < p . length ; i ++ ) { for ( int j = 0 ; j < p . length ; j ++ ) { if ( i != j && pTotal [ i ] >= 2 && pTotal [ j ] >= 24 ) ans ++ ; } } for ( int i = 0 ; i < p . length ; i ++ ) { for ( int j = 0 ; j < p . length ; j ++ ) { if ( i != j && pTotal [ i ] >= 4 && pTotal [ j ] >= 14 ) ans ++ ; } } int plus = 0 ; for ( int i = 0 ; i < p . length ; i ++ ) { for ( int j = 0 ; j < p . length ; j ++ ) { for ( int k = 0 ; k < p . length ; k ++ ) { if ( i != j && j != k && k != i && pTotal [ i ] >= 2 && pTotal [ j ] >= 4 && pTotal [ k ] >= 4 ) plus ++ ; } } } ans += plus / 2 ; System . out . println ( ans ) ; } static int legendre ( int n , int p ) { int c = 0 ; int m = p ; while ( m <= n ) { c += n / m ; m *= p ; } return c ; } }", "import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . HashMap ; @ SuppressWarnings ( \" unchecked \" ) public class Main { static HashMap < Integer , Integer > pf ; static void primeFactor ( int n ) { int a = 2 ; while ( a * a <= n ) { if ( n % a == 0 ) { pf . merge ( a , 1 , Integer :: sum ) ; n = n / a ; } else { a ++ ; } } pf . merge ( n , 1 , Integer :: sum ) ; } static int f ( int x ) { int cnt = 0 ; for ( Integer i : pf . values ( ) ) if ( x - 1 <= i ) cnt ++ ; return cnt ++ ; } 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 ) ; final String [ ] sl = s . split ( \" ▁ \" ) ; int N = Integer . parseInt ( sl [ 0 ] ) ; pf = new HashMap < > ( ) ; for ( int i = 2 ; i < N + 1 ; i ++ ) primeFactor ( i ) ; int ans = f ( 75 ) + f ( 25 ) * ( f ( 3 ) - 1 ) + f ( 15 ) * ( f ( 5 ) - 1 ) + f ( 5 ) * ( f ( 5 ) - 1 ) * ( f ( 3 ) - 2 ) / 2 ; out . println ( ans ) ; out . flush ( ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; HashMap < Integer , Integer > primeCount = new HashMap < > ( ) ; primeCount . put ( 1 , 1 ) ; for ( int i = 2 ; i <= N ; i ++ ) { int value = i ; for ( int j = 2 ; j <= i ; j ++ ) { while ( value % j == 0 ) { primeCount . put ( j , primeCount . containsKey ( j ) ? primeCount . get ( j ) + 1 : 1 ) ; value = value / j ; } } } int ans = 0 ; for ( Map . Entry < Integer , Integer > entry0 : primeCount . entrySet ( ) ) { for ( Map . Entry < Integer , Integer > entry1 : primeCount . entrySet ( ) ) { for ( Map . Entry < Integer , Integer > entry2 : primeCount . entrySet ( ) ) { if ( entry0 . getKey ( ) == entry1 . getKey ( ) ) continue ; if ( entry0 . getKey ( ) == entry2 . getKey ( ) ) continue ; if ( entry1 . getKey ( ) == entry2 . getKey ( ) ) continue ; if ( entry1 . getKey ( ) > entry2 . getKey ( ) ) continue ; if ( entry0 . getValue ( ) >= 2 && entry1 . getValue ( ) >= 4 && entry2 . getValue ( ) >= 4 ) ans ++ ; } } } for ( Map . Entry < Integer , Integer > entry0 : primeCount . entrySet ( ) ) { for ( Map . Entry < Integer , Integer > entry1 : primeCount . entrySet ( ) ) { if ( entry0 . getKey ( ) == entry1 . getKey ( ) ) continue ; if ( entry0 . getValue ( ) >= 4 && entry1 . getValue ( ) >= 14 ) ans ++ ; if ( entry0 . getValue ( ) >= 2 && entry1 . getValue ( ) >= 24 ) ans ++ ; } } for ( Integer count : primeCount . values ( ) ) { if ( count >= 74 ) ans ++ ; } System . out . println ( ans ) ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; sc . close ( ) ; int [ ] P = new int [ 48 ] ; int over74 = 0 ; int over24 = 0 ; int over14 = 0 ; int over4 = 0 ; int over2 = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { int x = i ; for ( int j = 2 ; j < Math . min ( N , 48 ) ; j ++ ) { while ( x % j == 0 ) { x /= j ; P [ j ] ++ ; } } } for ( int p : P ) { if ( p > 1 ) over2 ++ ; if ( p > 3 ) over4 ++ ; if ( p > 13 ) over14 ++ ; if ( p > 23 ) over24 ++ ; if ( p > 73 ) over74 ++ ; } int ans = 0 ; ans += over74 ; if ( over14 > 0 && over4 > 1 ) ans += over14 * ( over4 - 1 ) ; if ( over24 > 0 && over2 > 1 ) ans += over24 * ( over2 - 1 ) ; if ( over4 > 1 && over2 > 2 ) ans += ( over4 * ( over4 - 1 ) / 2 ) * ( over2 - 2 ) ; 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 ( ) ; boolean [ ] pr = new boolean [ N + 1 ] ; int count = 0 ; for ( int i = 2 ; i < N + 1 ; i ++ ) pr [ i ] = true ; for ( int i = 2 ; i < N + 1 ; i ++ ) { if ( pr [ i ] ) { count ++ ; for ( int j = 2 * i ; j < N + 1 ; j += i ) pr [ j ] = false ; } } final int C = count ; int [ ] prn = new int [ C ] ; int id = 0 ; for ( int i = 0 ; i < N + 1 ; i ++ ) { if ( pr [ i ] ) { int b = i ; while ( b <= N ) { prn [ id ] += N / b ; b *= i ; } id ++ ; } } int ans = 0 ; for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { for ( int k = j + 1 ; k < C ; k ++ ) { if ( i != j && i != k && prn [ i ] >= 2 && prn [ j ] >= 4 && prn [ k ] >= 4 ) ans ++ ; } } } for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( i != j && prn [ i ] >= 2 && prn [ j ] >= 24 ) ans ++ ; } } for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( i != j && prn [ i ] >= 4 && prn [ j ] >= 14 ) ans ++ ; } } if ( C > 0 && prn [ 0 ] >= 74 ) ans ++ ; System . out . println ( ans ) ; } }" ]
[ "import math NEW_LINE from collections import Counter NEW_LINE import itertools NEW_LINE def prime_factors ( n ) : NEW_LINE INDENT i = 2 NEW_LINE factors = [ ] NEW_LINE while i * i <= n : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT n //= i NEW_LINE factors . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT i += 1 NEW_LINE DEDENT DEDENT if n > 1 : NEW_LINE INDENT factors . append ( n ) NEW_LINE DEDENT return factors NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE num = math . factorial ( n ) NEW_LINE factors = prime_factors ( num ) NEW_LINE es = list ( Counter ( factors ) . values ( ) ) NEW_LINE m = len ( es ) NEW_LINE ans = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT if es [ i ] >= 74 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( m ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if i != j and es [ i ] >= 24 and es [ j ] >= 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( m ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if i != j and es [ i ] >= 14 and es [ j ] >= 4 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( m ) : NEW_LINE INDENT for j in range ( i + 1 , m ) : NEW_LINE INDENT for k in range ( m ) : NEW_LINE INDENT if i != k and j != k and es [ i ] >= 4 and es [ j ] >= 4 and es [ k ] >= 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "import bisect NEW_LINE from math import factorial as fact NEW_LINE import sys NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE prime = [ ] NEW_LINE p_flag = [ False ] * ( 101 ) NEW_LINE p_flag [ 0 ] = p_flag [ 1 ] = True NEW_LINE for i in range ( 2 , 101 ) : NEW_LINE INDENT if not p_flag [ i ] : NEW_LINE INDENT prime . append ( i ) NEW_LINE for j in range ( 2 * i , 101 , i ) : NEW_LINE INDENT p_flag [ j ] = True NEW_LINE DEDENT DEDENT DEDENT M = len ( prime ) NEW_LINE factor = [ 0 ] * M NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT for j in range ( M ) : NEW_LINE INDENT tmp = prime [ j ] NEW_LINE if tmp > i : NEW_LINE INDENT break NEW_LINE DEDENT while i % tmp == 0 : NEW_LINE INDENT factor [ j ] += 1 NEW_LINE tmp *= prime [ j ] NEW_LINE DEDENT DEDENT DEDENT factor = factor [ : : - 1 ] NEW_LINE point74 = M - bisect . bisect_left ( factor , 74 ) NEW_LINE point24 = M - bisect . bisect_left ( factor , 24 ) NEW_LINE point14 = M - bisect . bisect_left ( factor , 14 ) NEW_LINE point4 = M - bisect . bisect_left ( factor , 4 ) NEW_LINE point2 = M - bisect . bisect_left ( factor , 2 ) NEW_LINE if N < 10 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT ans = fact ( point4 ) // ( fact ( point4 - 2 ) * fact ( 2 ) ) * ( point2 - 2 ) NEW_LINE if point14 > 0 : NEW_LINE INDENT ans += point14 * ( point4 - 1 ) NEW_LINE DEDENT if point24 > 0 : NEW_LINE INDENT ans += point24 * ( point2 - 1 ) NEW_LINE DEDENT if point74 > 0 : NEW_LINE INDENT ans += point74 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "primes = [ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 ] NEW_LINE def get_prime ( n , count = { p : 0 for p in primes } ) : NEW_LINE INDENT for p in primes : NEW_LINE INDENT cp = n NEW_LINE while cp != 0 and cp % p == 0 : NEW_LINE INDENT count [ p ] += 1 NEW_LINE cp = cp // p NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT cnt = { p : 0 for p in primes } NEW_LINE for i in range ( 1 , int ( input ( ) ) + 1 ) : NEW_LINE INDENT get_prime ( i , cnt ) NEW_LINE DEDENT res = 0 NEW_LINE for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 4 : NEW_LINE INDENT for p2 in primes : NEW_LINE INDENT if cnt [ p2 ] >= 4 and p1 > p2 : NEW_LINE INDENT for p3 in primes : NEW_LINE INDENT if cnt [ p3 ] >= 2 and p3 != p1 and p3 != p2 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 14 : NEW_LINE INDENT for p2 in primes : NEW_LINE INDENT if cnt [ p2 ] >= 4 and p1 != p2 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 24 : NEW_LINE INDENT for p2 in primes : NEW_LINE INDENT if cnt [ p2 ] >= 2 and p1 != p2 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 74 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def POW ( x , y ) : NEW_LINE INDENT if y == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif y == 1 : NEW_LINE INDENT return x NEW_LINE DEDENT elif y % 2 == 0 : NEW_LINE INDENT return POW ( x , y // 2 ) ** 2 % MOD NEW_LINE DEDENT else : NEW_LINE INDENT return POW ( x , y // 2 ) ** 2 * x % MOD NEW_LINE DEDENT DEDENT def mod_factorial ( x , y ) : return x * POW ( y , MOD - 2 ) % MOD NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from collections import Counter NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE factors = Counter ( ) NEW_LINE for k in range ( 1 , N + 1 ) : NEW_LINE INDENT for i in ( 2 , 3 , 5 , 7 ) : NEW_LINE INDENT while k % i == 0 : NEW_LINE INDENT factors [ i ] += 1 NEW_LINE k //= i NEW_LINE DEDENT DEDENT if k != 1 : NEW_LINE INDENT factors [ k ] += 1 NEW_LINE DEDENT DEDENT nfactors = sorted ( factors . values ( ) ) NEW_LINE ans = 0 NEW_LINE dp = [ 0 ] * 76 NEW_LINE dp [ 1 ] = 1 NEW_LINE for cnt in nfactors : NEW_LINE INDENT pre = dp NEW_LINE dp = [ 0 ] * 76 NEW_LINE for c in range ( 1 , cnt + 2 ) : NEW_LINE INDENT for k in range ( 75 // c + 1 ) : NEW_LINE INDENT dp [ k * c ] += pre [ k ] NEW_LINE DEDENT DEDENT DEDENT ans = dp [ 75 ] NEW_LINE return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "import itertools NEW_LINE from operator import mul NEW_LINE from functools import reduce NEW_LINE N = int ( input ( ) ) NEW_LINE F = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT F = F * i NEW_LINE DEDENT pns = [ ] NEW_LINE for n in range ( 2 , N + 1 ) : NEW_LINE INDENT for pn in pns : NEW_LINE INDENT if n % pn == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT pns . append ( n ) NEW_LINE DEDENT DEDENT c = 0 NEW_LINE for num in pns : NEW_LINE INDENT if F % num ** 74 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for nums in itertools . combinations ( pns , 2 ) : NEW_LINE INDENT y1 = nums [ 0 ] ** 14 * nums [ 1 ] ** 4 NEW_LINE y2 = nums [ 1 ] ** 14 * nums [ 0 ] ** 4 NEW_LINE z1 = nums [ 0 ] ** 24 * nums [ 1 ] ** 2 NEW_LINE z2 = nums [ 1 ] ** 24 * nums [ 0 ] ** 2 NEW_LINE if F % y1 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT if F % y2 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT if F % z1 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT if F % z2 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for nums in itertools . combinations ( pns , 3 ) : NEW_LINE INDENT for num in nums : NEW_LINE INDENT num_except = [ n for n in nums if n != num ] NEW_LINE x = num ** 2 * ( num_except [ 0 ] * num_except [ 1 ] ) ** 4 NEW_LINE if F % x == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT DEDENT print ( c ) NEW_LINE" ]
atcoder_arc078_A
[ "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String args [ ] ) { ConsoleScanner cin = new ConsoleScanner ( ) ; PrintWriter cout = new PrintWriter ( System . out ) ; solve ( cin , cout ) ; cout . flush ( ) ; } static long now ( ) { return System . currentTimeMillis ( ) ; } static void trace ( Object ... objects ) { assert null != System . out . format ( \" trace : % s \\n \" , Arrays . deepToString ( objects ) ) ; } private static void solve ( ConsoleScanner cin , PrintWriter cout ) { int n = cin . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < a . length ; i ++ ) a [ i ] = cin . nextInt ( ) ; long start = now ( ) ; long ans = solve ( n , a ) ; cout . println ( ans ) ; trace ( \" elapsed \" , now ( ) - start ) ; } private static long solve ( int n , int [ ] a ) { long total = Arrays . stream ( a ) . mapToLong ( x -> x ) . sum ( ) ; long ans = Long . MAX_VALUE ; long s = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { s += a [ i ] ; ans = Math . min ( ans , Math . abs ( total - 2 * s ) ) ; } return ans ; } static class ConsoleScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( \" \" ) ; String next ( ) { try { while ( ! st . hasMoreElements ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } catch ( IOException e ) { throw new AssertionError ( e ) ; } } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }", "import java . util . * ; public class Main { private static long solve ( Scanner scanner ) { int N = Integer . parseInt ( scanner . nextLine ( ) ) ; long [ ] a = lineToNums ( scanner . nextLine ( ) ) ; long sumAll = Arrays . stream ( a ) . sum ( ) ; long [ ] xSum = new long [ N ] ; long [ ] ySum = new long [ N ] ; xSum [ 0 ] = a [ 0 ] ; ySum [ 0 ] = sumAll - xSum [ 0 ] ; long ret = Math . abs ( xSum [ 0 ] - ySum [ 0 ] ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { xSum [ i ] = xSum [ i - 1 ] + a [ i ] ; ySum [ i ] = sumAll - xSum [ i ] ; ret = Math . min ( ret , Math . abs ( xSum [ i ] - ySum [ i ] ) ) ; } return ret ; } private static final String ex1 = \"6 \\n \" + \"1 ▁ 2 ▁ 3 ▁ 4 ▁ 5 ▁ 6\" ; private static final String ex2 = \"2 \\n \" + \"10 ▁ - 10\" ; public static void main ( String [ ] args ) { System . out . println ( solve ( new Scanner ( System . in ) ) ) ; } private static long [ ] lineToNums ( 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 . io . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String c = stdReader . readLine ( ) ; String vals = stdReader . readLine ( ) ; long [ ] ls = new long [ Integer . valueOf ( c ) ] ; String [ ] ss = vals . split ( \" ▁ \" ) ; long total = 0 ; long [ ] sunu = new long [ Integer . valueOf ( c ) ] ; for ( int i = 0 ; i < ls . length ; i ++ ) { long v = Long . valueOf ( ss [ i ] ) ; ls [ i ] = v ; total += v ; sunu [ i ] = total ; } long min = 0 ; for ( int i = 0 ; i < ls . length - 1 ; i ++ ) { long arai = total - sunu [ i ] ; long current = Math . abs ( arai - sunu [ i ] ) ; if ( i == 0 ) { min = current ; } min = Math . min ( min , current ) ; } System . out . println ( min ) ; } }", "import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyReader in = new MyReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , MyReader in , PrintWriter out ) { int N = in . nextInt ( ) ; long [ ] a = new long [ N ] ; long tot = 0 ; long [ ] s = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = in . nextLong ( ) ; tot += a [ i ] ; s [ i ] = tot ; } long d = Long . MAX_VALUE ; for ( int i = 0 ; i < N - 1 ; i ++ ) { d = Math . min ( d , Math . abs ( s [ i ] - ( tot - s [ i ] ) ) ) ; } out . println ( d ) ; } } static class MyReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public MyReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }", "import java . util . Scanner ; public class Main { private static long x = 0 ; private static long y = 0 ; private static int N ; private static int a [ ] ; private static long ans ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } } public static void main ( String args [ ] ) { input ( ) ; x = a [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { y += a [ i ] ; } ans = Math . abs ( x - y ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { x += a [ i ] ; y -= a [ i ] ; ans = Math . min ( Math . abs ( x - y ) , ans ) ; } System . out . println ( ans ) ; } }" ]
[ "def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE import numpy as np NEW_LINE ans = float ( ' inf ' ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = np . cumsum ( np . array ( inpl ( ) ) ) NEW_LINE suma = a [ - 1 ] NEW_LINE a = np . delete ( a , - 1 ) NEW_LINE for i in a : NEW_LINE INDENT ans = min ( ans , abs ( suma - 2 * i ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "n = int ( input ( ) ) ; a = list ( map ( int , input ( ) . split ( ) ) ) ; b = [ 0 ] NEW_LINE for i in a : b . append ( b [ - 1 ] + i ) NEW_LINE b = b [ 1 : ] ; s = b [ - 1 ] ; mi = abs ( b [ 0 ] - ( b [ - 1 ] - b [ 0 ] ) ) NEW_LINE for i in range ( n - 1 ) : mi = min ( abs ( b [ i ] - ( b [ - 1 ] - b [ i ] ) ) , mi ) NEW_LINE print ( mi ) NEW_LINE", "from numpy import * ; n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; print ( min ( abs ( cumsum ( a [ : : - 1 ] ) [ : : - 1 ] - cumsum ( [ 0 ] + a [ : - 1 ] ) ) [ 1 : ] ) ) NEW_LINE", "def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE def getIntLines ( n ) : return [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE def getIntMat ( n ) : NEW_LINE INDENT mat = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT mat . append ( getIntList ( ) ) NEW_LINE DEDENT return mat NEW_LINE DEDENT def zeros2 ( n , m ) : return [ zeros ( m ) ] * n NEW_LINE ALPHABET = [ chr ( i + ord ( ' a ' ) ) for i in range ( 26 ) ] NEW_LINE DIGIT = [ chr ( i + ord ( '0' ) ) for i in range ( 10 ) ] NEW_LINE N1097 = 10 ** 9 + 7 NEW_LINE def dmp ( x , cmt = ' ' ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT print ( cmt , ' : ▁ ▁ ' , end = ' ' ) NEW_LINE DEDENT print ( x ) NEW_LINE DEDENT return x NEW_LINE DEDENT def probC ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE dmp ( ( N , A ) ) NEW_LINE sumFormer = A [ 0 ] NEW_LINE sumLatter = sum ( A [ 1 : ] ) NEW_LINE diff = abs ( sumFormer - sumLatter ) NEW_LINE dmp ( diff , ' init ' ) NEW_LINE for i in range ( 1 , N - 1 ) : NEW_LINE INDENT sumFormer += A [ i ] NEW_LINE sumLatter -= A [ i ] NEW_LINE diff = min ( diff , abs ( sumFormer - sumLatter ) ) NEW_LINE DEDENT return diff NEW_LINE DEDENT def probC_v1 ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE dmp ( ( N , A ) ) NEW_LINE diff = 10 ** ( 9 + 6 ) NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT diff = min ( diff , abs ( sum ( A [ : i ] ) - sum ( A [ i : ] ) ) ) NEW_LINE DEDENT return diff NEW_LINE DEDENT debug = False NEW_LINE ans = probC ( ) NEW_LINE print ( ans ) NEW_LINE NEW_LINE", "from itertools import accumulate NEW_LINE N = int ( input ( ) ) NEW_LINE card = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE acc = list ( accumulate ( card ) ) NEW_LINE s = acc [ - 1 ] NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT t = acc [ i ] NEW_LINE a = s - t NEW_LINE ans = min ( ans , abs ( t - a ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE" ]
atcoder_abc022_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int weight = 0 ; int output = 0 ; for ( int i = 0 ; i < n ; i ++ ) { weight += sc . nextInt ( ) ; if ( weight >= s && weight <= t ) { output ++ ; } } System . out . println ( output ) ; } }", "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 ( ) , s = nextInt ( ) , t = nextInt ( ) ; int w = nextInt ( ) ; int ans = 0 ; if ( s <= w && w <= t ) { ans ++ ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { w += nextInt ( ) ; if ( s <= w && w <= t ) { ans ++ ; } } out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int S = in . nextInt ( ) ; int T = in . nextInt ( ) ; int W = in . nextInt ( ) ; int count = 0 ; if ( S <= W && W <= T ) { count ++ ; } for ( int i = 1 ; i < N ; i ++ ) { W += in . nextInt ( ) ; if ( S <= W && W <= T ) { 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 a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int ans = 0 ; int g [ ] = new int [ a ] ; g [ 0 ] = sc . nextInt ( ) ; if ( b <= g [ 0 ] && g [ 0 ] <= c ) { ans ++ ; } for ( int i = 1 ; i < a ; i ++ ) { g [ i ] = g [ i - 1 ] + sc . nextInt ( ) ; if ( b <= g [ i ] && g [ i ] <= c ) { ans ++ ; } } System . out . println ( ans ) ; } 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 . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { w += a [ i ] ; if ( s <= w && w <= t ) { ans ++ ; } } System . out . println ( ans ) ; } }" ]
[ "ans = 0 NEW_LINE n , s , t = map ( int , input ( ) . split ( ) ) NEW_LINE w = int ( input ( ) ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if s <= w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT w += int ( input ( ) ) NEW_LINE DEDENT if s <= w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE n , s , t = [ int ( i ) for i in sys . stdin . readline ( ) . rstrip ( ) . split ( ) ] NEW_LINE w = 0 NEW_LINE ans = 0 NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a = int ( sys . stdin . readline ( ) . rstrip ( ) ) NEW_LINE w += a NEW_LINE if s <= w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "def solve ( ) : NEW_LINE INDENT n , s , t = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE w = int ( input ( ) ) NEW_LINE if s <= w and w <= t : NEW_LINE INDENT ans = 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE w += a NEW_LINE if s <= w and w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT solve ( ) NEW_LINE", "N , S , T = map ( int , input ( ) . split ( ) ) NEW_LINE W = int ( input ( ) ) NEW_LINE if S <= W <= T : NEW_LINE INDENT daycount = 1 NEW_LINE DEDENT else : NEW_LINE INDENT daycount = 0 NEW_LINE DEDENT for i in range ( N - 1 ) : NEW_LINE INDENT A = int ( input ( ) ) NEW_LINE W += A NEW_LINE if S <= W <= T : NEW_LINE INDENT daycount += 1 NEW_LINE DEDENT DEDENT print ( daycount ) NEW_LINE", "n , s , t = map ( int , input ( ) . split ( ) ) NEW_LINE w = int ( input ( ) ) NEW_LINE a_array = [ ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT a_array . append ( int ( input ( ) ) ) NEW_LINE DEDENT cnt = 1 if s <= w <= t else 0 NEW_LINE for a in a_array : NEW_LINE INDENT w += a NEW_LINE if s <= w <= t : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE" ]
atcoder_arc017_C
[ "import java . util . HashMap ; import java . util . Scanner ; public class Main { static int a ; static int [ ] w ; static HashMap < Integer , Integer > left = new HashMap < Integer , Integer > ( ) ; static HashMap < Integer , Integer > right = new HashMap < Integer , Integer > ( ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; w = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } a = N / 2 ; int ans = 0 ; pack ( 0 , a , left , 0 ) ; pack ( a , N , right , 0 ) ; for ( int c : left . keySet ( ) ) { if ( right . containsKey ( X - c ) ) { ans += left . get ( c ) * right . get ( X - c ) ; } } System . out . println ( ans ) ; } static void pack ( int s , int g , HashMap < Integer , Integer > map , int W ) { if ( s == g ) { if ( map . containsKey ( W ) ) { map . put ( W , map . get ( W ) + 1 ) ; } else { map . put ( W , 1 ) ; } } else { pack ( s + 1 , g , map , W ) ; pack ( s + 1 , g , map , W + w [ s ] ) ; } } }", "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 ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; HashMap < Long , Long > map1 = new HashMap < > ( ) ; HashMap < Long , Long > map2 = new HashMap < > ( ) ; int zen = n / 2 ; int c = 1 ; for ( int i = 0 ; i < zen ; i ++ ) c *= 2 ; for ( int i = 0 ; i < c ; i ++ ) { int d = i ; long v = 0 ; for ( int j = 0 ; j < zen ; j ++ ) { if ( d % 2 == 0 ) v += a [ j ] ; d /= 2 ; } if ( map1 . containsKey ( v ) ) map1 . put ( v , map1 . get ( v ) + 1 ) ; else map1 . put ( v , 1L ) ; } c = 1 ; for ( int i = zen ; i < n ; i ++ ) c *= 2 ; for ( int i = 0 ; i < c ; i ++ ) { int d = i ; long v = 0 ; for ( int j = zen ; j < n ; j ++ ) { if ( d % 2 == 0 ) v += a [ j ] ; d /= 2 ; } if ( map2 . containsKey ( v ) ) map2 . put ( v , map2 . get ( v ) + 1 ) ; else map2 . put ( v , 1L ) ; } long res = 0 ; Set < Long > set = map1 . keySet ( ) ; for ( long lo : set ) { if ( map2 . containsKey ( x - lo ) ) { res += map1 . get ( lo ) * map2 . get ( x - lo ) ; } } System . out . println ( res ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; long x = scan . nextInt ( ) ; long [ ] w = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) w [ i ] = scan . nextInt ( ) ; int m = n / 2 ; long [ ] f = new long [ 1 << m ] ; long [ ] s = new long [ 1 << n - m ] ; for ( int i = 0 ; i < 1 << m ; ++ i ) for ( int j = 0 ; j < m ; ++ j ) if ( ( i & 1 << j ) != 0 ) f [ i ] += w [ j ] ; for ( int i = 0 ; i < 1 << n - m ; ++ i ) for ( int j = 0 ; j < n - m ; ++ j ) if ( ( i & 1 << j ) != 0 ) s [ i ] += w [ m + j ] ; Map < Long , Integer > hs = new HashMap < Long , Integer > ( ) ; for ( long ss : s ) if ( ! hs . containsKey ( ss ) ) hs . put ( ss , 1 ) ; else hs . put ( ss , hs . get ( ss ) + 1 ) ; long total = 0 ; for ( long ff : f ) if ( hs . containsKey ( x - ff ) ) total += hs . get ( x - ff ) ; System . out . println ( total ) ; } }", "import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { static long R , B , x , y ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] w = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) w [ i ] = sc . nextInt ( ) ; long ans = help ( w , X ) ; System . out . println ( ans ) ; } static long help ( int [ ] w , int X ) { int n = w . length ; if ( n == 1 ) { return w [ 0 ] == X ? 1 : 0 ; } int ans = 0 ; int p = n / 2 ; HashMap < Integer , Integer > dic = getDic ( Arrays . copyOfRange ( w , p , n ) ) ; int [ ] first = Arrays . copyOfRange ( w , 0 , p ) ; for ( int i = 0 ; i < ( 1 << p ) ; i ++ ) { int cur = getSum ( first , i ) ; ans += dic . getOrDefault ( X - cur , 0 ) ; } return ans ; } static HashMap < Integer , Integer > getDic ( int [ ] a ) { int q = a . length ; HashMap < Integer , Integer > ans = new HashMap < > ( ) ; for ( int i = 0 ; i < ( 1 << q ) ; i ++ ) { int cur = getSum ( a , i ) ; int val = ans . getOrDefault ( cur , 0 ) + 1 ; ans . put ( cur , val ) ; } return ans ; } static int getSum ( int [ ] a , int mask ) { int sum = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( ( mask & ( 1 << i ) ) > 0 ) sum += a [ i ] ; } return sum ; } }" ]
[ "from bisect import bisect , bisect_left NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , X = inpl ( ) NEW_LINE W = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE A = N // 2 NEW_LINE B = N - A NEW_LINE C = [ ] NEW_LINE D = [ ] NEW_LINE for i in range ( 2 ** A ) : NEW_LINE INDENT C . append ( sum ( [ W [ a ] * ( i >> a & 1 ) for a in range ( A ) ] ) ) NEW_LINE DEDENT for j in range ( 2 ** B ) : NEW_LINE INDENT D . append ( sum ( [ W [ b + A ] * ( j >> b & 1 ) for b in range ( B ) ] ) ) NEW_LINE DEDENT ans = 0 NEW_LINE C = sorted ( C ) NEW_LINE D = sorted ( D ) NEW_LINE for c in C [ : bisect ( C , X ) ] : NEW_LINE INDENT ans += bisect ( D , X - c ) - bisect_left ( D , X - c ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT N , X = LI ( ) NEW_LINE W = sorted ( [ I ( ) for _ in range ( N ) ] , reverse = True ) NEW_LINE d = collections . defaultdict ( int ) NEW_LINE d [ 0 ] = 1 NEW_LINE for c in W [ N // 2 : ] : NEW_LINE INDENT t = collections . defaultdict ( int ) NEW_LINE for k , v in d . items ( ) : NEW_LINE INDENT if k + c > X : NEW_LINE INDENT continue NEW_LINE DEDENT t [ k + c ] += v NEW_LINE DEDENT for k , v in t . items ( ) : NEW_LINE INDENT d [ k ] += v NEW_LINE DEDENT DEDENT d2 = collections . defaultdict ( int ) NEW_LINE d2 [ 0 ] = 1 NEW_LINE for c in W [ : N // 2 ] : NEW_LINE INDENT t = collections . defaultdict ( int ) NEW_LINE for k , v in d2 . items ( ) : NEW_LINE INDENT if k + c > X : NEW_LINE INDENT continue NEW_LINE DEDENT t [ k + c ] += v NEW_LINE DEDENT for k , v in t . items ( ) : NEW_LINE INDENT d2 [ k ] += v NEW_LINE DEDENT DEDENT r = 0 NEW_LINE for k , v in d . items ( ) : NEW_LINE INDENT r += v * d2 [ X - k ] NEW_LINE DEDENT return r NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "def make ( n , r ) : NEW_LINE INDENT v = { 0 : 1 } NEW_LINE for _ in range ( n ) : NEW_LINE INDENT s = int ( input ( ) ) NEW_LINE w = dict ( v ) NEW_LINE for k , val in v . items ( ) : NEW_LINE INDENT w [ k + s ] = v . get ( k + s , 0 ) + val NEW_LINE DEDENT v = w NEW_LINE DEDENT return sorted ( v . items ( ) , reverse = r ) NEW_LINE DEDENT N , X = map ( int , input ( ) . split ( ) ) NEW_LINE S = make ( N // 2 , 0 ) NEW_LINE T = make ( N - N // 2 , 1 ) NEW_LINE ans = 0 NEW_LINE it = iter ( T ) NEW_LINE nn = ( None , None ) NEW_LINE t , w = next ( it , nn ) NEW_LINE for s , v in S : NEW_LINE INDENT while w and s + t > X : NEW_LINE INDENT t , w = next ( it , nn ) NEW_LINE DEDENT if w and s + t == X : NEW_LINE INDENT ans += v * w NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "from collections import defaultdict NEW_LINE import sys , heapq , bisect , math , itertools , string , queue , datetime NEW_LINE sys . setrecursionlimit ( 10 ** 8 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE eps = 10 ** - 7 NEW_LINE AtoZ = [ chr ( i ) for i in range ( 65 , 65 + 26 ) ] NEW_LINE atoz = [ chr ( i ) for i in range ( 97 , 97 + 26 ) ] NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def inpl_s ( ) : return list ( input ( ) . split ( ) ) NEW_LINE N , X = inpl ( ) NEW_LINE ww = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE k = N // 2 NEW_LINE flags1 = itertools . product ( [ 0 , 1 ] , repeat = k ) NEW_LINE flags2 = itertools . product ( [ 0 , 1 ] , repeat = N - k ) NEW_LINE dd1 = defaultdict ( int ) NEW_LINE ed = [ ] NEW_LINE dd2 = defaultdict ( int ) NEW_LINE for flag in flags1 : NEW_LINE INDENT tmp = 0 NEW_LINE for i , fl in enumerate ( flag ) : NEW_LINE INDENT if fl : NEW_LINE INDENT tmp += ww [ i ] NEW_LINE DEDENT DEDENT if dd1 [ tmp ] == 0 : NEW_LINE INDENT ed . append ( tmp ) NEW_LINE DEDENT dd1 [ tmp ] += 1 NEW_LINE DEDENT for flag in flags2 : NEW_LINE INDENT tmp = 0 NEW_LINE for i , fl in enumerate ( flag ) : NEW_LINE INDENT if fl : NEW_LINE INDENT tmp += ww [ i + k ] NEW_LINE DEDENT DEDENT dd2 [ tmp ] += 1 NEW_LINE DEDENT ans = 0 NEW_LINE for e in ed : NEW_LINE INDENT ans += dd1 [ e ] * dd2 [ X - e ] NEW_LINE DEDENT print ( ans ) NEW_LINE", "import sys NEW_LINE from collections import defaultdict , Counter NEW_LINE from itertools import product , groupby , count , permutations , combinations NEW_LINE from math import pi , sqrt , ceil , floor NEW_LINE from collections import deque NEW_LINE from bisect import bisect , bisect_left , bisect_right NEW_LINE from string import ascii_lowercase NEW_LINE INF = float ( \" inf \" ) NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE dy = [ 0 , - 1 , 0 , 1 ] NEW_LINE dx = [ 1 , 0 , - 1 , 0 ] NEW_LINE def inside ( y : int , x : int , H : int , W : int ) -> bool : return 0 <= y < H and 0 <= x < W NEW_LINE def main ( ) : NEW_LINE INDENT N , X = map ( int , input ( ) . split ( ) ) NEW_LINE w_list = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE w_list1 , w_list2 = w_list [ : N // 2 ] , w_list [ N // 2 : ] NEW_LINE n = len ( w_list1 ) NEW_LINE s = [ ] NEW_LINE for b in range ( 2 ** n ) : NEW_LINE INDENT total = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if b & 1 << i : NEW_LINE INDENT total += w_list1 [ i ] NEW_LINE DEDENT DEDENT s . append ( total ) NEW_LINE DEDENT n = len ( w_list2 ) NEW_LINE d = defaultdict ( int ) NEW_LINE for b in range ( 2 ** n ) : NEW_LINE INDENT total = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if b & 1 << i : NEW_LINE INDENT total += w_list2 [ i ] NEW_LINE DEDENT DEDENT d [ total ] += 1 NEW_LINE DEDENT ans = 0 NEW_LINE for a in s : NEW_LINE INDENT if a > X : NEW_LINE INDENT continue NEW_LINE DEDENT ans += d [ X - a ] NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT" ]
atcoder_agc001_A
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) * 2 ; long length [ ] = new long [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { length [ i ] = sc . nextLong ( ) ; } Arrays . sort ( length ) ; long ans = 0 ; for ( int i = 0 ; i < num ; i += 2 ) { ans += length [ i ] ; } System . out . println ( ans ) ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; Integer [ ] L = new Integer [ 2 * N ] ; for ( int i = 0 ; i < 2 * N ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } Arrays . sort ( L , Collections . reverseOrder ( ) ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ans += Math . min ( L [ 2 * i ] , L [ 2 * i + 1 ] ) ; } out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . lang . reflect . Array ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { static BufferedReader reader ; static StringTokenizer tokenizer ; static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( \" \" ) ; } static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int n = nextInt ( ) ; int A [ ] = new int [ 2 * n ] ; for ( int i = 0 ; i < 2 * n ; i ++ ) { A [ i ] = nextInt ( ) ; } Arrays . sort ( A ) ; int sum = 0 ; for ( int i = 0 ; i < 2 * n ; i += 2 ) { if ( A [ i ] < A [ i + 1 ] ) { sum += A [ i ] ; } else { sum += A [ i + 1 ] ; } } System . out . println ( sum ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; int N = Integer . parseInt ( line ) ; line = sc . nextLine ( ) ; String [ ] l1l2 = line . split ( \" ▁ \" ) ; List < Integer > kusi = new ArrayList < > ( ) ; for ( int i = 0 ; i < l1l2 . length ; i ++ ) { kusi . add ( Integer . parseInt ( l1l2 [ i ] ) ) ; } Collections . sort ( kusi ) ; calc ( kusi ) ; } public static void calc ( List < Integer > list ) { int total = 0 ; for ( int i = 0 ; i < list . size ( ) ; i = i + 2 ) { total += list . get ( i ) ; } System . out . println ( total ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int spitCount = Integer . valueOf ( scanner . nextLine ( ) ) * 2 ; int spits [ ] = new int [ spitCount ] ; for ( int i = 0 ; i < spitCount ; i ++ ) { spits [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( spits ) ; int dishSum = 0 ; for ( int i = 0 ; i < spitCount ; i ++ ) { if ( i % 2 == 0 ) { dishSum += spits [ i ] ; } } System . out . println ( dishSum ) ; } }" ]
[ "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 N = getInt ( ) NEW_LINE d . dmp ( ( N ) , ' N ' ) NEW_LINE L = getIntList ( ) NEW_LINE d . dmp ( ( L ) , ' L ' ) NEW_LINE L . sort ( ) NEW_LINE count = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT count += min ( L [ i * 2 ] , L [ i * 2 + 1 ] ) NEW_LINE DEDENT return count NEW_LINE DEDENT ans = prob ( ) NEW_LINE print ( ans ) NEW_LINE", "n , l = open ( 0 ) ; print ( sum ( sorted ( map ( int , l . split ( ) ) ) [ : : 2 ] ) ) NEW_LINE", "N = int ( input ( ) ) NEW_LINE L = [ ] NEW_LINE for n in [ int ( i ) for i in input ( ) . split ( ) ] : NEW_LINE INDENT L . append ( n ) NEW_LINE DEDENT L . sort ( ) NEW_LINE SUM = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT x = L . pop ( ) NEW_LINE y = L . pop ( ) NEW_LINE if x < y : NEW_LINE INDENT SUM = SUM + x NEW_LINE DEDENT elif x >= y : NEW_LINE INDENT SUM = SUM + y NEW_LINE DEDENT DEDENT print ( SUM ) NEW_LINE", "N = input ( ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def quicksort ( array ) : NEW_LINE INDENT if len ( array ) < 2 : NEW_LINE INDENT return array NEW_LINE DEDENT else : NEW_LINE INDENT pivot = array [ 0 ] NEW_LINE less = [ i for i in array [ 1 : ] if i <= pivot ] NEW_LINE greater = [ i for i in array [ 1 : ] if i > pivot ] NEW_LINE return quicksort ( less ) + [ pivot ] + quicksort ( greater ) NEW_LINE DEDENT DEDENT guzai = 0 NEW_LINE for i in range ( int ( N ) ) : NEW_LINE INDENT guzai += int ( quicksort ( L ) [ int ( 2 * i ) ] ) NEW_LINE DEDENT print ( guzai ) NEW_LINE", "import bisect NEW_LINE N = input ( ) NEW_LINE Ls = map ( int , input ( ) . split ( \" ▁ \" ) ) NEW_LINE Ls = sorted ( Ls ) NEW_LINE ans = sum ( [ L for i , L in enumerate ( Ls ) if i % 2 == 0 ] ) NEW_LINE print ( ans ) NEW_LINE" ]
atcoder_arc065_A
[ "import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; char [ ] array = sc . nextLine ( ) . toCharArray ( ) ; try { for ( int i = array . length - 1 ; i >= 0 ; i -- ) { if ( i >= 6 ) { if ( array [ i - 6 ] == ' d ' && array [ i - 5 ] == ' r ' && array [ i - 4 ] == ' e ' && array [ i - 3 ] == ' a ' && array [ i - 2 ] == ' m ' && array [ i - 1 ] == ' e ' && array [ i ] == ' r ' ) { i -= 6 ; continue ; } } if ( i >= 5 ) { if ( array [ i - 5 ] == ' e ' && array [ i - 4 ] == ' r ' && array [ i - 3 ] == ' a ' && array [ i - 2 ] == ' s ' && array [ i - 1 ] == ' e ' && array [ i ] == ' r ' ) { i -= 5 ; continue ; } } if ( ( array [ i - 4 ] == ' d ' && array [ i - 3 ] == ' r ' && array [ i - 2 ] == ' e ' && array [ i - 1 ] == ' a ' && array [ i ] == ' m ' ) || ( array [ i - 4 ] == ' e ' && array [ i - 3 ] == ' r ' && array [ i - 2 ] == ' a ' && array [ i - 1 ] == ' s ' && array [ i ] == ' e ' ) ) { i -= 4 ; } else { System . out . println ( \" NO \" ) ; return ; } } } catch ( ArrayIndexOutOfBoundsException e ) { System . out . println ( \" NO \" ) ; return ; } System . out . println ( \" YES \" ) ; } }", "import java . io . * ; import java . util . * ; public class Main { static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { try { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } public String next ( ) { if ( st . hasMoreTokens ( ) ) return st . nextToken ( ) ; try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { String line = \" \" ; if ( st . hasMoreTokens ( ) ) line = st . nextToken ( ) ; else try { return br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } while ( st . hasMoreTokens ( ) ) line += \" ▁ \" + st . nextToken ( ) ; return line ; } } public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; String s = sc . nextLine ( ) ; int k = s . length ( ) ; while ( k > 0 ) { if ( k >= 5 && s . substring ( k - 5 , k ) . equals ( \" dream \" ) ) { k -= 5 ; } else if ( k >= 7 && s . substring ( k - 7 , k ) . equals ( \" dreamer \" ) ) { k -= 7 ; } else if ( k >= 5 && s . substring ( k - 5 , k ) . equals ( \" erase \" ) ) { k -= 5 ; } else if ( k >= 6 && s . substring ( k - 6 , k ) . equals ( \" eraser \" ) ) { k -= 6 ; } else { pw . println ( \" NO \" ) ; pw . close ( ) ; return ; } } pw . println ( \" YES \" ) ; pw . close ( ) ; } }", "import java . util . * ; import java . io . * ; public class Main { static boolean match ( String temp , int start , String str ) { if ( start + temp . length ( ) > str . length ( ) ) return false ; for ( int j = 0 ; j < temp . length ( ) ; j ++ ) { if ( temp . charAt ( j ) != str . charAt ( j + start ) ) return false ; } return true ; } public static void main ( String [ ] args ) throws Exception { String array [ ] = new String [ ] { \" dreamer \" , \" dream \" , \" eraser \" , \" erase \" } ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; int start = 0 ; int last = - 1 ; while ( start < str . length ( ) && start >= 0 ) { boolean flag = false ; for ( int j = 0 ; j < 4 ; j ++ ) { if ( match ( array [ j ] , start , str ) ) { start += array [ j ] . length ( ) ; flag = true ; last = j ; break ; } } if ( ! flag && last == 0 ) { start -= 2 ; last = - 1 ; } else if ( ! flag ) break ; } if ( start == str . length ( ) ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } }", "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 [ ] [ ] addeds = { \" dream \" . toCharArray ( ) , \" dreamer \" . toCharArray ( ) , \" erase \" . toCharArray ( ) , \" eraser \" . toCharArray ( ) } ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int endIndex = s . length ; while ( endIndex > 0 ) { boolean f = false ; for ( char [ ] added : addeds ) { if ( isMatch ( s , added , endIndex ) ) { endIndex -= added . length ; f = true ; break ; } } if ( f == false ) { System . out . println ( \" NO \" ) ; return ; } } System . out . println ( \" YES \" ) ; } boolean isMatch ( char [ ] s , char [ ] added , int endIndex ) { if ( endIndex - added . length < 0 ) { return false ; } for ( int i = 0 ; i < added . length ; i ++ ) { if ( added [ i ] != s [ endIndex - added . length + i ] ) { return false ; } } return true ; } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String inputText = sc . next ( ) ; char [ ] p1 = { ' m ' , ' a ' , ' e ' , ' r ' , ' d ' } ; char [ ] p2 = { ' r ' , ' e ' , ' m ' , ' a ' , ' e ' , ' r ' , ' d ' } ; char [ ] p3 = { ' e ' , ' s ' , ' a ' , ' r ' , ' e ' } ; char [ ] p4 = { ' r ' , ' e ' , ' s ' , ' a ' , ' r ' , ' e ' } ; char [ ] inputArray = inputText . toCharArray ( ) ; int wordIndex = 0 ; char [ ] targetArray = null ; for ( int i = inputArray . length - 1 ; i >= 0 ; i -- ) { if ( wordIndex == 0 ) { if ( inputArray [ i ] == ' m ' ) { targetArray = p1 ; } else if ( inputArray [ i ] == ' e ' ) { targetArray = p3 ; } else if ( inputArray [ i ] == ' r ' ) { if ( i - 2 > 0 ) { if ( inputArray [ i - 2 ] == ' m ' ) { targetArray = p2 ; } else if ( inputArray [ i - 2 ] == ' s ' ) { targetArray = p4 ; } else { System . out . println ( \" NO \" ) ; return ; } } else { System . out . println ( \" NO \" ) ; return ; } } else { System . out . println ( \" NO \" ) ; return ; } } else { if ( targetArray [ wordIndex ] != inputArray [ i ] ) { System . out . println ( \" NO \" ) ; return ; } } if ( wordIndex < targetArray . length - 1 ) { wordIndex ++ ; } else { wordIndex = 0 ; targetArray = null ; } } System . out . println ( \" YES \" ) ; } }" ]
[ "s = list ( input ( ) ) NEW_LINE c = 0 NEW_LINE while len ( s ) > 0 : NEW_LINE INDENT p = \"1\" NEW_LINE q = \"1\" NEW_LINE r = \"1\" NEW_LINE if len ( s ) < 5 : NEW_LINE INDENT break NEW_LINE DEDENT if len ( s ) <= 7 : NEW_LINE INDENT if len ( s ) == 5 : NEW_LINE INDENT if s == list ( \" dream \" ) or s == list ( \" erase \" ) : NEW_LINE INDENT c = 1 NEW_LINE break NEW_LINE DEDENT DEDENT elif len ( s ) == 6 : NEW_LINE INDENT if s == list ( \" eraser \" ) : NEW_LINE INDENT c = 1 NEW_LINE break NEW_LINE DEDENT DEDENT elif len ( s ) == 7 : NEW_LINE INDENT if s == list ( \" dreamer \" ) : NEW_LINE INDENT c = 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT p = s [ len ( s ) - 5 : len ( s ) ] NEW_LINE q = s [ len ( s ) - 6 : len ( s ) ] NEW_LINE r = s [ len ( s ) - 7 : len ( s ) ] NEW_LINE if p == list ( \" dream \" ) or p == list ( \" erase \" ) : NEW_LINE INDENT del s [ len ( s ) - 5 : len ( s ) ] NEW_LINE DEDENT elif q == list ( \" eraser \" ) : NEW_LINE INDENT del s [ len ( s ) - 6 : len ( s ) ] NEW_LINE DEDENT elif r == list ( \" dreamer \" ) : NEW_LINE INDENT del s [ len ( s ) - 7 : len ( s ) ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( \" YES \" if c == 1 else \" NO \" ) NEW_LINE", "from collections import deque NEW_LINE def solve ( s ) : NEW_LINE INDENT stack = deque ( ) NEW_LINE stack . append ( s ) NEW_LINE while len ( stack ) > 0 : NEW_LINE INDENT top = stack . pop ( ) NEW_LINE if top == ' ' : NEW_LINE INDENT return ' YES ' NEW_LINE DEDENT if top [ : 5 ] == ' dream ' : NEW_LINE INDENT if top [ 5 : 7 ] == ' er ' : NEW_LINE INDENT stack . append ( top [ 7 : ] ) NEW_LINE DEDENT stack . append ( top [ 5 : ] ) NEW_LINE DEDENT elif top [ : 5 ] == ' erase ' : NEW_LINE INDENT if len ( top ) > 5 and top [ 5 ] == ' r ' : NEW_LINE INDENT stack . append ( top [ 6 : ] ) NEW_LINE DEDENT else : NEW_LINE INDENT stack . append ( top [ 5 : ] ) NEW_LINE DEDENT DEDENT DEDENT return ' NO ' NEW_LINE DEDENT print ( solve ( input ( ) ) ) NEW_LINE", "S = input ( ) NEW_LINE S = S [ : : - 1 ] NEW_LINE S = S . replace ( ' resare ' , ' ' ) NEW_LINE S = S . replace ( ' esare ' , ' ' ) NEW_LINE S = S . replace ( ' remaerd ' , ' ' ) NEW_LINE S = S . replace ( ' maerd ' , ' ' ) NEW_LINE if S : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT", "def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def gen ( tstr ) : NEW_LINE INDENT if len ( tstr ) <= len ( S ) : NEW_LINE INDENT for w in words : NEW_LINE INDENT yield tstr + w NEW_LINE for w2 in gen ( tstr + w ) : NEW_LINE INDENT yield w2 NEW_LINE DEDENT DEDENT DEDENT DEDENT def solve ( ) : NEW_LINE INDENT ans = False NEW_LINE for genstr in gen ( ' ' ) : NEW_LINE INDENT db ( genstr ) NEW_LINE if genstr == S : NEW_LINE INDENT ans = True NEW_LINE break NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT def solve2 ( ) : NEW_LINE INDENT stack = list ( words ) NEW_LINE while stack != [ ] : NEW_LINE INDENT str = stack . pop ( ) NEW_LINE db ( ( ' pop ' , str ) ) NEW_LINE if len ( str ) < len ( S ) : NEW_LINE INDENT for w in words : NEW_LINE INDENT stack . append ( str + w ) NEW_LINE DEDENT DEDENT elif len ( str ) == len ( S ) and str == S : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT def solve3 ( ) : NEW_LINE INDENT string = S + ' ▁ ' NEW_LINE n = len ( string ) NEW_LINE while n > 1 : NEW_LINE INDENT for w in words : NEW_LINE INDENT db ( ( string . rfind ( w , 0 , n ) , len ( w ) , n ) ) NEW_LINE if string . rfind ( w , 0 , n ) + len ( w ) + 1 == n : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT db ( ( n , w ) ) NEW_LINE n -= len ( w ) NEW_LINE DEDENT return True NEW_LINE DEDENT debug = False NEW_LINE words = ( ' dream ' , ' dreamer ' , ' erase ' , ' eraser ' ) NEW_LINE S = input ( ) NEW_LINE db ( S ) NEW_LINE if solve3 ( ) : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT", "def YESNO ( ans , yes = \" YES \" , no = \" NO \" ) : NEW_LINE INDENT print ( [ no , yes ] [ ans ] ) NEW_LINE DEDENT II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE MIL = lambda : list ( MI ( ) ) NEW_LINE MIS = lambda : input ( ) . split ( ) NEW_LINE def check ( s ) : NEW_LINE INDENT if s == \" \" : NEW_LINE INDENT return True NEW_LINE DEDENT if s [ : 5 ] in [ \" dream \" , \" erase \" ] : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT S = input ( ) NEW_LINE i = 0 NEW_LINE l = len ( S ) NEW_LINE while i < l : NEW_LINE INDENT if S [ i : i + 7 ] == \" dreamer \" and check ( S [ i + 7 : ] ) : NEW_LINE INDENT i += 7 NEW_LINE DEDENT elif S [ i : i + 6 ] == \" eraser \" and check ( S [ i + 6 : ] ) : NEW_LINE INDENT i += 6 NEW_LINE DEDENT elif check ( S [ i : ] ) : NEW_LINE INDENT i += 5 NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT YESNO ( main ( ) ) NEW_LINE DEDENT" ]
atcoder_arc061_B
[ "import java . util . * ; import java . awt . Point ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } public void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long H = scanner . nextLong ( ) ; long W = scanner . nextLong ( ) ; int N = scanner . nextInt ( ) ; Point [ ] point = new Point [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int row = scanner . nextInt ( ) ; int col = scanner . nextInt ( ) ; point [ i ] = new Point ( col , row ) ; } HashMap < Point , Integer > hashmap = new HashMap < Point , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int y = - 1 ; y < 2 ; y ++ ) { for ( int x = - 1 ; x < 2 ; x ++ ) { Point p = new Point ( point [ i ] . x + x , point [ i ] . y + y ) ; if ( hashmap . get ( p ) == null ) { hashmap . put ( p , 1 ) ; } else { hashmap . put ( p , hashmap . get ( p ) + 1 ) ; } } } } long [ ] counter = new long [ 10 ] ; for ( int i = 0 ; i < counter . length ; i ++ ) { counter [ i ] = 0 ; } long sum = ( H - 2 ) * ( W - 2 ) ; for ( HashMap . Entry < Point , Integer > map : hashmap . entrySet ( ) ) { if ( 1 < map . getKey ( ) . x && map . getKey ( ) . x < W && 1 < map . getKey ( ) . y && map . getKey ( ) . y < H ) { counter [ map . getValue ( ) ] ++ ; sum -- ; } } counter [ 0 ] = sum ; for ( int i = 0 ; i < counter . length ; i ++ ) { System . out . println ( counter [ i ] ) ; } } }", "import java . util . * ; class Point implements Comparable < Point > { int a , b ; Point ( int a , int b ) { this . a = a ; this . b = b ; } public int hashCode ( ) { return ( ( a & 0xFFFF0000 ) | ( b >> 16 ) ) ^ ( ( b & 0xFFFF0000 ) | ( a >> 16 ) ) ; } public boolean equals ( Object object ) { Point point = ( Point ) object ; return this . a == point . a && this . b == point . b ; } public int compareTo ( Point p ) { if ( this . a != p . a ) { return this . a - p . a ; } return this . b - p . b ; } } public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int h = s . nextInt ( ) ; int w = s . nextInt ( ) ; int n = s . nextInt ( ) ; HashMap < Point , Integer > map = new HashMap < Point , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = s . nextInt ( ) - 1 ; int b = s . nextInt ( ) - 1 ; for ( int da = Math . max ( 0 , a - 2 ) ; da <= Math . min ( h - 3 , a ) ; da ++ ) { for ( int db = Math . max ( 0 , b - 2 ) ; db <= Math . min ( w - 3 , b ) ; db ++ ) { Point p = new Point ( da , db ) ; if ( map . get ( p ) == null ) { map . put ( p , 1 ) ; } else { map . put ( p , map . get ( p ) + 1 ) ; } } } } long [ ] output = new long [ 10 ] ; output [ 0 ] = ( long ) ( h - 2 ) * ( long ) ( w - 2 ) ; for ( int value : map . values ( ) ) { output [ 0 ] -- ; output [ value ] ++ ; } for ( long value : output ) { System . out . println ( value ) ; } } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long h = in . nextLong ( ) , w = in . nextLong ( ) ; int n = in . nextInt ( ) ; Map < Long , Integer > map = new HashMap < > ( ) ; int [ ] dx = { 0 , 0 , 1 , 1 , 1 , 0 , - 1 , - 1 , - 1 } ; int [ ] dy = { 0 , - 1 , - 1 , 0 , 1 , 1 , 1 , 0 , - 1 } ; for ( int i = 0 ; i < n ; i ++ ) { int a = in . nextInt ( ) - 1 , b = in . nextInt ( ) - 1 ; for ( int k = 0 ; k < 9 ; k ++ ) { int y = a + dy [ k ] , x = b + dx [ k ] ; if ( x < 1 || w - 1 <= x || y < 1 || h - 1 <= y ) { continue ; } long key = ( long ) y << 32 | x ; Integer val = map . get ( key ) ; map . put ( key , val == null ? 1 : val + 1 ) ; } } System . out . println ( ( h - 2 ) * ( w - 2 ) - map . size ( ) ) ; long [ ] cnt = new long [ 10 ] ; for ( long key : map . keySet ( ) ) { cnt [ map . get ( key ) ] ++ ; } for ( int i = 1 ; i < 10 ; i ++ ) { System . out . println ( cnt [ i ] ) ; } } }", "import java . util . * ; class Point implements Comparable < Point > { int a , b ; Point ( int a , int b ) { this . a = a ; this . b = b ; } public int hashCode ( ) { return a ^ b ; } public boolean equals ( Object object ) { Point point = ( Point ) object ; return this . a == point . a && this . b == point . b ; } public int compareTo ( Point p ) { if ( this . a != p . a ) { return this . a - p . a ; } return this . b - p . b ; } } public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int h = s . nextInt ( ) ; int w = s . nextInt ( ) ; int n = s . nextInt ( ) ; TreeMap < Point , Integer > map = new TreeMap < Point , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = s . nextInt ( ) - 1 ; int b = s . nextInt ( ) - 1 ; for ( int da = Math . max ( 0 , a - 2 ) ; da <= Math . min ( h - 3 , a ) ; da ++ ) { for ( int db = Math . max ( 0 , b - 2 ) ; db <= Math . min ( w - 3 , b ) ; db ++ ) { Point p = new Point ( da , db ) ; if ( map . get ( p ) == null ) { map . put ( p , 1 ) ; } else { map . put ( p , map . get ( p ) + 1 ) ; } } } } long [ ] output = new long [ 10 ] ; output [ 0 ] = ( long ) ( h - 2 ) * ( long ) ( w - 2 ) ; for ( int value : map . values ( ) ) { output [ 0 ] -- ; output [ value ] ++ ; } for ( long value : output ) { System . out . println ( value ) ; } } }", "import java . util . HashMap ; import java . util . Scanner ; import java . awt . Point ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } public void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long H = scanner . nextLong ( ) ; long W = scanner . nextLong ( ) ; int N = scanner . nextInt ( ) ; Point [ ] point = new Point [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int row = scanner . nextInt ( ) ; int col = scanner . nextInt ( ) ; point [ i ] = new Point ( col , row ) ; } HashMap < Point , Integer > hashmap = new HashMap < Point , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int y = - 1 ; y < 2 ; y ++ ) { for ( int x = - 1 ; x < 2 ; x ++ ) { Point p = new Point ( point [ i ] . x + x , point [ i ] . y + y ) ; if ( hashmap . get ( p ) == null ) { hashmap . put ( p , 1 ) ; } else { hashmap . put ( p , hashmap . get ( p ) + 1 ) ; } } } } long [ ] counter = new long [ 10 ] ; for ( int i = 0 ; i < counter . length ; i ++ ) { counter [ i ] = 0 ; } long sum = ( H - 2 ) * ( W - 2 ) ; for ( HashMap . Entry < Point , Integer > map : hashmap . entrySet ( ) ) { if ( 1 < map . getKey ( ) . x && map . getKey ( ) . x < W && 1 < map . getKey ( ) . y && map . getKey ( ) . y < H ) { counter [ map . getValue ( ) ] ++ ; sum -- ; } } counter [ 0 ] = sum ; for ( int i = 0 ; i < counter . length ; i ++ ) { System . out . println ( counter [ i ] ) ; } } }" ]
[ "import sys NEW_LINE input = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 10000 ) NEW_LINE H , W , N = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE if N == 0 : NEW_LINE INDENT reslis = [ 0 ] * 10 NEW_LINE reslis [ 0 ] = ( H - 2 ) * ( W - 2 ) - sum ( reslis ) NEW_LINE DEDENT else : NEW_LINE INDENT L = [ ] NEW_LINE for k in range ( N ) : NEW_LINE INDENT a , b = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if 1 <= a - 2 + i <= H - 2 and 1 <= b - 2 + j <= W - 2 : NEW_LINE INDENT L . append ( ( a - 2 + i , b - 2 + j ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT L . sort ( ) NEW_LINE temp = None NEW_LINE cc = 1 NEW_LINE reslis = [ 0 ] * 10 NEW_LINE for se in L : NEW_LINE INDENT if temp == se : NEW_LINE INDENT cc += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if temp == None : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT reslis [ cc ] += 1 NEW_LINE cc = 1 NEW_LINE DEDENT temp = se NEW_LINE DEDENT DEDENT reslis [ cc ] += 1 NEW_LINE reslis [ 0 ] = ( H - 2 ) * ( W - 2 ) - sum ( reslis ) NEW_LINE DEDENT for i in reslis : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT", "f = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE h , w , n = f ( ) NEW_LINE c = [ ( h - 2 ) * ( w - 2 ) ] + [ 0 ] * 9 NEW_LINE d = { } NEW_LINE while n : NEW_LINE INDENT n -= 1 ; x , y = f ( ) NEW_LINE for i in range ( 9 ) : a = x + i % 3 , y + i // 3 ; g = h >= a [ 0 ] > 2 < a [ 1 ] <= w ; t = d [ a ] = d . get ( a , 0 ) + g ; c [ t - g ] -= 1 ; c [ t ] += 1 NEW_LINE DEDENT print ( * c ) NEW_LINE", "from collections import defaultdict NEW_LINE def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE HW = defaultdict ( lambda : 0 ) NEW_LINE direction = [ ( 0 , 0 ) , ( 1 , 1 ) , ( 1 , 0 ) , ( 1 , - 1 ) , ( 0 , - 1 ) , ( - 1 , - 1 ) , ( - 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) ] NEW_LINE H , W , N = inpl ( ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b = inpl ( ) NEW_LINE for dh , dw in direction : NEW_LINE INDENT if 2 <= a + dh <= H - 1 and 2 <= b + dw <= W - 1 : NEW_LINE INDENT HW [ ( a + dh , b + dw ) ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans = [ 0 for i in range ( 10 ) ] NEW_LINE print ( ( H - 2 ) * ( W - 2 ) - len ( HW ) ) NEW_LINE for j in HW . values ( ) : NEW_LINE INDENT ans [ j ] += 1 NEW_LINE DEDENT for i in ans [ 1 : ] : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT", "from collections import defaultdict NEW_LINE h , w , n = map ( int , input ( ) . split ( ) ) NEW_LINE abd = defaultdict ( int ) NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE abd [ ( a , b ) ] += 1 NEW_LINE abd [ ( a , b - 1 ) ] += 1 NEW_LINE abd [ ( a , b - 2 ) ] += 1 NEW_LINE abd [ ( a - 1 , b ) ] += 1 NEW_LINE abd [ ( a - 1 , b - 1 ) ] += 1 NEW_LINE abd [ ( a - 1 , b - 2 ) ] += 1 NEW_LINE abd [ ( a - 2 , b ) ] += 1 NEW_LINE abd [ ( a - 2 , b - 1 ) ] += 1 NEW_LINE abd [ ( a - 2 , b - 2 ) ] += 1 NEW_LINE DEDENT suma = [ 0 for _ in range ( 10 ) ] NEW_LINE for a , b in abd . keys ( ) : NEW_LINE INDENT if 0 < a < h - 1 and 0 < b < w - 1 : NEW_LINE INDENT suma [ abd [ ( a , b ) ] ] += 1 NEW_LINE DEDENT DEDENT suma [ 0 ] = ( h - 2 ) * ( w - 2 ) - sum ( suma ) NEW_LINE print ( * suma , sep = ' \\n ' ) NEW_LINE", "import sys , collections NEW_LINE 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 H , W , N = map ( int , input ( ) . split ( ) ) NEW_LINE L = [ 0 for _ in range ( 10 ) ] NEW_LINE L [ 0 ] = ( H - 2 ) * ( W - 2 ) NEW_LINE NL = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT y , x = map ( int , input ( ) . split ( ) ) NEW_LINE x -= 1 NEW_LINE y -= 1 NEW_LINE for i in range ( - 1 , 2 ) : NEW_LINE INDENT for j in range ( - 1 , 2 ) : NEW_LINE INDENT if check_range ( y + i , x + j , H - 1 , W - 1 ) : NEW_LINE INDENT NL . append ( ( y + i , x + j ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT NLD = collections . Counter ( NL ) NEW_LINE for v in NLD . values ( ) : NEW_LINE INDENT L [ v ] += 1 NEW_LINE L [ 0 ] -= 1 NEW_LINE DEDENT for v in L : NEW_LINE INDENT print ( v ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE" ]
atcoder_agc001_C
[ "import java . util . * ; class Main { static ArrayList < Integer > [ ] map ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x == 1 ) { System . out . println ( n - 2 ) ; System . exit ( 0 ) ; } map = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) map [ i ] = new ArrayList < > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; map [ a ] . add ( b ) ; map [ b ] . add ( a ) ; } long ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int first = 1 , second = 0 ; for ( int w : map [ i ] ) { int [ ] cur = dfs ( w , i , x / 2 - 1 ) ; first += cur [ 0 ] ; second = Math . max ( second , cur [ 1 ] ) ; } if ( x % 2 == 1 ) first += second ; ans = Math . max ( ans , first ) ; } System . out . println ( n - ans ) ; } static int [ ] dfs ( int root , int from , int level ) { if ( level == 0 ) return new int [ ] { 1 , map [ root ] . size ( ) - 1 } ; int first = 1 , second = 0 ; for ( int w : map [ root ] ) { if ( w == from ) continue ; int [ ] cur = dfs ( w , root , level - 1 ) ; first += cur [ 0 ] ; second += cur [ 1 ] ; } return new int [ ] { first , second } ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ." ]
[ "from collections import deque NEW_LINE n , k = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE b = [ [ int ( i ) - 1 for i in input ( ) . split ( ) ] for i in range ( n - 1 ) ] NEW_LINE x , d , ans , c = [ [ ] for i in range ( n ) ] , [ [ ] for i in range ( n ) ] , n , 0 NEW_LINE for i , j in b : NEW_LINE INDENT x [ i ] . append ( j ) NEW_LINE x [ j ] . append ( i ) NEW_LINE DEDENT def f ( s ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT q , v = deque ( ) , [ 1 ] * n NEW_LINE v [ i ] = 0 NEW_LINE for j in x [ i ] : NEW_LINE INDENT q . append ( ( j , 1 , j ) ) NEW_LINE d [ i ] . append ( j ) NEW_LINE v [ j ] = 0 NEW_LINE DEDENT while q : NEW_LINE INDENT p = q . pop ( ) NEW_LINE if p [ 1 ] < s : NEW_LINE INDENT for j in x [ p [ 0 ] ] : NEW_LINE INDENT if v [ j ] : NEW_LINE INDENT q . append ( ( j , p [ 1 ] + 1 , p [ 2 ] ) ) NEW_LINE d [ i ] . append ( p [ 2 ] ) NEW_LINE v [ j ] = 0 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT if k > n // 2 : NEW_LINE INDENT for i in x : c = max ( len ( i ) , c ) NEW_LINE DEDENT if n - c + 1 <= k : ans = 0 NEW_LINE elif k == 1 : ans = n - 2 NEW_LINE else : NEW_LINE INDENT f ( k // 2 ) NEW_LINE if k % 2 : NEW_LINE INDENT for i , j in b : ans = min ( ans , n - len ( d [ i ] ) - len ( d [ j ] ) + d [ i ] . count ( j ) + d [ j ] . count ( i ) - 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( n ) : ans = min ( ans , n - len ( d [ i ] ) - 1 ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE", "n , k = map ( int , input ( ) . split ( ) ) NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 2000 ) NEW_LINE l = [ [ ] for i in range ( n ) ] NEW_LINE e = [ ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE l [ a - 1 ] . append ( b - 1 ) NEW_LINE l [ b - 1 ] . append ( a - 1 ) NEW_LINE e . append ( [ a - 1 , b - 1 ] ) NEW_LINE DEDENT def first_search ( first , depth ) : NEW_LINE INDENT record = 0 NEW_LINE for i in l [ first ] : NEW_LINE INDENT temp = search ( first , i , depth - 1 ) NEW_LINE if record < temp : NEW_LINE INDENT record = temp NEW_LINE DEDENT DEDENT return record + 1 NEW_LINE DEDENT def search ( before , now , depth ) : NEW_LINE INDENT if depth <= 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = 1 NEW_LINE for i in l [ now ] : NEW_LINE INDENT if before != i : NEW_LINE INDENT ans += search ( now , i , depth - 1 ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT DEDENT ret = 0 NEW_LINE if k % 2 == 0 : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT temp = search ( - 1 , i , k // 2 ) NEW_LINE if temp > ret : NEW_LINE INDENT ret = temp NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i in e : NEW_LINE INDENT temp = search ( i [ 0 ] , i [ 1 ] , k // 2 ) + search ( i [ 1 ] , i [ 0 ] , k // 2 ) NEW_LINE if temp > ret : NEW_LINE INDENT ret = temp NEW_LINE DEDENT DEDENT DEDENT print ( n - ret ) NEW_LINE", "import sys NEW_LINE from collections import defaultdict , deque 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 , k = LI ( ) NEW_LINE G = defaultdict ( list ) NEW_LINE AB = [ LI_ ( ) for _ in range ( n - 1 ) ] NEW_LINE for a , b in AB : NEW_LINE INDENT G [ a ] . append ( b ) NEW_LINE G [ b ] . append ( a ) NEW_LINE DEDENT def DFS ( ss : list , t : int ) : NEW_LINE INDENT q = deque ( ) NEW_LINE for s in ss : NEW_LINE INDENT q . append ( ( s , 0 ) ) NEW_LINE DEDENT visited = [ 0 ] * n NEW_LINE visited [ ss [ 0 ] ] = visited [ ss [ - 1 ] ] = 1 NEW_LINE while q : NEW_LINE INDENT v , d = q . pop ( ) NEW_LINE if d >= t : NEW_LINE INDENT continue NEW_LINE DEDENT for to in G [ v ] : NEW_LINE INDENT if visited [ to ] : NEW_LINE INDENT continue NEW_LINE DEDENT visited [ to ] = 1 NEW_LINE q . append ( ( to , d + 1 ) ) NEW_LINE DEDENT DEDENT return n - sum ( visited ) NEW_LINE DEDENT res = INF NEW_LINE if k % 2 : NEW_LINE INDENT for a , b in AB : NEW_LINE INDENT res = min ( res , DFS ( [ a , b ] , ( k - 1 ) // 2 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT res = min ( res , DFS ( [ i ] , k // 2 ) ) NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "import copy NEW_LINE N , K = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE G = [ [ ] for i in range ( N ) ] NEW_LINE E = [ ] NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT A , B = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE E . append ( ( A - 1 , B - 1 ) ) NEW_LINE G [ A - 1 ] . append ( B - 1 ) NEW_LINE G [ B - 1 ] . append ( A - 1 ) NEW_LINE DEDENT def DFS ( u , n , G ) : NEW_LINE INDENT q = [ u ] NEW_LINE v = [ 0 ] * N NEW_LINE d = [ 0 ] * N NEW_LINE while q : NEW_LINE INDENT u1 = q . pop ( ) NEW_LINE v [ u1 ] = 1 NEW_LINE if d [ u1 ] < n : NEW_LINE INDENT for u2 in G [ u1 ] : NEW_LINE INDENT if not v [ u2 ] : NEW_LINE INDENT d [ u2 ] = d [ u1 ] + 1 NEW_LINE q . append ( u2 ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return sum ( v ) NEW_LINE DEDENT def DFS_E ( u , uu , n , G ) : NEW_LINE INDENT q = [ u , uu ] NEW_LINE v = [ 0 ] * N NEW_LINE d = [ 0 ] * N NEW_LINE while q : NEW_LINE INDENT u1 = q . pop ( ) NEW_LINE v [ u1 ] = 1 NEW_LINE if d [ u1 ] < n : NEW_LINE INDENT for u2 in G [ u1 ] : NEW_LINE INDENT if not v [ u2 ] and u2 != u : NEW_LINE INDENT d [ u2 ] = d [ u1 ] + 1 NEW_LINE q . append ( u2 ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return sum ( v ) NEW_LINE DEDENT if K % 2 == 0 : NEW_LINE INDENT ans = 0 NEW_LINE for v in range ( N ) : NEW_LINE INDENT ans = max ( ans , DFS ( v , K // 2 , G ) ) NEW_LINE DEDENT print ( N - ans ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE for u , v in E : NEW_LINE INDENT ans = max ( ans , DFS_E ( u , v , ( K - 1 ) // 2 , G ) ) NEW_LINE DEDENT print ( N - ans ) NEW_LINE DEDENT", "from collections import deque NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE es = [ tuple ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) for i in range ( N - 1 ) ] NEW_LINE tr = [ [ ] for i in range ( N ) ] NEW_LINE for i , ( a , b ) in enumerate ( es ) : NEW_LINE INDENT tr [ a ] . append ( ( b , i ) ) NEW_LINE tr [ b ] . append ( ( a , i ) ) NEW_LINE DEDENT def reachable_points ( root_v , cant_visit_v ) : NEW_LINE INDENT visited = [ 0 ] * N NEW_LINE visited [ root_v ] = visited [ cant_visit_v ] = 1 NEW_LINE q = deque ( [ ( root_v , 0 ) ] ) NEW_LINE ret = 0 NEW_LINE while q : NEW_LINE INDENT v , dep = q . popleft ( ) NEW_LINE if dep == K // 2 : break NEW_LINE for to , _ in tr [ v ] : NEW_LINE INDENT if visited [ to ] : continue NEW_LINE ret += 1 NEW_LINE q . append ( ( to , dep + 1 ) ) NEW_LINE visited [ to ] = 1 NEW_LINE DEDENT DEDENT return ret NEW_LINE DEDENT def reachable_edges ( root_e ) : NEW_LINE INDENT a , b = es [ root_e ] NEW_LINE return reachable_points ( a , b ) + reachable_points ( b , a ) NEW_LINE DEDENT if K % 2 : NEW_LINE INDENT ans = N NEW_LINE for center_e in range ( N - 1 ) : NEW_LINE INDENT ans = min ( ans , N - 2 - reachable_edges ( center_e ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = N NEW_LINE for center_v in range ( N ) : NEW_LINE INDENT ans = min ( ans , N - 1 - reachable_points ( center_v , center_v ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT" ]
atcoder_abc118_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { int INF = 100000000 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] dp = new int [ n + 1 ] ; int [ ] a = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] cost = { 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; Arrays . sort ( a ) ; Arrays . fill ( dp , - INF ) ; dp [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( i - cost [ a [ j ] ] < 0 ) continue ; else dp [ i ] = Math . max ( dp [ i ] , dp [ i - cost [ a [ j ] ] ] + 1 ) ; } } StringBuilder ans = new StringBuilder ( ) ; while ( n != 0 ) { for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( cost [ a [ j ] ] > n ) continue ; if ( dp [ n - cost [ a [ j ] ] ] == dp [ n ] - 1 ) { ans . append ( a [ j ] ) ; n -= cost [ a [ j ] ] ; break ; } } } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { static long t [ ] ; static long l [ ] ; static long h [ ] ; public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s ; String sl [ ] ; int d [ ] = new int [ 10 ] ; int c [ ] = { 999999 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; for ( int i = 0 ; i <= 9 ; i ++ ) { d [ i ] = 999999 ; } s = r . readLine ( ) ; sl = s . split ( \" ▁ \" ) ; int n = Integer . parseInt ( sl [ 0 ] ) ; int m = Integer . parseInt ( sl [ 1 ] ) ; s = r . readLine ( ) ; sl = s . split ( \" ▁ \" ) ; for ( int i = 0 ; i < m ; i ++ ) { int v = Integer . parseInt ( sl [ i ] ) ; d [ v ] = c [ v ] ; } int dp [ ] = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { dp [ i ] = - 999999 ; for ( int j = 1 ; j <= 9 ; j ++ ) { if ( i - d [ j ] >= 0 && dp [ i - d [ j ] ] >= 0 ) { dp [ i ] = Math . max ( dp [ i ] , dp [ i - d [ j ] ] + 1 ) ; } } } int z = dp [ n ] ; int q = n ; while ( q > 0 ) { for ( int i = 9 ; 1 <= i ; i -- ) { if ( q - d [ i ] >= 0 && dp [ q - d [ i ] ] == dp [ q ] - 1 ) { System . out . print ( i ) ; q -= d [ i ] ; break ; } } } } }", "import java . io . InputStream ; import java . io . PrintStream ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; int [ ] q = { 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; int [ ] a ; int compare ( String a , String b ) { if ( a == null ) { a = \" \" ; } if ( b == null ) { b = \" \" ; } int result = Integer . compare ( a . length ( ) , b . length ( ) ) ; if ( result == 0 ) { result = a . compareTo ( b ) ; } return result ; } String max ( String s1 , String s2 ) { if ( compare ( s1 , s2 ) > 0 ) { return s1 ; } else { return s2 ; } } Map < Integer , String > memo = new HashMap < > ( ) ; String dfs ( int n ) { if ( n == 0 ) { return \" \" ; } String x = memo . get ( n ) ; if ( x != null ) { return x ; } String ans = null ; for ( int i = 0 ; i < a . length ; i ++ ) { int newN = n - q [ a [ i ] ] ; if ( newN < 0 ) { continue ; } String tmp = dfs ( newN ) ; if ( tmp == null ) { continue ; } ans = max ( ans , a [ i ] + tmp ) ; } memo . put ( n , ans ) ; return ans ; } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; a = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } out . println ( dfs ( N ) ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; class Main { public static void reverse ( int [ ] A ) { for ( int i = 0 ; i < A . length / 2 ; i ++ ) { int tmp = A [ i ] ; A [ i ] = A [ A . length - i - 1 ] ; A [ A . length - i - 1 ] = tmp ; } } private static final int [ ] num = { 999999 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; private static final int INF = Integer . MAX_VALUE / 4 ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = Integer . parseInt ( scanner . next ( ) ) ; int M = Integer . parseInt ( scanner . next ( ) ) ; int [ ] A = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { A [ i ] = Integer . parseInt ( scanner . next ( ) ) ; } Arrays . sort ( A ) ; reverse ( A ) ; int [ ] dp = new int [ 10010 ] ; Arrays . fill ( dp , - INF ) ; dp [ 0 ] = 0 ; for ( int i = 0 ; i <= N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( i - num [ A [ j ] ] >= 0 ) { dp [ i ] = Math . max ( dp [ i ] , dp [ i - num [ A [ j ] ] ] + 1 ) ; } } } String ans = \" \" ; int goal = dp [ N ] ; for ( int k = 0 ; k < goal ; k ++ ) { for ( int i = 0 ; i < M ; i ++ ) { if ( N - num [ A [ i ] ] >= 0 && dp [ N ] != 0 && dp [ N - num [ A [ i ] ] ] == dp [ N ] - 1 ) { ans += A [ i ] ; N -= num [ A [ i ] ] ; break ; } } } System . out . println ( ans ) ; } }", "import java . util . Arrays ; import java . util . Scanner ; public class Main { private static final int [ ] NUMBER = { 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; scanner . nextLine ( ) ; int [ ] a = new int [ m ] ; int [ ] num = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; num [ i ] = num ( a [ i ] ) ; } scanner . nextLine ( ) ; Arrays . sort ( a ) ; Arrays . sort ( num ) ; int digit = dp ( n , num ) ; int remain = n ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < digit ; i ++ ) { for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( dp ( remain - num ( a [ j ] ) , num ) == dp ( remain , num ) - 1 ) { sb . append ( a [ j ] ) ; remain -= num ( a [ j ] ) ; break ; } } } System . out . println ( sb . toString ( ) ) ; } } private static int num ( int k ) { return NUMBER [ k ] ; } private static int dp ( int n , int [ ] num ) { if ( 0 == n ) { return 0 ; } int min = num [ 0 ] ; if ( n % min == 0 ) { return n / min ; } else { for ( int number : num ) { if ( n >= number ) { int next = dp ( n - number , num ) ; if ( next >= 0 ) { return next + 1 ; } } } } return - 1 ; } }" ]
[ "import sys NEW_LINE def solve ( N : int , M : int , A : \" List [ int ] \" ) : NEW_LINE INDENT costs = [ 10 ** 18 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] NEW_LINE cand = [ ( i , costs [ i ] ) for i in A ] NEW_LINE cand . sort ( reverse = True ) NEW_LINE digits = [ - 1 * 10 ** 16 for i in range ( N + 1 ) ] NEW_LINE digits [ 0 ] = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT r = - 1 * 10 ** 16 NEW_LINE for c in cand : NEW_LINE INDENT if i - c [ 1 ] >= 0 : NEW_LINE INDENT r = max ( r , digits [ i - c [ 1 ] ] + 1 ) NEW_LINE DEDENT DEDENT digits [ i ] = r NEW_LINE DEDENT digit = digits [ N ] NEW_LINE lastCost = N NEW_LINE result = 0 NEW_LINE for i in range ( digit ) : NEW_LINE INDENT for c in cand : NEW_LINE INDENT if lastCost - c [ 1 ] >= 0 and digits [ lastCost - c [ 1 ] ] == digits [ lastCost ] - 1 : NEW_LINE INDENT result = result * 10 + c [ 0 ] NEW_LINE lastCost = lastCost - c [ 1 ] NEW_LINE break NEW_LINE DEDENT DEDENT 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 M = int ( next ( tokens ) ) NEW_LINE A = [ int ( next ( tokens ) ) for _ in range ( M ) ] NEW_LINE solve ( N , M , A ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def num ( k ) : NEW_LINE INDENT costs = [ 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] NEW_LINE return costs [ k - 1 ] NEW_LINE DEDENT inf = 1000 NEW_LINE dp = [ - inf for _ in range ( N + 1 ) ] NEW_LINE dp [ 0 ] = 0 NEW_LINE cost_list = [ num ( k ) for k in A ] NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT for cost in cost_list : NEW_LINE INDENT if i - cost < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT temp = dp [ i - cost ] + 1 NEW_LINE dp [ i ] = max ( dp [ i ] , temp ) NEW_LINE DEDENT DEDENT DEDENT ans = ' ' NEW_LINE many = N NEW_LINE for d in range ( dp [ N ] ) : NEW_LINE INDENT for k in sorted ( A , reverse = True ) : NEW_LINE INDENT if many - num ( k ) < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT if dp [ many - num ( k ) ] == dp [ many ] - 1 : NEW_LINE INDENT ans += str ( k ) NEW_LINE many -= num ( k ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( int ( ans ) ) NEW_LINE", "def solve ( string ) : NEW_LINE INDENT n , m , * a = map ( int , string . split ( ) ) NEW_LINE needs = { i + 1 : n for i , n in enumerate ( map ( int , \"2 ▁ 5 ▁ 5 ▁ 4 ▁ 5 ▁ 6 ▁ 3 ▁ 7 ▁ 6\" . split ( ) ) ) } NEW_LINE if 2 in a and 5 in a : NEW_LINE INDENT a . remove ( 2 ) NEW_LINE DEDENT if 3 in a and 5 in a : NEW_LINE INDENT a . remove ( 3 ) NEW_LINE DEDENT if 2 in a and 3 in a : NEW_LINE INDENT a . remove ( 2 ) NEW_LINE DEDENT if 6 in a and 9 in a : NEW_LINE INDENT a . remove ( 6 ) NEW_LINE DEDENT b = sorted ( a , key = lambda x : needs [ x ] ) NEW_LINE index = 0 NEW_LINE base = str ( b [ 0 ] ) * ( n // needs [ b [ 0 ] ] ) NEW_LINE n %= needs [ b [ 0 ] ] NEW_LINE while n > 0 : NEW_LINE INDENT use = [ _b for _b in b if needs [ _b ] <= needs [ b [ 0 ] ] + n ] NEW_LINE if len ( use ) == 1 : NEW_LINE INDENT base = base [ : - 1 ] NEW_LINE n += needs [ b [ 0 ] ] NEW_LINE DEDENT elif max ( use ) == b [ 0 ] : NEW_LINE INDENT tmp_n = use [ - 1 ] NEW_LINE tmp_c = n // ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) NEW_LINE base = base [ : - tmp_c ] + str ( tmp_n ) * tmp_c NEW_LINE n -= ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) * tmp_c NEW_LINE DEDENT else : NEW_LINE INDENT tmp_n = max ( use ) NEW_LINE tmp_c = n // ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) NEW_LINE base = base [ : index ] + str ( tmp_n ) * tmp_c + base [ index + tmp_c : ] NEW_LINE n -= ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) * tmp_c NEW_LINE index += tmp_c NEW_LINE DEDENT DEDENT return base NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( ' \\n ' . join ( [ input ( ) , input ( ) ] ) ) ) 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 nms = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE n , m = nm ( ) NEW_LINE a = nl ( ) NEW_LINE lis = [ 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] NEW_LINE dp = [ - 1 for _ in range ( n + 1 ) ] NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in a : NEW_LINE INDENT if i - lis [ j ] >= 0 : NEW_LINE INDENT dp [ i ] = max ( dp [ i ] , dp [ i - lis [ j ] ] * 10 + j ) NEW_LINE DEDENT DEDENT DEDENT print ( dp [ n ] ) NEW_LINE", "import sys NEW_LINE RESOURCE_DICT = dict ( [ ( k , v ) for k , v in zip ( range ( 1 , 10 ) , [ 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] ) ] ) NEW_LINE def get_input ( ) : NEW_LINE INDENT N , M = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE A = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE return N , M , A NEW_LINE DEDENT def solve ( N , M , A ) : NEW_LINE INDENT sorted_A = sorted ( A ) [ : : - 1 ] NEW_LINE dp = fill_dp ( N , sorted_A ) NEW_LINE array = find_array ( dp , N , sorted_A ) NEW_LINE return \" \" . join ( map ( str , array ) ) NEW_LINE DEDENT def fill_dp ( N , A ) : NEW_LINE INDENT dp = [ - 100 * N for _ in range ( N + 1 ) ] NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT fill ( A , dp , i , N ) NEW_LINE DEDENT return dp NEW_LINE DEDENT def fill ( A , dp , n , N ) : NEW_LINE INDENT cand = [ dp [ n - RESOURCE_DICT [ num ] ] + 1 for num in A if n - RESOURCE_DICT [ num ] >= 0 ] NEW_LINE dp [ n ] = max ( cand ) if len ( cand ) > 0 else - 100 * N NEW_LINE DEDENT def find_array ( dp , N , sorted_A ) : NEW_LINE INDENT array = [ ] NEW_LINE current_n = N NEW_LINE for _ in range ( dp [ N ] ) : NEW_LINE INDENT for number in sorted_A : NEW_LINE INDENT if current_n - RESOURCE_DICT [ number ] >= 0 and dp [ current_n - RESOURCE_DICT [ number ] ] == dp [ current_n ] - 1 : NEW_LINE INDENT array . append ( number ) NEW_LINE current_n -= RESOURCE_DICT [ number ] NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT return array NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N , M , A = get_input ( ) NEW_LINE ans = solve ( N , M , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT" ]
atcoder_agc001_B
[ "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 ) ; long n = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; out . println ( f ( x , n - x ) + n ) ; } static long f ( long a , long b ) { if ( a > b ) { long t = a ; a = b ; b = t ; } if ( b % a == 0 ) return ( b / a - 1 ) * 2 * a + a ; return 2 * a * ( b / a ) + f ( b % a , a ) ; } }", "import java . util . * ; public class Main { public void main ( Scanner sc ) { long n = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long ans = n ; long a = n - x ; long b = x ; while ( b != 0 ) { long r = a / b ; long q = a % b ; ans += 2 * b * r ; if ( q == 0 ) { ans -= b ; } a = b ; b = q ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; long N = sc . nextLong ( ) ; long X = sc . nextLong ( ) ; long sum = 0 ; if ( X > N / 2 ) { X = N - X ; } long big = N - X ; long mini = X ; sum = N ; while ( true ) { if ( big % mini != 0 ) { sum += mini * 2 * ( big / mini ) ; long tmp = mini ; mini = big % mini ; big = tmp ; } else { sum += mini * ( ( big / mini ) * 2 - 1 ) ; break ; } } pl ( sum ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long num = sc . nextLong ( ) ; long start = sc . nextLong ( ) ; System . out . println ( num + cal ( start , num - start ) ) ; } public static long cal ( long width , long height ) { if ( width * height == 0 ) { return - Math . max ( width , height ) ; } else if ( width == height ) { return width ; } else if ( width > height ) { return width / height * height * 2 + cal ( width % height , height ) ; } else { return height / width * width * 2 + cal ( width , height % width ) ; } } }", "import java . util . Scanner ; public class Main { public long solve ( long N , long X ) { long longEdge = Math . max ( X , N - X ) ; long shortEdge = Math . min ( X , N - X ) ; long length = X + N - X ; long times = 1 ; while ( shortEdge > 0 ) { long num = longEdge / shortEdge ; long left = longEdge - ( shortEdge * num ) ; length += ( shortEdge * num * 2 ) ; longEdge = shortEdge ; shortEdge = left ; times ++ ; } length -= longEdge ; return length ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long N = in . nextLong ( ) ; long X = in . nextLong ( ) ; in . close ( ) ; Main main = new Main ( ) ; long result = main . solve ( N , X ) ; System . out . println ( result ) ; } }" ]
[ "import sys NEW_LINE stdin = sys . stdin NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE na = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) NEW_LINE nn = lambda : list ( stdin . readline ( ) . split ( ) ) NEW_LINE ns = lambda : stdin . readline ( ) . rstrip ( ) NEW_LINE n , x = na ( ) NEW_LINE def loop ( a , b ) : NEW_LINE INDENT h = max ( a , b ) NEW_LINE w = min ( a , b ) NEW_LINE if h % w == 0 : NEW_LINE INDENT return int ( ( 2 * h / w - 1 ) * w ) NEW_LINE DEDENT else : NEW_LINE INDENT m = h % w NEW_LINE q = h // w NEW_LINE return 2 * q * w + loop ( m , w ) NEW_LINE DEDENT DEDENT print ( loop ( x , n - x ) + n ) NEW_LINE", "n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if ( x > n // 2 and n % 2 == 0 ) or ( x > ( n + 1 ) // 2 and n % 2 == 1 ) : NEW_LINE INDENT x = n - x NEW_LINE DEDENT A = n - x NEW_LINE B = x NEW_LINE k = 0 NEW_LINE m = - 1 NEW_LINE ans = n NEW_LINE while m != 0 : NEW_LINE INDENT k = A // B NEW_LINE m = A % B NEW_LINE ans += B * k * 2 NEW_LINE if m == 0 : NEW_LINE INDENT ans -= B NEW_LINE DEDENT A = B NEW_LINE B = m NEW_LINE DEDENT print ( ans ) NEW_LINE", "def main ( ) : NEW_LINE INDENT n , x = map ( int , input ( ) . split ( ) ) NEW_LINE a , b = n - x , x NEW_LINE if ( a < b ) : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT path_length = calc_path ( a , b , n ) NEW_LINE print ( path_length ) NEW_LINE DEDENT def calc_path ( a1 , b1 , c1 ) : NEW_LINE INDENT q , mod = divmod ( a1 , b1 ) NEW_LINE count = 0 NEW_LINE if mod == 0 : NEW_LINE INDENT c2 = c1 + 2 * b1 * q - b1 NEW_LINE return c2 NEW_LINE DEDENT else : NEW_LINE INDENT count = count + 1 NEW_LINE c2 = c1 + 2 * b1 * q NEW_LINE a2 = a1 - b1 * q NEW_LINE b2 = b1 NEW_LINE if ( a2 < b2 ) : NEW_LINE INDENT a2 , b2 = b2 , a2 NEW_LINE DEDENT return calc_path ( a2 , b2 , c2 ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) 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 LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n , x = LI ( ) NEW_LINE b , a = sorted ( [ x , n - x ] ) NEW_LINE ans = a + b NEW_LINE while b : NEW_LINE INDENT q , mod = divmod ( a , b ) NEW_LINE ans += ( 2 * q - ( not mod ) ) * b NEW_LINE a , b = b , mod NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE", "def solve ( s , a , b ) : NEW_LINE INDENT if a % b == 0 : NEW_LINE INDENT return s + ( ( a // b ) * 2 - 1 ) * b NEW_LINE DEDENT if b % a == 0 : NEW_LINE INDENT return s + ( ( b // a ) * 2 - 1 ) * a NEW_LINE DEDENT elif a > b : NEW_LINE INDENT s += ( a // b ) * 2 * b NEW_LINE return solve ( s , a % b , b ) NEW_LINE DEDENT else : NEW_LINE INDENT s += ( b // a ) * 2 * a NEW_LINE return solve ( s , a , b % a ) NEW_LINE DEDENT DEDENT n , x = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( n , n - x , x ) ) NEW_LINE" ]
atcoder_abc011_B
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; scanner . close ( ) ; String formatted = \" \" ; if ( s . length ( ) == 1 ) { formatted = s . toUpperCase ( ) ; } else { formatted = s . substring ( 0 , 1 ) . toUpperCase ( ) + s . substring ( 1 , s . length ( ) ) . toLowerCase ( ) ; } System . out . println ( formatted ) ; } }", "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 ( ) ; out . print ( Character . toUpperCase ( s . charAt ( 0 ) ) ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { out . print ( Character . toLowerCase ( s . charAt ( i ) ) ) ; } out . println ( ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }", "import java . util . * ; import java . lang . * ; import java . math . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String cap = s . substring ( 0 , 1 ) . toUpperCase ( ) ; String other = s . substring ( 1 ) . toLowerCase ( ) ; System . out . println ( cap + other ) ; sc . close ( ) ; } private static long gcd ( Long m , long n ) { if ( m < n ) { return gcd ( n , m ) ; } if ( n == 0 ) { return m ; } return gcd ( n , m % n ) ; } private static long [ ] [ ] Combination_nCk ( long n , long k ) { n ++ ; k ++ ; long [ ] [ ] ans = new long [ ( int ) n ] [ ( int ) k ] ; for ( int i = 0 ; i < n ; i ++ ) { ans [ i ] [ 0 ] = 1 ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = 0 ; j < k - 1 ; j ++ ) { if ( i < j ) { ans [ i ] [ j ] = 0 ; } else { ans [ i + 1 ] [ j + 1 ] = ans [ i ] [ j ] + ans [ i ] [ j + 1 ] ; } } } return ans ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String S = in . next ( ) ; out . println ( S . toUpperCase ( ) . charAt ( 0 ) + S . substring ( 1 ) . toLowerCase ( ) ) ; } } 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 { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = sc . next ( ) ; System . out . println ( S . substring ( 0 , 1 ) . toUpperCase ( ) + S . substring ( 1 ) . toLowerCase ( ) ) ; } }" ]
[ "s = str ( input ( ) ) NEW_LINE print ( s . capitalize ( ) ) NEW_LINE", "s = input ( ) NEW_LINE s = s . lower ( ) NEW_LINE if len ( s ) >= 2 : NEW_LINE INDENT print ( s [ 0 ] . upper ( ) + s [ 1 : ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( s [ 0 ] . upper ( ) ) NEW_LINE DEDENT", "s = input ( ) NEW_LINE if len ( s ) == 1 : NEW_LINE INDENT print ( s . upper ( ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( s [ 0 ] . upper ( ) + s [ 1 : ] . lower ( ) ) NEW_LINE DEDENT", "print ( input ( ) . capitalize ( ) ) NEW_LINE", "s = list ( input ( ) ) NEW_LINE s [ 0 ] = s [ 0 ] . upper ( ) NEW_LINE for i in range ( 1 , len ( s ) ) : NEW_LINE INDENT s [ i ] = s [ i ] . lower ( ) NEW_LINE DEDENT print ( \" \" . join ( s ) ) NEW_LINE" ]
atcoder_abc104_B
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; boolean b1 , b2 = false , b3 = true ; b1 = ( s . charAt ( 0 ) == ' A ' ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( i != 1 && i != s . length ( ) - 1 && c == ' C ' ) { if ( ! b2 ) { b2 = true ; } else { b1 = false ; } } else if ( Character . isUpperCase ( c ) ) { b3 = false ; } } if ( b1 && b2 && b3 ) { System . out . println ( \" AC \" ) ; } else { System . out . println ( \" WA \" ) ; } } }", "import java . io . IOException ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; System . out . println ( s . matches ( \" A [ a - z ] + C [ a - z ] + \" ) ? \" AC \" : \" WA \" ) ; sc . close ( ) ; } }", "import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int size = str . length ( ) ; if ( \" A \" . equals ( str . substring ( 0 , 1 ) ) ) { int num = 0 ; String str2 = str . substring ( 2 , size - 1 ) ; int size2 = str2 . length ( ) ; for ( int i = 0 ; i < size2 ; i ++ ) { String str4 = str2 . substring ( 0 , 1 ) ; if ( str4 . equals ( \" C \" ) ) { num = num + 1 ; } str2 = str2 . substring ( 1 ) ; } if ( num == 1 ) { str2 = str . substring ( 2 , size - 1 ) ; str2 = str2 . replace ( \" C \" , \" c \" ) ; str2 = str2 . concat ( str . substring ( str . length ( ) - 1 ) ) ; str2 = str . substring ( 1 , 2 ) . concat ( str2 ) ; String str3 = str2 . toLowerCase ( ) ; if ( str2 . equals ( str3 ) ) { System . out . println ( \" AC \" ) ; } else { System . out . println ( \" WA \" ) ; } } else { System . out . println ( \" WA \" ) ; } } else { System . out . println ( \" WA \" ) ; } } }", "import java . io . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { String str = ( new Scanner ( System . in ) ) . next ( ) ; String ans = str . matches ( \" ^ A [ a - z ] + C [ a - z ] + $ \" ) ? \" AC \" : \" WA \" ; System . out . println ( ans ) ; } }", "import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int L = str . length ( ) ; int cnt = 0 ; boolean check = true ; for ( int i = 0 ; i < L ; i ++ ) { if ( i == 0 ) { if ( str . charAt ( i ) != ' A ' ) { check = false ; } } else if ( 2 <= i && i <= L - 2 ) { if ( str . charAt ( i ) == ' C ' ) { cnt ++ ; } else if ( ' A ' <= str . charAt ( i ) && str . charAt ( i ) <= ' Z ' ) { check = false ; } } else { if ( ' A ' <= str . charAt ( i ) && str . charAt ( i ) <= ' Z ' ) check = false ; } } if ( cnt != 1 ) { check = false ; } if ( check ) { System . out . println ( \" AC \" ) ; } else { System . out . println ( \" WA \" ) ; } } }" ]
[ "from collections import Counter NEW_LINE from functools import reduce NEW_LINE import fractions NEW_LINE import math NEW_LINE import statistics NEW_LINE import sys NEW_LINE import time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def IS ( ) : return input ( ) NEW_LINE def P ( x ) : return print ( x ) NEW_LINE def C ( x ) : return Counter ( x ) NEW_LINE def GCD_LIST ( numbers ) : NEW_LINE INDENT return reduce ( fractions . gcd , numbers ) NEW_LINE DEDENT def LCM_LIST ( numbers ) : NEW_LINE INDENT return reduce ( LCM , numbers ) NEW_LINE DEDENT def LCM ( m , n ) : NEW_LINE INDENT return ( m * n // fractions . gcd ( m , n ) ) NEW_LINE DEDENT s = IS ( ) NEW_LINE if s [ 0 ] == ' A ' and s [ 2 : len ( s ) - 1 ] . count ( ' C ' ) == 1 and ' ' . join ( [ s [ i ] for i in range ( 1 , len ( s ) ) if not i == s . index ( ' C ' ) ] ) . islower ( ) : NEW_LINE INDENT print ( ' AC ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' WA ' ) NEW_LINE DEDENT", "s = input ( ) NEW_LINE a = \" AC \" NEW_LINE if s [ 0 ] != \" A \" : NEW_LINE INDENT a = \" WA \" NEW_LINE DEDENT cnt = 0 NEW_LINE for i in range ( 2 , len ( s ) - 1 ) : NEW_LINE INDENT if s [ i ] == \" C \" : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT if cnt != 1 : NEW_LINE INDENT a = \" WA \" NEW_LINE DEDENT for i in range ( 1 , len ( s ) ) : NEW_LINE INDENT if s [ i ] != \" C \" and ord ( s [ i ] ) < ord ( \" a \" ) : NEW_LINE INDENT a = \" WA \" NEW_LINE DEDENT DEDENT print ( a ) 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 ( S : str ) : NEW_LINE INDENT if S [ 0 ] != \" A \" : NEW_LINE INDENT print ( \" WA \" ) NEW_LINE return NEW_LINE DEDENT if S [ 2 : - 1 ] . count ( \" C \" ) != 1 : NEW_LINE INDENT print ( \" WA \" ) NEW_LINE return NEW_LINE DEDENT flag = False NEW_LINE for i , c in enumerate ( S ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if ord ( \" a \" ) <= ord ( c ) and ord ( c ) <= ord ( \" z \" ) : NEW_LINE INDENT continue NEW_LINE DEDENT elif 1 < i and i < len ( S ) - 1 and c == \" C \" and flag == False : NEW_LINE INDENT flag = True NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" WA \" ) NEW_LINE return NEW_LINE DEDENT DEDENT print ( \" AC \" ) 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 solve ( S ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "S = [ i for i in input ( ) ] NEW_LINE count = 0 NEW_LINE if S . pop ( 0 ) == ' A ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if S [ 1 : - 1 ] . count ( ' C ' ) == 1 : NEW_LINE INDENT count += 1 NEW_LINE S . remove ( ' C ' ) NEW_LINE if ' ' . join ( S ) . islower ( ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( ' AC ' if count == 3 else ' WA ' ) NEW_LINE", "S = input ( ) NEW_LINE if S [ 0 ] == ' A ' : NEW_LINE INDENT f1 = True NEW_LINE DEDENT else : NEW_LINE INDENT f1 = False NEW_LINE DEDENT C_cnt = 0 NEW_LINE for s in S [ 2 : - 1 ] : NEW_LINE INDENT if s == ' C ' : NEW_LINE INDENT C_cnt += 1 NEW_LINE DEDENT DEDENT if C_cnt == 1 : NEW_LINE INDENT f2 = True NEW_LINE DEDENT else : NEW_LINE INDENT f2 = False NEW_LINE DEDENT f3 = True NEW_LINE for s in S : NEW_LINE INDENT if s == ' A ' or s == ' C ' : NEW_LINE INDENT continue NEW_LINE DEDENT if s != s . lower ( ) : NEW_LINE INDENT f3 = False NEW_LINE break NEW_LINE DEDENT DEDENT if f1 and f2 and f3 : NEW_LINE INDENT print ( ' AC ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' WA ' ) NEW_LINE DEDENT" ]
atcoder_abc040_C
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] dp = new int [ n ] ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( a [ 0 ] - a [ 1 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { dp [ i ] = Math . min ( dp [ i - 1 ] + Math . abs ( a [ i ] - a [ i - 1 ] ) , dp [ i - 2 ] + Math . abs ( a [ i ] - a [ i - 2 ] ) ) ; } System . out . println ( dp [ n - 1 ] ) ; } }", "import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] nums = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } int [ ] output = new int [ n ] ; output [ 1 ] = Math . abs ( nums [ 1 ] - nums [ 0 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { output [ i ] = Math . min ( output [ i - 1 ] + Math . abs ( nums [ i ] - nums [ i - 1 ] ) , output [ i - 2 ] + Math . abs ( nums [ i ] - nums [ i - 2 ] ) ) ; } System . out . println ( output [ n - 1 ] ) ; } }", "import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] = sc . nextInt ( ) ; solver ( N , a ) ; } public static void solver ( int N , int [ ] a ) { int [ ] ans = new int [ N ] ; for ( int n = N - 1 ; n >= 0 ; n -- ) { if ( n == N - 1 ) { continue ; } else if ( n == N - 2 ) { ans [ n ] = Math . abs ( a [ n ] - a [ n + 1 ] ) ; } else if ( n == N - 3 ) { ans [ n ] = Math . abs ( a [ n ] - a [ n + 2 ] ) ; } else { ans [ n ] = Math . min ( Math . abs ( ans [ n + 1 ] + Math . abs ( a [ n ] - a [ n + 1 ] ) ) , Math . abs ( ans [ n + 2 ] + Math . abs ( a [ n ] - a [ n + 2 ] ) ) ) ; } } out . println ( ans [ 0 ] ) ; } }", "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int [ ] cache = new int [ n ] ; Arrays . fill ( cache , - 1 ) ; System . out . println ( cost ( n - 1 , values , cache ) ) ; } private static int cost ( int i , int [ ] values , int [ ] cache ) { int ans = 0 ; if ( cache [ i ] != - 1 ) { return cache [ i ] ; } if ( i == 0 ) { ans = 0 ; } else if ( i == 1 ) { ans = Math . abs ( values [ 1 ] - values [ 0 ] ) ; } else { int a = cost ( i - 2 , values , cache ) + Math . abs ( values [ i ] - values [ i - 2 ] ) ; int b = cost ( i - 1 , values , cache ) + Math . abs ( values [ i ] - values [ i - 1 ] ) ; ans = Math . min ( a , b ) ; } if ( cache [ i ] == - 1 ) { cache [ i ] = ans ; } return ans ; } }", "import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; N = reader . nextInt ( ) ; int [ ] arr = new int [ N ] ; int [ ] gaps = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; if ( i > 0 ) { int r = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + gaps [ i - 1 ] ; if ( i > 1 ) { r = Math . min ( r , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + gaps [ i - 2 ] ) ; } gaps [ i ] = r ; } } System . out . println ( gaps [ N - 1 ] ) ; reader . close ( ) ; } }" ]
[ "n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE dp = [ 0 for i in range ( n ) ] NEW_LINE dp [ 1 ] = abs ( a [ 0 ] - a [ 1 ] ) NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT x = abs ( a [ i ] - a [ i - 2 ] ) + dp [ i - 2 ] NEW_LINE y = abs ( a [ i ] - a [ i - 1 ] ) + dp [ i - 1 ] NEW_LINE dp [ i ] = min ( x , y ) NEW_LINE DEDENT print ( dp [ - 1 ] ) NEW_LINE", "if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT scaffold_count = int ( input ( ) ) NEW_LINE scaffold_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE jump_costs = [ 0 ] * scaffold_count NEW_LINE jump_costs [ 0 ] = 0 NEW_LINE jump_costs [ 1 ] = abs ( scaffold_list [ 0 ] - scaffold_list [ 1 ] ) NEW_LINE for i in range ( 2 , scaffold_count ) : NEW_LINE INDENT jump_costs [ i ] = min ( jump_costs [ i - 2 ] + abs ( scaffold_list [ i - 2 ] - scaffold_list [ i ] ) , jump_costs [ i - 1 ] + abs ( scaffold_list [ i - 1 ] - scaffold_list [ i ] ) ) NEW_LINE DEDENT print ( jump_costs [ scaffold_count - 1 ] ) NEW_LINE DEDENT", "import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE dp = [ 0 ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE dp [ 1 ] = abs ( a [ 1 ] - a [ 0 ] ) NEW_LINE def dpdfs ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return dp [ 0 ] NEW_LINE DEDENT elif n == 1 : NEW_LINE INDENT return dp [ 1 ] NEW_LINE DEDENT if dp [ n ] != 0 : NEW_LINE INDENT return dp [ n ] NEW_LINE DEDENT dp [ n ] = min ( dpdfs ( n - 1 ) + abs ( a [ n ] - a [ n - 1 ] ) , dpdfs ( n - 2 ) + abs ( a [ n ] - a [ n - 2 ] ) ) NEW_LINE return dp [ n ] NEW_LINE DEDENT dpdfs ( N - 1 ) NEW_LINE print ( dp [ - 1 ] ) NEW_LINE", "_ , t = open ( 0 ) NEW_LINE b , * a = map ( int , t . split ( ) ) NEW_LINE c = b NEW_LINE e = f = 0 NEW_LINE for g in a : e , f , b , c = min ( abs ( b - g ) + e , abs ( c - g ) + f ) , e , g , b NEW_LINE print ( e ) NEW_LINE", "def poll_poll_poll_poll_poll ( N : int , A : list ) -> int : NEW_LINE INDENT dp = [ float ( ' inf ' ) ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] + abs ( A [ i ] - A [ i - 1 ] ) NEW_LINE if i > 1 : NEW_LINE INDENT dp [ i ] = min ( dp [ i ] , dp [ i - 2 ] + abs ( A [ i ] - A [ i - 2 ] ) ) NEW_LINE DEDENT DEDENT return dp [ N - 1 ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = poll_poll_poll_poll_poll ( N , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT" ]
atcoder_abc121_D
[ "import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = 0 ; long c = 0 ; if ( a % 2 == 0 ) { if ( b % 2 == 0 ) { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = b ; } else { ans = b ^ 1 ; } } else { c = b - a + 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = 0 ; } else { ans = 1 ; } } } else { if ( b % 2 == 0 ) { c = b - a - 1 ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ^ b ; } else { ans = ( a ^ b ) ^ 1 ; } } else { c = b - a ; c /= 2 ; if ( c % 2 == 0 ) { ans = a ; } else { ans = a ^ 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 LOG = 40 ; void solve ( ) { long A = in . nextLong ( ) , B = in . nextLong ( ) ; long ans = xor ( B ) ^ xor ( A - 1 ) ; out . println ( ans ) ; } long xor ( long n ) { if ( n <= 0 ) return 0 ; long res = 0 ; for ( int i = 0 ; i < LOG ; i ++ ) { long period = 1L << ( i + 1 ) ; long zeros = period / 2 , ones = period / 2 ; long q = ( n + 1 ) / period , r = ( n + 1 ) % period ; long v = 0 ; if ( q % 2 == 1 && ones % 2 == 1 ) v ^= 1 ; if ( r > zeros && ( r - zeros ) % 2 == 1 ) v ^= 1 ; res |= v << i ; } return res ; } 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 . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { out . println ( f ( sc . nextLong ( ) - 1 ) ^ f ( sc . nextLong ( ) ) ) ; out . close ( ) ; } static long f ( long x ) { long c = x % 4 ; if ( c == 0 ) return x ; if ( c == 1 ) return 1 ; if ( c == 2 ) return 1 ^ x ; return 0 ; } static long power ( long x , long n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; n >>= 1 ; } return ans ; } static PrintWriter out = new PrintWriter ( System . out ) ; static class sc { static Scanner s = new Scanner ( System . in ) ; static String next ( ) { return s . next ( ) ; } static int nextInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static double nextDouble ( ) { return Double . parseDouble ( s . next ( ) ) ; } } }", "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long A = scanner . nextLong ( ) ; long B = scanner . nextLong ( ) ; long answer = 0 ; long C = 0 ; if ( A % 2 == 0 ) { if ( B % 2 == 0 ) { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = B ; } else { answer = B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = 1 ; } else { answer = 0 ; } } } else { if ( B % 2 == 0 ) { C = ( B - A - 1 ) / 2 ; if ( C % 2 == 0 ) { answer = A ^ B ; } else { answer = A ^ B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = A ; } else { answer = A ^ 1 ; } } } System . out . println ( answer ) ; } }", "import java . util . * ; public class Main { public static class MyPair implements Comparable < MyPair > { int cost ; int supply ; public MyPair ( int cost , int supply ) { this . cost = cost ; this . supply = supply ; } @ Override public int compareTo ( MyPair other ) { return ( this . cost - other . cost ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; boolean AOdd = A % 2 == 1 ; boolean BOdd = B % 2 == 1 ; if ( A == B ) { System . out . println ( A ) ; } else if ( AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; if ( LSB == 1 ) { System . out . println ( A - 1 ) ; } else { System . out . println ( A ) ; } } else if ( AOdd && ! BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; long BToCompare = B + LSB ; long AToCompare = A ; long solution = 0 ; long multiplier = 1 ; while ( BToCompare > 0 ) { if ( AToCompare == 0 ) { solution += BToCompare % 2 * multiplier ; BToCompare /= 2 ; } else { if ( BToCompare % 2 != AToCompare % 2 ) { solution += multiplier ; } BToCompare /= 2 ; AToCompare /= 2 ; } multiplier *= 2 ; } System . out . println ( solution ) ; } else if ( ! AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff + 1 ) / 2 % 2 ; System . out . println ( LSB ) ; } else { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; System . out . println ( B + LSB ) ; } } }" ]
[ "A , B = map ( int , input ( ) . split ( ) ) NEW_LINE A -= 1 NEW_LINE if A % 4 == 1 : NEW_LINE INDENT A = 1 NEW_LINE DEDENT elif A % 4 == 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif A % 4 == 3 : NEW_LINE INDENT A = 0 NEW_LINE DEDENT if B % 4 == 1 : NEW_LINE INDENT B = 1 NEW_LINE DEDENT elif B % 4 == 2 : NEW_LINE INDENT B += 1 NEW_LINE DEDENT elif B % 4 == 3 : NEW_LINE INDENT B = 0 NEW_LINE DEDENT answer = A ^ B NEW_LINE print ( answer ) NEW_LINE", "def solve ( string ) : NEW_LINE INDENT a , b = map ( int , string . split ( ) ) NEW_LINE if b == 0 : NEW_LINE INDENT return \"0\" NEW_LINE DEDENT bin_a = \" { :040b } \" . format ( a ) NEW_LINE bin_b = \" { :040b } \" . format ( b ) NEW_LINE aa = [ - 1 if _a == \"0\" else int ( bin_a [ i + 1 : ] or \"0\" , 2 ) for i , _a in enumerate ( bin_a ) ] NEW_LINE bb = [ - 1 if _b == \"0\" else int ( bin_b [ i + 1 : ] or \"0\" , 2 ) for i , _b in enumerate ( bin_b ) ] NEW_LINE index = 0 NEW_LINE while True : NEW_LINE INDENT if bb [ index ] != - 1 : NEW_LINE INDENT break NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans = [ ] NEW_LINE while index < 40 : NEW_LINE INDENT if aa [ index ] == bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( \"0\" ) NEW_LINE DEDENT elif aa [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 ) % 2 ) ) NEW_LINE DEDENT elif bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( aa [ index ] % 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 - aa [ index ] ) % 2 ) ) NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans [ - 1 ] = str ( ( b - a ) // 2 % 2 ) if a % 2 == b % 2 == 0 else str ( ( ( b - a ) // 2 + 1 ) % 2 ) NEW_LINE return str ( int ( \" \" . join ( ans ) , 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT", "import sys NEW_LINE INF = float ( \" inf \" ) NEW_LINE def f ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT if ( n // 2 ) % 2 == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT return 1 ^ n NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( ( n + 1 ) // 2 ) % 2 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT DEDENT def solve ( A : int , B : int ) : NEW_LINE INDENT print ( f ( B ) ^ f ( A - 1 ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE solve ( A , B ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = int ( 0 ) NEW_LINE if B == 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = math . floor ( math . log2 ( B ) + 1 ) NEW_LINE A_mod = A % 4 NEW_LINE B_mod = B % 4 NEW_LINE if A_mod < 2 : NEW_LINE INDENT if B_mod == 1 or B_mod == 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod == 3 or B_mod == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT A_mod = A % ( 2 ** i ) NEW_LINE B_mod = B % ( 2 ** i ) NEW_LINE if A_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT if B_mod >= 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( ( B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( A_mod % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( ( A_mod + B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE", "def SI ( ) : return input ( ) NEW_LINE def II ( ) : return int ( SI ( ) ) NEW_LINE def STI ( ) : return SI ( ) . split ( ) NEW_LINE def ITI ( ) : return map ( int , STI ( ) ) NEW_LINE def SLI ( ) : return list ( SI ( ) ) NEW_LINE def ILI ( ) : return list ( ITI ( ) ) NEW_LINE A , B = ITI ( ) NEW_LINE def cum_xor ( n ) : NEW_LINE INDENT result = ( n + 1 ) // 2 % 2 NEW_LINE if ( n + 1 ) % 2 == 1 : result ^= n NEW_LINE return result NEW_LINE DEDENT print ( cum_xor ( A - 1 ) ^ cum_xor ( B ) ) NEW_LINE" ]
atcoder_arc027_A
[ "import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; if ( h < 17 ) { if ( m == 0 ) { ans = ( 18 - h ) * 60 ; } else { ans = ( ( 17 - h ) * 60 ) + ( 60 - m ) ; } } else { ans = 60 - m ; } System . out . println ( ans ) ; } }", "import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = 18 * 60 ; int H = sc . nextInt ( ) * 60 ; int M = sc . nextInt ( ) ; pl ( N - H - M ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }", "import java . 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 ( ( 18 - in . nextInt ( ) ) * 60 - in . nextInt ( ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }", "import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int limit = 18 * 60 ; System . out . println ( limit - s . nextInt ( ) * 60 - s . nextInt ( ) ) ; } }", "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 h = sc . nextInt ( ) , m = sc . nextInt ( ) ; out . println ( 18 * 60 - 60 * h - m ) ; } }" ]
[ "h , m = map ( int , input ( ) . split ( ) ) NEW_LINE min = 60 * h + m NEW_LINE a = 18 * 60 NEW_LINE print ( a - min ) NEW_LINE", "import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE h , m = map ( int , input ( ) . split ( ) ) NEW_LINE ams = 0 NEW_LINE if m == 0 : NEW_LINE INDENT ans = ( 18 - h ) * 60 NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( 18 - h - 1 ) * 60 + ( 60 - m ) NEW_LINE DEDENT print ( ans ) NEW_LINE", "H , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ( 18 - H ) * 60 - M ) NEW_LINE", "def main ( ) : NEW_LINE INDENT h , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( 18 * 60 - ( h * 60 + m ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT", "h , m = map ( int , input ( ) . split ( ) ) NEW_LINE def get_minute ( in_h , in_m ) : NEW_LINE INDENT return in_h * 60 + in_m NEW_LINE DEDENT ans = get_minute ( 18 , 0 ) - get_minute ( h , m ) NEW_LINE print ( ans ) NEW_LINE" ]

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
5
Add dataset card