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"
] |
atcoder_abc072_B | [
"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 ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { sb . append ( s . charAt ( i ) ) ; } System . out . println ( sb ) ; } }",
"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 ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { 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 ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int some = roundup ( s . length ( ) ) ; char [ ] ans = new char [ some ] ; for ( int i = 0 ; i < some ; i ++ ) { ans [ i ] = s . charAt ( i * 2 ) ; } System . out . print ( ans ) ; } public static int roundup ( int x ) { int ans = 0 ; if ( x % 2 == 0 ) { ans = x / 2 ; } else { ans = x / 2 + 1 ; } return ans ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < word . length ( ) ; i += 2 ) { builder . append ( word . charAt ( i ) ) ; } System . out . println ( builder ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BOddString solver = new BOddString ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BOddString { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; String concate = \" \" ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) 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 ( ) ; } } }"
] | [
"s = input ( ) NEW_LINE print ( s [ : : 2 ] ) NEW_LINE",
"import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE s = list ( ns ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , len ( s ) , 2 ) : NEW_LINE INDENT ans . append ( s [ i ] ) NEW_LINE DEDENT print ( ' ' . join ( ans ) ) NEW_LINE",
"s = input ( ) NEW_LINE n = len ( s ) NEW_LINE a = \" \" NEW_LINE if n % 2 == 0 : NEW_LINE INDENT for i in range ( 0 , n , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 0 , n + 1 , 2 ) : NEW_LINE INDENT a += s [ i ] NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE",
"A = input ( ) NEW_LINE B = [ ] NEW_LINE for i , v in enumerate ( A ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT B . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( \" \" . join ( B ) ) NEW_LINE",
"s = list ( input ( ) ) NEW_LINE AnsList = s [ : : 2 ] NEW_LINE print ( ' ' . join ( AnsList ) ) NEW_LINE"
] |
atcoder_arc087_C | [
"import java . util . * ; public class Main { static class TriTree { Node root = new Node ( ) ; class Node { ArrayList < Node > child = new ArrayList < > ( ) ; char c ; long depth ; public void add ( Node node ) { child . add ( node ) ; } public Node ( ) { } public Node ( char c , long depth ) { this . c = c ; this . depth = depth ; } public long xorGrundy ( ) { long xor = 0 ; for ( Node node : child ) xor ^= node . xorGrundy ( ) ; if ( child . size ( ) == 1 ) xor ^= grundy ( L - depth ) ; return xor ; } } public void addLeaf ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { boolean found = false ; for ( Node child : cur . child ) { if ( child . c == s . charAt ( i ) ) { cur = child ; found = true ; break ; } } if ( ! found ) { Node next = new Node ( s . charAt ( i ) , i + 1 ) ; cur . add ( next ) ; cur = next ; } } } public long xorGrundy ( ) { return root . xorGrundy ( ) ; } } static long L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; L = sc . nextLong ( ) ; TriTree tree = new TriTree ( ) ; for ( int i = 0 ; i < N ; i ++ ) tree . addLeaf ( sc . next ( ) ) ; System . out . println ( tree . xorGrundy ( ) == 0 ? \" Bob \" : \" Alice \" ) ; sc . close ( ) ; } static long grundy ( long n ) { long ans = 1 ; while ( n % ans == 0 ) ans <<= 1 ; return ans ; } }"
] | [
"def getGrundyNumber ( x ) : NEW_LINE INDENT ans = 1 NEW_LINE while x % ( ans * 2 ) == 0 : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT return ans NEW_LINE DEDENT N , L = map ( int , input ( ) . split ( ) ) NEW_LINE Ss = [ input ( ) for i in range ( N ) ] NEW_LINE Ss . sort ( ) NEW_LINE Hgts = { L : 2 } NEW_LINE prev = ' _ ' NEW_LINE for S in Ss : NEW_LINE INDENT for iS , ( a , b ) in enumerate ( zip ( prev , S ) ) : NEW_LINE INDENT if a != b : NEW_LINE INDENT Hgts [ L - iS ] -= 1 NEW_LINE for h in range ( L - len ( S ) + 1 , L - iS ) : NEW_LINE INDENT Hgts [ h ] = Hgts . get ( h , 0 ) + 1 NEW_LINE DEDENT break NEW_LINE DEDENT DEDENT prev = S NEW_LINE DEDENT ans = 0 NEW_LINE for Hgt , num in Hgts . items ( ) : NEW_LINE INDENT if num % 2 : NEW_LINE INDENT ans ^= getGrundyNumber ( Hgt ) NEW_LINE DEDENT DEDENT if ans : NEW_LINE INDENT print ( ' Alice ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Bob ' ) NEW_LINE DEDENT",
"import sys NEW_LINE sys . setrecursionlimit ( 2 * 10 ** 5 ) NEW_LINE class TrieNode : NEW_LINE INDENT def __init__ ( self , char ) : NEW_LINE INDENT self . char = char NEW_LINE self . nextnode = dict ( ) NEW_LINE self . is_indict = False NEW_LINE DEDENT DEDENT class Trie : NEW_LINE INDENT def __init__ ( self , charset ) : NEW_LINE INDENT self . charset = charset NEW_LINE self . root = TrieNode ( ' ' ) NEW_LINE DEDENT def add ( self , a_str ) : NEW_LINE INDENT node = self . root NEW_LINE for i , char in enumerate ( a_str ) : NEW_LINE INDENT if char not in node . nextnode : NEW_LINE INDENT node . nextnode [ char ] = TrieNode ( char ) NEW_LINE DEDENT node = node . nextnode [ char ] NEW_LINE if i == len ( a_str ) - 1 : NEW_LINE INDENT node . is_indict = True NEW_LINE DEDENT DEDENT DEDENT def dfs ( self , node , dep ) : NEW_LINE INDENT ret , cnt = 0 , 0 NEW_LINE if node . is_indict : NEW_LINE INDENT return 0 NEW_LINE DEDENT for s in '01' : NEW_LINE INDENT if s not in node . nextnode : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ret ^= self . dfs ( node . nextnode [ s ] , dep + 1 ) NEW_LINE DEDENT DEDENT height = L - dep NEW_LINE if cnt % 2 : NEW_LINE INDENT power2 = 0 NEW_LINE while height > 0 and height % 2 == 0 : NEW_LINE INDENT power2 += 1 NEW_LINE height //= 2 NEW_LINE DEDENT ret ^= 2 ** power2 NEW_LINE DEDENT return ret NEW_LINE DEDENT def debug_output ( self , node , now ) : NEW_LINE INDENT print ( node . char , list ( node . nextnode . items ( ) ) , node . is_indict , now ) NEW_LINE if node . is_indict : NEW_LINE INDENT print ( now ) NEW_LINE DEDENT for n in node . nextnode . values ( ) : NEW_LINE INDENT self . debug_output ( n , now + n . char ) NEW_LINE DEDENT DEDENT DEDENT N , L = map ( int , input ( ) . split ( ) ) NEW_LINE T = Trie ( '01' ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT T . add ( input ( ) ) NEW_LINE DEDENT print ( \" Alice \" if T . dfs ( T . root , 0 ) else \" Bob \" ) NEW_LINE",
"N , L = map ( int , input ( ) . split ( ) ) NEW_LINE make = lambda : [ None , None , 0 ] NEW_LINE root = make ( ) NEW_LINE def construct ( s ) : NEW_LINE INDENT n = root NEW_LINE for i in s : NEW_LINE INDENT if n [ i ] is None : NEW_LINE INDENT n [ i ] = n = make ( ) NEW_LINE DEDENT else : NEW_LINE INDENT n = n [ i ] NEW_LINE DEDENT DEDENT n [ 2 ] = 1 NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT s = map ( int , input ( ) ) NEW_LINE construct ( s ) NEW_LINE DEDENT caps = { } NEW_LINE st = [ ( root , 0 , 0 ) ] NEW_LINE while st : NEW_LINE INDENT n , i , l = st . pop ( ) NEW_LINE if i : NEW_LINE INDENT if n [ 1 ] is None : NEW_LINE INDENT caps [ L - l ] = caps . get ( L - l , 0 ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT if not n [ 1 ] [ 2 ] : NEW_LINE INDENT st . append ( ( n [ 1 ] , 0 , l + 1 ) ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT st . append ( ( n , 1 , l ) ) NEW_LINE if n [ 0 ] is None : NEW_LINE INDENT caps [ L - l ] = caps . get ( L - l , 0 ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT if not n [ 0 ] [ 2 ] : NEW_LINE INDENT st . append ( ( n [ 0 ] , 0 , l + 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for v in caps : NEW_LINE INDENT k = caps [ v ] NEW_LINE if k % 2 == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT v -= 1 NEW_LINE r = 1 NEW_LINE while v % 4 == 3 : NEW_LINE INDENT v //= 4 NEW_LINE r *= 4 NEW_LINE DEDENT if v % 4 == 1 : NEW_LINE INDENT ans ^= r * 2 NEW_LINE DEDENT else : NEW_LINE INDENT ans ^= r NEW_LINE DEDENT DEDENT print ( ' Alice ' if ans else ' Bob ' ) NEW_LINE",
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE from collections import deque NEW_LINE class Node : NEW_LINE INDENT def __init__ ( self , depth ) : NEW_LINE INDENT self . depth = depth NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def insert ( node , s ) : NEW_LINE INDENT n = node NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT t = s [ i ] NEW_LINE if t == '0' : NEW_LINE INDENT if n . left is None : NEW_LINE INDENT n . left = Node ( i + 1 ) NEW_LINE DEDENT n = n . left NEW_LINE DEDENT else : NEW_LINE INDENT if n . right is None : NEW_LINE INDENT n . right = Node ( i + 1 ) NEW_LINE DEDENT n = n . right NEW_LINE DEDENT DEDENT DEDENT class Trie : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . root = Node ( 0 ) NEW_LINE DEDENT def insert ( self , s : str ) : NEW_LINE INDENT insert ( self . root , s ) NEW_LINE DEDENT DEDENT n , l = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ input ( ) . strip ( ) for _ in range ( n ) ] NEW_LINE trie = Trie ( ) NEW_LINE for s in S : NEW_LINE INDENT trie . insert ( s ) NEW_LINE DEDENT Data = [ ] NEW_LINE q = deque ( [ trie . root ] ) NEW_LINE def dfs ( node ) : NEW_LINE INDENT if node . right is None and node . left is None : NEW_LINE INDENT return NEW_LINE DEDENT if node . right is None or node . left is None : NEW_LINE INDENT Data . append ( l - node . depth ) NEW_LINE DEDENT if node . right : NEW_LINE INDENT q . append ( node . right ) NEW_LINE DEDENT if node . left : NEW_LINE INDENT q . append ( node . left ) NEW_LINE DEDENT DEDENT while q : NEW_LINE INDENT dfs ( q . popleft ( ) ) NEW_LINE DEDENT xor = 0 NEW_LINE def Grundy ( n ) : NEW_LINE INDENT ret = 1 NEW_LINE while n % 2 == 0 : NEW_LINE INDENT n //= 2 NEW_LINE ret *= 2 NEW_LINE DEDENT return ret NEW_LINE DEDENT for i in Data : NEW_LINE INDENT xor ^= Grundy ( i ) NEW_LINE DEDENT print ( ' Alice ' if xor else ' Bob ' ) NEW_LINE",
"from collections import defaultdict NEW_LINE def solve ( n , l , nums ) : NEW_LINE INDENT xor = 0 NEW_LINE if n == 1 : NEW_LINE INDENT for i in range ( min ( nums ) , l + 1 ) : NEW_LINE INDENT xor ^= i & - i NEW_LINE DEDENT return xor NEW_LINE DEDENT for i in range ( min ( nums ) , l + 1 ) : NEW_LINE INDENT ni = nums [ i ] NEW_LINE for k in ni : NEW_LINE INDENT if k ^ 1 not in ni : NEW_LINE INDENT xor ^= i & - i NEW_LINE DEDENT nums [ i + 1 ] . add ( k // 2 ) NEW_LINE DEDENT del nums [ i ] NEW_LINE DEDENT return xor NEW_LINE DEDENT n , l = map ( int , input ( ) . split ( ) ) NEW_LINE nums = defaultdict ( set ) NEW_LINE for s in ( input ( ) for _ in range ( n ) ) : NEW_LINE INDENT nums [ l - len ( s ) + 1 ] . add ( int ( s , 2 ) + ( 1 << len ( s ) ) ) NEW_LINE DEDENT print ( ' Alice ' if solve ( n , l , nums ) else ' Bob ' ) NEW_LINE"
] |
atcoder_abc064_C | [
"import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] rate = new int [ ] { 400 , 800 , 1200 , 1600 , 2000 , 2400 , 2800 , 3200 } ; boolean [ ] exist = new boolean [ 8 ] ; int master = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= 3200 ) { master ++ ; continue ; } for ( int j = 0 ; j < rate . length ; j ++ ) { if ( a [ i ] < rate [ j ] ) { exist [ j ] = true ; break ; } } } int min = 0 ; for ( int i = 0 ; i < exist . length ; i ++ ) { if ( exist [ i ] ) { min ++ ; } } int max = min + master ; if ( min == 0 ) { min = 1 ; } out . print ( min + \" β \" + max ) ; } }",
"import java . util . * ; import java . lang . * ; import java . math . * ; class Main { static int n ; static int m ; static int ans ; static int [ ] rate ; static int var ; static int ansmin ; static int ansmax ; static int [ ] w ; static int [ ] ww ; static boolean [ ] visit ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; ansmin = 0 ; ansmax = 0 ; rate = new int [ 9 ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp >= 3200 ) { tmp = 3200 ; } rate [ tmp / 400 ] ++ ; } for ( int i = 0 ; i < 7 ; i ++ ) { if ( rate [ i ] != 0 ) { ansmin ++ ; ansmax ++ ; } } if ( rate [ 7 ] == 0 ) { if ( rate [ 8 ] != 0 ) { ansmin ++ ; ansmax += rate [ 8 ] ; } } else { ansmin ++ ; ansmax ++ ; if ( rate [ 8 ] != 0 ) { ansmax += ( rate [ 8 ] ) ; } } System . out . println ( ansmin + \" β \" + ansmax ) ; sc . close ( ) ; } public static void dfs ( int placenow ) { visit [ placenow ] = true ; boolean success = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( visit [ i ] == false ) { success = false ; break ; } } if ( success ) { ans ++ ; visit [ placenow ] = false ; return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( w [ i ] == placenow && visit [ ww [ i ] ] == false ) { dfs ( ww [ i ] ) ; } else if ( ww [ i ] == placenow && visit [ w [ i ] ] == false ) { dfs ( w [ i ] ) ; } else { continue ; } } visit [ placenow ] = false ; return ; } }",
"public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) , ans = 0 , colors [ ] = new int [ 9 ] ; for ( int i = 0 , temp ; i < n ; i ++ ) if ( ++ colors [ temp = Color . getColor ( scanner . nextInt ( ) ) . ordinal ( ) ] == 1 && temp != 8 ) ans ++ ; System . out . println ( Math . max ( 1 , ans ) + \" β \" + ( ans + colors [ 8 ] ) ) ; } enum Color { GRAY ( 1 , 399 ) , BROWN ( 400 , 799 ) , GREEN ( 800 , 1199 ) , LIGHT_BLUE ( 1200 , 1599 ) , BLUE ( 1600 , 1999 ) , YELLOW ( 2000 , 2399 ) , ORANGE ( 2400 , 2799 ) , RED ( 2800 , 3199 ) , FREE ( 3200 , 4800 ) ; int min , max ; Color ( int min , int max ) { this . min = min ; this . max = max ; } static Color getColor ( int rate ) { for ( Color color : values ( ) ) if ( color . min <= rate && rate <= color . max ) return color ; return null ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String remain = \"01234567\" ; int over = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int num = reader . nextInt ( ) / 400 ; if ( num < 8 ) { remain = remain . replace ( Integer . toString ( num ) , \" \" ) ; } else { over ++ ; } } int min = 8 - remain . length ( ) ; int max = min + over ; if ( min < 1 ) { min = 1 ; } reader . close ( ) ; System . out . print ( min + \" β \" + max ) ; } }",
"import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; HashSet < Integer > kinds = new HashSet < > ( ) ; int any = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int value = sc . nextInt ( ) ; if ( value <= 399 ) { kinds . add ( 0 ) ; } else if ( value <= 799 ) { kinds . add ( 1 ) ; } else if ( value <= 1199 ) { kinds . add ( 2 ) ; } else if ( value <= 1599 ) { kinds . add ( 3 ) ; } else if ( value <= 1999 ) { kinds . add ( 4 ) ; } else if ( value <= 2399 ) { kinds . add ( 5 ) ; } else if ( value <= 2799 ) { kinds . add ( 6 ) ; } else if ( value <= 3199 ) { kinds . add ( 7 ) ; } else { any ++ ; } } int min = ( kinds . size ( ) == 0 ) ? 1 : kinds . size ( ) ; int max = kinds . size ( ) + any ; System . out . println ( min + \" β \" + max ) ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE a = map ( int , input ( ) . split ( ) ) NEW_LINE color_set = set ( ) NEW_LINE original_cnt = 0 NEW_LINE red_flag = False NEW_LINE for val in a : NEW_LINE INDENT if val >= 3200 : NEW_LINE INDENT original_cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if val >= 2800 : NEW_LINE INDENT red_flag = True NEW_LINE DEDENT color_set . add ( int ( val / 400 ) ) NEW_LINE DEDENT DEDENT if red_flag is True : NEW_LINE INDENT print ( ' { } β { } ' . format ( len ( color_set ) , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if original_cnt > 0 : NEW_LINE INDENT print ( ' { } β { } ' . format ( len ( color_set ) + 1 , len ( color_set ) + original_cnt ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' { } β { } ' . format ( len ( color_set ) , len ( color_set ) ) ) NEW_LINE DEDENT DEDENT",
"from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE a = Counter ( list ( map ( lambda x : x // 400 , map ( int , input ( ) . split ( ) ) ) ) ) NEW_LINE c = n = 0 NEW_LINE for key in [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ] : NEW_LINE INDENT if a [ key ] : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for key in [ 8 , 9 , 10 , 11 , 12 ] : NEW_LINE INDENT n += a [ key ] NEW_LINE DEDENT max_n = c + n NEW_LINE if c : NEW_LINE INDENT min_n = c NEW_LINE DEDENT else : NEW_LINE INDENT min_n = 1 NEW_LINE DEDENT print ( min_n , max_n ) NEW_LINE",
"import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE l = [ 0 for _ in range ( 9 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] <= 399 : NEW_LINE INDENT l [ 0 ] += 1 NEW_LINE DEDENT elif 400 <= a [ i ] <= 799 : NEW_LINE INDENT l [ 1 ] += 1 NEW_LINE DEDENT elif 800 <= a [ i ] <= 1199 : NEW_LINE INDENT l [ 2 ] += 1 NEW_LINE DEDENT elif 1200 <= a [ i ] <= 1599 : NEW_LINE INDENT l [ 3 ] += 1 NEW_LINE DEDENT elif 1600 <= a [ i ] <= 1999 : NEW_LINE INDENT l [ 4 ] += 1 NEW_LINE DEDENT elif 2000 <= a [ i ] <= 2399 : NEW_LINE INDENT l [ 5 ] += 1 NEW_LINE DEDENT elif 2400 <= a [ i ] <= 2799 : NEW_LINE INDENT l [ 6 ] += 1 NEW_LINE DEDENT elif 2800 <= a [ i ] <= 3199 : NEW_LINE INDENT l [ 7 ] += 1 NEW_LINE DEDENT elif 3200 <= a [ i ] : NEW_LINE INDENT l [ 8 ] += 1 NEW_LINE DEDENT DEDENT if l [ 8 ] == 0 : NEW_LINE INDENT print ( 9 - l . count ( 0 ) , 9 - l . count ( 0 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if l . count ( 0 ) == 8 : NEW_LINE INDENT print ( 1 , l [ 8 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 8 - l . count ( 0 ) , 8 - l . count ( 0 ) + l [ 8 ] ) NEW_LINE DEDENT DEDENT",
"from collections import OrderedDict NEW_LINE import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE a = np . array ( [ int ( i ) for i in input ( ) . split ( ) ] ) NEW_LINE scores = OrderedDict ( ) NEW_LINE scores [ 1 ] = 0 NEW_LINE scores [ 400 ] = 0 NEW_LINE scores [ 800 ] = 0 NEW_LINE scores [ 1200 ] = 0 NEW_LINE scores [ 1600 ] = 0 NEW_LINE scores [ 2000 ] = 0 NEW_LINE scores [ 2400 ] = 0 NEW_LINE scores [ 2800 ] = 0 NEW_LINE scores [ 3200 ] = 0 NEW_LINE for record in a : NEW_LINE INDENT for s in list ( scores . keys ( ) ) [ : : - 1 ] : NEW_LINE INDENT if record >= s : NEW_LINE INDENT scores [ s ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT colors = np . sum ( [ int ( v > 0 ) for k , v in scores . items ( ) if k < 3200 ] ) NEW_LINE if scores [ 3200 ] > 0 and colors == 0 : NEW_LINE INDENT min_colors = 1 NEW_LINE DEDENT else : NEW_LINE INDENT min_colors = colors NEW_LINE DEDENT max_colors = colors + scores [ 3200 ] NEW_LINE print ( min_colors , max_colors ) NEW_LINE",
"import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE wildcard = 0 NEW_LINE color = [ 0 ] * 8 NEW_LINE for a in A : NEW_LINE INDENT if a < 400 : NEW_LINE INDENT color [ 0 ] = 1 NEW_LINE DEDENT elif a < 800 : NEW_LINE INDENT color [ 1 ] = 1 NEW_LINE DEDENT elif a < 1200 : NEW_LINE INDENT color [ 2 ] = 1 NEW_LINE DEDENT elif a < 1600 : NEW_LINE INDENT color [ 3 ] = 1 NEW_LINE DEDENT elif a < 2000 : NEW_LINE INDENT color [ 4 ] = 1 NEW_LINE DEDENT elif a < 2400 : NEW_LINE INDENT color [ 5 ] = 1 NEW_LINE DEDENT elif a < 2800 : NEW_LINE INDENT color [ 6 ] = 1 NEW_LINE DEDENT elif a < 3200 : NEW_LINE INDENT color [ 7 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT wildcard += 1 NEW_LINE DEDENT DEDENT nc = sum ( color ) NEW_LINE print ( max ( 1 , nc ) , nc + wildcard ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT"
] |
atcoder_abc122_B | [
"import java . util . * ; public class Main { public static boolean isValid ( char c ) { if ( c == ' A ' || c == ' C ' || c == ' T ' || c == ' G ' ) { return true ; } return false ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int max = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int count = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { if ( isValid ( s . charAt ( j ) ) ) { count ++ ; max = Math . max ( max , count ) ; } else { break ; } } } System . out . println ( max ) ; } }",
"import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { char moji [ ] = new char [ 11 ] ; int count [ ] = new int [ 11 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { moji [ i ] = ( char ) System . in . read ( ) ; if ( moji [ i ] == ' \\n ' ) { break ; } } for ( int i = 0 , j = 0 ; i < moji . length ; i ++ , j ++ ) { while ( moji [ i ] == ' A ' || moji [ i ] == ' C ' || moji [ i ] == ' G ' || moji [ i ] == ' T ' ) { count [ j ] ++ ; i ++ ; } } int max = 0 ; for ( int i = 0 ; i < count . length ; i ++ ) { if ( max < count [ i ] ) { max = count [ i ] ; } } System . out . println ( max ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BATCoder solver = new BATCoder ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BATCoder { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int longest = 0 ; int current = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' || s . charAt ( i ) == ' C ' || s . charAt ( i ) == ' G ' || s . charAt ( i ) == ' T ' ) { current ++ ; if ( current > longest ) { longest = current ; } } else { current = 0 ; } } out . println ( longest ) ; } } }",
"import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; char [ ] arr = br . readLine ( ) . toCharArray ( ) ; int max = 0 , cur = 0 ; for ( char c : arr ) { if ( c == ' A ' || c == ' T ' || c == ' C ' || c == ' G ' ) { max = Math . max ( max , ++ cur ) ; } else { cur = 0 ; } } bw . write ( max + \" \" ) ; bw . close ( ) ; } }",
"import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Main main = new Main ( ) ; main . start ( ) ; } public void start ( ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String letters [ ] = str . split ( \" \" ) ; int max = 0 ; for ( int i = 0 ; i < letters . length ; i ++ ) { int num = countLength ( letters , i ) ; if ( num > max ) max = num ; } System . out . println ( max ) ; } public int countLength ( String [ ] letters , int index ) { int count = 0 ; for ( int i = index ; i < letters . length ; i ++ ) { if ( letters [ i ] . equals ( \" A \" ) || letters [ i ] . equals ( \" C \" ) || letters [ i ] . equals ( \" T \" ) || letters [ i ] . equals ( \" G \" ) ) { count ++ ; } else { return count ; } } return count ++ ; } }"
] | [
"print ( len ( max ( \" \" . join ( str ( int ( c in { \" A \" , \" T \" , \" G \" , \" C \" } ) ) for c in input ( ) ) . split ( \"0\" ) ) ) ) NEW_LINE",
"s = input ( ) NEW_LINE counter = 0 NEW_LINE max_count = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == ' A ' or s [ i ] == ' C ' or s [ i ] == ' G ' or s [ i ] == ' T ' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE counter = 0 NEW_LINE DEDENT else : NEW_LINE INDENT counter = 0 NEW_LINE DEDENT DEDENT DEDENT if counter > max_count : NEW_LINE INDENT max_count = counter NEW_LINE DEDENT print ( max_count ) NEW_LINE",
"l = list ( input ( ) ) NEW_LINE counter = 0 NEW_LINE atcorder = [ ] NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if ( l [ i ] == \" A \" or l [ i ] == \" T \" or l [ i ] == \" G \" or l [ i ] == \" C \" ) : NEW_LINE INDENT counter += 1 NEW_LINE atcorder . append ( counter ) NEW_LINE continue NEW_LINE DEDENT counter = 0 NEW_LINE DEDENT if ( len ( atcorder ) != 0 ) : NEW_LINE INDENT print ( max ( atcorder ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \"0\" ) NEW_LINE DEDENT",
"import sys NEW_LINE def i2s ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) . rstrip ( ) NEW_LINE DEDENT def ii2ss ( n ) : NEW_LINE INDENT return [ sys . stdin . readline ( ) for _ in range ( n ) ] NEW_LINE DEDENT def sp2nn ( sp , sep = ' β ' ) : NEW_LINE INDENT return [ int ( s ) for s in sp . split ( sep ) ] NEW_LINE DEDENT def ss2nn ( ss ) : NEW_LINE INDENT return [ int ( s ) for s in list ( ss ) ] NEW_LINE DEDENT def main ( S ) : NEW_LINE INDENT st = set ( ( ' A ' , ' C ' , ' G ' , ' T ' ) ) NEW_LINE cmax = 0 NEW_LINE c = 0 NEW_LINE for s in S : NEW_LINE INDENT if s in st : NEW_LINE INDENT c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT c = 0 NEW_LINE DEDENT DEDENT if cmax < c : NEW_LINE INDENT cmax = c NEW_LINE DEDENT print ( cmax ) NEW_LINE DEDENT main ( i2s ( ) ) NEW_LINE",
"s = input ( ) NEW_LINE t = [ - 1 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] != \" A \" and s [ i ] != \" G \" and s [ i ] != \" C \" and s [ i ] != \" T \" : NEW_LINE INDENT t . append ( i ) NEW_LINE DEDENT DEDENT t . append ( len ( s ) ) NEW_LINE ans = 0 NEW_LINE for j in range ( len ( t ) - 1 ) : NEW_LINE INDENT x = t [ j + 1 ] - t [ j ] - 1 NEW_LINE if x > ans : NEW_LINE INDENT ans = x NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE"
] |
atcoder_abc029_D | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) * 10 ; long ans = 0 ; for ( long i = 10 ; i < 10000000000L ; i *= 10 ) { long digit = N % ( i * 10 ) / i ; ans += N / ( i * 10 ) * i / 10 ; if ( digit == 1 ) { ans += N % i / 10 + 1 ; } else if ( digit != 0 ) { ans += i / 10 ; } } System . out . println ( ans ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D1 solver = new D1 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D1 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= 100000000 ; i *= 10 ) { if ( n / i % 10 == 1 ) { ans += n % i + 1 ; } ans += ( n + 8 * i ) / ( 10 * i ) * i ; } out . println ( ans ) ; } } }",
"import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( ans ( n , 0 ) ) ; } static int ans ( int n , int c ) { if ( c == 10 ) return 0 ; int temp = 0 ; if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) { temp = power ( 10 , c ) ; } else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) { temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ; } return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ; } static int power ( int n , int m ) { if ( m == 0 ) return 1 ; if ( m % 2 == 1 ) return power ( n , m - 1 ) * n ; int e = power ( n , m / 2 ) ; return e * e ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; long count = 0 ; for ( int i = 0 ; i < 11 ; i ++ ) { count += ( n / pow10 ( i + 1 ) ) * pow10 ( i ) ; long target = ( n % pow10 ( i + 1 ) ) / pow10 ( i ) ; if ( target > 1 ) { count += pow10 ( i ) ; } else if ( target == 1 ) { count += n % pow10 ( i ) + 1 ; } } System . out . println ( count ) ; } static long pow10 ( int n ) { if ( n == 0 ) { return 1 ; } else { return 10 * pow10 ( n - 1 ) ; } } }",
"import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int souwa = 0 ; souwa += N / 10 ; if ( N % 10 >= 1 ) { souwa ++ ; } souwa += N / 100 * 10 ; if ( N % 100 >= 10 ) { souwa += Math . min ( N % 100 - 9 , 10 ) ; } souwa += N / 1000 * 100 ; if ( N % 1000 >= 100 ) { souwa += Math . min ( N % 1000 - 99 , 100 ) ; } souwa += N / 10000 * 1000 ; if ( N % 10000 >= 1000 ) { souwa += Math . min ( N % 10000 - 999 , 1000 ) ; } souwa += N / 100000 * 10000 ; if ( N % 100000 >= 10000 ) { souwa += Math . min ( N % 100000 - 9999 , 10000 ) ; } souwa += N / 1000000 * 100000 ; if ( N % 1000000 >= 100000 ) { souwa += Math . min ( N % 1000000 - 99999 , 100000 ) ; } souwa += N / 10000000 * 1000000 ; if ( N % 10000000 >= 1000000 ) { souwa += Math . min ( N % 10000000 - 999999 , 1000000 ) ; } souwa += N / 100000000 * 10000000 ; if ( N % 100000000 >= 10000000 ) { souwa += Math . min ( N % 100000000 - 9999999 , 10000000 ) ; } souwa += N / 1000000000 * 100000000 ; if ( N % 1000000000 >= 100000000 ) { souwa += Math . min ( N % 1000000000 - 99999999 , 100000000 ) ; } if ( N == 1000000000 ) { souwa ++ ; } System . out . println ( souwa ) ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 9 ) : NEW_LINE INDENT A = ( N // ( 10 ** ( i ) ) ) NEW_LINE if ( A ) % 10 == 1 : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE ans += ( N % ( 10 ** ( i ) ) + 1 ) NEW_LINE DEDENT elif ( A ) % 10 > 1 : NEW_LINE INDENT ans += ( A // 10 + 1 ) * ( 10 ** i ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( A // 10 ) * ( 10 ** i ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"def one ( N : int ) -> int : NEW_LINE INDENT res = 0 NEW_LINE M = 10 NEW_LINE while N // M : NEW_LINE INDENT R = N % M NEW_LINE res += ( N - R ) // 10 NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT res += R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT res += M // 10 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res += 0 NEW_LINE DEDENT M *= 10 NEW_LINE DEDENT R = N % M NEW_LINE if R * 10 >= M : NEW_LINE INDENT if R * 10 < 2 * M : NEW_LINE INDENT return res + R - M // 10 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return res + M // 10 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = one ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = input ( ) [ : - 1 ] NEW_LINE dp = [ [ [ 0 ] * ( len ( N ) + 1 ) for _ in range ( 2 ) ] for _ in range ( len ( N ) + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) ) : NEW_LINE INDENT if dp [ i ] [ j ] [ k ] == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT elif j == 1 : NEW_LINE INDENT dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] * 9 NEW_LINE DEDENT else : NEW_LINE INDENT if N [ i ] == '1' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT elif N [ i ] == '0' : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i + 1 ] [ 0 ] [ k ] = dp [ i ] [ j ] [ k ] NEW_LINE dp [ i + 1 ] [ 1 ] [ k ] = dp [ i ] [ j ] [ k ] * ( int ( N [ i ] ) - 1 ) NEW_LINE dp [ i + 1 ] [ 1 ] [ k + 1 ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 2 ) : NEW_LINE INDENT for k in range ( len ( N ) + 1 ) : NEW_LINE INDENT if dp [ len ( N ) ] [ j ] [ k ] : NEW_LINE INDENT ans += k * dp [ len ( N ) ] [ j ] [ k ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE",
"n = input ( ) NEW_LINE memo = [ [ [ None for _ in range ( len ( n ) + 1 ) ] for _ in range ( 2 ) ] for _ in range ( len ( n ) + 1 ) ] NEW_LINE def rec ( i , threshold , s ) : NEW_LINE INDENT if i == len ( n ) : NEW_LINE INDENT return s NEW_LINE DEDENT if memo [ i ] [ threshold ] [ s ] is not None : NEW_LINE INDENT return memo [ i ] [ threshold ] [ s ] NEW_LINE DEDENT ret = 0 NEW_LINE limit = int ( n [ i ] ) if threshold == 1 else 9 NEW_LINE for j in range ( limit + 1 ) : NEW_LINE INDENT nex_threshold = 1 if ( j == limit and threshold == 1 ) else 0 NEW_LINE if j == 1 : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ret += rec ( i + 1 , nex_threshold , s ) NEW_LINE DEDENT memo [ i ] [ threshold ] [ s ] = ret NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( rec ( 0 , 1 , 0 ) ) NEW_LINE",
"def dp_table ( * counts ) : NEW_LINE INDENT if counts : NEW_LINE INDENT return [ dp_table ( * counts [ 1 : ] ) for _ in range ( counts [ 0 ] ) ] NEW_LINE DEDENT else : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT def solve ( dp , N : str , index : int = 0 , tight : bool = True , amount_1 : int = 0 ) : NEW_LINE INDENT if len ( N ) == index : NEW_LINE INDENT return amount_1 NEW_LINE DEDENT elif dp [ index ] [ tight ] [ amount_1 ] is not None : NEW_LINE INDENT return dp [ index ] [ tight ] [ amount_1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if tight : NEW_LINE INDENT for_max = int ( N [ index ] ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT for_max = 10 NEW_LINE DEDENT return_ = 0 NEW_LINE for i in range ( for_max ) : NEW_LINE INDENT return_ += solve ( dp , N , index + 1 , tight and i == int ( N [ index ] ) , amount_1 + 1 if i == 1 else amount_1 ) NEW_LINE DEDENT dp [ index ] [ tight ] [ amount_1 ] = return_ NEW_LINE return return_ NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE digit_N = str ( N ) NEW_LINE dp = dp_table ( len ( digit_N ) + 1 , 2 , len ( digit_N ) + 1 ) NEW_LINE print ( solve ( dp , digit_N ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT"
] |
atcoder_arc094_A | [
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) a [ i ] = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; while ( true ) { Arrays . sort ( a ) ; if ( a [ 0 ] == a [ 1 ] && a [ 1 ] == a [ 2 ] ) break ; else if ( a [ 1 ] == a [ 2 ] ) a [ 0 ] += 2 ; else { a [ 0 ] ++ ; a [ 1 ] ++ ; } c ++ ; } System . out . println ( c ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String [ ] sl = r . readLine ( ) . split ( \" [ \\\\ s ] + \" ) ; int a = Integer . parseInt ( sl [ 0 ] ) ; int b = Integer . parseInt ( sl [ 1 ] ) ; int c = Integer . parseInt ( sl [ 2 ] ) ; if ( a > b ) { int t = a ; a = b ; b = t ; } if ( b > c ) { int t = b ; b = c ; c = t ; } if ( a > b ) { int t = a ; a = b ; b = t ; } if ( a == b && b == c ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } if ( b == c ) { if ( ( b - a ) % 2 == 0 ) { System . out . println ( ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } if ( a == b ) { System . out . println ( c - a ) ; System . exit ( 0 ) ; } int v = 0 ; v += c - b ; a += c - b ; b += c - b ; if ( ( b - a ) % 2 == 0 ) { System . out . println ( v + ( b - a ) / 2 ) ; System . exit ( 0 ) ; } else { System . out . println ( v + ( b - a + 1 ) / 2 + 1 ) ; System . exit ( 0 ) ; } } }",
"import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { List < Integer > list = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ; ) { list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int min = list . get ( 0 ) ; int middle = list . get ( 1 ) ; int max = list . get ( 2 ) ; int count = 0 ; while ( min != middle || middle != max ) { for ( int i = 0 ; i < 2 ; i ++ ) { min ++ ; if ( min > middle ) { int tmp = middle ; middle = min ; min = tmp ; } if ( min > max ) { int tmp = max ; max = min ; min = tmp ; } } count ++ ; } System . out . println ( count ) ; } }",
"import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int i = 0 ; i < abc . length ; i ++ ) abc [ i ] = nextInt ( ) ; Arrays . sort ( abc ) ; int diff1 = abc [ 2 ] - abc [ 0 ] ; int diff2 = abc [ 2 ] - abc [ 1 ] ; if ( diff1 % 2 == 0 && diff2 % 2 == 0 ) System . out . println ( diff1 / 2 + diff2 / 2 ) ; else if ( diff1 % 2 == 1 && diff2 % 2 == 0 ) System . out . println ( 1 + diff2 / 2 + ( diff1 + 1 ) / 2 ) ; else if ( diff1 % 2 == 0 && diff2 % 2 == 1 ) System . out . println ( 1 + diff1 / 2 + ( diff2 + 1 ) / 2 ) ; else System . out . println ( 1 + ( diff1 - 1 ) / 2 + ( diff2 - 1 ) / 2 ) ; } private static BufferedReader reader ; private static StringTokenizer tokenizer ; private static void init ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tokenizer = new StringTokenizer ( \" \" ) ; } private static String next ( ) throws IOException { String read ; while ( ! tokenizer . hasMoreTokens ( ) ) { read = reader . readLine ( ) ; if ( read == null || read . equals ( \" \" ) ) return \" - 1\" ; tokenizer = new StringTokenizer ( read ) ; } return tokenizer . nextToken ( ) ; } private static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } }",
"import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( \" β \" ) ; List < Integer > values = new ArrayList < > ( ) ; for ( String token : tokens ) { values . add ( Integer . parseInt ( token ) ) ; } Collections . sort ( values ) ; int result = 0 ; while ( true ) { int r = operation ( values ) ; if ( r == 0 ) { break ; } result += r ; Collections . sort ( values ) ; } System . out . println ( result ) ; in . close ( ) ; } public static int operation ( List < Integer > values ) { if ( values . get ( 0 ) == values . get ( 2 ) ) { return 0 ; } if ( values . get ( 0 ) == values . get ( 1 ) ) { int result = values . get ( 2 ) - values . get ( 1 ) ; values . set ( 0 , values . get ( 2 ) ) ; values . set ( 1 , values . get ( 2 ) ) ; return result ; } if ( ( values . get ( 1 ) - values . get ( 0 ) ) % 2 == 0 ) { int result = ( values . get ( 1 ) - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; return result ; } else { int result = ( values . get ( 1 ) + 1 - values . get ( 0 ) ) / 2 ; values . set ( 0 , values . get ( 1 ) ) ; values . set ( 1 , values . get ( 1 ) + 1 ) ; return result ; } } }"
] | [
"def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C , B , A = sorted ( inpl ( ) ) NEW_LINE if ( B - C ) % 2 == 0 : NEW_LINE INDENT print ( ( 2 * A - B - C ) // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( 2 * A - B - C + 3 ) // 2 ) NEW_LINE DEDENT",
"A , B , C = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ret = 0 NEW_LINE m = A % 2 + B % 2 + C % 2 NEW_LINE if m == 3 or m == 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ret += 1 NEW_LINE if m == 2 : NEW_LINE INDENT if A % 2 == 0 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 0 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A % 2 == 1 : NEW_LINE INDENT B += 1 NEW_LINE C += 1 NEW_LINE DEDENT elif B % 2 == 1 : NEW_LINE INDENT A += 1 NEW_LINE C += 1 NEW_LINE DEDENT else : NEW_LINE INDENT A += 1 NEW_LINE B += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ret + ( C - B ) // 2 + ( C - A ) // 2 ) NEW_LINE",
"a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = sorted ( a ) NEW_LINE c = a [ 0 ] % 2 + a [ 1 ] % 2 + a [ 2 ] % 2 NEW_LINE ans = 0 NEW_LINE if ( c == 0 or c == 3 ) : NEW_LINE INDENT ans += a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] NEW_LINE ans //= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if ( c == 1 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 == 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT elif ( c == 2 ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( a [ i ] % 2 != 0 ) : NEW_LINE INDENT a [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans += 1 NEW_LINE ans += ( a [ 2 ] - a [ 0 ] + a [ 2 ] - a [ 1 ] ) // 2 NEW_LINE DEDENT print ( ans ) NEW_LINE",
"import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE nums . sort ( ) NEW_LINE ans = 0 NEW_LINE while nums [ 0 ] != nums [ - 1 ] : NEW_LINE INDENT if nums [ 0 ] < nums [ 1 ] : NEW_LINE INDENT nums [ 0 ] += 2 NEW_LINE DEDENT else : NEW_LINE INDENT nums [ 0 ] += 1 NEW_LINE nums [ 1 ] += 1 NEW_LINE DEDENT ans += 1 NEW_LINE nums . sort ( ) NEW_LINE DEDENT print ( ans ) NEW_LINE",
"X , Y , Z = sorted ( list ( map ( int , input ( ) . split ( ' β ' ) ) ) ) NEW_LINE print ( ( Z - Y ) + ( Y - X ) // 2 + 2 * ( ( X - Y ) % 2 ) ) NEW_LINE"
] |
atcoder_arc008_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int num = Integer . parseInt ( br . readLine ( ) ) ; int tenNum = num / 10 ; int remainder = num % 10 ; int answer = 0 ; if ( remainder * 15 > 100 ) { answer = ( tenNum + 1 ) * 100 ; } else { answer = tenNum * 100 + remainder * 15 ; } System . out . println ( answer ) ; } }",
"import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; out . println ( n >= 10 ? min ( ( n / 10 ) * 100 + ( n % 10 ) * 15 , ( n / 10 + 1 ) * 100 ) : min ( n * 15 , 100 ) ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; out . println ( 100 * ( n / 10 ) + Math . min ( ( n % 10 ) * 15 , 100 ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; pl ( Math . min ( ( ( N / 10 ) * 100 + ( N % 10 ) * 15 ) , ( ( N + 9 ) / 10 ) * 100 ) ) ; } 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 . 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 ans = 0 ; while ( N > 10 ) { N -= 10 ; ans += 100 ; } if ( N >= 7 ) { out . println ( ans + 100 ) ; } else { out . println ( ans + N * 15 ) ; } } } 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 ( ) ) ; } } }"
] | [
"n = int ( input ( ) ) NEW_LINE print ( ( n // 10 ) * 100 + min ( 100 , ( n % 10 ) * 15 ) ) NEW_LINE",
"import sys NEW_LINE import copy NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE ans = 1000000000000000 NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT for j in range ( 100 ) : NEW_LINE INDENT money = i * 15 + j * 100 NEW_LINE tako = i + j * 10 NEW_LINE if tako >= N : NEW_LINE INDENT ans = min ( ans , money ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE",
"n = int ( input ( ) ) NEW_LINE num = float ( ' inf ' ) NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT num = min ( num , i * 100 + max ( 0 , ( n - i * 10 ) ) * 15 ) NEW_LINE DEDENT print ( num ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE print ( min ( ( n // 10 ) * 100 + ( n % 10 ) * 15 , ( ( n - 1 ) // 10 + 1 ) * 100 ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE ten = n // 10 NEW_LINE one = n % 10 NEW_LINE print ( min ( ( ten + 1 ) * 100 , ten * 100 + one * 15 ) ) NEW_LINE"
] |
atcoder_agc006_D | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int L = 2 * N - 1 ; int [ ] a = new int [ L ] ; for ( int i = 0 ; i < L ; i ++ ) a [ i ] = sc . nextInt ( ) ; int min = 1 ; int max = L ; boolean b [ ] = new boolean [ L ] ; while ( min + 1 < max ) { int mid = ( min + max ) / 2 ; for ( int i = 0 ; i < L ; i ++ ) b [ i ] = a [ i ] >= mid ; if ( satisfy ( b ) ) min = mid ; else max = mid ; } System . out . println ( min ) ; sc . close ( ) ; } static boolean satisfy ( boolean [ ] b ) { int L = b . length ; int N = ( L + 1 ) / 2 ; int l = N - 1 ; while ( l > 0 && b [ l ] != b [ l - 1 ] ) l -- ; int r = N - 1 ; while ( r < L - 1 && b [ r ] != b [ r + 1 ] ) r ++ ; if ( l > 0 ) { if ( r < L - 1 ) { if ( b [ l ] == b [ r ] ) return b [ l ] ; else return ( l + r ) / 2 >= N - 1 ? b [ l ] : b [ r ] ; } else { return b [ l ] ; } } else if ( r < L - 1 ) { return b [ r ] ; } else { return b [ N - 1 ] ^ N % 2 == 0 ; } } }"
] | [
"N = int ( input ( ) ) NEW_LINE a = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def check ( n ) : NEW_LINE INDENT b = [ False ] * ( len ( a ) ) NEW_LINE for i in range ( 1 , len ( a ) ) : NEW_LINE INDENT if a [ i ] >= n : NEW_LINE INDENT b [ i ] = True NEW_LINE DEDENT else : NEW_LINE INDENT b [ i ] = False NEW_LINE DEDENT DEDENT r = int ( 1e9 ) NEW_LINE l = int ( 1e9 ) NEW_LINE rb = b [ N ] NEW_LINE lb = b [ N ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if lb == b [ N - i ] : NEW_LINE INDENT l = i NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT lb = b [ N - i ] NEW_LINE DEDENT DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT if rb == b [ N + i ] : NEW_LINE INDENT r = i NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT rb = b [ N + i ] NEW_LINE DEDENT DEDENT if r == int ( 1e9 ) and l == int ( 1e9 ) : NEW_LINE INDENT if N % 2 == 1 : NEW_LINE INDENT return b [ N ] NEW_LINE DEDENT else : NEW_LINE INDENT return not b [ N ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if r < l : NEW_LINE INDENT return rb NEW_LINE DEDENT else : NEW_LINE INDENT return lb NEW_LINE DEDENT DEDENT DEDENT def binarySearch ( small , big ) : NEW_LINE INDENT mid = ( big + small ) // 2 NEW_LINE if big - small <= 1 : NEW_LINE INDENT if check ( small ) : return small NEW_LINE else : return big NEW_LINE DEDENT else : NEW_LINE INDENT if not check ( mid ) : NEW_LINE INDENT return binarySearch ( small , mid ) NEW_LINE DEDENT else : NEW_LINE INDENT return binarySearch ( mid , big ) NEW_LINE DEDENT DEDENT DEDENT print ( binarySearch ( 2 , 2 * N - 2 ) ) NEW_LINE"
] |
atcoder_arc083_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] [ ] A = new int [ N ] [ N ] ; long sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; sum += A [ i ] [ j ] ; } sum /= 2 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( i == k || j == k ) continue ; if ( A [ i ] [ j ] > A [ i ] [ k ] + A [ k ] [ j ] ) { System . out . println ( - 1 ) ; return ; } if ( A [ i ] [ j ] == A [ i ] [ k ] + A [ k ] [ j ] ) { sum -= A [ i ] [ j ] ; break ; } } } } System . out . println ( sum ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; long [ ] [ ] dist = new long [ n + 1 ] [ n + 1 ] ; for ( int i = 1 ; i <= n ; ++ i ) { for ( int j = 1 ; j <= n ; ++ j ) { long a = scanner . nextInt ( ) ; dist [ i ] [ j ] = a ; } } long totalLength = 0 ; for ( int i = 1 ; i <= n ; ++ i ) { for ( int j = i + 1 ; j <= n ; ++ j ) { boolean isNecessary = true ; for ( int k = 1 ; k <= n ; ++ k ) { if ( i == k || j == k ) { continue ; } if ( dist [ i ] [ k ] + dist [ k ] [ j ] < dist [ i ] [ j ] ) { System . out . println ( - 1 ) ; return ; } else if ( dist [ i ] [ k ] + dist [ k ] [ j ] == dist [ i ] [ j ] ) { isNecessary = false ; break ; } } if ( isNecessary ) { totalLength += dist [ i ] [ j ] ; } } } System . out . println ( totalLength ) ; } }",
"import java . util . * ; import java . util . stream . Stream ; public class Main { private static int N ; private static int A [ ] [ ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; A = new int [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } System . out . println ( solve ( ) ) ; } static long solve ( ) { boolean [ ] [ ] indirect = new boolean [ N ] [ N ] ; for ( int i = 0 ; i < N - 1 ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( k == i || k == j ) continue ; int ikj = A [ i ] [ k ] + A [ k ] [ j ] ; int ij = A [ i ] [ j ] ; if ( ikj < ij ) { return - 1 ; } else if ( ikj == ij ) { indirect [ i ] [ j ] = true ; } } } } long ans = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( ! indirect [ i ] [ j ] ) { ans += A [ i ] [ j ] ; } } } return ans ; } }",
"import java . util . Scanner ; public class Main { static int n ; static int [ ] [ ] dist ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; dist = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { dist [ i ] [ j ] = sc . nextInt ( ) ; } } long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { sum += ( long ) dist [ i ] [ j ] ; } } boolean [ ] [ ] subtracted = new boolean [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { if ( k == i || k == j ) { continue ; } if ( dist [ i ] [ j ] > dist [ i ] [ k ] + dist [ k ] [ j ] ) { System . out . println ( - 1 ) ; return ; } if ( ! subtracted [ i ] [ j ] && dist [ i ] [ j ] == dist [ i ] [ k ] + dist [ k ] [ j ] ) { sum -= ( long ) dist [ i ] [ j ] ; subtracted [ i ] [ j ] = true ; } } } } System . out . println ( sum ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] [ ] A = new long [ N ] [ N ] ; long [ ] [ ] D = new long [ N ] [ N ] ; Boolean nes [ ] [ ] = new Boolean [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { A [ i ] [ j ] = sc . nextLong ( ) ; if ( A [ i ] [ j ] == 0 && i != j ) { A [ i ] [ j ] = ( long ) 10e12 ; } D [ i ] [ j ] = A [ i ] [ j ] ; nes [ i ] [ j ] = true ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( j != i && k != i && D [ j ] [ k ] == D [ j ] [ i ] + D [ i ] [ k ] ) { nes [ j ] [ k ] = false ; } D [ j ] [ k ] = Math . min ( D [ j ] [ k ] , D [ j ] [ i ] + D [ i ] [ k ] ) ; } } } long ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( A [ i ] [ j ] != D [ i ] [ j ] ) { System . out . println ( - 1 ) ; return ; } if ( nes [ i ] [ j ] ) { ans += D [ i ] [ j ] ; } } } System . out . println ( ans ) ; } }"
] | [
"def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE import sys NEW_LINE import numpy NEW_LINE N = int ( input ( ) ) NEW_LINE A = numpy . asarray ( [ inpl ( ) for _ in range ( N ) ] ) NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT A [ i ] [ i ] = 10 ** 9 + 1 NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( i ) : NEW_LINE INDENT mindis = numpy . min ( [ A [ i ] + A [ j ] ] ) NEW_LINE if mindis > A [ i ] [ j ] : NEW_LINE INDENT ans += A [ i ] [ j ] NEW_LINE continue NEW_LINE DEDENT if mindis < A [ i ] [ j ] : NEW_LINE INDENT print ( - 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE",
"import numpy as np NEW_LINE import scipy . sparse . csgraph as csg NEW_LINE if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE G = np . asarray ( A , dtype = np . uint32 ) NEW_LINE G2 = csg . floyd_warshall ( G , directed = False ) NEW_LINE if np . any ( G != G2 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT ans = 0 NEW_LINE G [ G == 0 ] = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT n = np . min ( G [ i ] + G [ j ] ) NEW_LINE if n > G [ i , j ] : NEW_LINE INDENT ans += G [ i , j ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE DEDENT",
"def solve ( n , tbl ) : NEW_LINE INDENT ans = 0 NEW_LINE for i , row_i in enumerate ( tbl ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT row_j = tbl [ j ] NEW_LINE ij = row_i [ j ] NEW_LINE mind = min ( ( ik + kj for ik , kj in zip ( row_i , row_j ) if ik and kj ) , default = float ( ' inf ' ) ) NEW_LINE if ij > mind : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if ij < mind : NEW_LINE INDENT ans += ij NEW_LINE DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE tbl = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE print ( solve ( n , tbl ) ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE inf = float ( \" inf \" ) NEW_LINE A = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * N ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A [ i ] [ i ] = inf NEW_LINE DEDENT result = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT for j , dist in enumerate ( A [ i ] [ i + 1 : ] , start = i + 1 ) : NEW_LINE INDENT for _A in A : NEW_LINE INDENT if dist >= _A [ i ] + _A [ j ] : NEW_LINE INDENT if dist > _A [ i ] + _A [ j ] : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT result += dist NEW_LINE DEDENT DEDENT DEDENT print ( result ) NEW_LINE",
"import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE dist = [ [ 0.0 for _ in range ( N ) ] for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j , x in enumerate ( map ( int , input ( ) . split ( ) ) ) : NEW_LINE INDENT dist [ i ] [ j ] = float ( x ) NEW_LINE DEDENT DEDENT dist = np . array ( dist ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT dist [ i , i ] = float ( ' inf ' ) NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT min_ = min ( dist [ i ] + dist [ j ] ) NEW_LINE if min_ < dist [ i , j ] : NEW_LINE INDENT ans = - 1 NEW_LINE break NEW_LINE DEDENT elif min_ > dist [ i , j ] : NEW_LINE INDENT ans += dist [ i , j ] NEW_LINE DEDENT DEDENT if ans < 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( int ( ans ) ) NEW_LINE"
] |
atcoder_arc081_A | [
"import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; import java . util . TreeMap ; import java . util . Map . Entry ; 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 ( ) ; Map < Integer , Integer > aMap = new TreeMap < > ( ( x , y ) -> y - x ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; Integer count = aMap . getOrDefault ( a , 0 ) + 1 ; aMap . put ( a , count ) ; } long x = 0 ; for ( Entry < Integer , Integer > e : aMap . entrySet ( ) ) { if ( e . getValue ( ) >= 4 && x == 0 ) { System . out . println ( ( long ) e . getKey ( ) * e . getKey ( ) ) ; return ; } if ( e . getValue ( ) >= 2 && x == 0 ) { x = e . getKey ( ) ; continue ; } if ( e . getValue ( ) >= 2 ) { System . out . println ( x * e . getKey ( ) ) ; return ; } } System . out . println ( 0 ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Main { int n ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; SortedMap < Integer , Integer > counts = new TreeMap < > ( Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( ! counts . containsKey ( a ) ) { counts . put ( a , 1 ) ; } else { counts . put ( a , counts . get ( a ) + 1 ) ; } } int first = 0 ; int second = 0 ; for ( Map . Entry < Integer , Integer > entry : counts . entrySet ( ) ) { int value = entry . getValue ( ) ; if ( value >= 4 ) { if ( first == 0 ) { first = entry . getKey ( ) ; } second = entry . getKey ( ) ; break ; } else if ( value >= 2 ) { if ( first == 0 ) { first = entry . getKey ( ) ; } else { second = entry . getKey ( ) ; break ; } } } System . out . println ( ( long ) first * second ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }",
"import java . util . * ; import java . lang . * ; class Pair implements Comparable < Pair > { long a ; int cnt ; public Pair ( long i , int j ) { this . a = i ; this . cnt = j ; } public int compareTo ( Pair p ) { if ( this . cnt >= 2 && p . cnt >= 2 && this . a < p . a ) return - 1 ; if ( this . cnt < 2 && p . cnt >= 2 ) return - 1 ; return 1 ; } } class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; HashMap < Long , Pair > map = new HashMap < > ( ) ; ArrayList < Pair > l = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { long c = Long . parseLong ( sc . next ( ) ) ; if ( ! map . containsKey ( c ) ) { Pair p = new Pair ( c , 1 ) ; map . put ( c , p ) ; l . add ( p ) ; } else { Pair p = map . get ( c ) ; p . cnt ++ ; } } Collections . sort ( l ) ; int size = l . size ( ) ; Pair p1 = l . get ( size - 1 ) ; Pair p2 = l . get ( size - 2 ) ; long res = 0 ; if ( p1 . cnt >= 4 ) res = p1 . a * p1 . a ; else if ( p1 . cnt >= 2 && p2 . cnt >= 2 ) res = p1 . a * p2 . a ; System . out . println ( res ) ; } }",
"import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; long edge1 = 0 , edge2 = 0 ; TreeMap < Long , Long > tm = new TreeMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; tm . put ( a [ i ] , tm . getOrDefault ( a [ i ] , 0l ) + 1 ) ; } while ( tm . size ( ) > 0 && edge1 == 0 ) { Map . Entry < Long , Long > temp = tm . pollLastEntry ( ) ; if ( temp . getValue ( ) > 1 ) { edge1 = temp . getKey ( ) ; tm . put ( temp . getKey ( ) , temp . getValue ( ) - 2 ) ; } } while ( tm . size ( ) > 0 && edge2 == 0 ) { Map . Entry < Long , Long > temp = tm . pollLastEntry ( ) ; if ( temp . getValue ( ) > 1 ) { edge2 = temp . getKey ( ) ; } } out . println ( edge1 * edge2 ) ; } }",
"import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { int N = sc . nextInt ( ) ; Map < Long , Integer > cnt = new HashMap < > ( ) ; Set < Long > set = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { long x = sc . nextLong ( ) ; int nowCnt = cnt . getOrDefault ( x , 0 ) ; nowCnt ++ ; cnt . put ( x , nowCnt ) ; set . add ( x ) ; } List < Long > sortList = new ArrayList < > ( set ) ; sortList . sort ( Long :: compareTo ) ; long ans = 0 ; List < Long > hen = new ArrayList < > ( ) ; for ( int i = sortList . size ( ) - 1 ; hen . size ( ) < 2 && i >= 0 ; i -- ) { long len = sortList . get ( i ) ; if ( cnt . get ( len ) >= 2 ) { hen . add ( len ) ; } if ( cnt . get ( len ) >= 4 ) { hen . add ( len ) ; } } if ( hen . size ( ) >= 2 ) { ans = hen . get ( 0 ) * hen . get ( 1 ) ; } System . out . println ( ans ) ; } } }"
] | [
"import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE c = collections . Counter ( a ) NEW_LINE key = list ( c . keys ( ) ) NEW_LINE key . sort ( reverse = True ) NEW_LINE count = 0 NEW_LINE for i in range ( len ( key ) ) : NEW_LINE INDENT if c [ key [ i ] ] >= 4 and count != 1 : NEW_LINE INDENT print ( key [ i ] ** 2 ) NEW_LINE exit ( ) NEW_LINE DEDENT if c [ key [ i ] ] >= 2 : NEW_LINE INDENT if count == 0 : NEW_LINE INDENT a = key [ i ] NEW_LINE count += 1 NEW_LINE DEDENT elif count == 1 : NEW_LINE INDENT b = key [ i ] NEW_LINE count += 1 NEW_LINE DEDENT DEDENT if count >= 2 : NEW_LINE INDENT print ( a * b ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( 0 ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE dic = { } NEW_LINE max1 , max2 = 0 , 0 NEW_LINE count = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ( A [ i ] in dic ) : NEW_LINE INDENT dic [ A [ i ] ] += 1 NEW_LINE if ( dic [ A [ i ] ] % 2 == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE if ( max1 < A [ i ] ) : NEW_LINE INDENT max2 = max1 NEW_LINE max1 = A [ i ] NEW_LINE DEDENT if ( A [ i ] < max1 ) : NEW_LINE INDENT max2 = max ( max2 , A [ i ] ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT dic [ A [ i ] ] = 1 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE if ( count >= 2 ) : NEW_LINE INDENT if ( dic [ max1 ] >= 4 ) : NEW_LINE INDENT ans = max1 * max1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = max1 * max2 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE A = [ int ( a ) for a in input ( ) . split ( ) ] NEW_LINE d = { } NEW_LINE for a in A : NEW_LINE INDENT d [ a ] = d . get ( a , 0 ) + 1 NEW_LINE DEDENT B = [ 0 , 0 ] NEW_LINE for k in d : NEW_LINE INDENT if d [ k ] >= 4 : NEW_LINE INDENT B . append ( k ) NEW_LINE B . append ( k ) NEW_LINE DEDENT elif d [ k ] >= 2 : NEW_LINE INDENT B . append ( k ) NEW_LINE DEDENT DEDENT B . sort ( ) NEW_LINE print ( B [ - 1 ] * B [ - 2 ] ) NEW_LINE",
"import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE N = int ( input ( ) ) NEW_LINE As = map ( int , input ( ) . split ( ) ) NEW_LINE c = Counter ( As ) NEW_LINE ans = [ ] NEW_LINE for k in reversed ( sorted ( c . keys ( ) ) ) : NEW_LINE INDENT v = c [ k ] NEW_LINE while v >= 2 : NEW_LINE INDENT ans . append ( k ) NEW_LINE v -= 2 NEW_LINE if len ( ans ) == 2 : NEW_LINE INDENT print ( ans [ 0 ] * ans [ 1 ] ) NEW_LINE sys . exit ( 0 ) NEW_LINE DEDENT DEDENT DEDENT print ( 0 ) NEW_LINE",
"from collections import Counter NEW_LINE import sys NEW_LINE h = w = index = 0 NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l = Counter ( a ) NEW_LINE l2 = sorted ( l . items ( ) , reverse = True ) NEW_LINE for i in range ( len ( l2 ) ) : NEW_LINE INDENT if l2 [ i ] [ 1 ] >= 2 : NEW_LINE INDENT if l2 [ i ] [ 1 ] >= 4 : NEW_LINE INDENT print ( l2 [ i ] [ 0 ] ** 2 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT w = l2 [ i ] [ 0 ] NEW_LINE index = i NEW_LINE break NEW_LINE DEDENT DEDENT for i in range ( index + 1 , len ( l2 ) ) : NEW_LINE INDENT if l2 [ i ] [ 1 ] >= 2 : NEW_LINE INDENT h = l2 [ i ] [ 0 ] NEW_LINE break NEW_LINE DEDENT DEDENT print ( h * w ) NEW_LINE"
] |
atcoder_arc014_C | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int r = 0 ; int g = 0 ; int b = 0 ; for ( char c : s . toCharArray ( ) ) { switch ( c ) { case ' R ' : r ++ ; break ; case ' G ' : g ++ ; break ; case ' B ' : b ++ ; break ; } } System . out . println ( r % 2 + g % 2 + b % 2 ) ; } }",
"import java . util . * ; import java . util . stream . Collectors ; public class Main { enum Color { R ( \" R \" ) , B ( \" B \" ) , G ( \" G \" ) ; public String name ; private Color ( String string ) { this . name = string ; } public static Color toEnum ( String string ) { if ( string . equals ( R . name ) ) { return R ; } else if ( string . equals ( B . name ) ) { return B ; } else { return G ; } } } public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; final int N = scanner . nextInt ( ) ; final String S = scanner . next ( ) ; Deque < Color > deque = new ArrayDeque < > ( ) ; String [ ] strings = S . split ( \" \" ) ; for ( int i = 0 ; i < N ; i ++ ) { Color ball = Color . toEnum ( strings [ i ] ) ; if ( deque . size ( ) == 0 ) { deque . addLast ( ball ) ; continue ; } if ( deque . size ( ) == 1 ) { Color ball1 = deque . getFirst ( ) ; if ( ball1 == ball ) { deque . removeFirst ( ) ; } else { deque . addLast ( ball ) ; } continue ; } Color ball1 = deque . getFirst ( ) ; Color ball2 = deque . getLast ( ) ; if ( ball == ball1 ) { deque . removeFirst ( ) ; continue ; } if ( ball == ball2 ) { deque . removeLast ( ) ; continue ; } if ( i == N - 1 ) { deque . addLast ( ball ) ; continue ; } Color nextBall = Color . toEnum ( strings [ i + 1 ] ) ; if ( ball == nextBall ) { deque . addLast ( ball ) ; continue ; } if ( ball1 == nextBall ) { deque . addLast ( ball ) ; } else if ( ball2 == nextBall ) { deque . addFirst ( ball ) ; } } System . out . println ( deque . size ( ) ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; char s [ ] = sc . next ( ) . toCharArray ( ) ; int [ ] num = new int [ 3 ] ; for ( int i = 0 ; i < N ; i ++ ) { switch ( s [ i ] ) { case ' R ' : num [ 0 ] ++ ; break ; case ' G ' : num [ 1 ] ++ ; break ; case ' B ' : num [ 2 ] ++ ; break ; } } int ans = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { ans += num [ i ] % 2 ; } System . out . println ( ans ) ; } }"
] | [
"print ( ( lambda n , l : sum ( [ l . count ( c ) % 2 for c in [ ' R ' , ' G ' , ' B ' ] ] ) ) ( input ( ) , input ( ) ) ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE slot = ' ' NEW_LINE for idx in range ( 0 , len ( S ) , 1 ) : NEW_LINE INDENT if len ( slot ) == 0 : NEW_LINE INDENT slot = S [ idx ] NEW_LINE DEDENT elif len ( slot ) == 1 : NEW_LINE INDENT slot = slot + S [ idx ] NEW_LINE if slot [ 0 ] == slot [ 1 ] : NEW_LINE INDENT slot = ' ' NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if S [ idx ] == slot [ 0 ] : NEW_LINE INDENT slot = slot [ 1 : len ( slot ) ] NEW_LINE DEDENT elif S [ idx ] == slot [ - 1 ] : NEW_LINE INDENT slot = slot [ 0 : len ( slot ) - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if idx == len ( S ) - 1 : NEW_LINE INDENT slot = slot + S [ idx ] NEW_LINE DEDENT else : NEW_LINE INDENT if S [ idx + 1 ] == slot [ 0 ] : NEW_LINE INDENT slot = slot + S [ idx ] NEW_LINE DEDENT else : NEW_LINE INDENT slot = S [ idx ] + slot NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( len ( slot ) ) 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 global S NEW_LINE N = input ( ) NEW_LINE S = input ( ) NEW_LINE r , g , b = S . count ( \" R \" ) , S . count ( \" G \" ) , S . count ( \" B \" ) NEW_LINE print ( r % 2 + g % 2 + b % 2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE beam_width = 3 * 10 ** 4 NEW_LINE next_set = { \" \" } NEW_LINE for c in S : NEW_LINE INDENT a = sorted ( next_set , key = len ) [ : beam_width ] NEW_LINE next_set = set ( ) NEW_LINE add = next_set . add NEW_LINE if a [ 0 ] == \" \" : NEW_LINE INDENT add ( c ) NEW_LINE a = a [ 1 : ] NEW_LINE DEDENT for s in a : NEW_LINE INDENT add ( c + s if c != s [ 0 ] else s [ 1 : ] ) NEW_LINE add ( s + c if c != s [ - 1 ] else s [ : - 1 ] ) NEW_LINE DEDENT DEDENT ss = sorted ( next_set , key = len ) NEW_LINE print ( len ( ss [ 0 ] ) ) NEW_LINE",
"from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE counter = Counter ( S ) NEW_LINE ans = 0 NEW_LINE ans += counter [ ' R ' ] % 2 NEW_LINE ans += counter [ ' G ' ] % 2 NEW_LINE ans += counter [ ' B ' ] % 2 NEW_LINE print ( ans ) NEW_LINE"
] |
atcoder_abc054_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; if ( a == b ) { System . out . println ( \" Draw \" ) ; } else if ( a == 1 ) { System . out . println ( \" Alice \" ) ; } else if ( b == 1 ) { System . out . println ( \" Bob \" ) ; } else if ( a > b ) { System . out . println ( \" Alice \" ) ; } else { System . out . println ( \" Bob \" ) ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; if ( A == B ) { out . println ( \" Draw \" ) ; } else if ( ( A > B || A == 1 ) && B != 1 ) { out . println ( \" Alice \" ) ; } else { out . println ( \" Bob \" ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A == 1 ) { A = 14 ; } if ( B == 1 ) { B = 14 ; } if ( A == B ) { System . out . println ( \" Draw \" ) ; } else if ( A > B ) { System . out . println ( \" Alice \" ) ; } else { System . out . println ( \" Bob \" ) ; } } }",
"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; if ( a == b ) { System . out . println ( \" Draw \" ) ; return ; } if ( a == 1 ) { a += 13 ; } if ( b == 1 ) { b += 13 ; } System . out . println ( a > b ? \" Alice \" : \" Bob \" ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A == 1 ) A = 14 ; if ( B == 1 ) B = 14 ; String ans ; if ( A > B ) { ans = \" Alice \" ; } else if ( A < B ) { ans = \" Bob \" ; } else { ans = \" Draw \" ; } System . out . print ( ans ) ; } }"
] | [
"a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a == b : print ( \" Draw \" ) NEW_LINE elif a == 1 : print ( \" Alice \" ) NEW_LINE elif b == 1 : print ( \" Bob \" ) NEW_LINE elif a > b : print ( \" Alice \" ) NEW_LINE else : print ( \" Bob \" ) NEW_LINE",
"from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a , b = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE if a == 1 : NEW_LINE INDENT a = 14 NEW_LINE DEDENT if b == 1 : NEW_LINE INDENT b = 14 NEW_LINE DEDENT if a > b : NEW_LINE INDENT ans = ' Alice ' NEW_LINE DEDENT elif a == b : NEW_LINE INDENT ans = ' Draw ' NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' Bob ' NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"A , B = map ( int , input ( ) . split ( ) ) NEW_LINE a = ( A - 2 ) % 13 NEW_LINE b = ( B - 2 ) % 13 NEW_LINE print ( ' Alice ' if a > b else ' Bob ' if a < b else ' Draw ' ) NEW_LINE",
"A , B = map ( int , input ( ) . split ( ) ) NEW_LINE cards = [ num for num in range ( 2 , 14 ) ] NEW_LINE cards . append ( 1 ) NEW_LINE for i in reversed ( cards ) : NEW_LINE INDENT if i == A and i == B : NEW_LINE INDENT print ( \" Draw \" ) NEW_LINE DEDENT elif i == A and i != B : NEW_LINE INDENT print ( \" Alice \" ) NEW_LINE break NEW_LINE DEDENT elif i == B and i != A : NEW_LINE INDENT print ( \" Bob \" ) NEW_LINE break NEW_LINE DEDENT DEDENT",
"a , b = ( ( int ( x ) - 2 ) % 100 for x in input ( ) . split ( ) ) NEW_LINE print ( ' Draw ' if a == b else ' Alice ' if a > b else ' Bob ' ) NEW_LINE"
] |
atcoder_arc026_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; if ( n >= 5 ) { ans = 5 * b + ( n - 5 ) * a ; } else { ans = n * b ; } System . out . println ( ans ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int d = Math . min ( 5 , n ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . println ( d * b + ( n - d ) * a ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( N <= 5 ) { pl ( B * N ) ; } else if ( N > 5 ) { pl ( ( B * 5 + ( N - 5 ) * A ) ) ; } } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }",
"import java . util . Scanner ; class Main { static int min ( int a , int b ) { if ( a > b ) return b ; else return a ; } static void solve ( ) { int n , sc , di ; Scanner cin = new Scanner ( System . in ) ; n = cin . nextInt ( ) ; sc = cin . nextInt ( ) ; di = cin . nextInt ( ) ; System . out . println ( ( min ( n , 5 ) * di ) + ( n - min ( n , 5 ) ) * sc ) ; } public static void main ( String args [ ] ) { solve ( ) ; } }",
"import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , a = sc . nextInt ( ) , b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i <= 5 ) ans += b ; else ans += a ; } out . println ( ans ) ; } }"
] | [
"N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( N - 5 ) * A + 5 * B if N > 5 else N * B ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if n <= 5 : NEW_LINE INDENT print ( n * b ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 5 * b + ( n - 5 ) * a ) NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( max ( 0 , ( N - 5 ) ) * A + B * min ( 5 , N ) ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE nb = min ( n , 5 ) NEW_LINE na = n - nb NEW_LINE r = b * nb + a * na NEW_LINE print ( r ) NEW_LINE DEDENT main ( ) NEW_LINE",
"N , A , B = map ( int , input ( ) . split ( \" β \" ) ) NEW_LINE c = 0 NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if c < 5 : NEW_LINE INDENT ans += B NEW_LINE c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans += A NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE"
] |
atcoder_arc072_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long x = in . nextLong ( ) , y = in . nextLong ( ) ; System . out . println ( Math . abs ( x - y ) <= 1 ? \" Brown \" : \" Alice \" ) ; } }",
"import java . io . IOException ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; long [ ] V = { sc . nextLong ( ) , sc . nextLong ( ) } ; Arrays . sort ( V ) ; if ( V [ 1 ] - V [ 0 ] > 1 ) { System . out . println ( \" Alice \" ) ; } else { System . out . println ( \" Brown \" ) ; } } int [ ] [ ] memo = new int [ 1000 ] [ 1000 ] ; boolean dfs ( int a , int b ) { if ( memo [ a ] [ b ] != 0 ) { return memo [ a ] [ b ] == 1 ; } boolean f = false ; for ( int i = 1 ; 2 * i <= a ; ++ i ) { f |= ! dfs ( a - i * 2 , b + i ) ; } for ( int i = 1 ; 2 * i <= b ; ++ i ) { f |= ! dfs ( a + i , b - 2 * i ) ; } if ( f ) { memo [ a ] [ b ] = 1 ; } else { memo [ a ] [ b ] = - 1 ; } return f ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }",
"import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; out . println ( Math . abs ( x - y ) <= 1 ? \" Brown \" : \" Alice \" ) ; out . close ( ) ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }",
"import java . util . * ; import java . io . * ; import static java . lang . Math . * ; import static java . util . Arrays . * ; import static java . util . Collections . * ; public class Main { static final long mod = 1000000007 ; public static void main ( String [ ] args ) throws Exception , IOException { Reader sc = new Reader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; out . println ( abs ( x - y ) <= 1 ? \" Brown \" : \" Alice \" ) ; out . flush ( ) ; } static void db ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } } class P implements Comparable < P > { int id , d ; P ( int id , int d ) { this . id = id ; this . d = d ; } public int compareTo ( P p ) { return d - p . d ; } } class Reader { private BufferedReader x ; private StringTokenizer st ; public Reader ( InputStream in ) { x = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; } public String nextString ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( x . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( nextString ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( nextString ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( nextString ( ) ) ; } }",
"import java . io . * ; import java . math . * ; import java . util . * ; public class Main { private static boolean debug = false ; private static boolean elapsed = false ; private static PrintWriter _out = new PrintWriter ( System . out ) ; private static PrintWriter _err = new PrintWriter ( System . err ) ; private void solve ( Scanner sc ) { long X = sc . nextLong ( ) ; long Y = sc . nextLong ( ) ; if ( Math . abs ( X - Y ) <= 1 ) { _out . println ( \" Brown \" ) ; } else { _out . println ( \" Alice \" ) ; } } private static BigInteger C ( long n , long r ) { BigInteger res = BigInteger . ONE ; for ( long i = n ; i > n - r ; -- i ) { res = res . multiply ( BigInteger . valueOf ( i ) ) ; } for ( long i = r ; i > 1 ; -- i ) { res = res . divide ( BigInteger . valueOf ( i ) ) ; } return res ; } private static BigInteger P ( long n , long r ) { BigInteger res = BigInteger . ONE ; for ( long i = n ; i > n - r ; -- i ) { res = res . multiply ( BigInteger . valueOf ( i ) ) ; } return res ; } public static void main ( String [ ] args ) { long S = System . currentTimeMillis ( ) ; Scanner sc = new Scanner ( System . in ) ; new Main ( ) . solve ( sc ) ; _out . flush ( ) ; long G = System . currentTimeMillis ( ) ; if ( elapsed ) { _err . println ( ( G - S ) + \" ms \" ) ; } _err . flush ( ) ; } }"
] | [
"a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ' Alice ' if abs ( a - b ) > 1 else ' Brown ' ) NEW_LINE",
"X , Y = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE cache = { } NEW_LINE def calc ( X , Y ) : NEW_LINE INDENT if X < Y : NEW_LINE INDENT X , Y = Y , X NEW_LINE DEDENT def cal ( X , Y ) : NEW_LINE INDENT if X <= 1 : NEW_LINE INDENT return False NEW_LINE DEDENT for n in range ( 1 , X // 2 + 1 ) : NEW_LINE INDENT if calc ( X - n * 2 , Y + n ) == False : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT for n in range ( 1 , Y // 2 + 1 ) : NEW_LINE INDENT if calc ( X + n , Y - n * 2 ) == False : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT k = ( X , Y ) NEW_LINE if k in cache : NEW_LINE INDENT return cache [ k ] NEW_LINE DEDENT r = cal ( X , Y ) NEW_LINE cache [ k ] = r NEW_LINE return r NEW_LINE DEDENT def calc1 ( X , Y ) : NEW_LINE INDENT if abs ( X - Y ) < 2 : NEW_LINE INDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT if calc1 ( X , Y ) : NEW_LINE INDENT print ( \" Alice \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Brown \" ) NEW_LINE DEDENT",
"import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE x , y = li ( ) NEW_LINE print ( \" Brown \" ) if abs ( x - y ) <= 1 else print ( \" Alice \" ) NEW_LINE",
"print ( [ ' Alice ' , ' Brown ' ] [ abs ( eval ( input ( ) . replace ( ' β ' , ' - ' ) ) ) < 2 ] ) NEW_LINE",
"x , y = map ( int , input ( ) . split ( ) ) NEW_LINE m = min ( x , y ) NEW_LINE x -= m NEW_LINE y -= m NEW_LINE if x == y : NEW_LINE INDENT print ( \" Brown \" ) NEW_LINE DEDENT else : NEW_LINE INDENT if max ( x , y ) == 1 : NEW_LINE INDENT print ( \" Brown \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Alice \" ) NEW_LINE DEDENT DEDENT"
] |
atcoder_arc033_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int total = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { int count = 1 ; count += N - i ; total += count ; } System . out . println ( total ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int a = sc . nextInt ( ) ; pl ( a * ( a + 1 ) / 2 ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }",
"import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { ans ++ ; } } out . println ( ans ) ; } }",
"import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) ; System . out . println ( n * ( n + 1 ) / 2 ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long ans = 0 ; for ( int i = n ; i >= 1 ; i -- ) { ans += i ; } System . out . println ( ans ) ; } }"
] | [
"n = int ( input ( ) ) ; print ( n * ( n + 1 ) // 2 ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE res = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( i , N ) : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE print ( n * ( n + 1 ) // 2 ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"N = int ( input ( ) ) NEW_LINE def factorical ( n ) : NEW_LINE INDENT ret = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT ret += i NEW_LINE DEDENT return ret NEW_LINE DEDENT print ( factorical ( N ) ) NEW_LINE",
"n = int ( input ( ) ) ; print ( n * - ~ n // 2 ) NEW_LINE"
] |
atcoder_abc105_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; final int K = sc . nextInt ( ) ; System . out . println ( N % K == 0 ? 0 : 1 ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; numK = scanner . nextInt ( ) ; if ( numN % numK == 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( 1 ) ; } } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }",
"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( n % k == 0 ) System . out . println ( 0 ) ; else System . out . println ( 1 ) ; } }",
"import java . io . BufferedWriter ; import java . io . IOException ; import java . io . OutputStreamWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; BufferedWriter bufferedWriter = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; int N = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int res ; if ( N % K == 0 ) res = 0 ; else res = 1 ; bufferedWriter . write ( Integer . toString ( res ) ) ; bufferedWriter . close ( ) ; scanner . close ( ) ; } }",
"public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( scanner . nextInt ( ) % scanner . nextInt ( ) == 0 ? 0 : 1 ) ; } }"
] | [
"N , K = map ( int , input ( ) . split ( ) ) NEW_LINE if N % K == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT",
"import numpy as np NEW_LINE class Calculator : NEW_LINE INDENT def __init__ ( self , N , K ) : NEW_LINE INDENT self . arr = np . array ( [ N , K ] ) NEW_LINE self . max_num = int ( ( self . arr [ 0 ] + self . arr [ 1 ] - 1 ) / self . arr [ 1 ] ) NEW_LINE self . min_num = int ( self . arr [ 0 ] / self . arr [ 1 ] ) NEW_LINE DEDENT def get_answer ( self ) : NEW_LINE INDENT return self . max_num - self . min_num NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N , K , = map ( int , input ( ) . split ( ) ) NEW_LINE c = Calculator ( N , K ) NEW_LINE ans = c . get_answer ( ) NEW_LINE print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"n , k = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE print ( 0 if n % k == 0 else 1 ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE if N % K == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"N , K = map ( int , input ( ) . split ( ) ) NEW_LINE print ( [ 0 , 1 ] [ 0 < N % K ] ) NEW_LINE"
] |
atcoder_abc042_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { int value = input . nextInt ( ) ; if ( value == 5 ) a ++ ; else if ( value == 7 ) b ++ ; } if ( a == 2 && b == 1 ) System . out . println ( \" YES \" ) ; else System . out . println ( \" NO \" ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; IrohaAndHaikuABCEdition solver = new IrohaAndHaikuABCEdition ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class IrohaAndHaikuABCEdition { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int array [ ] = { a , b , c } ; Arrays . sort ( array ) ; if ( array [ 0 ] == 5 && array [ 1 ] == 5 && array [ 2 ] == 7 ) out . println ( \" YES \" ) ; else out . println ( \" NO \" ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Map < Integer , Integer > seen = new HashMap < > ( ) ; for ( int ix = 0 ; ix < 3 ; ix ++ ) { int value = scanner . nextInt ( ) ; seen . put ( value , seen . getOrDefault ( value , 0 ) + 1 ) ; } boolean result = seen . containsKey ( 5 ) && seen . containsKey ( 7 ) && seen . get ( 5 ) == 2 && seen . get ( 7 ) == 1 ; System . out . println ( result ? \" YES \" : \" NO \" ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int SideA = keyboard . nextInt ( ) ; int SideB = keyboard . nextInt ( ) ; int SideC = keyboard . nextInt ( ) ; int [ ] arr = new int [ ] { SideA , SideB , SideC } ; Arrays . sort ( arr ) ; if ( arr [ 0 ] == 5 && arr [ 1 ] == 5 && arr [ 2 ] == 7 ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } keyboard . close ( ) ; } }",
"import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int [ ] input = new int [ 3 ] ; int fiveCount = 0 ; int sevenCount = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { input [ i ] = sc . nextInt ( ) ; if ( input [ i ] == 5 && fiveCount < 2 ) { fiveCount ++ ; } else if ( input [ i ] == 7 && sevenCount < 1 ) { sevenCount ++ ; } else { System . out . println ( \" NO \" ) ; return ; } } System . out . println ( \" YES \" ) ; } }"
] | [
"A = input ( ) . split ( ) NEW_LINE print ( \" YES \" if A . count ( \"5\" ) == 2 and A . count ( \"7\" ) == 1 else \" NO \" ) NEW_LINE",
"a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE arr = [ a , b , c ] NEW_LINE arr = sorted ( arr ) NEW_LINE if arr [ 0 ] == arr [ 1 ] == 5 and arr [ 2 ] == 7 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT",
"print ( \" YES \" ) if input ( ) in ( \"5 β 7 β 5\" , \"5 β 5 β 7\" , \"7 β 5 β 5\" ) else print ( \" NO \" ) NEW_LINE",
"a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = 0 NEW_LINE c = 0 NEW_LINE for i in a : NEW_LINE INDENT if i == 7 : NEW_LINE INDENT b += 1 NEW_LINE DEDENT elif i == 5 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT if b == 1 and c == 2 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT",
"from sys import stdin NEW_LINE a = stdin . readline ( ) . rstrip ( ) NEW_LINE a . count ( '5' ) NEW_LINE if a . count ( '5' ) == 2 : NEW_LINE INDENT print ( ' YES ' ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT"
] |
atcoder_abc058_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String po = sc . nextLine ( ) ; String popo = sc . nextLine ( ) ; for ( int i = 0 ; i < popo . length ( ) ; i ++ ) { System . out . print ( po . substring ( i , i + 1 ) + popo . substring ( i , i + 1 ) ) ; } System . out . println ( ( po . length ( ) == popo . length ( ) ) ? \" \" : po . substring ( po . length ( ) - 1 , po . length ( ) ) ) ; } }",
"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 O = in . next ( ) ; String E = in . next ( ) ; for ( int i = 0 ; i < E . length ( ) ; i ++ ) { out . print ( \" \" + O . charAt ( i ) + E . charAt ( i ) ) ; } if ( O . length ( ) > E . length ( ) ) { out . println ( \" \" + O . charAt ( O . length ( ) - 1 ) ) ; } else { 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 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 . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String o = input . readLine ( ) ; String e = input . readLine ( ) ; StringBuilder out = new StringBuilder ( ) ; for ( int i = 0 ; i < Math . max ( o . length ( ) , e . length ( ) ) ; i ++ ) { if ( i < o . length ( ) ) out . append ( o . charAt ( i ) ) ; if ( i < e . length ( ) ) out . append ( e . charAt ( i ) ) ; } System . out . println ( out ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String O = sc . next ( ) ; String E = sc . next ( ) ; int Olen = O . length ( ) ; int Elen = E . length ( ) ; for ( int i = 0 ; i < Elen ; i ++ ) { System . out . print ( O . charAt ( i ) ) ; System . out . print ( E . charAt ( i ) ) ; } if ( Olen > Elen ) System . out . print ( O . charAt ( Olen - 1 ) ) ; } }",
"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 ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { sb . append ( a . charAt ( i ) ) ; if ( b . length ( ) > i ) { sb . append ( b . charAt ( i ) ) ; } } System . out . println ( sb ) ; } }"
] | [
"O = input ( ) NEW_LINE E = input ( ) NEW_LINE if len ( O ) == len ( E ) : NEW_LINE INDENT for i in range ( len ( O ) ) : NEW_LINE INDENT print ( O [ i ] + E [ i ] , end = ' ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( len ( E ) ) : NEW_LINE INDENT print ( O [ i ] + E [ i ] , end = ' ' ) NEW_LINE DEDENT print ( O [ - 1 : ] ) NEW_LINE DEDENT",
"j = ' ' . join ; print ( j ( map ( j , zip ( * open ( 0 ) ) ) ) ) NEW_LINE",
"import sys NEW_LINE ni = lambda : int ( sys . stdin . readline ( ) . rstrip ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE o = list ( ns ( ) ) NEW_LINE e = list ( ns ( ) ) NEW_LINE ans = ' ' NEW_LINE for i in range ( len ( e ) ) : NEW_LINE INDENT ans += o [ i ] + e [ i ] NEW_LINE DEDENT if len ( o ) > len ( e ) : NEW_LINE INDENT ans += o [ - 1 ] NEW_LINE DEDENT print ( ans ) NEW_LINE",
"from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT O = list ( _ for _ in input ( ) ) NEW_LINE E = list ( _ for _ in input ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( len ( E ) ) : NEW_LINE INDENT ans . append ( O [ i ] ) NEW_LINE ans . append ( E [ i ] ) NEW_LINE DEDENT if ( len ( O ) > len ( E ) ) : NEW_LINE INDENT ans . append ( O [ - 1 ] ) NEW_LINE DEDENT print ( ' ' . join ( ans ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"O = input ( ) NEW_LINE E = input ( ) NEW_LINE res = \" \" NEW_LINE o_cnt = 0 NEW_LINE e_cnt = 0 NEW_LINE while True : NEW_LINE INDENT if o_cnt == len ( O ) and e_cnt == len ( E ) : NEW_LINE INDENT break NEW_LINE DEDENT if o_cnt < len ( O ) : NEW_LINE INDENT res += O [ o_cnt ] NEW_LINE o_cnt += 1 NEW_LINE DEDENT if e_cnt < len ( E ) : NEW_LINE INDENT res += E [ e_cnt ] NEW_LINE e_cnt += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE"
] |
atcoder_abc083_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( a + b > c + d ) { System . out . println ( \" Left \" ) ; } else if ( a + b < c + d ) { System . out . println ( \" Right \" ) ; } else { System . out . println ( \" Balanced \" ) ; } } }",
"import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { int l = in . nextInt ( ) + in . nextInt ( ) ; int r = in . nextInt ( ) + in . nextInt ( ) ; out . println ( l == r ? \" Balanced \" : l > r ? \" Left \" : \" Right \" ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( \" End β of β Input \" ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a , b , c , d ; a = Integer . parseInt ( sc . next ( ) ) ; b = Integer . parseInt ( sc . next ( ) ) ; c = Integer . parseInt ( sc . next ( ) ) ; d = Integer . parseInt ( sc . next ( ) ) ; int left = a + b ; int right = c + d ; if ( left > right ) { System . out . println ( \" Left \" ) ; } else if ( left < right ) { System . out . println ( \" Right \" ) ; } else { System . out . println ( \" Balanced \" ) ; } sc . close ( ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int L = A + B ; int R = C + D ; if ( L > R ) { System . out . println ( \" Left \" ) ; } else if ( L == R ) { System . out . println ( \" Balanced \" ) ; } else { System . out . println ( \" Right \" ) ; } } }",
"import java . util . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; String ans = ( a + b > c + d ) ? \" Left \" : ( a + b == c + d ) ? \" Balanced \" : \" Right \" ; System . out . println ( ans ) ; } }"
] | [
"a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE l = a + b NEW_LINE r = c + d NEW_LINE if l > r : NEW_LINE INDENT print ( \" Left \" ) NEW_LINE DEDENT elif l == r : NEW_LINE INDENT print ( \" Balanced \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Right \" ) NEW_LINE DEDENT",
"A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE left = A + B NEW_LINE right = C + D NEW_LINE if left > right : NEW_LINE INDENT print ( \" Left \" ) NEW_LINE DEDENT elif left < right : NEW_LINE INDENT print ( \" Right \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" Balanced \" ) NEW_LINE DEDENT",
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT a , b , c , d = map ( int , io ( ) . split ( ) ) NEW_LINE rets = [ ' Left ' , ' Balanced ' , ' Right ' ] NEW_LINE if a + b > c + d : NEW_LINE INDENT return rets [ 0 ] NEW_LINE DEDENT elif a + b < c + d : NEW_LINE INDENT return rets [ 2 ] NEW_LINE DEDENT else : NEW_LINE INDENT return rets [ 1 ] NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE print ( main ( io ) ) NEW_LINE DEDENT",
"A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE L , R = A + B , C + D NEW_LINE print ( [ \" Balanced \" , \" Left \" , \" Right \" ] [ ( R < L ) + - ( R > L ) ] ) NEW_LINE",
"W = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if ( sum ( W [ : 2 : ] ) > sum ( W [ 2 : : ] ) ) : NEW_LINE INDENT print ( ' Left ' ) NEW_LINE DEDENT elif ( sum ( W [ : 2 : ] ) < sum ( W [ 2 : : ] ) ) : NEW_LINE INDENT print ( ' Right ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Balanced ' ) NEW_LINE DEDENT"
] |
atcoder_abc001_D | [
"import java . util . * ; import java . io . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int N = Integer . parseInt ( br . readLine ( ) ) ; boolean [ ] rainTimes = new boolean [ 24 * 12 + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { String [ ] rainTime = br . readLine ( ) . split ( \" - \" ) ; int rainFrom = Integer . parseInt ( rainTime [ 0 ] ) ; int rainTo = Integer . parseInt ( rainTime [ 1 ] ) ; for ( int j = rainFrom / 100 * 12 + ( rainFrom % 100 ) / 5 ; j < rainTo / 100 * 12 + ( rainTo % 100 + 4 ) / 5 ; j ++ ) { rainTimes [ j ] = true ; } } for ( int i = 0 ; i < 24 * 12 ; i ++ ) { if ( ! rainTimes [ i ] ) continue ; System . out . print ( String . format ( \" % 02d % 02d - \" , i / 12 , i % 12 * 5 ) ) ; while ( i < 24 * 12 && rainTimes [ i ] && rainTimes [ i + 1 ] ) i ++ ; i ++ ; System . out . println ( String . format ( \" % 02d % 02d \" , i / 12 , i % 12 * 5 ) ) ; } } }",
"import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int [ ] range = new int [ ( 60 * 24 ) + 2 ] ; int m = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { String [ ] sp = sc . next ( ) . split ( \" - \" ) ; int s = timeToIntB ( sp [ 0 ] ) , e = timeToIntA ( sp [ 1 ] ) ; range [ s ] += 1 ; range [ e + 1 ] -= 1 ; } for ( int i = 1 ; i <= ( 60 * 24 ) ; i ++ ) { range [ i ] += range [ i - 1 ] ; } for ( int i = 0 ; i <= ( 60 * 24 ) ; i ++ ) { if ( range [ i ] > 0 ) { int s = i ; int e = i ; for ( ; i <= 60 * 24 && range [ i ] > 0 ; i ++ ) { e = i ; } System . out . println ( intToTime ( s ) + \" - \" + intToTime ( e ) ) ; } } } int timeToIntB ( String time ) { int h = Integer . parseInt ( time . substring ( 0 , 2 ) ) ; int m = Integer . parseInt ( time . substring ( 2 ) ) ; m = ( m / 5 ) * 5 ; return ( h * 60 + m ) ; } int timeToIntA ( String time ) { int h = Integer . parseInt ( time . substring ( 0 , 2 ) ) ; int m = Integer . parseInt ( time . substring ( 2 ) ) ; m = ( m + 4 ) / 5 * 5 ; return ( h * 60 + m ) ; } String intToTime ( int time ) { int h = ( time ) / 60 ; int m = ( time ) % 60 ; return String . format ( \" % 02d % 02d \" , h , m ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { int timeData = 0 ; int [ ] [ ] times = new int [ 289 ] [ 2 ] ; for ( int i = 0 ; i < 289 ; i ++ ) { times [ i ] [ 0 ] = timeData ; timeData += 5 ; if ( i != 0 && ( times [ i ] [ 0 ] % 100 ) == 55 ) timeData = ( timeData / 100 + 1 ) * 100 ; } Scanner sc = new Scanner ( System . in ) ; int inputCount = sc . nextInt ( ) ; for ( int i = 0 ; i < inputCount ; i ++ ) { String [ ] lainTime = sc . next ( ) . split ( \" - \" ) ; int from = Integer . valueOf ( lainTime [ 0 ] ) ; int to = Integer . valueOf ( lainTime [ 1 ] ) ; from = from - from % 5 ; for ( int j = 0 ; j < 289 ; j ++ ) { if ( times [ j ] [ 0 ] >= from && times [ j ] [ 0 ] < to ) times [ j ] [ 1 ] = 1 ; } } ArrayList < String > resultList = new ArrayList < > ( ) ; String result = \" \" ; boolean isContinue = false ; for ( int i = 0 ; i < times . length ; i ++ ) { if ( isContinue ) { if ( times [ i ] [ 1 ] == 0 ) { isContinue = false ; String intResult = \"0000\" + times [ i ] [ 0 ] ; result += \" - \" + intResult . substring ( intResult . length ( ) - 4 ) ; resultList . add ( result ) ; result = \" \" ; } } else { if ( times [ i ] [ 1 ] == 1 ) { isContinue = true ; result = \"0000\" + ( times [ i ] [ 0 ] ) ; result = result . substring ( result . length ( ) - 4 ) ; } } if ( isContinue && i == 288 ) { result += \" - 2400\" ; resultList . add ( result ) ; } } for ( String output : resultList ) { System . out . println ( output ) ; } } }",
"import static java . util . Comparator . * ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { static public void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int size = scan . nextInt ( ) ; List < String > list = new ArrayList < > ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { list . add ( scan . next ( ) ) ; } list . sort ( naturalOrder ( ) ) ; int start = 9999 ; int end = - 1 ; for ( String data : list ) { String [ ] record = data . split ( \" - \" ) ; int rainStart = Integer . parseInt ( record [ 0 ] ) ; int rainEnd = Integer . parseInt ( record [ 1 ] ) ; rainStart -= rainStart % 5 ; if ( rainEnd % 5 > 0 ) { rainEnd += 5 - rainEnd % 5 ; } if ( rainEnd % 100 == 60 ) { rainEnd += 40 ; } if ( rainStart > end ) { if ( start != 9999 ) { System . out . println ( String . format ( \" % 04d \" , start ) + \" - \" + String . format ( \" % 04d \" , end ) ) ; } start = rainStart ; end = - 1 ; } if ( end < rainEnd ) { end = rainEnd ; } } System . out . println ( String . format ( \" % 04d \" , start ) + \" - \" + String . format ( \" % 04d \" , end ) ) ; scan . close ( ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int plot [ ] = new int [ 1000 ] ; for ( int i = 0 ; i < plot . length ; i ++ ) { plot [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { String baseTime = sc . next ( ) ; String times [ ] = baseTime . split ( \" - \" ) ; int startTime = Integer . parseInt ( times [ 0 ] ) ; int endTime = Integer . parseInt ( times [ 1 ] ) ; int start = startTime - ( startTime % 5 ) ; int end = endTime + ( 5 - ( endTime % 5 ) == 5 ? 0 : 5 - ( endTime % 5 ) ) ; if ( end % 100 > 59 ) { end += 100 - 60 + ( end % 100 - 60 ) ; } int startIndex = start / 5 ; int endIndex = end / 5 ; for ( int j = startIndex ; j < endIndex ; j ++ ) { plot [ j ] = 1 ; } } boolean startFlag = false ; for ( int i = 0 ; i < plot . length ; i ++ ) { if ( ! startFlag ) { if ( plot [ i ] == 1 ) { System . out . print ( String . format ( \" % 04d \" , ( i * 5 ) ) + \" - \" ) ; startFlag = true ; } } else { if ( plot [ i ] == 0 ) { System . out . println ( String . format ( \" % 04d \" , ( i * 5 ) ) ) ; startFlag = false ; } } } } }"
] | [
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE n = int ( input ( ) ) NEW_LINE lis = [ list ( map ( int , input ( ) . rstrip ( ) . split ( ' - ' ) ) ) for _ in range ( n ) ] NEW_LINE lis . sort ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT lis [ i ] [ 0 ] = lis [ i ] [ 0 ] - lis [ i ] [ 0 ] % 5 NEW_LINE if ( lis [ i ] [ 1 ] % 5 != 0 ) : NEW_LINE INDENT lis [ i ] [ 1 ] = lis [ i ] [ 1 ] - lis [ i ] [ 1 ] % 5 + 5 NEW_LINE DEDENT tmp2 = lis [ i ] [ 1 ] / 100 NEW_LINE if ( tmp2 - int ( tmp2 ) > 0.59999 ) : NEW_LINE INDENT lis [ i ] [ 1 ] = ( int ( tmp2 ) + 1 ) * 100 NEW_LINE DEDENT if ( lis [ i ] [ 1 ] >= 2360 ) : NEW_LINE INDENT lis [ i ] [ 1 ] = 2400 NEW_LINE DEDENT DEDENT ans1 = [ lis [ 0 ] ] NEW_LINE aaaa = ans1 [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( aaaa [ 1 ] < lis [ i ] [ 0 ] ) : NEW_LINE INDENT ans1 . append ( lis [ i ] ) NEW_LINE aaaa = ans1 [ - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT if ( aaaa [ 1 ] < lis [ i ] [ 1 ] ) : NEW_LINE INDENT ans1 [ - 1 ] [ 1 ] = lis [ i ] [ 1 ] NEW_LINE DEDENT DEDENT DEDENT for i in range ( len ( ans1 ) ) : NEW_LINE INDENT start = str ( ans1 [ i ] [ 0 ] ) NEW_LINE end = str ( ans1 [ i ] [ 1 ] ) NEW_LINE print ( start . zfill ( 4 ) + ' - ' + end . zfill ( 4 ) ) NEW_LINE DEDENT",
"N = int ( input ( ) ) NEW_LINE def r_forward ( string ) : NEW_LINE INDENT return str ( int ( string ) - int ( string ) % 5 ) . zfill ( 4 ) NEW_LINE DEDENT def r_backward ( string ) : NEW_LINE INDENT ret = str ( int ( string ) + 4 - ( int ( string ) - 1 ) % 5 ) . zfill ( 4 ) NEW_LINE if ret [ 2 ] == \"6\" : NEW_LINE INDENT ret = ( str ( int ( ret [ : 2 ] ) + 1 ) + \"00\" ) . zfill ( 4 ) NEW_LINE DEDENT return ret NEW_LINE DEDENT time_lst = [ ] NEW_LINE for i in range ( 24 ) : NEW_LINE INDENT for j in range ( 12 ) : NEW_LINE INDENT time_lst . append ( str ( i ) . zfill ( 2 ) + str ( j * 5 ) . zfill ( 2 ) ) NEW_LINE DEDENT DEDENT time_lst . append ( \"2400\" ) NEW_LINE rained = [ list ( [ time , 0 ] ) for time in time_lst ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT st_ , end_ = input ( ) . split ( \" - \" ) NEW_LINE for idx in range ( time_lst . index ( r_forward ( st_ ) ) , time_lst . index ( r_backward ( end_ ) ) ) : NEW_LINE INDENT rained [ idx ] [ 1 ] = 1 NEW_LINE DEDENT DEDENT prev = 0 NEW_LINE for i , j in rained : NEW_LINE INDENT if prev == 0 and j == 1 : NEW_LINE INDENT st = i NEW_LINE DEDENT if prev == 1 and ( j == 0 or i == \"2400\" ) : NEW_LINE INDENT print ( \" { } - { } \" . format ( st , i ) ) NEW_LINE DEDENT prev = j NEW_LINE DEDENT",
"from sys import stdin NEW_LINE def my_round ( val , digit = 0 ) : NEW_LINE INDENT p = 10 ** digit NEW_LINE return ( val * p * 2 + 1 ) // 2 / p NEW_LINE DEDENT def rounded_time_before ( time ) : NEW_LINE INDENT tmp = int ( 10 * my_round ( time * 0.1 , 0 ) ) NEW_LINE if time < float ( tmp ) : NEW_LINE INDENT tmp -= 5 NEW_LINE DEDENT return tmp NEW_LINE DEDENT def rounded_time_after ( time ) : NEW_LINE INDENT if str ( time ) [ - 1 ] == \"5\" : NEW_LINE INDENT time -= 1 NEW_LINE DEDENT tmp = int ( 10 * my_round ( time * 0.1 , 0 ) ) NEW_LINE if time > float ( tmp ) : NEW_LINE INDENT tmp += 5 NEW_LINE DEDENT if str ( tmp ) [ - 2 : ] == \"60\" : NEW_LINE INDENT tmp += 40 NEW_LINE DEDENT return tmp NEW_LINE DEDENT N = int ( stdin . readline ( ) . rstrip ( ) ) NEW_LINE SE = [ list ( map ( int , stdin . readline ( ) . rstrip ( ) . split ( \" - \" ) ) ) for _ in range ( N ) ] NEW_LINE start , end = None , None NEW_LINE for before , after in sorted ( SE ) : NEW_LINE INDENT bf = int ( rounded_time_before ( before ) ) NEW_LINE af = int ( rounded_time_after ( after ) ) NEW_LINE if not start and not end : NEW_LINE INDENT start , end = bf , af NEW_LINE DEDENT if bf > end : NEW_LINE INDENT print ( \" { } - { } \" . format ( str ( start ) . zfill ( 4 ) , str ( end ) . zfill ( 4 ) ) ) NEW_LINE start , end = bf , af NEW_LINE DEDENT else : NEW_LINE INDENT if af > end : NEW_LINE INDENT end = af NEW_LINE DEDENT DEDENT DEDENT print ( \" { } - { } \" . format ( str ( start ) . zfill ( 4 ) , str ( end ) . zfill ( 4 ) ) ) NEW_LINE",
"def convert ( m , e = False ) : NEW_LINE INDENT if m % 5 == 0 : return m NEW_LINE else : NEW_LINE INDENT if e : return m + ( 5 - m % 5 ) NEW_LINE else : return m - ( m % 5 ) NEW_LINE DEDENT DEDENT blocks = [ False ] * 12 * 24 NEW_LINE n = int ( input ( ) ) NEW_LINE for _ in range ( n ) : NEW_LINE INDENT s , e = map ( int , input ( ) . split ( ' - ' ) ) NEW_LINE sb = int ( s / 100 ) * 12 + int ( convert ( s % 100 ) / 5 ) NEW_LINE eb = int ( e / 100 ) * 12 + int ( convert ( e % 100 , True ) / 5 ) NEW_LINE for a in range ( sb , eb ) : NEW_LINE INDENT blocks [ a ] = True NEW_LINE DEDENT DEDENT pb = False NEW_LINE for i , e in enumerate ( blocks ) : NEW_LINE INDENT if pb == False and e == True : NEW_LINE INDENT print ( ' % 02d % 02d - ' % ( i / 12 , 5 * ( i % 12 ) ) , end = ' ' ) NEW_LINE DEDENT elif pb == True and e == False : NEW_LINE INDENT print ( ' % 02d % 02d ' % ( i / 12 , 5 * ( i % 12 ) ) ) NEW_LINE DEDENT elif e == True and i == len ( blocks ) - 1 : NEW_LINE INDENT print ( '2400' ) NEW_LINE DEDENT pb = e NEW_LINE DEDENT",
"N = int ( input ( ) ) NEW_LINE imos = [ 0 for i in range ( 1443 ) ] NEW_LINE def mystart ( a_minute ) : NEW_LINE INDENT while ( 1 ) : NEW_LINE INDENT if a_minute % 5 == 0 : break NEW_LINE a_minute -= 1 NEW_LINE DEDENT return a_minute NEW_LINE DEDENT def myend ( a_minute ) : NEW_LINE INDENT while ( 1 ) : NEW_LINE INDENT if a_minute % 5 == 0 : break NEW_LINE a_minute += 1 NEW_LINE DEDENT return a_minute NEW_LINE DEDENT def output_time ( a_minute ) : NEW_LINE INDENT h = a_minute // 60 NEW_LINE h = ' % 02d ' % h NEW_LINE m = a_minute % 60 NEW_LINE m = ' % 02d ' % m NEW_LINE return h + m NEW_LINE DEDENT nums = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT time = [ t for t in input ( ) . split ( \" - \" ) ] NEW_LINE time = [ int ( t [ : 2 ] ) * 60 + int ( t [ 2 : ] ) for t in time ] NEW_LINE time = [ mystart ( time [ 0 ] ) , myend ( time [ 1 ] ) ] NEW_LINE nums . append ( time ) NEW_LINE DEDENT for n in nums : NEW_LINE INDENT imos [ n [ 0 ] ] += 1 NEW_LINE imos [ n [ 1 ] + 1 ] -= 1 NEW_LINE DEDENT ans = [ ] NEW_LINE j = 0 NEW_LINE for i in imos : NEW_LINE INDENT ans . append ( j + i ) NEW_LINE j += i NEW_LINE DEDENT start , end , flag = 0 , 0 , False NEW_LINE for i in range ( len ( ans ) ) : NEW_LINE INDENT if ans [ i ] == 0 and flag == False : continue NEW_LINE elif ans [ i ] == 0 and flag == True : NEW_LINE INDENT end = i NEW_LINE print ( output_time ( start ) + \" - \" + output_time ( end - 1 ) ) NEW_LINE start , end , flag = 0 , 0 , False NEW_LINE DEDENT elif ans [ i ] != 0 and flag == False : NEW_LINE INDENT start = i NEW_LINE flag = True NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT"
] |
atcoder_abc016_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; System . out . println ( ( a + b == n ) ? ( a - b == n ) ? \" ? \" : \" + \" : ( a - b == n ) ? \" - \" : \" ! \" ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; if ( A + B == C && A - B == C ) { out . println ( \" ? \" ) ; } else if ( A + B == C ) { out . println ( \" + \" ) ; } else if ( A - B == C ) { out . println ( \" - \" ) ; } else { 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 char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int state = 0 ; if ( n + m == l ) state += 1 ; if ( n - m == l ) state += 2 ; String ans = \" ! \" ; switch ( state ) { case 0 : break ; case 1 : ans = \" + \" ; break ; case 2 : ans = \" - \" ; break ; case 3 : ans = \" ? \" ; break ; } System . out . println ( ans ) ; } }",
"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] line = scanner . nextLine ( ) . split ( \" β \" , 3 ) ; int a = Integer . parseInt ( line [ 0 ] ) ; int b = Integer . parseInt ( line [ 1 ] ) ; int c = Integer . parseInt ( line [ 2 ] ) ; if ( a + b == c && a - b != c ) { System . out . println ( \" + \" ) ; } else if ( a + b != c && a - b == c ) { System . out . println ( \" - \" ) ; } else if ( a + b == c && a - b == c ) { System . out . println ( \" ? \" ) ; } else { System . out . println ( \" ! \" ) ; } } }",
"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } if ( a [ 0 ] + a [ 1 ] == a [ 2 ] && a [ 0 ] - a [ 1 ] == a [ 2 ] ) { System . out . println ( \" ? \" ) ; } else if ( a [ 0 ] + a [ 1 ] == a [ 2 ] ) { System . out . println ( \" + \" ) ; } else if ( a [ 0 ] - a [ 1 ] == a [ 2 ] ) { System . out . println ( \" - \" ) ; } else { System . out . println ( \" ! \" ) ; } } }"
] | [
"a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if a - b == c : NEW_LINE INDENT if a + b == c : NEW_LINE INDENT print ( \" ? \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" - \" ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if a + b == c : NEW_LINE INDENT print ( \" + \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" ! \" ) NEW_LINE DEDENT DEDENT",
"x , y , c = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE judge = 0 NEW_LINE if x + y == c : NEW_LINE INDENT judge += 2 NEW_LINE DEDENT if x - y == c : NEW_LINE INDENT judge -= 1 NEW_LINE DEDENT if judge == 2 : NEW_LINE INDENT print ( \" + \" ) NEW_LINE DEDENT elif judge == - 1 : NEW_LINE INDENT print ( \" - \" ) NEW_LINE DEDENT elif judge == 1 : NEW_LINE INDENT print ( \" ? \" ) NEW_LINE DEDENT elif judge == 0 : NEW_LINE INDENT print ( \" ! \" ) NEW_LINE DEDENT",
"[ a , b , c ] = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE if a + b != c and a - b != c : NEW_LINE INDENT print ( \" ! \" ) NEW_LINE DEDENT elif a + b != c : NEW_LINE INDENT print ( \" - \" ) NEW_LINE DEDENT elif a - b != c : NEW_LINE INDENT print ( \" + \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" ? \" ) NEW_LINE DEDENT",
"x , y , z = map ( int , input ( ) . split ( ) ) NEW_LINE print ( \" ? \" if x - y == z and x + y == z else \" + \" if x + y == z else \" - \" if x - y == z else \" ! \" ) NEW_LINE",
"A , B , C = map ( int , input ( ) . split ( ' β ' ) ) NEW_LINE if A + B == C : NEW_LINE INDENT if A - B != C : NEW_LINE INDENT print ( ' + ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' ? ' ) NEW_LINE DEDENT DEDENT elif A + B != C : NEW_LINE INDENT if A - B == C : NEW_LINE INDENT print ( ' - ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' ! ' ) NEW_LINE DEDENT DEDENT"
] |
atcoder_abc036_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int tmp = ( B - 1 ) / A ; System . out . println ( tmp + 1 ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; out . println ( B % A == 0 ? B / A : B / A + 1 ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int a = nextInt ( ) , b = nextInt ( ) ; out . println ( ( int ) Math . ceil ( ( double ) b / ( double ) a ) ) ; } }",
"import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int a = Integer . parseInt ( scan . next ( ) ) ; int b = Integer . parseInt ( scan . next ( ) ) ; int ans = 0 ; if ( b % a == 0 ) { ans = b / a ; } else if ( a > b ) { ans = 1 ; } else { ans = b / a + 1 ; } PrintWriter out = new PrintWriter ( System . out ) ; out . println ( ans ) ; out . flush ( ) ; scan . close ( ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double a = scan . nextInt ( ) ; double b = Integer . parseInt ( scan . next ( ) ) ; double box = b / a ; double calc = b % a ; int result = 0 ; if ( calc == 0 ) { result = ( int ) box ; System . out . println ( result ) ; } else { box = Math . ceil ( box ) ; result = ( int ) box ; System . out . println ( result ) ; } } }"
] | [
"a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( - ( - b // a ) ) NEW_LINE",
"from math import ceil NEW_LINE def tea ( A : int , B : int ) -> int : NEW_LINE INDENT return ceil ( B / A ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = tea ( A , B ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"A , B = map ( int , input ( ) . split ( ) ) NEW_LINE tmp = A NEW_LINE ansFlg = True NEW_LINE ans = 1 NEW_LINE while ansFlg : NEW_LINE INDENT if A >= B : NEW_LINE INDENT print ( ans ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT A += tmp NEW_LINE ans += 1 NEW_LINE DEDENT DEDENT",
"A , B = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE if ( B % A == 0 ) : NEW_LINE INDENT print ( int ( B / A ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( B / A ) + 1 ) NEW_LINE DEDENT",
"a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( b // a + ( b % a != 0 ) ) NEW_LINE"
] |
atcoder_abc027_D | [
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String S = sc . next ( ) ; sc . close ( ) ; int mNum = 0 ; for ( char c : S . toCharArray ( ) ) { if ( c == ' M ' ) mNum ++ ; } int [ ] m = new int [ mNum ] ; int at = S . length ( ) - 1 ; int current = 0 ; int mIndex = mNum - 1 ; while ( mIndex >= 0 ) { char c = S . charAt ( at ) ; if ( c == ' M ' ) { m [ mIndex ] = current ; mIndex -- ; } else if ( c == ' + ' ) { current ++ ; } else if ( c == ' - ' ) { current -- ; } at -- ; } Arrays . sort ( m ) ; int ans = 0 ; for ( int i = 0 ; i < mNum / 2 ; i ++ ) ans -= m [ i ] ; for ( int i = mNum / 2 ; i < mNum ; i ++ ) ans += m [ i ] ; System . out . println ( ans ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String S = sc . next ( ) ; sc . close ( ) ; int mNum = 0 ; for ( char c : S . toCharArray ( ) ) { if ( c == ' M ' ) mNum ++ ; } int [ ] m = new int [ mNum ] ; int at = S . length ( ) - 1 ; int current = 0 ; int mIndex = mNum - 1 ; while ( mIndex >= 0 ) { char c = S . charAt ( at ) ; if ( c == ' M ' ) { m [ mIndex ] = current ; mIndex -- ; } else if ( c == ' + ' ) { current ++ ; } else if ( c == ' - ' ) { current -- ; } at -- ; } Arrays . sort ( m ) ; int ans = 0 ; for ( int i = 0 ; i < mNum / 2 ; i ++ ) ans -= m [ i ] ; for ( int i = mNum / 2 ; i < mNum ; i ++ ) ans += m [ i ] ; System . out . println ( ans ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int m = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' M ' ) m ++ ; } int [ ] a = new int [ m ] ; int countp = 0 ; int countm = 0 ; int j = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == ' + ' ) countp ++ ; else if ( s . charAt ( i ) == ' - ' ) countm ++ ; else if ( s . charAt ( i ) == ' M ' ) { a [ j ++ ] = countp - countm ; } } Arrays . sort ( a ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { if ( i < m / 2 ) sum -= a [ i ] ; else sum += a [ i ] ; } System . out . println ( sum ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . StringTokenizer ; public class Main { char [ ] cs ; List < Integer > list ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; cs = sc . next ( ) . toCharArray ( ) ; solve ( ) ; } void solve ( ) { list = new ArrayList < > ( ) ; int plus = 0 ; int minus = 0 ; for ( int i = cs . length - 1 ; i >= 0 ; i -- ) { if ( cs [ i ] == ' + ' ) { plus ++ ; } else if ( cs [ i ] == ' - ' ) { minus ++ ; } else { list . add ( plus - minus ) ; } } Collections . sort ( list ) ; long ans = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( i * 2 < list . size ( ) ) { ans -= list . get ( i ) ; } else { ans += list . get ( i ) ; } } System . out . println ( ans ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }"
] | [
"S = input ( ) NEW_LINE p = 0 NEW_LINE m = 0 NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i ] == ' + ' : NEW_LINE INDENT p += 1 NEW_LINE DEDENT elif S [ i ] == ' - ' : NEW_LINE INDENT m += 1 NEW_LINE DEDENT DEDENT l = [ ] NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i ] == ' + ' : NEW_LINE INDENT p -= 1 NEW_LINE DEDENT elif S [ i ] == ' - ' : NEW_LINE INDENT m -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT l . append ( p - m ) NEW_LINE DEDENT DEDENT l . sort ( ) NEW_LINE ans = 0 NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if i <= len ( l ) / 2 - 1 : NEW_LINE INDENT ans -= l [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT ans += l [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"S = input ( ) NEW_LINE plus , minus = S . count ( \" + \" ) , S . count ( \" - \" ) NEW_LINE ans = [ ] NEW_LINE append = ans . append NEW_LINE for c in S : NEW_LINE INDENT if c == \" M \" : NEW_LINE INDENT append ( plus - minus ) NEW_LINE DEDENT elif c == \" + \" : NEW_LINE INDENT plus -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT minus -= 1 NEW_LINE DEDENT DEDENT ans . sort ( ) NEW_LINE print ( - sum ( ans [ : len ( ans ) // 2 ] ) + sum ( ans [ len ( ans ) // 2 : ] ) ) NEW_LINE",
"def robot ( S : str ) -> int : NEW_LINE INDENT N = len ( S ) NEW_LINE Sp , Sm = [ 0 ] * ( N + 1 ) , [ 0 ] * ( N + 1 ) NEW_LINE A = [ float ( ' inf ' ) ] * ( N + 1 ) NEW_LINE S = reversed ( S ) NEW_LINE M = 0 NEW_LINE for i , c in enumerate ( S ) : NEW_LINE INDENT Sp [ i + 1 ] , Sm [ i + 1 ] = Sp [ i ] , Sm [ i ] NEW_LINE if c == ' M ' : NEW_LINE INDENT M += 1 NEW_LINE A [ i + 1 ] = Sp [ i ] - Sm [ i ] NEW_LINE DEDENT elif c == ' + ' : NEW_LINE INDENT Sp [ i + 1 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT Sm [ i + 1 ] += 1 NEW_LINE DEDENT DEDENT A . sort ( ) NEW_LINE return sum ( A [ M // 2 : M ] ) - sum ( A [ : M // 2 ] ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT S = input ( ) NEW_LINE ans = robot ( S ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"from itertools import accumulate NEW_LINE S = input ( ) NEW_LINE N = len ( S ) NEW_LINE M_cnt = S . count ( ' M ' ) NEW_LINE cnt_plus = list ( accumulate ( [ ( 1 if s == ' + ' else 0 ) for s in S [ : : - 1 ] ] ) ) [ : : - 1 ] NEW_LINE cnt_minus = list ( accumulate ( [ ( 1 if s == ' - ' else 0 ) for s in S [ : : - 1 ] ] ) ) [ : : - 1 ] NEW_LINE p = [ ] NEW_LINE for i , s in enumerate ( S ) : NEW_LINE INDENT if s == ' M ' : NEW_LINE INDENT p . append ( cnt_plus [ i ] - cnt_minus [ i ] ) NEW_LINE DEDENT DEDENT p . sort ( ) NEW_LINE ans = sum ( p [ M_cnt // 2 : ] ) - sum ( p [ : M_cnt // 2 ] ) NEW_LINE print ( ans ) NEW_LINE",
"s = input ( ) NEW_LINE n = len ( s ) NEW_LINE a = [ [ 0 , 0 ] for i in range ( n ) ] NEW_LINE for i , j in enumerate ( s ) : NEW_LINE INDENT a [ i ] [ 0 ] += a [ i - 1 ] [ 0 ] NEW_LINE a [ i ] [ 1 ] += a [ i - 1 ] [ 1 ] NEW_LINE if j == \" + \" : NEW_LINE INDENT a [ i ] [ 0 ] += 1 NEW_LINE DEDENT if j == \" - \" : NEW_LINE INDENT a [ i ] [ 1 ] += 1 NEW_LINE DEDENT DEDENT b = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT b [ i ] = ( a [ - 1 ] [ 0 ] - a [ i ] [ 0 ] ) - ( a [ - 1 ] [ 1 ] - a [ i ] [ 1 ] ) NEW_LINE DEDENT ans = [ ] NEW_LINE for i , j in enumerate ( s ) : NEW_LINE INDENT if j == \" M \" : NEW_LINE INDENT ans . append ( b [ i ] ) NEW_LINE DEDENT DEDENT ans . sort ( ) NEW_LINE ans1 = ans [ : len ( ans ) // 2 ] NEW_LINE ans2 = ans [ len ( ans ) // 2 : ] NEW_LINE print ( sum ( ans2 ) - sum ( ans1 ) ) NEW_LINE"
] |
atcoder_abc078_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { String a = sc . next ( ) ; String b = sc . next ( ) ; char ach = a . charAt ( 0 ) ; char bch = b . charAt ( 0 ) ; if ( ach > bch ) { System . out . println ( \" > \" ) ; } else if ( ach < bch ) { System . out . println ( \" < \" ) ; } else { System . out . println ( \" = \" ) ; } } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { A ( ) ; } public static void A ( ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; if ( s1 . compareTo ( s2 ) < 0 ) System . out . println ( \" < \" ) ; else if ( s1 . compareTo ( s2 ) == 0 ) System . out . println ( \" = \" ) ; else System . out . println ( \" > \" ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String X = sc . next ( ) ; String Y = sc . next ( ) ; sc . close ( ) ; if ( X . equals ( Y ) ) { System . out . println ( \" = \" ) ; } else if ( X . compareTo ( Y ) < 0 ) { System . out . println ( \" < \" ) ; } else { System . out . println ( \" > \" ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; String y = sc . next ( ) ; byte [ ] x_byte = x . getBytes ( ) ; byte [ ] y_byte = y . getBytes ( ) ; if ( x_byte [ 0 ] > y_byte [ 0 ] ) { System . out . println ( \" > \" ) ; } else if ( x_byte [ 0 ] < y_byte [ 0 ] ) { System . out . println ( \" < \" ) ; } else { System . out . println ( \" = \" ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; char X = sc . next ( ) . charAt ( 0 ) ; char Y = sc . next ( ) . charAt ( 0 ) ; int num = X - Y ; System . out . println ( num < 0 ? \" < \" : ( num > 0 ) ? \" > \" : \" = \" ) ; } }"
] | [
"a , b = input ( ) . split ( ) NEW_LINE if a == b : NEW_LINE INDENT print ( \" = \" ) NEW_LINE DEDENT elif a < b : NEW_LINE INDENT print ( \" < \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" > \" ) NEW_LINE DEDENT",
"arr = { ' A ' : 0 , ' B ' : 1 , ' C ' : 2 , ' D ' : 3 , ' E ' : 4 , ' F ' : 5 } NEW_LINE x , y = map ( str , input ( ) . split ( ) ) NEW_LINE if arr [ x ] > arr [ y ] : NEW_LINE INDENT print ( ' > ' ) NEW_LINE DEDENT elif arr [ x ] < arr [ y ] : NEW_LINE INDENT print ( ' < ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' = ' ) NEW_LINE DEDENT",
"X , Y = input ( ) . split ( ) NEW_LINE print ( \" = < > \" [ ( X < Y ) + 2 * ( Y < X ) ] ) NEW_LINE",
"a , b = [ item for item in input ( ) . split ( ) ] NEW_LINE if a < b : NEW_LINE INDENT print ( \" < \" ) NEW_LINE DEDENT elif a > b : NEW_LINE INDENT print ( \" > \" ) NEW_LINE DEDENT elif a == b : NEW_LINE INDENT print ( \" = \" ) NEW_LINE DEDENT else : NEW_LINE INDENT pass NEW_LINE DEDENT",
"x , y = input ( ) . split ( ) ; print ( \" = \" if x == y else \" < > \" [ x > y : : 2 ] ) NEW_LINE"
] |
atcoder_abc115_D | [
"import java . util . Scanner ; public class Main { private static final long FIRST_SLICE_IS_BUN = 1 ; private static final long MIDDLE_PATTY = 1 ; public static long process ( TestCase testCase ) { final int N = testCase . N ; final long X = testCase . X ; return countNumPatty ( N , X ) ; } private static long countNumPatty ( int N , long X ) { if ( X == 0 ) { return 0L ; } final long burgerLength = burgerLength ( N ) ; boolean isWholeBurgerEaten = X >= burgerLength ; if ( isWholeBurgerEaten ) { return numPatty ( N ) ; } else { boolean isOnlyTopSliceRemaining = X == burgerLength - 1 ; final long oneSmallerLayerLength = burgerLength ( N - 1 ) ; final long oneSmallerLayerPatty = numPatty ( N - 1 ) ; if ( isOnlyTopSliceRemaining ) { return numPatty ( N ) ; } else { boolean canFinishHalfBurger = X >= ( burgerLength - FIRST_SLICE_IS_BUN - oneSmallerLayerLength ) ; if ( canFinishHalfBurger ) { return oneSmallerLayerPatty + MIDDLE_PATTY + countNumPatty ( N - 1 , X - FIRST_SLICE_IS_BUN - oneSmallerLayerLength - MIDDLE_PATTY ) ; } else { boolean canFinishOneSmallerLayer = ( X - FIRST_SLICE_IS_BUN ) >= ( FIRST_SLICE_IS_BUN + oneSmallerLayerLength ) ; if ( canFinishOneSmallerLayer ) { return oneSmallerLayerPatty ; } else { boolean canEatSomePatty = X > FIRST_SLICE_IS_BUN ; if ( canEatSomePatty ) { return countNumPatty ( N - 1 , X - FIRST_SLICE_IS_BUN ) ; } else { return 0L ; } } } } } } private static long burgerLength ( int layer ) { return ( long ) Math . pow ( 2 , layer + 2 ) - 3L ; } private static long numPatty ( int layer ) { return ( long ) Math . pow ( 2 , layer + 1 ) - 1L ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final long result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long X = sc . nextLong ( ) ; sc . close ( ) ; return new TestCase ( N , X ) ; } private static void output ( long result ) { System . out . println ( result ) ; } public static class TestCase { final int N ; final long X ; public TestCase ( int N , long X ) { this . N = N ; this . X = 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 ) ; int n = sc . nextInt ( ) ; long x = sc . nextLong ( ) ; long [ ] a = new long [ 51 ] ; a [ 0 ] = 1 ; long [ ] p = new long [ 51 ] ; p [ 0 ] = 1 ; for ( int i = 0 ; i < 50 ; i ++ ) { a [ i + 1 ] = 2 * a [ i ] + 3 ; p [ i + 1 ] = 2 * p [ i ] + 1 ; } out . println ( f ( a , p , n , x ) ) ; } static long f ( long [ ] a , long [ ] p , int n , long x ) { if ( x == 1 ) return n > 0 ? 0 : 1 ; if ( x == 3 + 2 * a [ n - 1 ] ) return p [ n - 1 ] * 2 + 1 ; if ( x == a [ n - 1 ] + 2 ) return p [ n - 1 ] + 1 ; if ( 1 < x && x <= a [ n - 1 ] + 1 ) return f ( a , p , n - 1 , x - 1 ) ; return p [ n - 1 ] + 1 + f ( a , p , n - 1 , x - a [ n - 1 ] - 2 ) ; } }",
"import java . util . * ; public class Main { static class Burger { public static long getNumPatties ( int level ) { return pow ( 2 , level + 1 ) - 1 ; } public static long getHeight ( int level ) { return pow ( 2 , level + 2 ) - 3 ; } static long pow ( int a , int b ) { long product = 1 ; while ( b > 0 ) { product *= a ; b -- ; } return product ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long X = sc . nextLong ( ) ; System . out . println ( countPatties ( N , X ) ) ; } public static long countPatties ( int level , long x ) { if ( x == 0 ) { return 0 ; } else if ( level == 0 ) { return 1 ; } else if ( x >= Burger . getHeight ( level ) - level ) { return Burger . getNumPatties ( level ) ; } if ( x < Burger . getHeight ( level - 1 ) + 2 ) { return countPatties ( level - 1 , x - 1 ) ; } else { return Burger . getNumPatties ( level - 1 ) + 1 + countPatties ( level - 1 , x - Burger . getHeight ( level - 1 ) - 2 ) ; } } }",
"import java . util . * ; import java . io . * ; public class Main { private static void solve ( ) { int n = nextInt ( ) ; long x = nextLong ( ) ; long [ ] l = new long [ n + 1 ] ; long [ ] p = new long [ n + 1 ] ; l [ 0 ] = 1 ; p [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { l [ i ] = 2 * l [ i - 1 ] + 3 ; p [ i ] = 2 * p [ i - 1 ] + 1 ; } System . out . println ( get ( n , x , l , p ) ) ; } private static long get ( int n , long x , long [ ] l , long [ ] p ) { if ( n == 0 ) { return 1 ; } if ( x == 1 ) { return 0 ; } x -- ; if ( x <= l [ n - 1 ] ) { return get ( n - 1 , x , l , p ) ; } x -= l [ n - 1 ] ; if ( x == 1 ) { return p [ n - 1 ] + 1 ; } x -- ; if ( x == l [ n - 1 ] + 1 ) { x -- ; } return p [ n - 1 ] + 1 + get ( n - 1 , x , l , p ) ; } private static void run ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; solve ( ) ; out . close ( ) ; } private static StringTokenizer st ; private static BufferedReader br ; private static PrintWriter out ; private static String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { String s ; try { s = br . readLine ( ) ; } catch ( IOException e ) { return null ; } st = new StringTokenizer ( s ) ; } return st . nextToken ( ) ; } private static int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } private static long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public static void main ( String [ ] args ) { run ( ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int N = scanner . nextInt ( ) ; long X = scanner . nextLong ( ) ; long [ ] as = new long [ N ] ; long [ ] ps = new long [ N ] ; as [ 0 ] = 1 ; ps [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { as [ i ] = as [ i - 1 ] * 2 + 3 ; ps [ i ] = ps [ i - 1 ] * 2 + 1 ; } System . out . println ( f ( N , X , as , ps ) ) ; } } static long f ( int n , long x , long [ ] a , long [ ] p ) { if ( n == 0 ) { return x > 0 ? 1 : 0 ; } long anp = a [ n - 1 ] ; long pnp = p [ n - 1 ] ; if ( x <= anp + 1 ) { return f ( n - 1 , x - 1 , a , p ) ; } if ( x == x + anp ) { return pnp ; } if ( x <= 2 * anp + 2 ) { return pnp + 1 + f ( n - 1 , x - anp - 2 , a , p ) ; } return 2 * pnp + 1 ; } static class Pair { final int kind ; final long point ; Pair ( int kind , long point ) { this . kind = kind ; this . point = point ; } } }"
] | [
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE N , X = map ( int , input ( ) . split ( ) ) NEW_LINE b = [ 2 ** ( i + 2 ) - 3 for i in range ( N ) ] NEW_LINE p = [ 2 ** ( i + 1 ) - 1 for i in range ( N ) ] NEW_LINE def f ( N , X ) : NEW_LINE INDENT if N == 0 : NEW_LINE INDENT return 0 if X <= 0 else 1 NEW_LINE DEDENT elif X <= 1 + b [ N - 1 ] : NEW_LINE INDENT return f ( N - 1 , X - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT return p [ N - 1 ] + 1 + f ( N - 1 , X - 2 - b [ N - 1 ] ) NEW_LINE DEDENT DEDENT print ( f ( N , X ) ) NEW_LINE",
"ans = 0 NEW_LINE def count_ans ( level , index , len_dic , p_dic ) : NEW_LINE INDENT global ans NEW_LINE if level == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if index == 0 : NEW_LINE INDENT pass NEW_LINE DEDENT elif index == len_dic [ level ] // 2 : NEW_LINE INDENT ans += 1 NEW_LINE ans += p_dic [ level - 1 ] NEW_LINE DEDENT elif index == len_dic [ level ] - 1 : NEW_LINE INDENT ans += p_dic [ level ] NEW_LINE DEDENT elif index > len_dic [ level ] // 2 : NEW_LINE INDENT ans += p_dic [ level - 1 ] + 1 NEW_LINE index_next = index - len_dic [ level - 1 ] - 2 NEW_LINE count_ans ( level - 1 , index_next , len_dic , p_dic ) NEW_LINE DEDENT else : NEW_LINE INDENT index_next = index - 1 NEW_LINE count_ans ( level - 1 , index_next , len_dic , p_dic ) NEW_LINE DEDENT DEDENT DEDENT def get_len_dic ( level ) : NEW_LINE INDENT len_dic = [ 1 ] NEW_LINE for i in range ( level ) : NEW_LINE INDENT len_dic . append ( len_dic [ - 1 ] * 2 + 3 ) NEW_LINE DEDENT return len_dic NEW_LINE DEDENT def get_p_dic ( level ) : NEW_LINE INDENT p_dic = [ 1 ] NEW_LINE for i in range ( level ) : NEW_LINE INDENT p_dic . append ( p_dic [ - 1 ] * 2 + 1 ) NEW_LINE DEDENT return p_dic NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT global ans NEW_LINE level , eat_num = map ( int , input ( ) . split ( ) ) NEW_LINE len_dic = get_len_dic ( level ) NEW_LINE p_dic = get_p_dic ( level ) NEW_LINE count_ans ( level , eat_num - 1 , len_dic , p_dic ) NEW_LINE print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"nums = [ 0 ] * 51 NEW_LINE ps = [ 0 ] * 51 NEW_LINE def calc ( l , x ) : NEW_LINE INDENT global nums , ps NEW_LINE if l == 0 : NEW_LINE INDENT if x == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT if x == 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif x <= 1 + nums [ l - 1 ] : NEW_LINE INDENT return calc ( l - 1 , x - 1 ) NEW_LINE DEDENT elif x == 2 + nums [ l - 1 ] : NEW_LINE INDENT return ps [ l - 1 ] + 1 NEW_LINE DEDENT elif x <= 2 + 2 * nums [ l - 1 ] : NEW_LINE INDENT return ps [ l - 1 ] + 1 + calc ( l - 1 , x - 2 - nums [ l - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT return ps [ l ] NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT global nums , ps NEW_LINE nums [ 0 ] = 1 NEW_LINE ps [ 0 ] = 1 NEW_LINE for i in range ( len ( nums ) ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT nums [ i ] = 2 * nums [ i - 1 ] + 3 NEW_LINE ps [ i ] = 2 * ps [ i - 1 ] + 1 NEW_LINE DEDENT n , x = map ( int , input ( ) . split ( ) ) NEW_LINE print ( calc ( n , x ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"burger = [ 1 for i in range ( 52 ) ] NEW_LINE for i in range ( 1 , 52 ) : NEW_LINE INDENT burger [ i ] = burger [ i - 1 ] * 2 + 3 NEW_LINE DEDENT patty = [ 1 for i in range ( 52 ) ] NEW_LINE for i in range ( 1 , 52 ) : NEW_LINE INDENT patty [ i ] = patty [ i - 1 ] * 2 + 1 NEW_LINE DEDENT def solve ( L , X ) : NEW_LINE INDENT if X == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT if burger [ L ] == X : NEW_LINE INDENT return patty [ L ] NEW_LINE DEDENT elif ( burger [ L ] - 1 ) // 2 + 1 == X : NEW_LINE INDENT return patty [ L - 1 ] + 1 NEW_LINE DEDENT elif ( burger [ L ] - 1 ) // 2 + 1 > X : NEW_LINE INDENT return solve ( L - 1 , X - 1 ) NEW_LINE DEDENT elif ( burger [ L ] - 1 ) // 2 + 1 < X : NEW_LINE INDENT return patty [ L - 1 ] + 1 + solve ( L - 1 , X - burger [ L - 1 ] - 2 ) NEW_LINE DEDENT DEDENT N , X = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( solve ( N , X ) ) NEW_LINE",
"N , X = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE layers = { 0 : 1 } NEW_LINE def layers_of_level ( n ) : NEW_LINE INDENT if n in layers : NEW_LINE INDENT return layers [ n ] NEW_LINE DEDENT layers [ n ] = 2 * layers_of_level ( n - 1 ) + 3 NEW_LINE return layers [ n ] NEW_LINE DEDENT def how_many_putty ( n , x ) : NEW_LINE INDENT if n == 0 and x == 1 : NEW_LINE INDENT return 1 NEW_LINE DEDENT if n == layers_of_level ( n ) : NEW_LINE INDENT return 2 ** ( n + 1 ) - 1 NEW_LINE DEDENT total_layers = layers_of_level ( n ) NEW_LINE if x == 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT if x <= 1 + layers_of_level ( n - 1 ) : NEW_LINE INDENT return how_many_putty ( n - 1 , x - 1 ) NEW_LINE DEDENT if x == 1 + layers_of_level ( n - 1 ) + 1 : NEW_LINE INDENT return how_many_putty ( n - 1 , x - 2 ) + 1 NEW_LINE DEDENT if x <= 1 + 2 * layers_of_level ( n - 1 ) + 1 : NEW_LINE INDENT return how_many_putty ( n - 1 , layers_of_level ( n - 1 ) ) + 1 + how_many_putty ( n - 1 , x - layers_of_level ( n - 1 ) - 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT return 2 * how_many_putty ( n - 1 , layers_of_level ( n - 1 ) ) + 1 NEW_LINE DEDENT DEDENT print ( how_many_putty ( N , X ) ) NEW_LINE"
] |
atcoder_agc001_D | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; ArrayList < Integer > odd = new ArrayList < > ( ) ; ArrayList < Integer > even = new ArrayList < > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int A = sc . nextInt ( ) ; if ( A % 2 == 0 ) even . add ( A ) ; else odd . add ( A ) ; } if ( odd . size ( ) > 2 ) { System . out . println ( \" Impossible \" ) ; } else { ArrayList < Integer > list = new ArrayList < > ( ) ; if ( odd . size ( ) > 0 ) list . add ( odd . get ( 0 ) ) ; list . addAll ( even ) ; if ( odd . size ( ) > 1 ) list . add ( odd . get ( 1 ) ) ; printList ( list ) ; if ( list . size ( ) == 1 ) { if ( list . get ( 0 ) > 1 ) { list . set ( 0 , list . get ( 0 ) - 1 ) ; list . add ( 1 ) ; } } else { list . set ( 0 , list . get ( 0 ) - 1 ) ; list . set ( list . size ( ) - 1 , list . get ( list . size ( ) - 1 ) - 1 ) ; list . add ( 1 , 2 ) ; if ( list . get ( 0 ) == 0 ) list . remove ( 0 ) ; if ( list . get ( list . size ( ) - 1 ) == 0 ) list . remove ( list . size ( ) - 1 ) ; } System . out . println ( list . size ( ) ) ; printList ( list ) ; } sc . close ( ) ; } static void printList ( ArrayList < Integer > list ) { for ( int i = 0 ; i < list . size ( ) ; i ++ ) System . out . print ( list . get ( i ) + ( i == list . size ( ) - 1 ? \" \\n \" : \" β \" ) ) ; } }",
"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; List < Integer > odd = new ArrayList < > ( ) ; List < Integer > even = new ArrayList < > ( ) ; for ( int i = 0 ; i < M ; ++ i ) { int a = scan . nextInt ( ) ; if ( a % 2 == 0 ) even . add ( a ) ; else odd . add ( a ) ; } if ( odd . size ( ) > 2 ) { System . out . println ( \" Impossible \" ) ; return ; } List < Integer > ans = new ArrayList < > ( ) ; if ( odd . size ( ) >= 1 ) { int d = odd . remove ( 0 ) ; System . out . print ( d + \" β \" ) ; while ( d > 1 ) { ans . add ( 2 ) ; d -= 2 ; } } else { int d = even . remove ( 0 ) ; System . out . print ( d + \" β \" ) ; ans . add ( d - 1 ) ; } for ( int i = 0 ; i < even . size ( ) ; ++ i ) { ans . add ( even . get ( i ) ) ; System . out . print ( even . get ( i ) + \" β \" ) ; } if ( odd . size ( ) >= 1 ) { int d = odd . remove ( 0 ) ; System . out . print ( d + \" β \" ) ; while ( d > 0 ) { ans . add ( 2 ) ; d -= 2 ; } } else { ans . add ( 1 ) ; } System . out . println ( ) ; System . out . println ( ans . size ( ) ) ; for ( int i : ans ) System . out . print ( i + \" β \" ) ; System . out . println ( ) ; } }"
] | [
"n , m = map ( int , input ( ) . split ( ) ) NEW_LINE ali = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if m == 1 and ali [ 0 ] == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE print ( 1 ) NEW_LINE print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT if m == 1 : NEW_LINE INDENT print ( ali [ 0 ] ) NEW_LINE print ( 2 ) NEW_LINE print ( ali [ 0 ] - 1 , 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT flag = 0 NEW_LINE c = [ ] NEW_LINE for a in ali : NEW_LINE INDENT if a % 2 == 1 : NEW_LINE INDENT if flag == 0 : NEW_LINE INDENT lm = a NEW_LINE flag += 1 NEW_LINE DEDENT elif flag == 1 : NEW_LINE INDENT rm = a NEW_LINE flag += 1 NEW_LINE DEDENT elif flag == 2 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT c . append ( a ) NEW_LINE DEDENT DEDENT if flag == 0 : NEW_LINE INDENT lm = c [ 0 ] NEW_LINE del c [ 0 ] NEW_LINE rm = c . pop ( ) NEW_LINE DEDENT if flag == 1 : NEW_LINE INDENT rm = c . pop ( ) NEW_LINE DEDENT b = [ lm + 1 ] + c NEW_LINE d = [ lm ] + c + [ rm ] NEW_LINE if rm > 1 : NEW_LINE INDENT b . append ( rm - 1 ) NEW_LINE DEDENT print ( \" β \" . join ( map ( str , d ) ) ) NEW_LINE print ( len ( b ) ) NEW_LINE print ( \" β \" . join ( map ( str , b ) ) ) NEW_LINE",
"S , N = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE O = [ a for a in A if a % 2 == 1 ] NEW_LINE E = [ a for a in A if a % 2 == 0 ] NEW_LINE if len ( O ) > 2 : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE DEDENT else : NEW_LINE INDENT A = O [ : min ( len ( O ) , 1 ) ] + E + O [ 1 : ] NEW_LINE B = A [ : ] + ( [ 0 ] if N == 1 else [ ] ) NEW_LINE B [ 0 ] -= 1 NEW_LINE B [ - 1 ] += 1 NEW_LINE if B [ 0 ] == 0 : NEW_LINE INDENT B = B [ 1 : ] NEW_LINE DEDENT print ( * A , sep = \" β \" ) NEW_LINE print ( len ( B ) ) NEW_LINE print ( * B , sep = \" β \" ) NEW_LINE DEDENT",
"S , N = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE O = [ a for a in A if a % 2 == 1 ] NEW_LINE E = [ a for a in A if a % 2 == 0 ] NEW_LINE if len ( O ) > 2 : NEW_LINE INDENT print ( \" Impossible \" ) NEW_LINE DEDENT else : NEW_LINE INDENT A = O [ : min ( len ( O ) , 1 ) ] + E + O [ min ( 1 , len ( O ) ) : ] NEW_LINE B = A [ : ] + ( [ 0 ] if len ( A ) == 1 else [ ] ) NEW_LINE B [ 0 ] -= 1 NEW_LINE B [ - 1 ] += 1 NEW_LINE if B [ 0 ] == 0 : NEW_LINE INDENT B = B [ 1 : ] NEW_LINE DEDENT print ( \" β \" . join ( str ( a ) for a in A ) ) NEW_LINE print ( len ( B ) ) NEW_LINE print ( \" β \" . join ( str ( b ) for b in B ) ) NEW_LINE DEDENT",
"def solve ( n , m , a ) : NEW_LINE INDENT odd = [ ] NEW_LINE even = [ ] NEW_LINE for a_i in a : NEW_LINE INDENT if a_i % 2 == 0 : NEW_LINE INDENT even += [ a_i ] NEW_LINE DEDENT else : NEW_LINE INDENT odd += [ a_i ] NEW_LINE DEDENT DEDENT if len ( odd ) >= 3 : NEW_LINE INDENT return None NEW_LINE DEDENT a , b = [ ] , [ ] NEW_LINE if odd : NEW_LINE INDENT x = odd . pop ( ) NEW_LINE a += [ x ] NEW_LINE b += [ x - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT x = even . pop ( ) NEW_LINE a += [ x ] NEW_LINE b += [ x - 1 ] NEW_LINE DEDENT a += even NEW_LINE b += even NEW_LINE if odd : NEW_LINE INDENT x = odd . pop ( ) NEW_LINE a += [ x ] NEW_LINE b += [ x + 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT b += [ 1 ] NEW_LINE DEDENT return a , b NEW_LINE DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE it = solve ( n , m , a ) NEW_LINE if it is None : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE DEDENT else : NEW_LINE INDENT a , b = it NEW_LINE b = list ( filter ( lambda b_i : b_i , b ) ) NEW_LINE print ( * a ) NEW_LINE print ( len ( b ) ) NEW_LINE print ( * b ) NEW_LINE DEDENT"
] |
atcoder_abc099_C | [
"import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int ans = Integer . MAX_VALUE ; int s1 = n / 6 , s2 = n / 9 ; int [ ] TS = new int [ n + 1 ] ; int [ ] TN = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { int temp = i ; while ( temp / 6 > 0 ) { TS [ i ] += temp % 6 ; temp /= 6 ; } TS [ i ] += temp ; temp = i ; while ( temp / 9 > 0 ) { TN [ i ] += temp % 9 ; temp /= 9 ; } TN [ i ] += temp ; } for ( int i = 0 ; i <= s1 ; i ++ ) { int six = 6 * i ; int nine = ( n - six ) - ( n - six ) % 9 ; if ( six + nine <= n && six <= n && nine <= n ) ans = min ( ans , TS [ six ] + TN [ nine ] + ( n - six - nine ) ) ; } out . println ( ans ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int count = n ; for ( int i = 0 ; i <= n ; i ++ ) { int t = i ; int c = 0 ; while ( t > 0 ) { c += t % 6 ; t /= 6 ; } t = n - i ; while ( t > 0 ) { c += t % 9 ; t /= 9 ; } count = Math . min ( count , c ) ; } System . out . println ( count ) ; } }",
"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 ( ) ; Set < Integer > candidates = new TreeSet < > ( ) ; long tmp = 1 ; while ( tmp <= N ) { candidates . add ( ( int ) tmp ) ; tmp *= 6 ; } tmp = 1 ; while ( tmp <= N ) { candidates . add ( ( int ) tmp ) ; tmp *= 9 ; } int INF = 1_000_000 ; int dp [ ] = new int [ N + 1 ] ; Arrays . fill ( dp , INF ) ; dp [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int n : candidates ) { if ( i >= n ) { dp [ i ] = Math . min ( dp [ i ] , dp [ i - n ] + 1 ) ; } } } out . println ( dp [ N ] ) ; } }",
"import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static int [ ] dp = new int [ 0 ] ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; dp = new int [ N + 1 ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; dp [ 0 ] = 0 ; calc ( N ) ; System . out . println ( dp [ N ] ) ; } private static void calc ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { int power = 1 ; int ans = Integer . MAX_VALUE ; while ( 0 <= i - power ) { ans = Math . min ( ans , 1 + dp [ i - power ] ) ; power *= 6 ; } power = 1 ; while ( 0 <= i - power ) { ans = Math . min ( ans , 1 + dp [ i - power ] ) ; power *= 9 ; } dp [ i ] = ans ; } } }",
"import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final int INF = Integer . MAX_VALUE ; Scanner scn = new Scanner ( System . in ) ; int N = scn . nextInt ( ) ; ArrayList < Integer > coins = new ArrayList < Integer > ( ) ; coins . add ( 1 ) ; for ( int i = 1 ; ; i ++ ) { int buf = ( int ) Math . pow ( 6 , i ) ; if ( buf > N ) break ; coins . add ( buf ) ; } for ( int i = 1 ; ; i ++ ) { int buf = ( int ) Math . pow ( 9 , i ) ; if ( buf > N ) break ; coins . add ( buf ) ; } int [ ] DP = new int [ N + 1 ] ; DP [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { DP [ i ] = INF ; } int length = coins . size ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 0 ; j < length ; j ++ ) { int coin = coins . get ( j ) ; if ( i >= coin ) { DP [ i ] = Math . min ( DP [ i ] , DP [ i - coin ] + 1 ) ; } } } System . out . println ( DP [ N ] ) ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE dp = [ 0 for i in range ( N + 1 ) ] NEW_LINE dp [ 1 ] = 1 NEW_LINE kazu = [ 1 ] NEW_LINE i = 6 NEW_LINE while i <= N : NEW_LINE INDENT kazu . append ( i ) NEW_LINE i *= 6 NEW_LINE DEDENT i = 9 NEW_LINE while i <= N : NEW_LINE INDENT kazu . append ( i ) NEW_LINE i *= 9 NEW_LINE DEDENT kazu . sort ( ) NEW_LINE kazulazor = len ( kazu ) NEW_LINE temp = [ 1 ] NEW_LINE lentemp = 1 NEW_LINE index = 1 NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT kouho = [ ] NEW_LINE if index < kazulazor and i == kazu [ index ] : NEW_LINE INDENT temp . append ( i ) NEW_LINE index += 1 NEW_LINE lentemp += 1 NEW_LINE DEDENT for j in range ( lentemp ) : NEW_LINE INDENT kouho . append ( dp [ i - temp [ j ] ] + 1 ) NEW_LINE DEDENT dp [ i ] = min ( kouho ) NEW_LINE DEDENT print ( str ( dp [ N ] ) ) NEW_LINE",
"import bisect NEW_LINE six_list = [ 6 ** i for i in range ( 7 ) ] NEW_LINE nine_list = [ 9 ** i for i in range ( 6 ) ] NEW_LINE from functools import lru_cache NEW_LINE @ lru_cache ( maxsize = 1000 ) NEW_LINE def six_nine ( n ) : NEW_LINE INDENT if n < 6 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT six = six_list [ bisect . bisect_right ( six_list , n ) - 1 ] NEW_LINE nine = nine_list [ bisect . bisect_right ( nine_list , n ) - 1 ] NEW_LINE return min ( n // six + six_nine ( n % six ) , 1 + six_nine ( n - nine ) ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT x = int ( input ( ) ) NEW_LINE print ( six_nine ( x ) ) NEW_LINE DEDENT",
"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 N = int ( input ( ) ) NEW_LINE dp = [ INF ] * 100001 NEW_LINE dp [ 0 ] , dp [ 1 ] = 0 , 1 NEW_LINE L = [ 1 , 6 , 36 , 216 , 1296 , 7776 , 46656 , 9 , 81 , 729 , 6561 , 59049 ] NEW_LINE for i in range ( 2 , 100001 ) : NEW_LINE INDENT for j in range ( len ( L ) ) : NEW_LINE INDENT if i - L [ j ] >= 0 : NEW_LINE INDENT dp [ i ] = min ( dp [ i - L [ j ] ] + 1 , dp [ i ] ) NEW_LINE DEDENT DEDENT DEDENT print ( dp [ N ] ) NEW_LINE",
"import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE dp = [ 0 ] * ( N + 1 ) NEW_LINE def fun ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif dp [ n ] != 0 : NEW_LINE INDENT return dp [ n ] NEW_LINE DEDENT ans = N NEW_LINE for i in [ 6 ** k for k in range ( 7 ) ] : NEW_LINE INDENT if i <= n : NEW_LINE INDENT ans = min ( ans , fun ( n - i ) + 1 ) NEW_LINE DEDENT DEDENT for j in [ 9 ** l for l in range ( 6 ) ] : NEW_LINE INDENT if j <= n : NEW_LINE INDENT ans = min ( ans , fun ( n - j ) + 1 ) NEW_LINE DEDENT DEDENT dp [ n ] = ans NEW_LINE return dp [ n ] NEW_LINE DEDENT fun ( N ) NEW_LINE print ( dp [ - 1 ] ) NEW_LINE",
"import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE N = int ( stdin . readline ( ) ) NEW_LINE large = float ( ' inf ' ) NEW_LINE memo = { } NEW_LINE def cal_count ( total ) : NEW_LINE INDENT global memo NEW_LINE if total in memo : return memo [ total ] NEW_LINE if total < 0 : return large NEW_LINE if total == 0 : return 0 NEW_LINE cans = [ ] NEW_LINE for i in range ( 1 , 8 ) : NEW_LINE INDENT if 6 ** i > total : break NEW_LINE cans . append ( cal_count ( total - 9 ** i ) ) NEW_LINE cans . append ( cal_count ( total - 6 ** i ) ) NEW_LINE DEDENT cans . append ( cal_count ( total - 1 ) ) NEW_LINE res = min ( cans ) + 1 NEW_LINE memo [ total ] = res NEW_LINE return res NEW_LINE DEDENT cnt = cal_count ( N ) NEW_LINE print ( cnt ) NEW_LINE"
] |
atcoder_agc032_B | [
"import java . util . ArrayList ; import java . util . Scanner ; class Problem { private int N ; Problem ( ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; } void solve ( ) { int n = N % 2 == 1 ? N : N + 1 ; int M = N % 2 == 1 ? ( N - 1 ) / 2 : N / 2 ; ArrayList < String > edges = new ArrayList < > ( ) ; for ( int i = 1 ; i < M ; i ++ ) { edges . add ( i + \" β \" + ( i + 1 ) ) ; edges . add ( i + \" β \" + ( n - ( i + 1 ) ) ) ; edges . add ( ( i + 1 ) + \" β \" + ( n - i ) ) ; edges . add ( ( n - ( i + 1 ) ) + \" β \" + ( n - i ) ) ; } if ( N % 2 == 0 && M > 2 ) { edges . add ( 1 + \" β \" + M ) ; edges . add ( 1 + \" β \" + ( M + 1 ) ) ; edges . add ( M + \" β \" + ( n - 1 ) ) ; edges . add ( ( M + 1 ) + \" β \" + ( n - 1 ) ) ; } else if ( N % 2 == 1 ) { edges . add ( 1 + \" β \" + N ) ; edges . add ( ( n - 1 ) + \" β \" + N ) ; if ( M > 1 ) { edges . add ( M + \" β \" + N ) ; edges . add ( ( M + 1 ) + \" β \" + N ) ; } } System . out . println ( edges . size ( ) ) ; for ( String e : edges ) { System . out . println ( e ) ; } } } public class Main { public static void main ( String [ ] args ) { new Problem ( ) . solve ( ) ; } }",
"import java . util . * ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n == 4 ) { System . out . println ( 4 ) ; System . out . println ( 1 + \" β \" + 2 ) ; System . out . println ( 1 + \" β \" + 3 ) ; System . out . println ( 4 + \" β \" + 2 ) ; System . out . println ( 4 + \" β \" + 3 ) ; return ; } else if ( n == 3 ) { System . out . println ( 2 ) ; System . out . println ( 3 + \" β \" + 1 ) ; System . out . println ( 3 + \" β \" + 2 ) ; return ; } ArrayList < ArrayList < Integer > > ans = new ArrayList < > ( ) ; if ( n % 2 == 1 ) { ArrayList < Integer > a = new ArrayList < > ( ) ; a . add ( n ) ; ans . add ( a ) ; n -- ; } for ( int i = 1 ; i <= n / 2 ; i ++ ) { ArrayList < Integer > a = new ArrayList < > ( ) ; a . add ( i ) ; a . add ( n - i + 1 ) ; ans . add ( a ) ; } int len = ans . size ( ) ; int m = 0 ; for ( int i = 0 ; i < len ; i ++ ) { m += ans . get ( i ) . size ( ) * ans . get ( ( i + 1 ) % len ) . size ( ) ; } System . out . println ( m ) ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j : ans . get ( i ) ) for ( int k : ans . get ( ( i + 1 ) % len ) ) { System . out . println ( j + \" β \" + k ) ; } } } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = 0 ; int [ ] [ ] ans ; if ( n % 2 == 0 ) { m = ( n - 2 ) * n / 2 ; ans = new int [ m ] [ 2 ] ; int c = 0 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = i + 1 ; j <= n ; j ++ ) { if ( i + j == n + 1 ) continue ; ans [ c ] [ 0 ] = i ; ans [ c ] [ 1 ] = j ; c ++ ; } } } else { int n2 = n - 1 ; m = ( n2 - 2 ) * n2 / 2 + n2 ; ans = new int [ m ] [ 2 ] ; int c = 0 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = i + 1 ; j <= n ; j ++ ) { if ( i + j == n ) continue ; ans [ c ] [ 0 ] = i ; ans [ c ] [ 1 ] = j ; c ++ ; } } } System . out . println ( m ) ; for ( int i = 0 ; i < m ; i ++ ) { System . out . println ( ans [ i ] [ 0 ] + \" β \" + ans [ i ] [ 1 ] ) ; } sc . close ( ) ; } }",
"import java . util . * ; public class Main { int N ; List < Set < Integer > > groups = new ArrayList < > ( ) ; Main ( ) { Scanner in = new Scanner ( System . in ) ; N = in . nextInt ( ) ; in . close ( ) ; } void makeGroups ( ) { if ( N % 2 == 0 ) { for ( int i = 0 ; i < N / 2 ; ++ i ) { Set < Integer > set = new HashSet < > ( ) ; set . add ( i + 1 ) ; set . add ( N - i ) ; this . groups . add ( set ) ; } } else { for ( int i = 0 ; i < N / 2 ; ++ i ) { Set < Integer > set = new HashSet < > ( ) ; set . add ( i + 1 ) ; set . add ( N - i - 1 ) ; this . groups . add ( set ) ; } Set < Integer > s = new HashSet < > ( ) ; s . add ( N ) ; this . groups . add ( s ) ; } } void show ( ) { List < String > results = new ArrayList < > ( ) ; for ( int i = 0 ; i < this . groups . size ( ) ; ++ i ) { Set < Integer > grA = this . groups . get ( i ) ; for ( int j = i + 1 ; j < this . groups . size ( ) ; ++ j ) { Set < Integer > grB = this . groups . get ( j ) ; for ( Integer a : grA ) { for ( Integer b : grB ) { results . add ( a + \" β \" + b ) ; } } } } System . out . println ( results . size ( ) ) ; for ( String line : results ) { System . out . println ( line ) ; } } public static void main ( String [ ] args ) { Main ins = new Main ( ) ; ins . makeGroups ( ) ; ins . show ( ) ; } }",
"import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; System . out . println ( num * ( num - 1 ) / 2 - num / 2 ) ; for ( int i = 1 ; i <= num ; i ++ ) { for ( int j = 1 ; j < i ; j ++ ) { if ( i + j == num / 2 * 2 + 1 ) { continue ; } System . out . println ( i + \" β \" + j ) ; } } } }"
] | [
"n = int ( input ( ) ) ; print ( * [ ( n - 1 ) ** 2 // 2 ] + [ ' % d β % d ' % ( i , j ) * ( j > i != n - j + 1 - n % 2 ) for i in range ( 1 , n ) for j in range ( n + 1 ) ] ) NEW_LINE",
"import sys NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def list2d ( a , b , c ) : return [ [ c ] * b for i in range ( a ) ] NEW_LINE def list3d ( a , b , c , d ) : return [ [ [ d ] * c for j in range ( b ) ] for i in range ( a ) ] NEW_LINE def ceil ( x , y = 1 ) : return int ( - ( - x // y ) ) NEW_LINE def INT ( ) : return int ( input ( ) ) NEW_LINE def MAP ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def Yes ( ) : print ( ' Yes ' ) NEW_LINE def No ( ) : print ( ' No ' ) NEW_LINE def YES ( ) : print ( ' YES ' ) NEW_LINE def NO ( ) : print ( ' NO ' ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE N = INT ( ) NEW_LINE ans = [ ] NEW_LINE if N % 2 == 0 : NEW_LINE INDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT for j in range ( i + 1 , N + 1 ) : NEW_LINE INDENT if i + j != N + 1 : NEW_LINE INDENT ans . append ( ( i , j ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( ( i , N ) ) NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT if i + j != N : NEW_LINE INDENT ans . append ( ( i , j ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for edge in ans : NEW_LINE INDENT print ( * edge ) NEW_LINE DEDENT",
"N = int ( input ( ) ) NEW_LINE ls = [ i for i in range ( 1 , N + 1 ) ] NEW_LINE import itertools NEW_LINE plist = list ( itertools . combinations ( ls , 2 ) ) NEW_LINE ls = [ ] NEW_LINE cnt = 0 NEW_LINE all_pattern = len ( plist ) NEW_LINE if N % 2 == 0 : NEW_LINE INDENT print ( all_pattern - ( N // 2 ) ) NEW_LINE idx_x = N NEW_LINE DEDENT else : NEW_LINE INDENT print ( all_pattern - ( N - 1 ) // 2 ) NEW_LINE idx_x = N - 1 NEW_LINE DEDENT idx_y = 1 NEW_LINE for p in plist : NEW_LINE INDENT if p [ 0 ] == idx_y and p [ 1 ] == idx_x : NEW_LINE INDENT idx_x = idx_x - 1 NEW_LINE idx_y = idx_y + 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( p [ 0 ] , p [ 1 ] ) NEW_LINE DEDENT DEDENT",
"N = int ( input ( ) ) NEW_LINE matrix = [ [ 1 for i in range ( N ) ] for i in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT matrix [ i ] [ i ] = 0 NEW_LINE DEDENT if N % 2 == 0 : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT matrix [ i ] [ N - i - 1 ] = 0 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( N - 1 ) : NEW_LINE INDENT matrix [ i ] [ N - i - 2 ] = 0 NEW_LINE DEDENT DEDENT print ( int ( ( N * ( N - 1 ) / 2 ) - int ( N / 2 ) ) ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT if matrix [ i ] [ j ] == 1 : NEW_LINE INDENT print ( i + 1 , j + 1 ) NEW_LINE DEDENT DEDENT DEDENT",
"n = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE if n % 2 == 0 : NEW_LINE INDENT p = [ [ i , n + 1 - i ] for i in range ( 1 , n // 2 + 1 ) ] NEW_LINE for i in range ( len ( p ) ) : NEW_LINE INDENT for x in p [ i ] : NEW_LINE INDENT for j in range ( i + 1 , len ( p ) ) : NEW_LINE INDENT for y in p [ j ] : NEW_LINE INDENT ans . append ( [ x , y ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT p = [ [ i , n - i ] for i in range ( 1 , ( n - 1 ) // 2 + 1 ) ] NEW_LINE p . append ( [ n ] ) NEW_LINE for i in range ( len ( p ) ) : NEW_LINE INDENT for x in p [ i ] : NEW_LINE INDENT for j in range ( i + 1 , len ( p ) ) : NEW_LINE INDENT for y in p [ j ] : NEW_LINE INDENT ans . append ( [ x , y ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for edge in ans : NEW_LINE INDENT print ( edge [ 0 ] , edge [ 1 ] ) NEW_LINE DEDENT"
] |
atcoder_arc025_A | [
"import java . util . * ; public class Main { private static int D [ ] = new int [ 7 ] ; private static int J [ ] = new int [ 7 ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; for ( int i = 0 ; i < 7 ; i ++ ) { D [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { J [ i ] = scan . nextInt ( ) ; } } public static void main ( String args [ ] ) { input ( ) ; int ans = 0 ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( D [ i ] >= J [ i ] ) ans += D [ i ] ; else ans += J [ i ] ; } System . out . println ( ans ) ; } }",
"import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int ans = 0 ; int [ ] d = new int [ 7 ] ; int [ ] j = new int [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { j [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { ans += max ( d [ i ] , j [ i ] ) ; } out . println ( ans ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String args [ ] ) { int max_sum = 0 ; Scanner scan = new Scanner ( System . in ) ; ArrayList < Integer > d = new ArrayList < Integer > ( ) ; ArrayList < Integer > j = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 7 ; i ++ ) d . add ( scan . nextInt ( ) ) ; for ( int i = 0 ; i < 7 ; i ++ ) j . add ( scan . nextInt ( ) ) ; for ( int i = 0 ; i < 7 ; i ++ ) max_sum += Math . max ( d . get ( i ) , j . get ( i ) ) ; System . out . println ( max_sum ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] d = new int [ 7 ] ; int [ ] j = new int [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { j [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( d [ i ] >= j [ i ] ) { ans += d [ i ] ; } else { ans += j [ i ] ; } } System . out . println ( ans ) ; } }",
"import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] d = new int [ 7 ] , j = new int [ 7 ] ; int sum = 0 ; for ( int i = 0 ; i < 7 ; i ++ ) d [ i ] = s . nextInt ( ) ; for ( int i = 0 ; i < 7 ; i ++ ) j [ i ] = s . nextInt ( ) ; for ( int i = 0 ; i < 7 ; i ++ ) sum += Math . max ( d [ i ] , j [ i ] ) ; System . out . println ( sum ) ; } }"
] | [
"D = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE J = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = 0 NEW_LINE for i in range ( 7 ) : NEW_LINE INDENT if D [ i ] >= J [ i ] : NEW_LINE INDENT res += D [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT res += J [ i ] NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE",
"print ( sum ( map ( max , zip ( * eval ( ' map ( int , input ( ) . split ( ) ) , ' * 2 ) ) ) ) ) NEW_LINE",
"import numpy as np NEW_LINE D = np . array ( [ int ( _ ) for _ in input ( ) . split ( ) ] ) NEW_LINE J = np . array ( [ int ( _ ) for _ in input ( ) . split ( ) ] ) NEW_LINE print ( sum ( np . maximum ( D , J ) ) ) NEW_LINE",
"D , J = input ( ) . split ( \" β \" ) , input ( ) . split ( \" β \" ) NEW_LINE D , J = [ int ( i ) for i in D ] , [ int ( i ) for i in J ] NEW_LINE ans = 0 NEW_LINE for i in range ( 7 ) : NEW_LINE INDENT ans += max ( D [ i ] , J [ i ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT dd = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE jj = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = sum ( max ( d , j ) for d , j in zip ( dd , jj ) ) NEW_LINE print ( res ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT"
] |
atcoder_abc026_C | [
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int B [ ] = new int [ N ] ; LinkedList list [ ] = new LinkedList [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { list [ i ] = new LinkedList ( ) ; } for ( int i = 1 ; i < N ; i ++ ) { B [ i ] = sc . nextInt ( ) ; list [ B [ i ] - 1 ] . add ( i ) ; } System . out . println ( get_money ( 0 , list ) ) ; } public static int get_money ( int num , LinkedList list [ ] ) { if ( list [ num ] . size ( ) == 0 ) { return 1 ; } else { int min = Integer . MAX_VALUE ; int max = 0 ; for ( int i = 0 ; i < list [ num ] . size ( ) ; i ++ ) { int n = get_money ( list [ num ] . get ( i ) , list ) ; min = Math . min ( min , n ) ; max = Math . max ( max , n ) ; } return min + max + 1 ; } } } class LinkedList { ArrayList < Integer > link = new ArrayList < Integer > ( ) ; public void add ( int vertex ) { link . add ( vertex ) ; } public int get ( int i ) { return link . get ( i ) ; } public void remove ( int vertex ) { } public void view ( ) { for ( int i = 0 ; i < link . size ( ) ; i ++ ) { System . out . println ( link . get ( i ) ) ; } } public boolean linked ( int vertex ) { if ( Arrays . asList ( link ) . contains ( vertex ) ) { return true ; } else { return false ; } } public int size ( ) { return link . size ( ) ; } }",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) ; int [ ] salary = new int [ n ] ; List < Integer > [ ] list = IntStream . range ( 0 , n ) . mapToObj ( i -> new ArrayList < > ( ) ) . toArray ( List [ ] :: new ) ; for ( int i = 1 ; i < n ; i ++ ) list [ scanner . nextInt ( ) - 1 ] . add ( i ) ; boolean flag = true ; while ( flag ) { flag = false ; for ( int i = 0 ; i < n ; i ++ ) { int [ ] array = list [ i ] . stream ( ) . mapToInt ( j -> salary [ j ] ) . toArray ( ) ; if ( salary [ i ] == 0 && Arrays . stream ( array ) . noneMatch ( j -> j == 0 ) ) { flag = true ; salary [ i ] = Arrays . stream ( array ) . min ( ) . orElse ( 0 ) + Arrays . stream ( array ) . max ( ) . orElse ( 0 ) + 1 ; } } } System . out . println ( salary [ 0 ] ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .",
"import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] boss = new int [ N + 1 ] ; boss [ 0 ] = - 1 ; Map < Integer , List < Integer > > members = new HashMap < Integer , List < Integer > > ( ) ; for ( int i = 1 ; i <= N - 1 ; i ++ ) { int b = sc . nextInt ( ) ; boss [ i + 1 ] = b ; List < Integer > member = new ArrayList < Integer > ( ) ; if ( members . containsKey ( b ) ) { member = members . get ( b ) ; } member . add ( i + 1 ) ; members . put ( b , member ) ; } Queue < Integer > checkMember = new ArrayDeque < Integer > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( ! members . containsKey ( i ) ) { checkMember . add ( i ) ; } } int [ ] salary = new int [ N + 1 ] ; while ( ! checkMember . isEmpty ( ) ) { int n = checkMember . poll ( ) ; if ( ! members . containsKey ( n ) ) { salary [ n ] = 1 ; } else { int max = Integer . MIN_VALUE ; int min = Integer . MAX_VALUE ; for ( Integer m : members . get ( n ) ) { max = Math . max ( max , salary [ m ] ) ; min = Math . min ( min , salary [ m ] ) ; } salary [ n ] = max + min + 1 ; } if ( ! checkMember . contains ( boss [ n ] ) && boss [ n ] != - 1 ) { checkMember . add ( boss [ n ] ) ; } } out . println ( salary [ 1 ] ) ; } }",
"import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] b = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } List < List < Integer > > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { List < Integer > subList = new ArrayList < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( i + 1 == b [ j ] ) { subList . add ( j ) ; } } list . add ( subList ) ; } int [ ] p = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( list . get ( i ) . size ( ) == 0 ) { p [ i ] = 1 ; } else { int min = ( int ) 1e9 ; int max = 0 ; for ( int j = 0 ; j < list . get ( i ) . size ( ) ; j ++ ) { min = Math . min ( min , p [ list . get ( i ) . get ( j ) ] ) ; max = Math . max ( max , p [ list . get ( i ) . get ( j ) ] ) ; } p [ i ] = min + max + 1 ; } } System . out . println ( p [ 0 ] ) ; } }",
"import java . util . * ; public class Main { static ArrayList < Integer > [ ] lists ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; lists = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { lists [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 2 ; i <= n ; i ++ ) { int x = sc . nextInt ( ) ; lists [ x ] . add ( i ) ; } System . out . println ( getIncome ( 1 ) ) ; } static int getIncome ( int idx ) { if ( lists [ idx ] . size ( ) == 0 ) { return 1 ; } int max = 0 ; int min = Integer . MAX_VALUE ; for ( int x : lists [ idx ] ) { int y = getIncome ( x ) ; if ( max < y ) { max = y ; } if ( min > y ) { min = y ; } } return max + min + 1 ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details ."
] | [
"from collections import defaultdict as dd NEW_LINE n = int ( input ( ) ) NEW_LINE salary = [ 0 ] * ( n + 1 ) NEW_LINE d = dd ( list ) NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT d [ int ( input ( ) ) ] . append ( i ) NEW_LINE DEDENT def calcsalary ( i ) : NEW_LINE INDENT if d [ i ] == [ ] : NEW_LINE INDENT salary [ i ] = 1 NEW_LINE return 1 NEW_LINE DEDENT else : NEW_LINE INDENT subord = [ ] NEW_LINE for x in d [ i ] : NEW_LINE INDENT if salary [ x ] : NEW_LINE INDENT subord . append ( salary [ x ] ) NEW_LINE DEDENT else : NEW_LINE INDENT subord . append ( calcsalary ( x ) ) NEW_LINE DEDENT DEDENT salary [ x ] = max ( subord ) + min ( subord ) + 1 NEW_LINE return salary [ x ] NEW_LINE DEDENT DEDENT print ( calcsalary ( 1 ) ) NEW_LINE",
"def salary ( N : int , B : list ) -> int : NEW_LINE INDENT tree = [ [ ] for _ in range ( N ) ] NEW_LINE for i , b in enumerate ( B ) : NEW_LINE INDENT tree [ b - 1 ] . append ( i + 1 ) NEW_LINE DEDENT def dfs ( v : int ) -> int : NEW_LINE INDENT if not tree [ v ] : NEW_LINE INDENT return 1 NEW_LINE DEDENT max_s , min_s = 0 , float ( ' inf ' ) NEW_LINE for child in tree [ v ] : NEW_LINE INDENT d = dfs ( child ) NEW_LINE max_s = max ( max_s , d ) NEW_LINE min_s = min ( min_s , d ) NEW_LINE DEDENT return max_s + min_s + 1 NEW_LINE DEDENT return dfs ( 0 ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE B = [ int ( input ( ) ) for _ in range ( N - 1 ) ] NEW_LINE ans = salary ( N , B ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE class Tree : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . par = [ i for i in range ( n ) ] NEW_LINE DEDENT def unite ( self , par , chi ) : NEW_LINE INDENT self . par [ chi ] = par NEW_LINE DEDENT def get_child ( self , par ) : NEW_LINE INDENT child = set ( ) NEW_LINE for i in range ( len ( self . par ) ) : NEW_LINE INDENT if i != par and self . par [ i ] == par : NEW_LINE INDENT child . add ( i ) NEW_LINE DEDENT DEDENT return child NEW_LINE DEDENT DEDENT def salary ( x ) : NEW_LINE INDENT if money [ x ] != - 1 : NEW_LINE INDENT return money [ x ] NEW_LINE DEDENT else : NEW_LINE INDENT chilist = member . get_child ( x ) NEW_LINE if len ( chilist ) == 0 : NEW_LINE INDENT money [ x ] = 1 NEW_LINE return money [ x ] NEW_LINE DEDENT else : NEW_LINE INDENT sub = set ( ) NEW_LINE for i in chilist : NEW_LINE INDENT sub . add ( salary ( i ) ) NEW_LINE DEDENT money [ x ] = max ( sub ) + min ( sub ) + 1 NEW_LINE return money [ x ] NEW_LINE DEDENT DEDENT DEDENT N = int ( input ( ) ) NEW_LINE B = [ 0 ] * 2 + [ int ( input ( ) ) for _ in range ( N - 1 ) ] NEW_LINE member = Tree ( N + 1 ) NEW_LINE money = [ - 1 ] * ( N + 1 ) NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT member . unite ( B [ i ] , i ) NEW_LINE DEDENT print ( salary ( 1 ) ) NEW_LINE",
"n = int ( input ( ) ) NEW_LINE b = [ [ 0 , 0 ] ] + [ [ i , int ( input ( ) ) - 1 ] for i in range ( 1 , n ) ] NEW_LINE b = b [ : : - 1 ] NEW_LINE salary = [ [ ] for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if not salary [ i ] : NEW_LINE INDENT salary [ i ] . append ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT salary [ i ] . append ( min ( salary [ i ] ) + max ( salary [ i ] ) + 1 ) NEW_LINE DEDENT salary [ ( n - 1 ) - b [ i ] [ 1 ] ] . append ( salary [ i ] [ - 1 ] ) NEW_LINE DEDENT print ( salary [ n - 1 ] [ - 1 ] ) NEW_LINE",
"n = int ( input ( ) ) NEW_LINE salary = [ 0 , 1 ] NEW_LINE ans = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT k = int ( input ( ) ) NEW_LINE salary . append ( k ) NEW_LINE DEDENT def find ( x , i ) : NEW_LINE INDENT if salary [ x ] == x : NEW_LINE INDENT return i NEW_LINE DEDENT return find ( salary [ x ] , i + 1 ) NEW_LINE DEDENT order = [ ] NEW_LINE for i in range ( len ( salary ) ) : NEW_LINE INDENT order . append ( [ find ( salary [ i ] , 0 ) , i ] ) NEW_LINE DEDENT order . sort ( ) NEW_LINE order . reverse ( ) NEW_LINE salary [ 1 ] = 0 NEW_LINE for i in order : NEW_LINE INDENT stack = [ ] NEW_LINE if salary . count ( i [ 1 ] ) == 0 : NEW_LINE INDENT ans [ i [ 1 ] ] = 1 NEW_LINE DEDENT elif salary . count ( i [ 1 ] ) == 1 : NEW_LINE INDENT for j in range ( len ( salary ) ) : NEW_LINE INDENT if salary [ j ] == i [ 1 ] : NEW_LINE INDENT ans [ i [ 1 ] ] = ans [ j ] * 2 + 1 NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for j in range ( len ( salary ) ) : NEW_LINE INDENT if salary [ j ] == i [ 1 ] : NEW_LINE INDENT stack . append ( ans [ j ] ) NEW_LINE DEDENT DEDENT ans [ i [ 1 ] ] = min ( stack ) + max ( stack ) + 1 NEW_LINE DEDENT DEDENT print ( ans [ 1 ] ) NEW_LINE"
] |
atcoder_abc060_B | [
"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int c = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int target = c % b ; for ( int i = 1 ; i <= b ; i ++ ) { if ( i * a % b == target ) { System . out . println ( \" YES \" ) ; return ; } } System . out . println ( \" NO \" ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int total = 0 ; String ans = \" NO \" ; for ( int i = 0 ; i <= A * B ; i ++ ) { total += A ; if ( total % B == C ) { ans = \" YES \" ; break ; } } out . println ( ans ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . 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 ( ) ; a = a % b ; String ans = \" NO \" ; for ( int i = 1 ; i <= b ; i ++ ) { if ( a * i % b == c ) { ans = \" YES \" ; } } 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 . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int cnt = 1 ; List < Integer > list = new ArrayList < > ( ) ; while ( true ) { int i = a * cnt % b ; if ( i == c ) { System . out . println ( \" YES \" ) ; System . exit ( 0 ) ; } else if ( list . contains ( i ) ) { System . out . println ( \" NO \" ) ; System . exit ( 0 ) ; } else { list . add ( i ) ; cnt ++ ; } } } }",
"import java . util . Scanner ; public class Main { static int k ; static String ans = \" NO \" ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; for ( int i = 1 ; i <= b ; i ++ ) { if ( a * i % b == c ) ans = \" YES \" ; } System . out . println ( ans ) ; } }"
] | [
"A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE R = { i : False for i in range ( B ) } NEW_LINE X = 0 NEW_LINE while True : NEW_LINE INDENT X += A NEW_LINE r = X % B NEW_LINE if r == C : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE exit ( ) NEW_LINE DEDENT if R [ r ] : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE exit ( ) NEW_LINE DEDENT R [ r ] = True NEW_LINE DEDENT",
"def gcd ( x , y ) : NEW_LINE INDENT while y : NEW_LINE INDENT x , y = y , x % y NEW_LINE DEDENT return x NEW_LINE DEDENT A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if C % gcd ( A , B ) == 0 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT",
"from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a , b , c = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE i = 1 NEW_LINE ans = ' NO ' NEW_LINE while i < b : NEW_LINE INDENT if ( a * i % b == c ) : NEW_LINE INDENT ans = ' YES ' NEW_LINE break NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( 1 , B + 1 ) : NEW_LINE INDENT if ( A * i ) % B == C : NEW_LINE INDENT return ' YES ' NEW_LINE DEDENT DEDENT return ' NO ' NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT",
"A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE amaris = [ ] NEW_LINE flag = False NEW_LINE count = 1 NEW_LINE tmp = A NEW_LINE while True : NEW_LINE INDENT amari = tmp % B NEW_LINE if C == amari : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT if amari in amaris : NEW_LINE INDENT break NEW_LINE DEDENT amaris . append ( amari ) NEW_LINE count += 1 NEW_LINE tmp = A * count NEW_LINE DEDENT if flag : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT"
] |
atcoder_abc021_B | [
"import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; int a = reader . nextInt ( ) ; int b = reader . nextInt ( ) ; int K = reader . nextInt ( ) ; List < Integer > P = new ArrayList < Integer > ( ) ; String ans = \" YES \" ; for ( int i = 0 ; i < K ; i ++ ) { int num = reader . nextInt ( ) ; if ( P . contains ( num ) || num == a || num == b ) { ans = \" NO \" ; } P . add ( num ) ; } System . out . println ( ans ) ; reader . close ( ) ; } }",
"import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Map < Integer , Integer > map = new TreeMap ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; for ( int i = 0 ; i < d ; i ++ ) map . put ( sc . nextInt ( ) , 1 ) ; System . out . println ( map . size ( ) == d && map . containsKey ( b ) == false && map . containsKey ( c ) == false ? \" YES \" : \" NO \" ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .",
"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 . HashSet ; import java . util . Set ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int K = in . nextInt ( ) ; String ans = \" YES \" ; Set < Integer > list = new HashSet < Integer > ( ) ; int tmp ; for ( int i = 0 ; i < K ; i ++ ) { tmp = in . nextInt ( ) ; if ( tmp == a || tmp == b ) { ans = \" NO \" ; } list . add ( tmp ) ; } if ( list . size ( ) < K ) { ans = \" NO \" ; } if ( N < K ) { ans = \" NO \" ; } out . println ( ans ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Collection ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . io . UncheckedIOException ; import java . util . List ; import java . util . stream . Stream ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; List < Integer > s = new ArrayList < > ( ) ; s . add ( in . ints ( ) ) ; s . add ( in . ints ( ) ) ; int k = in . ints ( ) ; for ( int i = 0 ; i < k ; i ++ ) { s . add ( in . ints ( ) ) ; } if ( s . size ( ) > s . stream ( ) . distinct ( ) . count ( ) ) { out . println ( \" NO \" ) ; } else { out . println ( \" YES \" ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }",
"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] line = scanner . nextLine ( ) . split ( \" β \" , 2 ) ; int a = Integer . parseInt ( line [ 0 ] ) ; int b = Integer . parseInt ( line [ 1 ] ) ; boolean [ ] passed = new boolean [ n ] ; passed [ a - 1 ] = true ; passed [ b - 1 ] = true ; int k = Integer . parseInt ( scanner . nextLine ( ) ) ; line = scanner . nextLine ( ) . split ( \" β \" , k ) ; boolean yes = true ; for ( int i = 0 ; i < k ; i ++ ) { int p = Integer . parseInt ( line [ i ] ) ; if ( passed [ p - 1 ] ) { yes = false ; break ; } passed [ p - 1 ] = true ; } if ( yes ) { System . out . println ( \" YES \" ) ; } else { System . out . println ( \" NO \" ) ; } } }"
] | [
"n = input ( ) NEW_LINE org = list ( map ( int , input ( ) . split ( ' β ' ) ) ) NEW_LINE k = input ( ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ' β ' ) ) ) NEW_LINE t_arr = list ( set ( arr + org ) ) NEW_LINE print ( ' YES ' ) if len ( arr + org ) == len ( t_arr ) else print ( ' NO ' ) NEW_LINE",
"from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" YES \" ) NEW_LINE else : print ( \" NO \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def pne ( n ) : NEW_LINE INDENT print ( n , end = ' ' ) NEW_LINE DEDENT rem = pow ( 10 , 9 ) + 7 NEW_LINE n = ip ( ) NEW_LINE x , y = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE k = ip ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a . append ( x ) NEW_LINE a . append ( y ) NEW_LINE s = set ( a ) NEW_LINE if len ( s ) == len ( a ) : NEW_LINE INDENT j ( 1 ) NEW_LINE DEDENT else : j ( 0 ) NEW_LINE",
"import sys NEW_LINE N = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE P = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE visited = [ a , b ] NEW_LINE for p in P : NEW_LINE INDENT if p in visited : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT visited . append ( p ) NEW_LINE DEDENT print ( \" YES \" ) NEW_LINE",
"def solve ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a , b = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE p = list ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE ans = ' YES ' NEW_LINE if a in p or b in p : NEW_LINE INDENT ans = ' NO ' NEW_LINE DEDENT if len ( p ) != len ( set ( p ) ) : NEW_LINE INDENT ans = ' NO ' NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT solve ( ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE Plist = ( input ( ) . split ( ) ) NEW_LINE Plist_i = [ int ( s ) for s in Plist ] NEW_LINE def is_unique ( seq ) : NEW_LINE INDENT return len ( seq ) == len ( set ( seq ) ) NEW_LINE DEDENT if N < 2 : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT elif K > ( N - 2 ) : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT elif a == b : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT elif is_unique ( Plist_i ) == False : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT"
] |
atcoder_abc027_A | [
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( a == b ) { System . out . println ( c ) ; } else if ( a == c ) { System . out . println ( b ) ; } else if ( b == c ) { System . out . println ( a ) ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . List ; 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 l1 = in . nextInt ( ) ; int l2 = in . nextInt ( ) ; int l3 = in . nextInt ( ) ; int ans = 0 ; if ( l1 == l2 ) ans = l3 ; if ( l2 == l3 ) ans = l1 ; if ( l3 == l1 ) ans = l2 ; out . println ( ans ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }",
"import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int a = nextInt ( ) , b = nextInt ( ) , c = nextInt ( ) ; out . println ( a == b ? c : b == c ? a : b ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( a == b ? c : a == c ? b : a ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , l = sc . nextInt ( ) ; if ( n == m ) System . out . println ( l ) ; else if ( n == l ) System . out . println ( m ) ; else System . out . println ( n ) ; } }"
] | [
"a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if a == b : NEW_LINE INDENT print ( int ( c ) ) NEW_LINE DEDENT elif b == c : NEW_LINE INDENT print ( int ( a ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( b ) ) NEW_LINE DEDENT",
"def rect ( l1 : int , l2 : int , l3 : int ) -> int : NEW_LINE INDENT if l1 == l2 : NEW_LINE INDENT return l3 NEW_LINE DEDENT if l1 == l3 : NEW_LINE INDENT return l2 NEW_LINE DEDENT return l1 NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT l1 , l2 , l3 = map ( int , input ( ) . split ( ) ) NEW_LINE ans = rect ( l1 , l2 , l3 ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"print ( eval ( input ( ) . replace ( ' β ' , ' ^ ' ) ) ) NEW_LINE",
"llist = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cnt1 = 1 NEW_LINE cnt2 = 0 NEW_LINE l4 = 0 NEW_LINE for i in range ( 1 , 3 ) : NEW_LINE INDENT if llist [ 0 ] == llist [ i ] : NEW_LINE INDENT cnt1 += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt2 += 1 NEW_LINE l4 = llist [ i ] NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE if cnt1 == 1 : NEW_LINE INDENT ans = llist [ 0 ] NEW_LINE DEDENT elif cnt1 == 2 : NEW_LINE INDENT ans = l4 NEW_LINE DEDENT else : NEW_LINE INDENT ans = llist [ 0 ] NEW_LINE DEDENT print ( ans ) NEW_LINE",
"import collections NEW_LINE l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = collections . Counter ( l ) NEW_LINE b = len ( set ( l ) ) NEW_LINE if b == 1 : NEW_LINE INDENT ans = l [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT for k in a . keys ( ) : NEW_LINE INDENT if a [ k ] == 1 : NEW_LINE INDENT ans = k NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE"
] |
atcoder_abc121_C | [
"import java . math . BigDecimal ; import java . util . AbstractMap . SimpleEntry ; import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; BigDecimal sum = BigDecimal . ZERO ; List < Entry < Integer , Integer > > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) list . add ( new SimpleEntry < Integer , Integer > ( sc . nextInt ( ) , sc . nextInt ( ) ) ) ; list = list . stream ( ) . sorted ( Comparator . comparingInt ( entry -> entry . getKey ( ) ) ) . collect ( Collectors . toList ( ) ) ; for ( Entry < Integer , Integer > entry : list ) { if ( m == 0 ) break ; BigDecimal a = BigDecimal . valueOf ( entry . getKey ( ) ) ; BigDecimal b = BigDecimal . valueOf ( entry . getValue ( ) ) ; if ( m > entry . getValue ( ) ) { m -= entry . getValue ( ) ; sum = sum . add ( a . multiply ( b ) ) ; } else if ( m <= entry . getValue ( ) ) { b = BigDecimal . valueOf ( m ) ; sum = sum . add ( a . multiply ( b ) ) ; m = 0 ; } } System . out . println ( sum . toString ( ) ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] [ ] A = new long [ N ] [ 2 ] ; int k = 0 ; int number = 0 ; long sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } Arrays . sort ( A , ( a , b ) -> Long . compare ( a [ 0 ] , b [ 0 ] ) ) ; while ( M > k ) { k += A [ number ] [ 1 ] ; sum += A [ number ] [ 0 ] * A [ number ] [ 1 ] ; number ++ ; } if ( k != M ) { sum -= A [ number - 1 ] [ 0 ] * ( k - M ) ; } PrintWriter out = new PrintWriter ( System . out ) ; out . print ( sum ) ; out . flush ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Data > list = new ArrayList < Data > ( ) ; String [ ] line_list = sc . nextLine ( ) . split ( \" β \" ) ; int N = Integer . parseInt ( line_list [ 0 ] ) ; int M = Integer . parseInt ( line_list [ 1 ] ) ; for ( int i = 0 ; i < N ; i ++ ) { line_list = sc . nextLine ( ) . split ( \" β \" ) ; list . add ( new Data ( Long . parseLong ( line_list [ 0 ] ) , Integer . parseInt ( line_list [ 1 ] ) ) ) ; } list . sort ( ( a , b ) -> a . compareTo ( b ) ) ; long kingaku = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Data data = list . get ( i ) ; if ( M < data . getSuryou ( ) ) { kingaku = kingaku + M * data . getTanka ( ) ; break ; } else { kingaku = kingaku + data . getSuryou ( ) * data . getTanka ( ) ; M = M - data . getSuryou ( ) ; } } System . out . println ( kingaku ) ; } public static class Data implements Comparable < Data > { long tanka ; int suryou ; public Data ( long p_tanka , int p_suryou ) { this . tanka = p_tanka ; this . suryou = p_suryou ; } @ Override public int compareTo ( Data d ) { if ( this . tanka < d . tanka ) return - 1 ; if ( this . tanka > d . tanka ) return 1 ; return 0 ; } public long getTanka ( ) { return tanka ; } public void setTanka ( long tanka ) { this . tanka = tanka ; } public int getSuryou ( ) { return suryou ; } public void setSuryou ( int suryou ) { this . suryou = suryou ; } } }",
"import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; scanner . nextLine ( ) ; List < Store > list = IntStream . range ( 0 , n ) . mapToObj ( i -> { Store store = new Store ( ) ; store . price = scanner . nextInt ( ) ; store . amount = scanner . nextInt ( ) ; scanner . nextLine ( ) ; return store ; } ) . sorted ( ( x , y ) -> x . price - y . price ) . collect ( Collectors . toList ( ) ) ; long sum = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Store store = list . get ( i ) ; if ( store . amount >= m ) { sum += ( long ) store . price * m ; break ; } else { sum += ( long ) store . price * store . amount ; m -= store . amount ; } } System . out . println ( sum ) ; } } private static class Store { int price ; int amount ; } }",
"import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; TreeMap < Long , Integer > map = new TreeMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { long cost = sc . nextLong ( ) ; int num = sc . nextInt ( ) ; map . put ( cost , map . containsKey ( cost ) ? num + map . get ( cost ) : num ) ; } sc . close ( ) ; long totalcost = 0 ; int bought = 0 ; for ( Map . Entry < Long , Integer > kv : map . entrySet ( ) ) { long cost = kv . getKey ( ) ; int maxnum = kv . getValue ( ) ; int buycount = Math . min ( maxnum , M - bought ) ; totalcost += buycount * cost ; bought += buycount ; if ( bought > M ) { break ; } } System . out . println ( totalcost ) ; } }"
] | [
"N , M = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = { } NEW_LINE B = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT A [ i ] , B [ i ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT A = sorted ( A . items ( ) , key = lambda x : x [ 1 ] ) NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if M > B [ A [ i ] [ 0 ] ] : NEW_LINE INDENT ans += A [ i ] [ 1 ] * B [ A [ i ] [ 0 ] ] NEW_LINE M -= B [ A [ i ] [ 0 ] ] NEW_LINE DEDENT else : NEW_LINE INDENT ans += A [ i ] [ 1 ] * M NEW_LINE break ; NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"import sys ; n , m = input ( ) . split ( ) ; m = int ( m ) ; a = [ ] ; i = n = c = 0 ; a = sorted ( tuple ( map ( int , e . split ( ) ) ) for e in sys . stdin ) NEW_LINE while m > 0 : c += a [ i ] [ 0 ] * a [ i ] [ 1 ] ; m -= a [ i ] [ 1 ] ; i += 1 NEW_LINE print ( c + m * a [ ~ - i ] [ 0 ] ) NEW_LINE",
"from collections import namedtuple NEW_LINE Shop = namedtuple ( ' Shop ' , ( ' a ' , ' b ' ) ) NEW_LINE def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE shops = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE shops . append ( Shop ( a , b ) ) NEW_LINE DEDENT print ( solve ( shops , m ) ) NEW_LINE DEDENT def solve ( shops , m ) : NEW_LINE INDENT cost = 0 NEW_LINE count = 0 NEW_LINE for shop in sorted ( shops ) : NEW_LINE INDENT if count + shop . b >= m : NEW_LINE INDENT cost += shop . a * ( m - count ) NEW_LINE return cost NEW_LINE DEDENT count += shop . b NEW_LINE cost += shop . a * shop . b NEW_LINE DEDENT DEDENT main ( ) NEW_LINE",
"n , m , * t = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for a , b in sorted ( zip ( t [ : : 2 ] , t [ 1 : : 2 ] ) ) : NEW_LINE INDENT ans += min ( b , m ) * a NEW_LINE m -= b NEW_LINE if m <= 0 : NEW_LINE INDENT print ( ans ) NEW_LINE break NEW_LINE DEDENT DEDENT",
"import itertools NEW_LINE N , M = tuple ( [ int ( x ) for x in input ( ) . split ( ' β ' ) ] ) NEW_LINE AB = [ tuple ( [ int ( x ) for x in input ( ) . split ( ' β ' ) ] ) for i in range ( N ) ] NEW_LINE ans = 0 NEW_LINE count = 0 NEW_LINE for a , b in sorted ( AB , key = lambda x : x [ 0 ] ) : NEW_LINE INDENT if M - count <= b : NEW_LINE INDENT ans += ( M - count ) * a NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT count += b NEW_LINE ans += a * b NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE"
] |
atcoder_abc080_A | [
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( a * b <= c ) { System . out . println ( a * b ) ; } else if ( c < a * b ) { System . out . println ( c ) ; } } }",
"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int n = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; System . out . println ( n * a > b ? b : n * a ) ; } }",
"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; import java . util . TreeSet ; import org . omg . Messaging . SyncScopeHelper ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_100 ( ) . doIt ( ) ; } class Test_100 { void doIt ( ) { int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int PlanA = N * A ; int PlanB = B ; if ( PlanA < PlanB ) System . out . println ( PlanA ) ; else System . out . println ( PlanB ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numN = 0 ; int numA = 0 ; int numB = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; numA = scanner . nextInt ( ) ; numB = scanner . nextInt ( ) ; System . out . println ( Math . min ( numA * numN , numB ) ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( \" \" ) ; } finally { if ( scanner != null ) { scanner . 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 ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( A * N < B ? A * N : B ) ; } }"
] | [
"n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( min ( n * a , b ) ) NEW_LINE",
"N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if ( N * A > B ) : NEW_LINE INDENT print ( B ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( N * A ) NEW_LINE DEDENT",
"N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if N * A < B : NEW_LINE INDENT print ( N * A ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( B ) NEW_LINE DEDENT",
"n , a , b = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE print ( min ( n * a , b ) ) NEW_LINE",
"N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( N * A if N * A < B else B ) NEW_LINE"
] |
atcoder_agc023_B | [
"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = readInt ( ) ; char [ ] [ ] charMatrix = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String tmpStr = sc . next ( ) ; for ( int j = 0 ; j < N ; j ++ ) { charMatrix [ i ] [ j ] = tmpStr . charAt ( j ) ; } } long cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { char [ ] [ ] shiftedMatrix = shiftCharMatrix ( charMatrix , 0 , i ) ; if ( checkCharMatrixSymmetry ( shiftedMatrix ) ) { cnt += N ; } } System . out . println ( cnt ) ; } private static char [ ] [ ] shiftCharMatrix ( char [ ] [ ] matrix , int H , int W ) { int SIZE_H = matrix . length ; int SIZE_W = matrix [ 0 ] . length ; char [ ] [ ] shiftedMatrix = new char [ SIZE_H ] [ SIZE_W ] ; for ( int h = 0 ; h < SIZE_H ; h ++ ) { for ( int w = 0 ; w < SIZE_W ; w ++ ) { int next_h = ( h + H ) % SIZE_H ; int next_w = ( w + W ) % SIZE_W ; shiftedMatrix [ next_h ] [ next_w ] = matrix [ h ] [ w ] ; } } return shiftedMatrix ; } private static boolean checkCharMatrixSymmetry ( char [ ] [ ] matrix ) { int N = matrix . length ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i ; j < N ; j ++ ) { if ( matrix [ i ] [ j ] != matrix [ j ] [ i ] ) { return false ; } } } return true ; } private static char readChar ( ) { return sc . next ( ) . charAt ( 0 ) ; } private static int readInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } private static long readLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; String [ ] s = in . nextStringArray ( n ) ; int count = 0 ; out : for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { if ( j == k ) continue ; if ( s [ j ] . charAt ( ( k + i ) % n ) != s [ k ] . charAt ( ( j + i ) % n ) ) continue out ; } } count ++ ; } count *= n ; out . println ( count ) ; } } static class InputReader { BufferedReader in ; StringTokenizer tok ; public String nextString ( ) { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) , \" β \" ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return tok . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } public String [ ] nextStringArray ( int n ) { String [ ] res = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { res [ i ] = nextString ( ) ; } return res ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( \" \" ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ansbase = 0 ; String [ ] S = new String [ N ] ; char [ ] [ ] s = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { S [ i ] = sc . next ( ) ; for ( int j = 0 ; j < N ; j ++ ) { s [ i ] [ j ] = S [ i ] . charAt ( j ) ; } } for ( int i = 0 ; i < N ; i ++ ) { Boolean OK = true ; for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( s [ ( i + j ) % N ] [ k ] != s [ ( i + k ) % N ] [ j ] ) { OK = false ; } } } if ( OK ) { ansbase ++ ; } } System . out . println ( ansbase * N ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; char [ ] [ ] board ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; board = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { board [ i ] = sc . next ( ) . toCharArray ( ) ; } solve ( ) ; } void solve ( ) { long count = 0 ; for ( int a = 0 ; a < n ; a ++ ) { int b = 0 ; boolean flag = true ; b : for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( board [ ( i + a ) % n ] [ ( j + b ) % n ] != board [ ( j + a ) % n ] [ ( i + b ) % n ] ) { flag = false ; break b ; } } } if ( flag ) { count ++ ; } } System . out . println ( count * n ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] [ ] str = new String [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String tmpStr = sc . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { str [ i ] [ j ] = String . valueOf ( tmpStr . charAt ( j ) ) ; } } int count = 0 ; String [ ] [ ] secondStr = new String [ n ] [ n ] ; for ( int A = 0 ; A < n ; A ++ ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { secondStr [ i ] [ j ] = str [ ( i + A ) % n ] [ j ] ; } } boolean ans = true ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ! ( secondStr [ i ] [ j ] . equals ( secondStr [ j ] [ i ] ) ) ) { ans = false ; } } } if ( ans == true ) count += n ; } System . out . println ( count ) ; } }"
] | [
"import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ list ( input ( ) ) for i in range ( n ) ] NEW_LINE a = np . array ( a ) NEW_LINE c = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT a = np . roll ( a , 1 , axis = 0 ) NEW_LINE if len ( a [ a != a . T ] ) == 0 : c += n NEW_LINE DEDENT print ( c ) NEW_LINE",
"if __name__ == ' _ _ main _ sample _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE rows = [ input ( ) for _ in range ( N ) ] NEW_LINE ans = 0 NEW_LINE for n in range ( N ) : NEW_LINE INDENT flag = False NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT num = j - n if j - n >= 0 else N + ( j - n ) NEW_LINE a = i - n if i - n >= 0 else N + ( i - n ) NEW_LINE if rows [ i ] [ num ] != rows [ j ] [ a ] : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT if flag == True : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if flag == False : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans * N ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE Sss = [ input ( ) for _ in range ( N ) ] NEW_LINE Sss_tr = list ( map ( ' ' . join , zip ( * Sss ) ) ) NEW_LINE ans = 0 NEW_LINE for k in range ( N ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if ( Sss [ i ] [ - k : ] + Sss [ i ] [ : - k ] ) != Sss_tr [ i - k ] : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans += N NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT",
"import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE B = [ tuple ( SI ( ) ) for _ in range ( n ) ] NEW_LINE BT = list ( zip ( * B ) ) NEW_LINE res = 0 NEW_LINE for a in range ( n ) : NEW_LINE INDENT is_good = True NEW_LINE for i in range ( n ) : NEW_LINE INDENT if B [ i ] [ n - a : ] + B [ i ] [ : n - a ] != BT [ ( i - a ) % n ] : NEW_LINE INDENT is_good = False NEW_LINE DEDENT DEDENT if is_good : NEW_LINE INDENT res += n NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT print ( main ( ) ) NEW_LINE",
"import numpy as np NEW_LINE from scipy . ndimage . interpolation import shift as scipy_shift NEW_LINE class shift : NEW_LINE INDENT def __init__ ( self , a ) : NEW_LINE INDENT self . arr = a NEW_LINE self . height = a . shape [ 0 ] NEW_LINE self . width = a . shape [ 1 ] NEW_LINE DEDENT def shifted ( self , down , right ) : NEW_LINE INDENT temp1 = self . arr [ list ( np . linspace ( - down , - down + self . height - 1 , self . height ) . astype ( np . int32 ) % self . height ) , : ] NEW_LINE temp2 = temp1 [ : , list ( np . linspace ( - right , - right + self . width - 1 , self . width ) . astype ( np . int32 ) % self . width ) ] NEW_LINE return temp2 NEW_LINE DEDENT def shifted_zero ( self , down , right ) : NEW_LINE INDENT index_vertical = np . arange ( self . height ) NEW_LINE index_horizontal = np . arange ( self . width ) NEW_LINE temp1 = self . arr [ list ( scipy_shift ( index_vertical , down , output = int , mode = ' constant ' ) ) , : ] NEW_LINE temp2 = temp1 [ : , list ( scipy_shift ( index_horizontal , right , output = int , mode = ' constant ' ) ) ] NEW_LINE return temp2 NEW_LINE DEDENT def is_sym ( self , down , right ) : NEW_LINE INDENT temp = self . shifted ( down , right ) NEW_LINE delta = temp - temp . T NEW_LINE return ( not ( delta * delta ) . sum ( ) ) NEW_LINE DEDENT DEDENT N = int ( input ( ) ) NEW_LINE array = [ list ( input ( ) ) for i in range ( N ) ] NEW_LINE array_int = np . array ( [ [ ord ( i ) for i in j ] for j in array ] ) NEW_LINE if N >= 2 : NEW_LINE INDENT count = np . array ( [ shift ( array_int ) . is_sym ( 0 , i ) * ( N - i ) for i in range ( N ) ] ) . sum ( ) + np . array ( [ shift ( array_int ) . is_sym ( i , 0 ) * ( N - i ) for i in range ( 1 , N ) ] ) . sum ( ) NEW_LINE DEDENT else : NEW_LINE INDENT count = int ( shift ( array_int ) . is_sym ( 0 , 0 ) ) NEW_LINE DEDENT print ( count ) NEW_LINE",
"import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE n = ni ( ) NEW_LINE grid = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT s = ns ( ) NEW_LINE s = s + s NEW_LINE grid . append ( s ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT grid . append ( grid [ i ] ) NEW_LINE DEDENT vert = [ ] NEW_LINE hrzn = [ ] NEW_LINE for i in range ( 2 * n ) : NEW_LINE INDENT hrzn . append ( grid [ i ] ) NEW_LINE DEDENT for j in range ( 2 * n ) : NEW_LINE INDENT temp = \" \" NEW_LINE for i in range ( 2 * n ) : NEW_LINE INDENT temp += grid [ i ] [ j : j + 1 ] NEW_LINE DEDENT vert . append ( temp ) NEW_LINE DEDENT ans = 0 NEW_LINE for a in range ( n ) : NEW_LINE INDENT for b in range ( 1 ) : NEW_LINE INDENT ok = True NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if vert [ b + i ] [ a + i : a + n ] != hrzn [ a + i ] [ b + i : b + n ] : NEW_LINE INDENT ok = False NEW_LINE break NEW_LINE DEDENT DEDENT if ok : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans * n ) NEW_LINE"
] |
atcoder_agc005_A | [
"import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; String s = sc . next ( ) ; int l = 0 , r = 1 ; int n = s . length ( ) ; int ans = 0 ; while ( r < n && l < n - 1 ) { if ( l == r ) r ++ ; if ( s . charAt ( l ) == ' S ' ) { if ( s . charAt ( r ) == ' T ' ) { ans ++ ; r ++ ; l ++ ; } else { r ++ ; } } else { l ++ ; } } out . println ( n - ans * 2 ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ASTring solver = new ASTring ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ASTring { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String x = in . string ( ) ; int ans = x . length ( ) ; int stack = 0 ; for ( char c : x . toCharArray ( ) ) { if ( c == ' S ' ) { stack ++ ; } else if ( stack > 0 ) { stack -- ; ans -= 2 ; } } out . println ( ans ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }",
"import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? \" Yes \" : \" No \" ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; ArrayDeque < Character > dq = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == ' T ' ) { if ( dq . peekFirst ( ) == null || dq . peekFirst ( ) == ' T ' ) { dq . addFirst ( c ) ; } else if ( dq . peekFirst ( ) == ' S ' ) { dq . removeFirst ( ) ; } } else if ( c == ' S ' ) { dq . addFirst ( c ) ; } } System . out . println ( dq . size ( ) ) ; } }",
"import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; int [ ] stacks = new int [ a . length ( ) ] ; int kaisu = 0 ; int pointer = 0 ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) == ' S ' ) { stacks [ pointer ] = 1 ; pointer ++ ; } else if ( a . charAt ( i ) == ' T ' ) { stacks [ pointer ] = 2 ; pointer ++ ; } if ( pointer >= 2 ) { if ( stacks [ pointer - 2 ] == 1 && stacks [ pointer - 1 ] == 2 ) { stacks [ pointer - 2 ] = 0 ; stacks [ pointer - 1 ] = 0 ; pointer -= 2 ; kaisu ++ ; } } } System . out . println ( ( a . length ( ) - kaisu * 2 ) ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String X = sc . next ( ) ; Deque < Character > stack = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < X . length ( ) ; i ++ ) { if ( X . charAt ( i ) == ' S ' ) { stack . push ( X . charAt ( i ) ) ; } else { if ( stack . size ( ) == 0 ) { stack . push ( X . charAt ( i ) ) ; } else if ( stack . peek ( ) == ' S ' ) { stack . pop ( ) ; } else if ( stack . peek ( ) == ' T ' ) { stack . push ( X . charAt ( i ) ) ; } } } System . out . println ( stack . size ( ) ) ; } }"
] | [
"s = input ( ) NEW_LINE t = [ ] NEW_LINE for a in s : NEW_LINE INDENT t . append ( a ) NEW_LINE if len ( t ) >= 2 : NEW_LINE INDENT if t [ - 2 ] == ' S ' and t [ - 1 ] == ' T ' : NEW_LINE INDENT for i in range ( 2 ) : NEW_LINE INDENT t . pop ( - 1 ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( len ( t ) ) NEW_LINE",
"X = input ( ) NEW_LINE from collections import deque NEW_LINE lt = deque ( ) NEW_LINE r = 0 NEW_LINE ans = 0 NEW_LINE while r < len ( X ) : NEW_LINE INDENT if ( X [ r : r + 2 ] == ' ST ' ) : NEW_LINE INDENT ans += 2 NEW_LINE r += 2 NEW_LINE continue NEW_LINE DEDENT elif ( len ( lt ) > 0 and X [ lt [ - 1 ] ] + X [ r ] == ' ST ' ) : NEW_LINE INDENT ans += 2 NEW_LINE lt . pop ( ) NEW_LINE r += 1 NEW_LINE continue NEW_LINE DEDENT if ( X [ r ] == ' S ' ) : NEW_LINE INDENT lt . append ( r ) NEW_LINE r += 1 NEW_LINE DEDENT else : NEW_LINE INDENT r += 1 NEW_LINE lt . clear ( ) NEW_LINE DEDENT DEDENT print ( len ( X ) - ans ) NEW_LINE",
"def solve ( s ) : NEW_LINE INDENT sums = 0 NEW_LINE sumt = 0 NEW_LINE ans = 0 NEW_LINE for i in s : NEW_LINE INDENT if i == ' S ' : NEW_LINE INDENT sums += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if sums > 0 : NEW_LINE INDENT sums -= 1 NEW_LINE ans += 2 NEW_LINE DEDENT DEDENT DEDENT return len ( s ) - ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT",
"S = input ( ) NEW_LINE N = len ( S ) NEW_LINE ans = N NEW_LINE stack = [ ] NEW_LINE stack . append ( S [ 0 ] ) NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if len ( stack ) != 0 and stack [ len ( stack ) - 1 ] == ' S ' and S [ i ] == ' T ' : NEW_LINE INDENT ans -= 2 NEW_LINE stack . pop ( ) NEW_LINE DEDENT elif S [ i ] == ' S ' : NEW_LINE INDENT stack . append ( S [ i ] ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"S = input ( ) NEW_LINE result = \" \" NEW_LINE for s in S : NEW_LINE INDENT if ( s == \" T \" and result == \" \" ) : NEW_LINE INDENT result += s NEW_LINE DEDENT elif ( s == \" T \" and result [ - 1 ] == \" S \" ) : NEW_LINE INDENT result = result [ : - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT result += s NEW_LINE DEDENT DEDENT print ( len ( result ) ) NEW_LINE"
] |
atcoder_arc042_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int i , j ; double p , q , n , a , b , c , d , ans ; int pX [ ] = new int [ 12 ] ; int pY [ ] = new int [ 12 ] ; ans = 10000000 ; p = sc . nextInt ( ) ; q = sc . nextInt ( ) ; n = sc . nextInt ( ) ; for ( i = 0 ; i < n ; i ++ ) { pX [ i ] = sc . nextInt ( ) ; pY [ i ] = sc . nextInt ( ) ; } for ( i = 0 ; i < n ; i ++ ) { j = ( i < n - 1 ) ? i + 1 : 0 ; a = pX [ j ] - pX [ i ] ; b = pY [ j ] - pY [ i ] ; c = Math . sqrt ( a * a + b * b ) ; d = ( a * ( q - pY [ i ] ) + b * ( pX [ i ] - p ) ) / c ; d = ( d >= 0 ) ? d : - d ; if ( ans > d ) ans = d ; } System . out . println ( ans ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double cx = sc . nextDouble ( ) ; double cy = sc . nextDouble ( ) ; int N = sc . nextInt ( ) ; double [ ] x = new double [ N + 2 ] ; double [ ] y = new double [ N + 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextDouble ( ) ; y [ i ] = sc . nextDouble ( ) ; } double min = 100000000 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { double l = dist ( x [ i ] , x [ i + 1 ] , y [ i ] , y [ i + 1 ] , cx , cy ) ; min = Math . min ( l , min ) ; } double l = dist ( x [ N - 1 ] , x [ 0 ] , y [ N - 1 ] , y [ 0 ] , cx , cy ) ; min = Math . min ( l , min ) ; System . out . println ( min ) ; } public static double dist ( double x1 , double x2 , double y1 , double y2 , double x , double y ) { if ( x1 == x2 ) { return Math . abs ( x - x1 ) ; } else if ( y1 == y2 ) { return Math . abs ( y - y1 ) ; } else { double a = ( y1 - y2 ) / ( x1 - x2 ) ; double b = y1 - a * x1 ; return Math . abs ( y - a * x - b ) / Math . sqrt ( 1 + a * a ) ; } } }"
] | [
"import cmath , sys NEW_LINE t_x , t_y = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE poly = [ list ( map ( int , e . split ( ) ) ) for e in sys . stdin ] NEW_LINE ans = 10000 NEW_LINE for i in range ( N ) : NEW_LINE INDENT p1 , p2 = poly [ i - 1 ] , poly [ i ] NEW_LINE p = complex ( p2 [ 0 ] - p1 [ 0 ] , p2 [ 1 ] - p1 [ 1 ] ) NEW_LINE t = complex ( t_x - p1 [ 0 ] , t_y - p1 [ 1 ] ) NEW_LINE t *= p . conjugate ( ) / abs ( p ) NEW_LINE dist = abs ( t . imag ) NEW_LINE if dist < ans : NEW_LINE INDENT ans = dist NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"from math import sqrt NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * N ] NEW_LINE a += [ a [ 0 ] ] NEW_LINE ans = float ( \" inf \" ) NEW_LINE for ( x1 , y1 ) , ( x2 , y2 ) in zip ( a , a [ 1 : ] ) : NEW_LINE INDENT if x1 == x2 : NEW_LINE INDENT d = abs ( x - x1 ) NEW_LINE DEDENT elif y1 == y2 : NEW_LINE INDENT d = abs ( y - y1 ) NEW_LINE DEDENT else : NEW_LINE INDENT inc = ( y2 - y1 ) / ( x2 - x1 ) NEW_LINE a = inc NEW_LINE b = - 1 NEW_LINE c = - inc * x1 + y1 NEW_LINE d = abs ( ( a * x + b * y + c ) / sqrt ( a ** 2 + b ** 2 ) ) NEW_LINE DEDENT ans = min ( ans , d ) NEW_LINE DEDENT print ( ans ) NEW_LINE",
"class Vector : NEW_LINE INDENT def __init__ ( self , x , y ) : NEW_LINE INDENT self . x = x NEW_LINE self . y = y NEW_LINE DEDENT def __add__ ( self , other ) : NEW_LINE INDENT return Vector ( self . x + other . x , self . y + other . y ) NEW_LINE DEDENT def __sub__ ( self , other ) : NEW_LINE INDENT return Vector ( self . x - other . x , self . y - other . y ) NEW_LINE DEDENT def __mult__ ( self , scaler ) : NEW_LINE INDENT return Vector ( self . x * scaler , self . y * scaler ) NEW_LINE DEDENT def dot ( self , other ) : NEW_LINE INDENT return self . x * other . x + self . y * other . y NEW_LINE DEDENT def length ( self ) : NEW_LINE INDENT return self . dot ( self ) ** 0.5 NEW_LINE DEDENT def abs_cross ( self , other ) : NEW_LINE INDENT return abs ( self . x * other . y - self . y * other . x ) NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE xy = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT xi , yi = map ( int , input ( ) . split ( ) ) NEW_LINE xy . append ( ( xi - x , yi - y ) ) NEW_LINE DEDENT xy . append ( xy [ 0 ] ) NEW_LINE del x , y NEW_LINE mi = 999999999.0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT v1 = Vector ( * xy [ i ] ) NEW_LINE v2 = Vector ( * xy [ i + 1 ] ) NEW_LINE mi = min ( mi , v1 . length ( ) ) NEW_LINE if cross_orthogonal ( v1 , v2 ) : NEW_LINE INDENT mi = min ( mi , dist_orthogonal ( v1 , v2 ) ) NEW_LINE DEDENT DEDENT print ( mi ) NEW_LINE DEDENT def cross_orthogonal ( v1 , v2 ) : NEW_LINE INDENT v3 = v2 - v1 NEW_LINE return v1 . dot ( v3 ) * v2 . dot ( v3 ) < 0 NEW_LINE DEDENT def dist_orthogonal ( v1 , v2 ) : NEW_LINE INDENT return v1 . abs_cross ( v2 ) / ( v2 - v1 ) . length ( ) NEW_LINE DEDENT main ( ) NEW_LINE",
"def b_ant ( X , Y , N , Pos ) : NEW_LINE INDENT import numpy NEW_LINE import math NEW_LINE pos_initial = numpy . array ( [ X , Y ] ) NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT v1 = numpy . array ( Pos [ i ] ) NEW_LINE v2 = numpy . array ( Pos [ ( i + 1 ) % N ] ) NEW_LINE vec_edge = v2 - v1 NEW_LINE vec_init = pos_initial - v1 NEW_LINE vec_edge_norm = numpy . linalg . norm ( vec_edge ) NEW_LINE vec_init_norm = numpy . linalg . norm ( vec_init ) NEW_LINE theta = math . acos ( numpy . dot ( vec_edge , vec_init ) / ( vec_edge_norm * vec_init_norm ) ) NEW_LINE ans = min ( ans , vec_init_norm * math . sin ( theta ) ) NEW_LINE DEDENT ans = round ( ans , 10 ) NEW_LINE return ans NEW_LINE DEDENT X , Y = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE Pos = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( N ) ] NEW_LINE print ( b_ant ( X , Y , N , Pos ) ) NEW_LINE",
"import numpy as np NEW_LINE from numpy import * NEW_LINE def distance_l ( a , b , c ) : NEW_LINE INDENT u = np . array ( [ b [ 0 ] - a [ 0 ] , b [ 1 ] - a [ 1 ] ] ) NEW_LINE v = np . array ( [ c [ 0 ] - a [ 0 ] , c [ 1 ] - a [ 1 ] ] ) NEW_LINE L = abs ( cross ( u , v ) / linalg . norm ( u ) ) NEW_LINE return L NEW_LINE DEDENT def distance_seg ( a , b , c ) : NEW_LINE INDENT u = np . array ( [ b [ 0 ] - a [ 0 ] , b [ 1 ] - a [ 1 ] ] ) NEW_LINE v = np . array ( [ c [ 0 ] - a [ 0 ] , c [ 1 ] - a [ 1 ] ] ) NEW_LINE w = np . array ( [ c [ 0 ] - b [ 0 ] , c [ 1 ] - b [ 1 ] ] ) NEW_LINE res = 0 NEW_LINE if dot ( u , v ) <= 0 : NEW_LINE INDENT res = linalg . norm ( v ) NEW_LINE DEDENT elif dot ( - u , w ) <= 0 : NEW_LINE INDENT res = linalg . norm ( w ) NEW_LINE DEDENT else : NEW_LINE INDENT res = distance_l ( a , b , c ) NEW_LINE DEDENT return res NEW_LINE DEDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE px = [ 0 ] * N NEW_LINE py = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT px [ i ] , py [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT res = float ( ' inf ' ) NEW_LINE u = np . array ( [ x , y ] ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT j = ( i + 1 ) % N NEW_LINE v = np . array ( [ px [ i ] , py [ i ] ] ) NEW_LINE w = np . array ( [ px [ j ] , py [ j ] ] ) NEW_LINE curr = distance_seg ( v , w , u ) NEW_LINE res = min ( res , curr ) NEW_LINE DEDENT print ( res ) NEW_LINE"
] |
atcoder_abc093_B | [
"import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; TreeSet < Integer > set = new TreeSet < > ( ) ; for ( int i = a ; i <= Math . min ( b , a + k - 1 ) ; i ++ ) set . add ( i ) ; for ( int i = b ; i >= Math . max ( a , b - k + 1 ) ; i -- ) set . add ( i ) ; set . forEach ( out :: println ) ; } }",
"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . HashSet ; import java . util . Set ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int c = Integer . parseInt ( tokenizer . nextToken ( ) ) ; Set < Integer > hashSet = new HashSet < > ( ) ; StringBuilder out = new StringBuilder ( ) ; for ( int i = a ; i < a + c && i <= b ; i ++ ) { if ( ! hashSet . contains ( i ) ) { out . append ( i ) . append ( \" \\n \" ) ; hashSet . add ( i ) ; } } for ( int i = b - c + 1 ; i <= b && i > a ; i ++ ) { if ( ! hashSet . contains ( i ) ) { out . append ( i ) . append ( \" \\n \" ) ; hashSet . add ( i ) ; } } System . out . print ( out ) ; } }",
"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 a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; for ( int i = a ; i <= a + k - 1 && i <= b ; i ++ ) { System . out . println ( i ) ; if ( i == a + k - 1 || i == b ) { i ++ ; for ( int j = Math . max ( i , b - k + 1 ) ; j <= b ; j ++ ) System . out . println ( j ) ; } } } }",
"import java . io . * ; import java . util . Arrays ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] input = Arrays . stream ( stdin . readLine ( ) . split ( \" β \" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; IntStream . rangeClosed ( input [ 0 ] , input [ 1 ] ) . filter ( i -> { int order = i - input [ 0 ] ; if ( order < input [ 2 ] || input [ 1 ] - input [ 0 ] - input [ 2 ] < order ) return true ; else return false ; } ) . forEach ( System . out :: println ) ; } }",
"import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > array = new ArrayList < > ( ) ; for ( int i = 0 ; i < K ; i ++ ) { if ( A + i <= B ) array . add ( A + i ) ; } for ( int i = K - 1 ; i >= 0 ; i -- ) { if ( ! array . contains ( B - i ) && B - i >= A ) array . add ( B - i ) ; } for ( int i = 0 ; i < array . size ( ) ; i ++ ) { System . out . println ( array . get ( i ) ) ; } } }"
] | [
"a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE res = [ ] NEW_LINE for i in range ( a , min ( a + k , b ) ) : NEW_LINE INDENT res . append ( i ) NEW_LINE DEDENT for j in range ( max ( a , b - k + 1 ) , b + 1 ) : NEW_LINE INDENT res . append ( j ) NEW_LINE DEDENT res = sorted ( set ( res ) ) NEW_LINE for i in res : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT",
"lists = input ( ) . split ( ) NEW_LINE a = int ( lists [ 0 ] ) NEW_LINE b = int ( lists [ 1 ] ) NEW_LINE x = int ( lists [ 2 ] ) * 2 NEW_LINE answer = [ ] NEW_LINE next = 0 NEW_LINE for num in range ( 0 , x ) : NEW_LINE INDENT if ( a == b ) : NEW_LINE INDENT answer . append ( a ) NEW_LINE break NEW_LINE DEDENT answer . append ( a ) NEW_LINE answer . append ( b ) NEW_LINE a += 1 NEW_LINE b -= 1 NEW_LINE if ( len ( answer ) >= x or a > b or b < 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT if ( a == b ) : NEW_LINE INDENT answer . append ( a ) NEW_LINE if ( a + num < b - num ) : NEW_LINE INDENT for b_num in range ( b , a ) : NEW_LINE INDENT answer . append ( b_num ) NEW_LINE if ( len ( answer ) > x ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT elif ( a + num > b - num ) : NEW_LINE INDENT for a_num in range ( a , b ) : NEW_LINE INDENT answer . append ( a_num ) NEW_LINE if ( len ( answer ) > x ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT break NEW_LINE DEDENT DEDENT answer . sort ( ) NEW_LINE for a in answer : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT",
"a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE if b - a < k * 2 : NEW_LINE INDENT for i in range ( a , b + 1 ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( a , b + 1 ) [ : k ] : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT for i in range ( a , b + 1 ) [ - k : ] : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT",
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE if b - a + 1 >= 2 * k : NEW_LINE INDENT for i in range ( 0 , k ) : NEW_LINE INDENT print ( a + i ) NEW_LINE DEDENT for i in range ( k - 1 , - 1 , - 1 ) : NEW_LINE INDENT print ( b - i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( a , b + 1 ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT",
"a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE N = [ int ( i ) for i in range ( a , min ( a + k , b + 1 ) ) ] NEW_LINE M = [ int ( i ) for i in range ( max ( a , b - k + 1 ) , b + 1 ) ] NEW_LINE print ( * sorted ( set ( M + N ) ) , sep = \" \\n \" ) NEW_LINE"
] |
atcoder_abc040_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = ( int ) 1e9 ; if ( n == 1 ) { ans = 0 ; System . out . println ( ans ) ; return ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 1 ; i + j <= n && i * j <= n ; j ++ ) { int x = Math . abs ( i - j ) ; int v = i * j ; int res = n - v ; int sum = x + res ; if ( res >= 0 && sum < ans ) { ans = sum ; } } } System . out . println ( ans ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int ans = Integer . MAX_VALUE ; int n = in . nextInt ( ) ; for ( int h = 1 ; h <= n ; h ++ ) { int w = n / h ; ans = Math . min ( ans , n - h * w + Math . abs ( h - w ) ) ; } out . println ( ans ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; int score = 10000000 ; for ( int i = 1 ; i <= n ; i ++ ) { int h = n / i ; int ns = Math . abs ( h - i ) + n - h * i ; score = Math . min ( ns , score ) ; } out . println ( score ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }",
"import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int hen = 1 ; int min = 20000000 ; while ( ! ( hen * hen > n ) ) { hen ++ ; } hen -- ; while ( hen != 0 ) { min = Math . min ( ( n - n / hen * hen ) + ( n / hen - hen ) , min ) ; hen -- ; } System . out . println ( min ) ; sc . close ( ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int A = reader . nextInt ( ) ; int base = getMaxSqueaBase ( A ) ; int min = A - ( int ) Math . pow ( base , 2 ) ; if ( min > 0 ) { for ( int i = base ; i > 0 ; i -- ) { int remain = A - ( int ) Math . pow ( i , 2 ) ; int tmp = 0 ; while ( i <= remain ) { remain -= i ; tmp ++ ; } if ( remain + tmp < min ) { min = remain + tmp ; } } } System . out . println ( min ) ; reader . close ( ) ; } public static int getMaxSqueaBase ( int num ) { int base = 1 ; while ( Math . pow ( ( base + 1 ) , 2 ) <= num ) { base ++ ; } return base ; } }"
] | [
"n = int ( input ( ) ) NEW_LINE s = int ( n ** 0.5 ) NEW_LINE best = 10 ** 9 NEW_LINE for i in range ( s , 0 , - 1 ) : NEW_LINE INDENT q , m = divmod ( n , i ) NEW_LINE best = min ( best , abs ( i - q ) + m ) NEW_LINE DEDENT print ( best ) NEW_LINE",
"def rect_rect_rect_rect_rect ( n : int ) -> int : NEW_LINE INDENT h = 1 NEW_LINE min_d = float ( ' inf ' ) NEW_LINE while h * h <= n : NEW_LINE INDENT w = n // h NEW_LINE min_d = min ( abs ( h - w ) + ( n - w * h ) , min_d ) NEW_LINE h += 1 NEW_LINE DEDENT return min_d NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE ans = rect_rect_rect_rect_rect ( n ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"import sys NEW_LINE import math NEW_LINE def solve ( n : int ) : NEW_LINE INDENT ans = n NEW_LINE for i in range ( 1 , int ( math . sqrt ( n ) ) + 1 ) : NEW_LINE INDENT w = int ( n / i ) NEW_LINE ans = min ( ans , abs ( i - w ) + n - ( i * w ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE n = int ( next ( tokens ) ) NEW_LINE solve ( n ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE mnsk = [ ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for h in range ( 1 , n + 1 ) : NEW_LINE INDENT if i * h <= n : NEW_LINE INDENT mnsk . append ( n - i * h + abs ( i - h ) ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( min ( mnsk ) ) NEW_LINE",
"from math import sqrt NEW_LINE n = int ( input ( ) ) NEW_LINE ans = 10 ** 9 NEW_LINE for i in range ( 1 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT ans = min ( ans , n - i * ( n // i ) + abs ( i - ( n // i ) ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE"
] |
atcoder_arc092_C | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean [ ] a = new boolean [ N + 1 ] ; long odd = 0 ; long even = 0 ; long max = Long . MIN_VALUE ; int mp = - 1 ; for ( int i = 1 ; i <= N ; ++ i ) { long temp = sc . nextLong ( ) ; if ( temp > max ) { max = temp ; mp = i ; } if ( temp > 0 ) { a [ i ] = true ; if ( i % 2 == 1 ) odd += temp ; else even += temp ; } } if ( odd == 0 && even == 0 ) { System . out . println ( max ) ; System . out . println ( N - 1 ) ; for ( int i = N ; i > mp ; -- i ) { System . out . println ( i ) ; } for ( int i = 1 ; i < mp ; ++ i ) { System . out . println ( 1 ) ; } return ; } System . out . println ( Math . max ( odd , even ) ) ; int offset = odd > even ? 1 : 0 ; int p = N ; ArrayList < Integer > al = new ArrayList < Integer > ( ) ; while ( ! a [ p ] || ( p + offset ) % 2 != 0 ) { al . add ( p ) ; p -- ; } int left = 0 ; while ( ! a [ left ] || ( left + offset ) % 2 != 0 ) left ++ ; for ( int i = p - 2 ; i >= left ; i -= 2 ) { if ( a [ i ] ) al . add ( i + 1 ) ; else al . add ( i ) ; } for ( int i = 1 ; i < left ; ++ i ) al . add ( 1 ) ; System . out . println ( al . size ( ) ) ; for ( int i = 0 ; i < al . size ( ) ; i ++ ) { System . out . println ( al . get ( i ) ) ; } return ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE * A , = map ( int , input ( ) . split ( ) ) NEW_LINE def calc ( A ) : NEW_LINE INDENT if len ( A ) == 1 : NEW_LINE INDENT return [ ] , A [ 0 ] NEW_LINE DEDENT res = [ ] NEW_LINE if len ( A ) % 2 == 0 : NEW_LINE INDENT res . append ( len ( A ) ) NEW_LINE A = A [ : - 1 ] NEW_LINE DEDENT if all ( a <= 0 for a in A [ : : 2 ] ) : NEW_LINE INDENT ma = max ( A [ : : 2 ] ) NEW_LINE i = 0 NEW_LINE while A [ i ] != ma : NEW_LINE INDENT i += 1 NEW_LINE res . append ( 1 ) NEW_LINE DEDENT j = len ( A ) NEW_LINE while i < j - 1 : NEW_LINE INDENT res . append ( j - i ) NEW_LINE j -= 1 NEW_LINE DEDENT return res , ma NEW_LINE DEDENT l = 0 ; r = len ( A ) NEW_LINE while A [ 0 ] < 0 : NEW_LINE INDENT res . append ( 1 ) NEW_LINE res . append ( 1 ) NEW_LINE A = A [ 2 : ] NEW_LINE DEDENT v = 0 NEW_LINE while len ( A ) > 2 : NEW_LINE INDENT if A [ 2 ] < 0 : NEW_LINE INDENT res . append ( 3 ) NEW_LINE if len ( A ) > 4 : NEW_LINE INDENT A = A [ : 2 ] + A [ 4 : ] NEW_LINE DEDENT else : NEW_LINE INDENT A = A [ : 2 ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res . append ( 2 ) NEW_LINE A [ 2 ] += A [ 0 ] NEW_LINE A = A [ 2 : ] NEW_LINE DEDENT DEDENT if len ( A ) > 1 : NEW_LINE INDENT res . append ( 2 ) NEW_LINE DEDENT return res , A [ 0 ] NEW_LINE DEDENT r , v = calc ( A ) NEW_LINE if len ( A ) > 1 : NEW_LINE INDENT r0 , v0 = calc ( A [ 1 : ] ) NEW_LINE if v < v0 : NEW_LINE INDENT r = [ 1 ] + r0 NEW_LINE v = v0 NEW_LINE DEDENT DEDENT print ( v , len ( r ) , * r , sep = ' \\n ' ) NEW_LINE",
"def solve ( n , aaa ) : NEW_LINE INDENT odd_idx , even_idx = [ ] , [ ] NEW_LINE odd_sum , even_sum = 0 , 0 NEW_LINE for i in range ( 0 , n , 2 ) : NEW_LINE INDENT if aaa [ i ] > 0 : NEW_LINE INDENT even_idx . append ( i ) NEW_LINE even_sum += aaa [ i ] NEW_LINE DEDENT DEDENT for i in range ( 1 , n , 2 ) : NEW_LINE INDENT if aaa [ i ] > 0 : NEW_LINE INDENT odd_idx . append ( i ) NEW_LINE odd_sum += aaa [ i ] NEW_LINE DEDENT DEDENT if odd_sum < even_sum : NEW_LINE INDENT ans = even_sum NEW_LINE idx = even_idx NEW_LINE DEDENT else : NEW_LINE INDENT ans = odd_sum NEW_LINE idx = odd_idx NEW_LINE DEDENT if ans == 0 : NEW_LINE INDENT import numpy as np NEW_LINE i = np . argmax ( aaa ) NEW_LINE ans = aaa [ i ] NEW_LINE buf = list ( range ( n , i + 1 , - 1 ) ) + [ 1 ] * i NEW_LINE return ans , buf NEW_LINE DEDENT j = idx [ - 1 ] NEW_LINE buf = list ( range ( n , j + 1 , - 1 ) ) NEW_LINE for i in idx [ - 2 : : - 1 ] : NEW_LINE INDENT buf . extend ( range ( ( i + j ) // 2 + 1 , i + 1 , - 1 ) ) NEW_LINE j = i NEW_LINE DEDENT buf += [ 1 ] * idx [ 0 ] NEW_LINE return ans , buf NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE aaa = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans , buf = solve ( n , aaa ) NEW_LINE print ( ans ) NEW_LINE print ( len ( buf ) ) NEW_LINE print ( ' \\n ' . join ( map ( str , buf ) ) ) NEW_LINE",
"import sys NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ ( int ( v ) , i ) for i , v in enumerate ( input ( ) . split ( ) ) ] NEW_LINE ao = sum ( [ v for v , i in a if i % 2 and v > 0 ] ) NEW_LINE ae = sum ( [ v for v , i in a if not i % 2 and v > 0 ] ) NEW_LINE if max ( ao , ae ) == 0 : NEW_LINE INDENT ai = a . index ( max ( a ) ) NEW_LINE Ans = [ 1 ] * ( ai ) + list ( range ( N - ai , 1 , - 1 ) ) NEW_LINE print ( max ( a ) [ 0 ] ) NEW_LINE print ( len ( Ans ) ) NEW_LINE for i in Ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT if ao >= ae : NEW_LINE INDENT print ( ao ) NEW_LINE yn = [ i for v , i in a if i % 2 and v > 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT print ( ae ) NEW_LINE yn = [ i for v , i in a if not i % 2 and v > 0 ] NEW_LINE DEDENT listyn = [ i in yn for i in range ( N ) ] NEW_LINE Ans = [ ] NEW_LINE while not listyn [ 0 ] : NEW_LINE INDENT Ans . append ( 1 ) NEW_LINE listyn = listyn [ 1 : ] NEW_LINE DEDENT while not listyn [ - 1 ] : NEW_LINE INDENT Ans . append ( len ( listyn ) ) NEW_LINE listyn = listyn [ : - 1 ] NEW_LINE DEDENT while True : NEW_LINE INDENT if len ( listyn ) == 1 : NEW_LINE INDENT break NEW_LINE DEDENT if len ( listyn ) == [ 2 , 3 ] : NEW_LINE INDENT Ans . append ( 2 ) NEW_LINE break NEW_LINE DEDENT if listyn [ 2 ] : NEW_LINE INDENT Ans . append ( 2 ) NEW_LINE listyn = [ True ] + listyn [ 3 : ] NEW_LINE DEDENT else : NEW_LINE INDENT Ans . append ( 3 ) NEW_LINE listyn = [ True , False ] + listyn [ 4 : ] NEW_LINE DEDENT DEDENT print ( len ( Ans ) ) NEW_LINE for i in Ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE use = [ False ] * n NEW_LINE mx = max ( a ) NEW_LINE if mx < 0 : NEW_LINE INDENT use [ a . index ( mx ) ] = True NEW_LINE DEDENT else : NEW_LINE INDENT evn = sum ( max ( i , 0 ) for i in a [ : : 2 ] ) NEW_LINE odd = sum ( max ( i , 0 ) for i in a [ 1 : : 2 ] ) NEW_LINE mx = max ( evn , odd ) NEW_LINE for i in range ( int ( evn < odd ) , n , 2 ) : NEW_LINE INDENT if a [ i ] > 0 : NEW_LINE INDENT use [ i ] = True NEW_LINE DEDENT DEDENT DEDENT print ( mx ) NEW_LINE beg = 0 NEW_LINE while not use [ beg ] : NEW_LINE INDENT beg += 1 NEW_LINE DEDENT res = [ 1 ] * beg NEW_LINE end = n - 1 NEW_LINE while beg < end : NEW_LINE INDENT if use [ end ] : NEW_LINE INDENT if use [ end - 2 ] : NEW_LINE INDENT a [ end - 2 ] += a [ end ] NEW_LINE res . append ( end - beg ) NEW_LINE end -= 2 NEW_LINE use [ end ] = True NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( end - beg - 1 ) NEW_LINE a [ end - 2 ] = a [ end ] NEW_LINE end -= 2 NEW_LINE use [ end ] = True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res . append ( end - beg + 1 ) NEW_LINE end -= 1 NEW_LINE DEDENT DEDENT print ( len ( res ) ) NEW_LINE for i in res : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE mx = max ( a ) NEW_LINE a [ a . index ( mx ) ] = abs ( mx ) NEW_LINE evn = sum ( max ( 0 , i ) for i in a [ : : 2 ] ) NEW_LINE odd = sum ( max ( 0 , i ) for i in a [ 1 : : 2 ] ) NEW_LINE if mx < 0 : NEW_LINE INDENT print ( mx ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( max ( evn , odd ) ) NEW_LINE DEDENT oe = int ( evn < odd ) NEW_LINE res = [ ] NEW_LINE beg = 0 NEW_LINE while beg % 2 != oe or a [ beg ] < 0 : NEW_LINE INDENT res . append ( 1 ) NEW_LINE beg += 1 NEW_LINE DEDENT end = n - 1 NEW_LINE while end % 2 != oe or a [ end ] < 0 : NEW_LINE INDENT res . append ( end - beg + 1 ) NEW_LINE end -= 1 NEW_LINE DEDENT while beg < end : NEW_LINE INDENT if a [ end - 2 ] < 0 : NEW_LINE INDENT res . append ( end - beg - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( end - beg ) NEW_LINE DEDENT end -= 2 NEW_LINE DEDENT print ( len ( res ) ) NEW_LINE for i in res : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT"
] |
atcoder_abc028_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] c = new int [ 6 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' ) { c [ 0 ] ++ ; } else if ( s . charAt ( i ) == ' B ' ) { c [ 1 ] ++ ; } else if ( s . charAt ( i ) == ' C ' ) { c [ 2 ] ++ ; } else if ( s . charAt ( i ) == ' D ' ) { c [ 3 ] ++ ; } else if ( s . charAt ( i ) == ' E ' ) { c [ 4 ] ++ ; } else if ( s . charAt ( i ) == ' F ' ) { c [ 5 ] ++ ; } } System . out . printf ( \" % d β % d β % d β % d β % d β % d % n \" , c [ 0 ] , c [ 1 ] , c [ 2 ] , c [ 3 ] , c [ 4 ] , c [ 5 ] ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . util . stream . LongStream ; import java . io . IOException ; import java . util . stream . Collectors ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . stream . Stream ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String s = in . string ( ) ; out . println ( IntStream . rangeClosed ( ' A ' , ' F ' ) . mapToLong ( t -> s . chars ( ) . filter ( x -> x == t ) . count ( ) ) . mapToObj ( Long :: toString ) . collect ( Collectors . joining ( \" β \" ) ) ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }",
"import java . 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 ( ) ; int [ ] count = new int [ 6 ] ; for ( char cc : s . toCharArray ( ) ) count [ cc - ' A ' ] ++ ; out . printf ( \" % d β % d β % d β % d β % d β % d \\n \" , count [ 0 ] , count [ 1 ] , count [ 2 ] , count [ 3 ] , count [ 4 ] , count [ 5 ] ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }",
"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; int [ ] count = new int [ 6 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count [ s . charAt ( i ) - ' A ' ] ++ ; } System . out . println ( count [ 0 ] + \" β \" + count [ 1 ] + \" β \" + count [ 2 ] + \" β \" + count [ 3 ] + \" β \" + count [ 4 ] + \" β \" + count [ 5 ] ) ; } }",
"import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > map = new TreeMap < > ( ) ; String s = sc . next ( ) ; String A [ ] = { \" A \" , \" B \" , \" C \" , \" D \" , \" E \" , \" F \" } ; for ( int i = 0 ; i < 6 ; i ++ ) map . put ( A [ i ] , 0 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String S = s . substring ( i , i + 1 ) ; map . put ( S , map . get ( S ) + 1 ) ; } System . out . println ( map . get ( \" A \" ) + \" β \" + map . get ( \" B \" ) + \" β \" + map . get ( \" C \" ) + \" β \" + map . get ( \" D \" ) + \" β \" + map . get ( \" E \" ) + \" β \" + map . get ( \" F \" ) ) ; } }"
] | [
"str = list ( input ( ) ) NEW_LINE moji = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ] NEW_LINE for i in range ( 6 ) : NEW_LINE INDENT print ( str . count ( moji [ i ] ) , end = ' ' ) NEW_LINE if i < 5 : NEW_LINE INDENT print ( ' β ' , end = ' ' ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE",
"def count_up ( S : str ) -> list : NEW_LINE INDENT freq = { c : 0 for c in ' ABCDEF ' } NEW_LINE for c in S : NEW_LINE INDENT freq . setdefault ( c , 0 ) NEW_LINE freq [ c ] += 1 NEW_LINE DEDENT return [ v for _ , v in sorted ( freq . items ( ) ) ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT S = input ( ) NEW_LINE ans = count_up ( S ) NEW_LINE print ( ' β ' . join ( map ( str , ans ) ) ) NEW_LINE DEDENT",
"from collections import Counter NEW_LINE S = [ i for i in input ( ) ] NEW_LINE ans = [ ] NEW_LINE ans . append ( str ( S . count ( \" A \" ) ) ) NEW_LINE ans . append ( str ( S . count ( \" B \" ) ) ) NEW_LINE ans . append ( str ( S . count ( \" C \" ) ) ) NEW_LINE ans . append ( str ( S . count ( \" D \" ) ) ) NEW_LINE ans . append ( str ( S . count ( \" E \" ) ) ) NEW_LINE ans . append ( str ( S . count ( \" F \" ) ) ) NEW_LINE print ( \" β \" . join ( ans ) ) NEW_LINE",
"l = list ( input ( ) ) NEW_LINE ca = 0 NEW_LINE cb = 0 NEW_LINE cc = 0 NEW_LINE cd = 0 NEW_LINE ce = 0 NEW_LINE cf = 0 NEW_LINE for i in l : NEW_LINE INDENT if i == \" A \" : NEW_LINE INDENT ca += 1 NEW_LINE DEDENT elif i == \" B \" : NEW_LINE INDENT cb += 1 NEW_LINE DEDENT elif i == \" C \" : NEW_LINE INDENT cc += 1 NEW_LINE DEDENT elif i == \" D \" : NEW_LINE INDENT cd += 1 NEW_LINE DEDENT elif i == \" E \" : NEW_LINE INDENT ce += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cf += 1 NEW_LINE DEDENT DEDENT print ( ca , cb , cc , cd , ce , cf ) NEW_LINE",
"s = input ( ) NEW_LINE alpha = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ] NEW_LINE cnt = [ ] NEW_LINE for a in alpha [ : 5 ] : NEW_LINE INDENT print ( s . count ( a ) , end = \" β \" ) NEW_LINE DEDENT print ( s . count ( alpha [ 5 ] ) ) NEW_LINE"
] |
atcoder_abc081_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String string = scanner . nextLine ( ) ; System . out . println ( string . chars ( ) . filter ( x -> x == '1' ) . count ( ) ) ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final PrintWriter sysout = new PrintWriter ( System . out , false ) ; private static StringTokenizer buffer ; private static String readLine ( ) { buffer = null ; try { return br . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } private static String read ( ) { if ( buffer == null || ! buffer . hasMoreTokens ( ) ) { buffer = new StringTokenizer ( readLine ( ) ) ; } return buffer . nextToken ( ) ; } private static int readInt ( ) { return Integer . parseInt ( read ( ) ) ; } private static int [ ] readIntArray ( int loop ) { int [ ] result = new int [ loop ] ; for ( int i = 0 ; i < loop ; i ++ ) { result [ i ] = readInt ( ) ; } return result ; } private static int [ ] splitInt ( ) { String [ ] tmp = read ( ) . split ( \" \" ) ; int [ ] result = new int [ tmp . length ] ; for ( int i = 0 , n = tmp . length ; i < n ; i ++ ) { result [ i ] = Integer . parseInt ( tmp [ i ] ) ; } return result ; } private static long readLong ( ) { return Long . parseLong ( read ( ) ) ; } private static double readDouble ( ) { return Double . parseDouble ( read ( ) ) ; } public static void main ( String [ ] args ) { run ( ) ; } private static void run ( ) { String [ ] input = readLine ( ) . split ( \" \" ) ; int count = 0 ; if ( input [ 0 ] . equals ( \"1\" ) ) count ++ ; if ( input [ 1 ] . equals ( \"1\" ) ) count ++ ; if ( input [ 2 ] . equals ( \"1\" ) ) count ++ ; System . out . println ( count ) ; } }",
"import java . util . Scanner ; class Main { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; System . out . println ( calc ( S ) ) ; } public static int calc ( String S ) { String [ ] s = S . split ( \" \" ) ; int count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] . equals ( \"1\" ) ) { count ++ ; } } return count ; } }",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int num = scan . nextInt ( ) ; int cnt = 0 ; boolean a = num > 99 ; if ( a ) { cnt ++ ; num = num - 100 ; } boolean b = num > 9 ; if ( b ) { num = num - 10 ; cnt ++ ; } boolean c = num == 1 ; if ( c ) { cnt ++ ; } System . out . println ( cnt ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] array = sc . nextLine ( ) . split ( \" \" ) ; int sum = 0 ; for ( String s : array ) { if ( Integer . parseInt ( s ) == 1 ) { sum ++ ; } } System . out . println ( sum ) ; } }"
] | [
"print ( input ( ) . count ( \"1\" ) ) NEW_LINE",
"s = int ( input ( ) ) NEW_LINE i = 0 NEW_LINE if ( s // 100 == 1 ) : NEW_LINE INDENT i = i + 1 NEW_LINE s = s - 100 NEW_LINE DEDENT if ( s // 10 == 1 ) : NEW_LINE INDENT i = i + 1 NEW_LINE s = s - 10 NEW_LINE DEDENT if ( s == 1 ) : NEW_LINE INDENT i = i + 1 NEW_LINE DEDENT print ( i ) NEW_LINE",
"s = input ( ) NEW_LINE counter = 0 NEW_LINE if s [ 0 ] == '1' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT if s [ 1 ] == '1' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT if s [ 2 ] == '1' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT print ( counter ) NEW_LINE",
"str = list ( input ( ) ) NEW_LINE s1 = int ( str [ 0 ] ) NEW_LINE s2 = int ( str [ 1 ] ) NEW_LINE s3 = int ( str [ 2 ] ) NEW_LINE print ( s1 + s2 + s3 ) NEW_LINE",
"S = input ( ) NEW_LINE cnt = 0 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT if S [ i ] == \"1\" : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE"
] |
atcoder_abc089_C | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] cnt = new long [ 5 ] ; for ( int i = 0 ; i < n ; i ++ ) { char ch = sc . next ( ) . charAt ( 0 ) ; if ( ch == ' M ' ) cnt [ 0 ] ++ ; if ( ch == ' A ' ) cnt [ 1 ] ++ ; if ( ch == ' R ' ) cnt [ 2 ] ++ ; if ( ch == ' C ' ) cnt [ 3 ] ++ ; if ( ch == ' H ' ) cnt [ 4 ] ++ ; } sc . close ( ) ; int c = 0 ; for ( int i = 0 ; i < cnt . length ; i ++ ) { if ( cnt [ i ] > 0 ) c ++ ; } if ( c < 3 ) { System . out . println ( 0 ) ; return ; } long ans = 0L ; for ( int i = 0 ; i < cnt . length ; i ++ ) { for ( int j = i + 1 ; j < cnt . length ; j ++ ) { for ( int k = j + 1 ; k < cnt . length ; k ++ ) { ans += cnt [ i ] * cnt [ j ] * cnt [ k ] ; } } } System . out . println ( ans ) ; } }",
"public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; long m = 0 , a = 0 , r = 0 , c = 0 , h = 0 ; for ( int i = 0 ; i < n ; i ++ ) { switch ( scanner . next ( ) . charAt ( 0 ) ) { case ' M ' : m ++ ; continue ; case ' A ' : a ++ ; continue ; case ' R ' : r ++ ; continue ; case ' C ' : c ++ ; continue ; case ' H ' : h ++ ; } } System . out . println ( m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h ) ; } }",
"import java . util . * ; public class Main { static long Examine ( long countM , long countA , long countR , long countC , long countH ) { long count = 0 ; count += countR * countC * countH ; count += countA * countC * countH ; count += countA * countR * countH ; count += countA * countR * countC ; count += countM * countC * countH ; count += countM * countR * countH ; count += countM * countR * countC ; count += countM * countA * countH ; count += countM * countA * countC ; count += countM * countA * countR ; return count ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String [ ] names = new String [ N ] ; long countM = 0 ; long countA = 0 ; long countR = 0 ; long countC = 0 ; long countH = 0 ; String [ ] I = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { names [ i ] = sc . next ( ) ; I [ i ] = names [ i ] . substring ( 0 , 1 ) ; } for ( int k = 0 ; k < N ; k ++ ) { if ( I [ k ] . equals ( \" M \" ) ) countM ++ ; else if ( I [ k ] . equals ( \" A \" ) ) countA ++ ; else if ( I [ k ] . equals ( \" R \" ) ) countR ++ ; else if ( I [ k ] . equals ( \" C \" ) ) countC ++ ; else if ( I [ k ] . equals ( \" H \" ) ) countH ++ ; } System . out . println ( Examine ( countM , countA , countR , countC , countH ) ) ; sc . close ( ) ; } }",
"import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] startNum = new long [ ' Z ' - ' A ' + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { String str = sc . next ( ) ; startNum [ str . charAt ( 0 ) - ' A ' ] ++ ; } long comb = 0 ; char [ ] march = new char [ ] { ' M ' , ' A ' , ' R ' , ' C ' , ' H ' } ; for ( int i = 0 ; i < march . length ; i ++ ) { for ( int j = i + 1 ; j < march . length ; j ++ ) { for ( int k = j + 1 ; k < march . length ; k ++ ) { comb += startNum [ march [ i ] - ' A ' ] * startNum [ march [ j ] - ' A ' ] * startNum [ march [ k ] - ' A ' ] ; } } } out . println ( comb ) ; } }",
"import java . io . File ; import java . io . IOException ; import java . lang . reflect . Array ; import java . util . * ; import java . util . Map . Entry ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; long [ ] march = new long [ 5 ] ; String marchS = \" MARCH \" ; for ( int i = 0 ; i < N ; i ++ ) { String S = in . next ( ) . substring ( 0 , 1 ) ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( S . equals ( String . valueOf ( marchS . charAt ( j ) ) ) ) { march [ j ] ++ ; break ; } } } long ans = 0 ; for ( int i = 0 ; i < 5 - 2 ; i ++ ) { for ( int j = i + 1 ; j < 5 - 1 ; j ++ ) { for ( int k = j + 1 ; k < 5 ; k ++ ) { ans += march [ i ] * march [ j ] * march [ k ] ; } } } System . out . println ( ans ) ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE S = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT S . append ( list ( input ( ) ) [ 0 ] ) NEW_LINE DEDENT count = [ 0 ] * 5 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] == \" M \" : NEW_LINE INDENT count [ 0 ] += 1 NEW_LINE DEDENT elif S [ i ] == \" A \" : NEW_LINE INDENT count [ 1 ] += 1 NEW_LINE DEDENT elif S [ i ] == \" R \" : NEW_LINE INDENT count [ 2 ] += 1 NEW_LINE DEDENT elif S [ i ] == \" C \" : NEW_LINE INDENT count [ 3 ] += 1 NEW_LINE DEDENT elif S [ i ] == \" H \" : NEW_LINE INDENT count [ 4 ] += 1 NEW_LINE DEDENT DEDENT sum = 0 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT sum += count [ i ] * count [ i + 1 ] * count [ i + 2 ] NEW_LINE DEDENT for i in range ( 2 ) : NEW_LINE INDENT sum += count [ i ] * count [ i + 1 ] * count [ i + 3 ] NEW_LINE sum += count [ i ] * count [ i + 2 ] * count [ i + 3 ] NEW_LINE DEDENT for i in range ( 3 ) : NEW_LINE INDENT sum += count [ 0 ] * count [ i + 1 ] * count [ 4 ] NEW_LINE DEDENT print ( sum ) NEW_LINE",
"from itertools import combinations NEW_LINE from numpy import prod NEW_LINE N = int ( input ( ) ) NEW_LINE S = [ input ( ) for _ in range ( N ) ] NEW_LINE first_chars = { ' M ' : 0 , ' A ' : 0 , ' R ' : 0 , ' C ' : 0 , ' H ' : 0 } NEW_LINE for s in S : NEW_LINE INDENT if s [ 0 ] in first_chars . keys ( ) : NEW_LINE INDENT first_chars [ s [ 0 ] ] += 1 NEW_LINE DEDENT DEDENT combs = list ( combinations ( [ v for v in first_chars . values ( ) if v > 0 ] , 3 ) ) NEW_LINE print ( sum ( [ prod ( comb ) for comb in combs ] ) ) NEW_LINE",
"from itertools import * ; s , * _ = zip ( * open ( 0 ) ) ; print ( sum ( p * q * r for p , q , r in combinations ( map ( s . count , ' MARCH ' ) , 3 ) ) ) NEW_LINE",
"import itertools NEW_LINE n = int ( input ( ) ) NEW_LINE s = [ [ ] for _ in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT s [ i ] = list ( input ( ) ) NEW_LINE DEDENT delete = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if s [ i ] [ 0 ] == \" M \" or s [ i ] [ 0 ] == \" A \" or s [ i ] [ 0 ] == \" R \" or s [ i ] [ 0 ] == \" C \" or s [ i ] [ 0 ] == \" H \" : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT delete . append ( i ) NEW_LINE DEDENT DEDENT diff = 0 NEW_LINE for i in range ( len ( delete ) ) : NEW_LINE INDENT del s [ delete [ i ] - diff ] NEW_LINE diff += 1 NEW_LINE DEDENT cand = [ 0 , 0 , 0 , 0 , 0 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] [ 0 ] == \" M \" : NEW_LINE INDENT cand [ 0 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == \" A \" : NEW_LINE INDENT cand [ 1 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == \" R \" : NEW_LINE INDENT cand [ 2 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == \" C \" : NEW_LINE INDENT cand [ 3 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == \" H \" : NEW_LINE INDENT cand [ 4 ] += 1 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 5 ) : NEW_LINE INDENT for j in range ( 5 ) : NEW_LINE INDENT if i == j : NEW_LINE INDENT break NEW_LINE DEDENT for k in range ( 5 ) : NEW_LINE INDENT if i == k : NEW_LINE INDENT break NEW_LINE DEDENT if j == k : NEW_LINE INDENT break NEW_LINE DEDENT ans += int ( cand [ i ] * cand [ j ] * cand [ k ] ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE S = [ input ( ) for i in range ( N ) ] NEW_LINE S_march = [ ] NEW_LINE MARCH = [ \" M \" , \" A \" , \" R \" , \" C \" , \" H \" ] NEW_LINE cmb = [ ] NEW_LINE ans = 0 NEW_LINE N_march = [ 0 ] * 5 NEW_LINE for Si in S : NEW_LINE INDENT for j in range ( 5 ) : NEW_LINE INDENT if Si [ : 1 ] == MARCH [ j ] : NEW_LINE INDENT N_march [ j ] += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( 2 ** 5 ) : NEW_LINE INDENT check = [ False ] * 5 NEW_LINE for j in range ( 5 ) : NEW_LINE INDENT if ( i >> j ) & 1 : NEW_LINE INDENT check [ j ] = True NEW_LINE DEDENT DEDENT if check . count ( True ) == 3 : NEW_LINE INDENT cmb . append ( check ) NEW_LINE DEDENT DEDENT for i in cmb : NEW_LINE INDENT tmp_list = [ ] NEW_LINE for j in range ( 5 ) : NEW_LINE INDENT if i [ j ] : NEW_LINE INDENT tmp_list . append ( N_march [ j ] ) NEW_LINE DEDENT DEDENT ans += tmp_list [ 0 ] * tmp_list [ 1 ] * tmp_list [ 2 ] NEW_LINE DEDENT print ( ans ) NEW_LINE NEW_LINE"
] |
atcoder_abc077_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ans = 1 ; int tmp = 0 ; while ( ( tmp + 1 ) * ( tmp + 1 ) <= N ) { ans = ( tmp + 1 ) * ( tmp + 1 ) ; tmp ++ ; } System . out . println ( ans ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; true ; i ++ ) { if ( Math . pow ( i , 2 ) > N ) { ans = ( int ) Math . pow ( i - 1 , 2 ) ; break ; } else if ( Math . pow ( i , 2 ) == N ) { ans = ( int ) Math . pow ( i - 1 , 2 ) ; } } out . println ( ans ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { B ( ) ; } public static void A ( ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s1 . charAt ( i ) != s2 . charAt ( 2 - i ) ) { System . out . println ( \" NO \" ) ; return ; } } System . out . println ( \" YES \" ) ; } public static long binsearchN2 ( long left , long right , int N ) { if ( left >= right ) return ( long ) Math . pow ( right , 2 ) ; long mid = ( left + right ) / 2 ; if ( Math . pow ( mid , 2 ) > N ) return binsearchN2 ( left , mid - 1 , N ) ; else { if ( Math . pow ( mid + 1 , 2 ) > N ) return ( long ) Math . pow ( mid , 2 ) ; else return binsearchN2 ( mid + 1 , right , N ) ; } } public static void B ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; System . out . println ( binsearchN2 ( 0 , N , N ) ) ; } }",
"import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; System . out . println ( ( int ) Math . pow ( ( int ) Math . sqrt ( n ) , 2 ) ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long n = in . nextLong ( ) ; long ans = 0 ; for ( long i = 1 ; i * i <= n ; i ++ ) { ans = i * i ; } out . print ( ans ) ; } } }"
] | [
"N = int ( input ( ) ) NEW_LINE print ( int ( N ** .5 ) ** 2 ) NEW_LINE",
"N = int ( input ( ) . strip ( ) ) NEW_LINE for i in range ( N , 0 , - 1 ) : NEW_LINE INDENT kai = int ( pow ( i , 0.5 ) ) NEW_LINE if i == kai * kai : NEW_LINE INDENT print ( i ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT",
"from sys import exit NEW_LINE N = int ( input ( ) ) NEW_LINE anss = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( i ** 2 > N ) : NEW_LINE INDENT anss = i - 1 NEW_LINE break NEW_LINE DEDENT DEDENT print ( anss ** 2 ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE heihousu = [ ] NEW_LINE s = 0 NEW_LINE t = 0 NEW_LINE while ( t <= N ) : NEW_LINE INDENT s += 1 NEW_LINE t = s ** 2 NEW_LINE heihousu . append ( t ) NEW_LINE DEDENT print ( heihousu [ - 2 ] ) NEW_LINE",
"n = int ( input ( ) ) NEW_LINE import math NEW_LINE a = math . floor ( math . sqrt ( n ) ) NEW_LINE print ( a ** 2 ) NEW_LINE"
] |
atcoder_abc078_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; sc . close ( ) ; X = X - Z ; int ans = 0 ; while ( X >= 0 ) { X = X - ( Y + Z ) ; ans ++ ; } System . out . println ( ans == 0 ? 0 : ans - 1 ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int x = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int y = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int z = Integer . parseInt ( tokenizer . nextToken ( ) ) ; x -= z ; if ( x < 1 ) { System . out . println ( 0 ) ; } else { System . out . println ( x / ( y + z ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { B ( ) ; } public static void A ( ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; if ( s1 . compareTo ( s2 ) < 0 ) System . out . println ( \" < \" ) ; else if ( s1 . compareTo ( s2 ) == 0 ) System . out . println ( \" = \" ) ; else System . out . println ( \" > \" ) ; } public static void B ( ) { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; if ( X < Y || X < Z ) { System . out . println ( 0 ) ; return ; } X -= Z ; System . out . println ( X / ( Y + Z ) ) ; } }",
"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int ans = x / ( z + y ) ; if ( ans * ( z + y ) + z <= x ) System . out . println ( ans ) ; else System . out . println ( ans - 1 ) ; } }",
"import java . util . Scanner ; public class Main { static long N ; static long ans ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int semians = x / ( y + z ) ; if ( x % ( y + z ) < z ) semians -= 1 ; System . out . println ( semians ) ; } }"
] | [
"x , y , z = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE num = ( x - z ) // ( z + y ) NEW_LINE print ( num ) NEW_LINE",
"X , Y , Z = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE width_sum = 0 NEW_LINE while 1 : NEW_LINE INDENT if width_sum + Y + Z <= X - Z : NEW_LINE INDENT width_sum += Y + Z NEW_LINE ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"x , width , space = map ( int , input ( ) . split ( ) ) NEW_LINE N = 0 NEW_LINE if x < width + space : NEW_LINE INDENT print ( \"0\" ) NEW_LINE DEDENT else : NEW_LINE INDENT total_space = width + ( space ) NEW_LINE N = ( x - space ) // total_space NEW_LINE DEDENT print ( N ) NEW_LINE",
"import math NEW_LINE a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE a -= c NEW_LINE print ( math . floor ( a / ( b + c ) ) ) NEW_LINE",
"x , y , z = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE print ( ( x - z ) // ( y + z ) ) NEW_LINE"
] |
atcoder_abc041_D | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] x = new int [ M ] ; int [ ] y = new int [ M ] ; ArrayList [ ] edge = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { edge [ i ] = new ArrayList ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { x [ i ] = sc . nextInt ( ) - 1 ; y [ i ] = sc . nextInt ( ) - 1 ; edge [ x [ i ] ] . add ( y [ i ] ) ; } long [ ] dp = new long [ ( int ) Math . pow ( 2 , N ) ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < ( int ) Math . pow ( 2 , N ) ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) { boolean flg = true ; for ( int k = 0 ; k < N ; k ++ ) { if ( ( i & ( 1 << k ) ) != 0 && edge [ j ] . contains ( k ) ) flg = false ; } if ( flg ) dp [ i ] += dp [ i - ( 1 << j ) ] ; } } } System . out . println ( dp [ ( int ) Math . pow ( 2 , N ) - 1 ] ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .",
"import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; boolean [ ] [ ] info = new boolean [ N ] [ N ] ; for ( int i = 0 ; i < M ; i ++ ) { info [ sc . nextInt ( ) - 1 ] [ sc . nextInt ( ) - 1 ] = true ; } long [ ] dp = new long [ ( int ) Math . pow ( 2 , N ) ] ; boolean [ ] flag = new boolean [ ( int ) Math . pow ( 2 , N ) ] ; dp [ 0 ] = 1L ; flag [ 0 ] = true ; Queue < Integer > que = new ArrayDeque < > ( ) ; que . add ( 0 ) ; while ( ! que . isEmpty ( ) ) { int cur = que . poll ( ) ; check : for ( int i = 0 ; i < N ; i ++ ) { if ( ( cur >> i & 1 ) == 1 ) { continue ; } for ( int j = 0 ; j < N ; j ++ ) { if ( ( cur >> j & 1 ) == 1 && info [ i ] [ j ] ) { continue check ; } } dp [ cur + ( 1 << i ) ] += dp [ cur ] ; if ( ! flag [ cur + ( 1 << i ) ] ) { que . add ( cur + ( 1 << i ) ) ; flag [ cur + ( 1 << i ) ] = true ; } } } for ( int i = 0 ; i < ( int ) Math . pow ( 2 , N ) ; i ++ ) { } System . out . println ( dp [ ( int ) Math . pow ( 2 , N ) - 1 ] ) ; } }",
"import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] g = new int [ n ] ; for ( int i = 0 ; i < m ; ++ i ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; g [ x ] |= 1 << y ; } long [ ] dp = new long [ 1 << n ] ; dp [ 0 ] = 1 ; for ( int b = 1 ; b < 1 << n ; ++ b ) { for ( int i = 0 ; i < n ; ++ i ) { if ( ( b & 1 << i ) == 0 ) continue ; if ( ( ( b ^ 1 << i ) & g [ i ] ) == 0 ) dp [ b ] += dp [ b ^ 1 << i ] ; } } out . println ( dp [ ( 1 << n ) - 1 ] ) ; out . close ( ) ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = \" \" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }",
"import java . util . ArrayDeque ; import java . util . HashMap ; import java . util . Map ; import java . util . Queue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; Node [ ] nodes = new Node [ N ] ; for ( int i = 0 ; i < N ; i ++ ) nodes [ i ] = new Node ( i ) ; for ( int i = 0 ; i < M ; i ++ ) { Node x = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ; Node y = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ; x . neighbor . put ( y , 1 ) ; } sc . close ( ) ; int S = 1 << N ; long [ ] dp = new long [ S ] ; dp [ 0 ] = 1 ; Queue < Integer > que = new ArrayDeque < > ( ) ; que . add ( 0 ) ; while ( ! que . isEmpty ( ) ) { int s = que . remove ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( 1 << i & s ) > 0 ) continue ; boolean check = true ; for ( int j = 0 ; j < N ; j ++ ) { if ( ( 1 << j & s ) > 0 && nodes [ i ] . neighbor . containsKey ( nodes [ j ] ) ) { check = false ; break ; } } if ( check ) { if ( dp [ s + ( 1 << i ) ] == 0 ) { que . add ( s + ( 1 << i ) ) ; } dp [ s + ( 1 << i ) ] += dp [ s ] ; } } } System . out . println ( dp [ S - 1 ] ) ; } static class Node { int id ; Map < Node , Integer > neighbor = new HashMap < > ( ) ; Node ( int id ) { this . id = id ; } } }",
"import java . util . Scanner ; public class Main { static int [ ] [ ] xy ; static int [ ] two ; static int N ; static long [ ] dp ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; two = new int [ N ] ; two [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { two [ i ] = two [ i - 1 ] * 2 ; } xy = new int [ N ] [ N ] ; for ( int i = 0 ; i < M ; i ++ ) { int x = scan . nextInt ( ) - 1 ; int y = scan . nextInt ( ) - 1 ; xy [ y ] [ x ] = - 1 ; } dp = new long [ two [ N - 1 ] * 2 ] ; dp [ 0 ] = 1 ; System . out . println ( res ( two [ N - 1 ] * 2 - 1 ) ) ; } static long res ( int bit ) { if ( dp [ bit ] > 0 ) return dp [ bit ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( two [ i ] & bit ) > 0 ) { if ( admit ( bit - two [ i ] , i ) ) { dp [ bit ] += res ( bit - two [ i ] ) ; } } } return dp [ bit ] ; } static boolean admit ( int bit , int k ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( two [ i ] & bit ) > 0 ) { if ( xy [ i ] [ k ] == - 1 ) { return false ; } } } return true ; } }"
] | [
"def running ( N : int , M : int , queries : list ) -> int : NEW_LINE INDENT PHI = 0 NEW_LINE g = [ [ 0 ] * N for _ in range ( N ) ] NEW_LINE for u , v in queries : NEW_LINE INDENT g [ u - 1 ] [ v - 1 ] = 1 NEW_LINE g [ v - 1 ] [ u - 1 ] = - 1 NEW_LINE DEDENT dp = [ 0 for _ in range ( 1 << N ) ] NEW_LINE dp [ PHI ] = 1 NEW_LINE for S in range ( 1 , 1 << N ) : NEW_LINE INDENT for v in range ( N ) : NEW_LINE INDENT if S & ( 1 << v ) == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT S_v = S & ~ ( 1 << v ) NEW_LINE if any ( ( S_v & ( 1 << k ) ) and g [ k ] [ v ] == - 1 for k in range ( N ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT dp [ S ] += dp [ S_v ] NEW_LINE DEDENT DEDENT return dp [ ( 1 << N ) - 1 ] NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT M = 0 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( M ) ] NEW_LINE ans = running ( N , M , queries ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"from collections import defaultdict NEW_LINE from heapq import heappush , heappop NEW_LINE import sys NEW_LINE import math NEW_LINE import bisect NEW_LINE import random NEW_LINE def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def LS ( ) : return list ( map ( list , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE def S ( ) : return list ( sys . stdin . readline ( ) ) [ : - 1 ] NEW_LINE def IR ( n ) : return [ I ( ) for i in range ( n ) ] NEW_LINE def LIR ( n ) : return [ LI ( ) for i in range ( n ) ] NEW_LINE def SR ( n ) : return [ S ( ) for i in range ( n ) ] NEW_LINE def LSR ( n ) : return [ LS ( ) for i in range ( n ) ] NEW_LINE mod = 1000000007 NEW_LINE n , m = LI ( ) NEW_LINE out = [ 0 for i in range ( n ) ] NEW_LINE pow2 = [ 1 ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT pow2 . append ( pow2 [ - 1 ] * 2 ) NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT x , y = LI ( ) NEW_LINE x -= 1 NEW_LINE y -= 1 NEW_LINE out [ x ] += pow2 [ y ] NEW_LINE DEDENT k = pow2 [ n ] NEW_LINE dp = [ 0 for i in range ( k ) ] NEW_LINE dp [ 0 ] = 1 NEW_LINE bi = [ [ i , pow2 [ i ] ] for i in range ( n ) ] NEW_LINE for i in range ( k ) : NEW_LINE INDENT for j , bij in bi : NEW_LINE INDENT if ( not ( i & bij ) ) and ( not ( i & out [ j ] ) ) : NEW_LINE INDENT dp [ i | bij ] += dp [ i ] NEW_LINE DEDENT DEDENT DEDENT print ( dp [ - 1 ] ) NEW_LINE NEW_LINE",
"N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE li = [ 1 << i for i in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT x , y = [ int ( i ) - 1 for i in input ( ) . split ( ) ] NEW_LINE li [ x ] = li [ x ] | ( 1 << y ) NEW_LINE DEDENT lisDP = [ { } for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ke = 1 << i NEW_LINE lisDP [ 0 ] [ ke ] = 1 NEW_LINE DEDENT for i in range ( N - 1 ) : NEW_LINE INDENT for bik , biv in lisDP [ i ] . items ( ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if bik & li [ j ] == 0 : NEW_LINE INDENT foo = bik | ( 1 << j ) NEW_LINE if foo in lisDP [ i + 1 ] . keys ( ) : NEW_LINE INDENT lisDP [ i + 1 ] [ foo ] += biv NEW_LINE DEDENT else : NEW_LINE INDENT lisDP [ i + 1 ] [ foo ] = biv NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT allnum = ( 1 << N ) - 1 NEW_LINE print ( lisDP [ N - 1 ] [ allnum ] ) NEW_LINE",
"import sys NEW_LINE from collections import deque , defaultdict NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE n , m = LI ( ) NEW_LINE G = [ [ ] for _ in range ( n ) ] NEW_LINE for _ in range ( m ) : NEW_LINE INDENT x , y = LI_ ( ) NEW_LINE G [ x ] . append ( y ) NEW_LINE DEDENT dp = [ 0 ] * ( 1 << n ) NEW_LINE dp [ 0 ] = 1 NEW_LINE for s in range ( 1 << n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if s >> i & 1 == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT others = s ^ ( 1 << i ) NEW_LINE for to in G [ i ] : NEW_LINE INDENT if others & ( 1 << to ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT dp [ s ] += dp [ others ] NEW_LINE DEDENT DEDENT DEDENT print ( dp [ - 1 ] ) NEW_LINE",
"I = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE n , m = I ( ) NEW_LINE v = [ 0 ] * n NEW_LINE d = [ 1 ] + [ 0 ] * 2 ** n NEW_LINE for _ in [ 0 ] * m : s , g = I ( ) ; v [ s - 1 ] += 1 << g - 1 NEW_LINE i , j = 0 , - 1 NEW_LINE for _ in range ( n * 2 ** n ) : NEW_LINE INDENT j += 1 NEW_LINE if j == n : NEW_LINE INDENT i += 1 NEW_LINE j = 0 NEW_LINE DEDENT d [ i | 1 << j ] += d [ i ] * ( i & ( 1 << j | v [ j ] ) < 1 ) NEW_LINE DEDENT print ( d [ - 2 ] ) NEW_LINE"
] |
atcoder_arc075_D | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int D = sc . nextInt ( ) ; System . out . println ( solve ( D ) ) ; sc . close ( ) ; } static final int MAXL = 17 ; static int N ; static long [ ] v ; static long solve ( int D ) { if ( D % 9 != 0 ) return 0 ; D /= 9 ; long [ ] B = new long [ MAXL ] ; B [ 0 ] = 1 ; for ( int i = 1 ; i < MAXL ; i ++ ) B [ i ] = B [ i - 1 ] * 10 ; long ans = 0 ; for ( int i = 1 ; i <= MAXL ; i ++ ) { N = ( i + 1 ) / 2 ; v = new long [ N ] ; for ( int j = 0 ; j < N ; j ++ ) for ( int k = j ; k < i - j ; k ++ ) v [ j ] += B [ k ] ; ans += count ( D , i , 0 , new int [ N ] ) ; } return ans ; } static long count ( long D , int l , int t , int [ ] x ) { if ( t == N ) { if ( D != 0 ) return 0 ; long ans = 1 ; for ( int i = 0 ; i < N ; i ++ ) { ans *= ( i == 0 ? 9 : 10 ) - Math . abs ( x [ i ] ) ; } if ( l % 2 == 0 ) ans *= 10 ; return ans ; } long ans = 0 ; for ( int m = - 9 ; m <= 9 ; m ++ ) { if ( - v [ t ] < D + v [ t ] * m && D + v [ t ] * m < v [ t ] ) { x [ t ] = m ; ans += count ( D + v [ t ] * m , l , t + 1 , x ) ; } } return ans ; } }",
"import java . util . * ; public class Main { public static long [ ] buildValues ( int d ) { long [ ] res = new long [ d / 2 ] ; long high = ( long ) Math . pow ( 10 , d - 1 ) ; long low = 1L ; for ( int i = 0 ; i < d / 2 ; i ++ ) { res [ i ] = high - low ; high /= 10 ; low *= 10 ; } return res ; } public static long calc ( long [ ] vs , long D ) { long res = 1 ; long ten = 10 ; for ( int i = 0 ; i < vs . length ; i ++ ) { long now = 0 ; while ( D % ten != 0 && now < 9 ) { D -= vs [ i ] ; now ++ ; } D = Math . abs ( D ) ; ten *= 10 ; res *= ( i == 0 ) ? ( 9 - now ) : ( 10 - now ) ; } return D == 0 ? res : 0 ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int D = in . nextInt ( ) ; long res = 0 ; for ( int d = 1 ; d <= 20 ; d ++ ) { long [ ] vs = buildValues ( d ) ; long next = calc ( vs , D ) ; if ( d % 2 == 1 ) next *= 10 ; res += next ; } System . out . println ( res ) ; } static int rev ( int x ) { String s = \"0\" ; while ( x > 0 ) { s += x % 10 + \" \" ; x /= 10 ; } return Integer . valueOf ( s ) ; } }"
] | [
"def solve ( d , K ) : NEW_LINE INDENT r = 1 NEW_LINE for k in range ( K , 1 , - 2 ) : NEW_LINE INDENT if d >= 10 ** k : NEW_LINE INDENT return 0 NEW_LINE DEDENT t = ( - d ) % 10 NEW_LINE d = abs ( ( d - t * ( 10 ** ( k - 1 ) - 1 ) ) // 10 ) NEW_LINE r *= 10 - t - ( K == k ) NEW_LINE DEDENT return r * ( 10 ** ( K % 2 ) ) if d == 0 else 0 NEW_LINE DEDENT D = int ( input ( ) ) NEW_LINE result = 0 NEW_LINE l = len ( str ( D ) ) NEW_LINE for k in range ( l , 2 * l + 1 ) : NEW_LINE INDENT result += solve ( D , k ) NEW_LINE DEDENT print ( result ) NEW_LINE",
"def solve ( k , d , fl ) : NEW_LINE INDENT if k <= 1 : NEW_LINE INDENT if d == 0 : NEW_LINE INDENT return 10 ** k NEW_LINE DEDENT return 0 NEW_LINE DEDENT x = ( - d ) % 10 NEW_LINE c = 9 - x + 1 - fl NEW_LINE d -= 10 ** ( k - 1 ) * x - x NEW_LINE return c * solve ( k - 2 , abs ( d ) // 10 , 0 ) NEW_LINE DEDENT d = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , 100 ) : NEW_LINE INDENT ans += solve ( i , d , 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE",
"def result ( letters , number , cant_zero ) : NEW_LINE INDENT if letters <= 1 : NEW_LINE INDENT if number == 0 : NEW_LINE INDENT return 10 ** letters NEW_LINE DEDENT return 0 NEW_LINE DEDENT diff = ( 10 - number % 10 ) % 10 NEW_LINE variants = number % 10 - cant_zero NEW_LINE if number % 10 == 0 : NEW_LINE INDENT variants = 10 - cant_zero NEW_LINE DEDENT number -= diff * ( 10 ** ( letters - 1 ) - 1 ) NEW_LINE number = abs ( number // 10 ) NEW_LINE return variants * result ( letters - 2 , number , 0 ) NEW_LINE DEDENT d = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 20 ) : NEW_LINE INDENT ans += result ( i , d , 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE",
"def solve ( d , k , outer ) : NEW_LINE INDENT if k <= 1 : NEW_LINE INDENT return 10 ** k if d == 0 else 0 NEW_LINE DEDENT t = ( - d ) % 10 NEW_LINE d -= t * 10 ** ( k - 1 ) - t NEW_LINE return ( 10 - t - outer ) * solve ( abs ( d // 10 ) , k - 2 , 0 ) NEW_LINE DEDENT D = int ( input ( ) ) NEW_LINE result = 0 NEW_LINE for k in range ( 1 , 20 ) : NEW_LINE INDENT result += solve ( D , k , 1 ) NEW_LINE DEDENT print ( result ) NEW_LINE"
] |
atcoder_arc083_A | [
"import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static IntStream REPS ( int v ) { return IntStream . range ( 0 , v ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INS ( int n ) { return REPS ( n ) . map ( i -> getInt ( ) ) ; } static Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { int a = getInt ( ) , b = getInt ( ) , c = getInt ( ) , d = getInt ( ) , e = getInt ( ) , f = getInt ( ) ; int rw = 100 * a , rs = 0 ; double max = 0 ; for ( int i = 0 ; true ; ++ i ) { int va = 100 * a * i ; if ( va > f ) break ; for ( int j = 0 ; true ; ++ j ) { int vb = 100 * b * j ; if ( va + vb > f ) break ; for ( int k = 0 ; true ; ++ k ) { int vc = c * k ; if ( va + vb + vc > f ) break ; for ( int l = 0 ; true ; ++ l ) { int vd = d * l ; if ( va + vb + vc + vd > f ) break ; if ( max < calc ( va + vb , vc + vd , e ) ) { max = calc ( va + vb , vc + vd , e ) ; rw = va + vb ; rs = vc + vd ; } } } } } System . out . println ( rw + rs + \" β \" + rs ) ; } private static double calc ( int w , int s , int e ) { double r = w == 0 ? 0 : 100.0 * s / ( w + s ) ; return w / 100 * e < s ? 0 : r ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; int e = in . nextInt ( ) ; int f = in . nextInt ( ) ; int res = 0 , sugar = 0 ; for ( int va = 0 ; va <= f ; va += 100 * a ) { for ( int vb = 0 ; va + vb <= f ; vb += 100 * b ) { int water = va + vb ; int upper = water / 100 * e ; for ( int vc = 0 ; water + vc <= f && vc <= upper ; vc += c ) { for ( int vd = 0 ; water + vc + vd <= f && vc + vd <= upper ; vd += d ) { if ( sugar == 0 ) { sugar = vc + vd ; res = water + sugar ; } else { if ( ( vc + vd ) * res > sugar * ( water + vc + vd ) ) { sugar = vc + vd ; res = water + sugar ; } } } } } } System . out . println ( res + \" β \" + sugar ) ; } } }",
"import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int E = sc . nextInt ( ) ; int F = sc . nextInt ( ) ; Set < Integer > waterSet = new HashSet < > ( ) ; Set < Integer > sugarSet = new HashSet < > ( ) ; createSugar ( sugarSet , C , D , F ) ; createWater ( waterSet , A , B , F ) ; double maxRatio = - 1 ; int resultSugar = - 1 ; int resultWater = - 1 ; for ( int water : waterSet ) { for ( int sugar : sugarSet ) { if ( ( water + sugar ) <= F && sugar <= ( water / 100 ) * E ) { double ratio = ( ( double ) ( 100 * sugar ) ) / ( water + sugar ) ; if ( ratio > maxRatio ) { maxRatio = ( ( double ) ( 100 * sugar ) ) / ( water + sugar ) ; resultSugar = sugar ; resultWater = water ; } } } } System . out . println ( resultSugar + resultWater + \" β \" + resultSugar ) ; } private static void createWater ( Set < Integer > waterSet , int A , int B , int F ) { for ( int i = 0 ; i < F ; i ++ ) { for ( int j = 0 ; j < F ; j ++ ) { int water = A * 100 * i + B * 100 * j ; if ( water != 0 && water < F ) waterSet . add ( water ) ; } } } private static void createSugar ( Set < Integer > sugarSet , int C , int D , int F ) { for ( int i = 0 ; i < F ; i ++ ) { for ( int j = 0 ; j < F ; j ++ ) { int sugar = C * i + D * j ; if ( sugar < F ) sugarSet . add ( sugar ) ; } } } }",
"import java . util . ArrayList ; import java . util . Scanner ; public class Main { int a , b , c , d , e , f ; private ArrayList < Integer > listW , listS ; public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . read ( ) ; m . solve ( ) ; } private void read ( ) { Scanner sc = new Scanner ( System . in ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; d = sc . nextInt ( ) ; e = sc . nextInt ( ) ; f = sc . nextInt ( ) ; listW = new ArrayList < > ( ) ; listS = new ArrayList < > ( ) ; } private double calc ( int a , int b ) { return ( double ) ( 100 * b ) / ( a + b ) ; } private void solve ( ) { for ( int i = 0 ; i < f ; i ++ ) { for ( int j = 0 ; j < f ; j ++ ) { int w = a * i + b * j ; w *= 100 ; if ( w != 0 && w < f ) { listW . add ( w ) ; } } } for ( int i = 0 ; i < f ; i ++ ) { for ( int j = 0 ; j < f ; j ++ ) { int s = c * i + d * j ; if ( s < f ) listS . add ( s ) ; } } double rate = - 1. ; int ansS = - 1 , ansW = - 1 ; for ( int w : listW ) { for ( int s : listS ) { if ( w + s <= f && s <= ( w / 100 ) * e ) { double tmp = calc ( w , s ) ; if ( rate < tmp ) { ansS = s ; ansW = w ; rate = tmp ; } } } } System . out . printf ( \" % d β % d \\n \" , ( ansS + ansW ) , ansS ) ; } }",
"import java . util . Scanner ; public class Main { private static boolean isGreater ( int p , int q , int pp , int qq ) { p *= qq ; pp *= q ; return p > pp ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int E = sc . nextInt ( ) ; int F = sc . nextInt ( ) ; int ansX = 100 * A ; int ansY = 0 ; int maxP = 0 ; int maxQ = 1 ; for ( int ai = 0 ; ai * 100 <= F ; ai += A ) { int a = ai * 100 ; for ( int bi = 0 ; a + 100 * bi <= F ; bi += B ) { int b = bi * 100 ; for ( int c = 0 ; a + b + c <= F ; c += C ) { for ( int d = 0 ; a + b + c + d <= F ; d += D ) { if ( ( ai + bi ) * E < c + d ) { continue ; } int water = a + b ; int sugar = c + d ; if ( isGreater ( sugar * 100 , water + sugar , maxP , maxQ ) ) { maxP = sugar * 100 ; maxQ = water + sugar ; ansX = water + sugar ; ansY = sugar ; } } } } } System . out . println ( ansX + \" β \" + ansY ) ; } }"
] | [
"A , B , C , D , E , F = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 100 * A , 0 NEW_LINE w = set ( ) NEW_LINE for a in range ( 0 , F + 1 , 100 * A ) : NEW_LINE INDENT for b in range ( 0 , F - a + 1 , 100 * B ) : NEW_LINE INDENT if a + b : NEW_LINE INDENT w . add ( a + b ) NEW_LINE DEDENT DEDENT DEDENT s = set ( ) NEW_LINE for c in range ( 0 , F + 1 , C ) : NEW_LINE INDENT for d in range ( 0 , F + 1 - c , D ) : NEW_LINE INDENT s . add ( c + d ) NEW_LINE DEDENT DEDENT for wi in w : NEW_LINE INDENT for sj in s : NEW_LINE INDENT if wi + sj <= F and 100 * sj / wi <= E : NEW_LINE INDENT ans = max ( ans , ( wi + sj , sj ) , key = lambda x : x [ 1 ] / x [ 0 ] ) NEW_LINE DEDENT DEDENT DEDENT print ( * ans ) NEW_LINE",
"from fractions import Fraction NEW_LINE from collections import Counter , defaultdict NEW_LINE II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE def main ( ) : NEW_LINE INDENT A , B , C , D , E , F = MI ( ) NEW_LINE A *= 100 NEW_LINE B *= 100 NEW_LINE water_ws = set ( ) NEW_LINE for a in range ( F // A + 1 ) : NEW_LINE INDENT for b in range ( F // B + 1 ) : NEW_LINE INDENT w = a * A + b * B NEW_LINE if w <= F : water_ws . add ( w ) NEW_LINE DEDENT DEDENT water_ws . remove ( 0 ) NEW_LINE sugar_w_max = max ( [ ww // 100 * E for ww in water_ws ] ) NEW_LINE sugar_ws = set ( ) NEW_LINE for c in range ( sugar_w_max // C ) : NEW_LINE INDENT for d in range ( sugar_w_max // D ) : NEW_LINE INDENT w = c * C + d * D NEW_LINE if w <= sugar_w_max : sugar_ws . add ( w ) NEW_LINE DEDENT DEDENT ans_w , ans_s = A , 0 NEW_LINE dens_max = - 1 NEW_LINE for ww in water_ws : NEW_LINE INDENT for sw in sugar_ws : NEW_LINE INDENT dens = Fraction ( sw , ww + sw ) NEW_LINE if ww + sw <= F and sw <= ww // 100 * E and dens > dens_max : NEW_LINE INDENT ans_w = ww + sw NEW_LINE ans_s = sw NEW_LINE dens_max = dens NEW_LINE DEDENT DEDENT DEDENT print ( ans_w , ans_s ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"A , B , C , D , E , F = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE ablist = [ ] NEW_LINE a , b = 0 , 0 NEW_LINE while ( 100 * A * a + 100 * B * b <= F ) : NEW_LINE INDENT while ( 100 * A * a + 100 * B * b <= F ) : NEW_LINE INDENT ablist . append ( ( a , b ) ) NEW_LINE b += 1 NEW_LINE DEDENT a += 1 NEW_LINE b = 0 NEW_LINE DEDENT ablist . remove ( ( 0 , 0 ) ) NEW_LINE wlist = [ 100 * A * ab [ 0 ] + 100 * B * ab [ 1 ] for ab in ablist ] NEW_LINE wset = set ( wlist ) NEW_LINE cdlist = [ ] NEW_LINE c , d = 0 , 0 NEW_LINE while ( C * c + D * d <= F ) : NEW_LINE INDENT while ( C * c + D * d <= F ) : NEW_LINE INDENT cdlist . append ( ( c , d ) ) NEW_LINE d += 1 NEW_LINE DEDENT c += 1 NEW_LINE d = 0 NEW_LINE DEDENT slist = [ C * cd [ 0 ] + D * cd [ 1 ] for cd in cdlist ] NEW_LINE sset = set ( slist ) NEW_LINE max_rate = - 1 NEW_LINE ret_sw = 0 NEW_LINE ret_s = 0 NEW_LINE for w in wset : NEW_LINE INDENT for s in sset : NEW_LINE INDENT if s + w <= F : NEW_LINE INDENT rate = s / ( s + w ) NEW_LINE if rate <= E / ( E + 100 ) : NEW_LINE INDENT if max_rate < rate : NEW_LINE INDENT max_rate = rate NEW_LINE ret_sw = s + w NEW_LINE ret_s = s NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( \" { } β { } \" . format ( ret_sw , ret_s ) ) NEW_LINE",
"def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE from collections import defaultdict NEW_LINE A , B , C , D , E , F = inpl ( ) NEW_LINE H = defaultdict ( lambda : 0 ) NEW_LINE H [ ( 0 , 0 ) ] = 1 NEW_LINE x = [ ( 100 * A , 0 ) , ( 100 * B , 0 ) , ( 0 , C ) , ( 0 , D ) ] NEW_LINE flag = True NEW_LINE while flag : NEW_LINE INDENT flag = False NEW_LINE for i , j in x : NEW_LINE INDENT for ni , nj in H . copy ( ) . keys ( ) : NEW_LINE INDENT if i + j + ni + nj <= F and ni + i : NEW_LINE INDENT if ( nj + j ) / ( ni + i ) <= E / 100 : NEW_LINE INDENT if not H [ ( i + ni , j + nj ) ] : NEW_LINE INDENT H [ ( i + ni , j + nj ) ] = 1 NEW_LINE flag = True NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT anssw , anss = ( 100 * A , 0 ) NEW_LINE for k , l in H . keys ( ) : NEW_LINE INDENT if not k : NEW_LINE INDENT continue NEW_LINE DEDENT if anss / anssw < l / ( k + l ) : NEW_LINE INDENT anssw , anss = k + l , l NEW_LINE DEDENT DEDENT print ( anssw , anss ) NEW_LINE",
"import fractions as frac NEW_LINE a , b , c , d , e , f = map ( int , input ( ) . split ( ) ) NEW_LINE memo = [ [ ( - 1 , - 1 ) ] * 1000 for i in range ( 10000 ) ] NEW_LINE func = lambda t : frac . Fraction ( t [ 0 ] , t [ 1 ] ) if t [ 1 ] > 0 else - 10 NEW_LINE def dp ( s , w ) : NEW_LINE INDENT if w * e < s or w * 100 + s > f : NEW_LINE INDENT return ( - 1 , - 1 ) NEW_LINE DEDENT m = memo [ s ] [ w ] NEW_LINE if m [ 0 ] > 0 : NEW_LINE INDENT return m NEW_LINE DEDENT p0 = ( s , w ) NEW_LINE p1 = dp ( s , w + a ) NEW_LINE p2 = dp ( s , w + b ) NEW_LINE p3 = dp ( s + c , w ) NEW_LINE p4 = dp ( s + d , w ) NEW_LINE memo [ s ] [ w ] = max ( p0 , p1 , p2 , p3 , p4 , key = func ) if w > 0 else max ( p1 , p2 , key = func ) NEW_LINE return memo [ s ] [ w ] NEW_LINE DEDENT ans = dp ( 0 , 0 ) NEW_LINE print ( ans [ 0 ] + ans [ 1 ] * 100 , ans [ 0 ] ) NEW_LINE"
] |
atcoder_abc035_C | [
"import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] stones = new int [ N + 1 ] ; for ( int i = 0 ; i < Q ; i ++ ) { int start = sc . nextInt ( ) - 1 ; int end = sc . nextInt ( ) ; stones [ start ] += 1 ; stones [ end ] += - 1 ; } for ( int i = 0 ; i < N ; i ++ ) { if ( i > 0 ) stones [ i ] += stones [ i - 1 ] ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < N ; i ++ ) { sb . append ( stones [ i ] % 2 == 0 ? '0' : '1' ) ; } System . out . println ( sb . toString ( ) ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; int [ ] l = new int [ Q + 1 ] ; int [ ] r = new int [ Q + 1 ] ; int [ ] field = new int [ N + 2 ] ; int [ ] sum = new int [ N + 2 ] ; sum [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { field [ i ] = 0 ; } for ( int i = 0 ; i < Q ; i ++ ) { l [ i ] = scanner . nextInt ( ) ; r [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < Q ; i ++ ) { field [ l [ i ] ] += 1 ; field [ r [ i ] + 1 ] += - 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { sum [ i ] = sum [ i - 1 ] + field [ i ] ; } for ( int i = 1 ; i <= N ; i ++ ) { if ( sum [ i ] % 2 == 0 ) { System . out . print ( 0 ) ; } else { System . out . print ( 1 ) ; } } System . out . println ( ) ; } }",
"import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] cum = new int [ N + 2 ] ; for ( int i = 0 ; i < Q ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; cum [ l ] += 1 ; cum [ r + 1 ] -= 1 ; } for ( int n = 1 ; n < N + 2 ; n ++ ) { cum [ n ] += cum [ n - 1 ] ; } for ( int n = 1 ; n <= N ; n ++ ) { if ( cum [ n ] % 2 == 0 ) { out . print ( 0 ) ; } else { out . print ( 1 ) ; } } out . println ( ) ; } }",
"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] a = new int [ N + 1 ] ; for ( int i = 0 ; i < Q ; i ++ ) { int start = sc . nextInt ( ) ; int end = sc . nextInt ( ) ; a [ start - 1 ] ++ ; a [ end ] -- ; } int [ ] b = new int [ N ] ; b [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { b [ i ] = b [ i - 1 ] + a [ i ] ; } for ( int i : b ) { System . out . print ( ( i % 2 == 0 ) ? 0 : 1 ) ; } System . out . println ( ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; int [ ] left = new int [ Q ] ; int [ ] right = new int [ Q ] ; for ( int i = 0 ; i < Q ; i ++ ) { left [ i ] = scanner . nextInt ( ) ; right [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( left ) ; Arrays . sort ( right ) ; long count = 0 ; int li = 0 ; int ri = 0 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { while ( li < Q && left [ li ] == i ) { li ++ ; count ++ ; } sb . append ( count % 2 == 0 ? '0' : '1' ) ; while ( ri < Q && right [ ri ] == i ) { ri ++ ; count -- ; } } System . out . println ( sb . toString ( ) ) ; } }"
] | [
"import math NEW_LINE import numpy as np NEW_LINE import copy NEW_LINE from collections import defaultdict , Counter NEW_LINE from itertools import product NEW_LINE from bisect import bisect_left , bisect_right NEW_LINE def s_inpl ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , Q = s_inpl ( ) NEW_LINE imos = [ 0 for _ in range ( N + 1 ) ] NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT li , ri = s_inpl ( ) NEW_LINE li -= 1 NEW_LINE ri -= 1 NEW_LINE imos [ li ] += 1 NEW_LINE imos [ ri + 1 ] -= 1 NEW_LINE DEDENT res = [ str ( i % 2 ) for i in np . cumsum ( imos ) [ : - 1 ] ] NEW_LINE print ( \" \" . join ( res ) ) NEW_LINE",
"from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" Yes \" ) NEW_LINE else : print ( \" No \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def pne ( n ) : NEW_LINE INDENT print ( n , end = ' ' ) NEW_LINE DEDENT rem = pow ( 10 , 9 ) + 7 NEW_LINE n , q = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE add = [ 0 for i in range ( n + 1 ) ] NEW_LINE subtract = [ 0 for i in range ( n + 1 ) ] NEW_LINE a = [ ] NEW_LINE for i in range ( q ) : NEW_LINE INDENT left , right = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE add [ left ] += 1 NEW_LINE subtract [ right ] += 1 NEW_LINE DEDENT t = \"01\" NEW_LINE c = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT c += add [ i ] NEW_LINE print ( t [ c % 2 ] , end = ' ' ) NEW_LINE c -= subtract [ i ] NEW_LINE DEDENT print ( ) NEW_LINE",
"from itertools import accumulate NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE for i in range ( Q ) : NEW_LINE INDENT a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT b = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( Q ) : NEW_LINE INDENT b [ a [ i ] [ 0 ] - 1 ] += 1 NEW_LINE b [ a [ i ] [ 1 ] ] += - 1 NEW_LINE DEDENT ans = ' ' NEW_LINE for x in list ( accumulate ( b ) ) [ : - 1 ] : NEW_LINE INDENT if x % 2 == 0 : NEW_LINE INDENT ans += '0' NEW_LINE DEDENT else : NEW_LINE INDENT ans += '1' NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"def othello ( N : int , Q : int , queries : list ) -> str : NEW_LINE INDENT s = [ 0 ] * N NEW_LINE for l , r in queries : NEW_LINE INDENT s [ l - 1 ] += 1 NEW_LINE if r < N : NEW_LINE INDENT s [ r ] -= 1 NEW_LINE DEDENT DEDENT cum = [ 0 ] * N NEW_LINE cum [ 0 ] = s [ 0 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT cum [ i ] = cum [ i - 1 ] + s [ i ] NEW_LINE DEDENT return ' ' . join ( '0' if c % 2 == 0 else '1' for c in cum ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT Q = 0 NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( Q ) ] NEW_LINE ans = othello ( N , Q , queries ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE n , q = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE lr = [ [ int ( i ) - 1 for i in input ( ) . split ( ) ] for i in range ( q ) ] NEW_LINE cnt = [ 0 ] * n NEW_LINE for l , r in lr : NEW_LINE INDENT cnt [ l ] += 1 NEW_LINE if r < n - 1 : NEW_LINE INDENT cnt [ r + 1 ] -= 1 NEW_LINE DEDENT DEDENT res = \" \" NEW_LINE c = 0 NEW_LINE for x in cnt : NEW_LINE INDENT c += x NEW_LINE res += str ( c % 2 ) NEW_LINE DEDENT print ( res ) NEW_LINE"
] |
atcoder_abc115_B | [
"import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int p = sc . nextInt ( ) ; max = Math . max ( max , p ) ; sum += p ; } System . out . println ( sum -= max / 2 ) ; sc . close ( ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int sum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += list . get ( i ) ; } System . out . println ( sum += list . get ( n - 1 ) / 2 ) ; sc . close ( ) ; } }",
"import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int N = Integer . parseInt ( bf . readLine ( ) ) , max = 0 , sum = 0 ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = Integer . parseInt ( bf . readLine ( ) ) ; sum += p [ i ] ; if ( max < p [ i ] ) { max = p [ i ] ; } } sum -= max / 2 ; System . out . println ( sum ) ; } }",
"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int max = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; max = Math . max ( max , tmp ) ; ans += tmp ; } System . out . println ( ans - max / 2 ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; list . set ( n - 1 , list . get ( n - 1 ) / 2 ) ; int sum = 0 ; for ( int i : list ) { sum += i ; } System . out . println ( sum ) ; sc . close ( ) ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE P = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE M = int ( max ( P ) ) NEW_LINE print ( int ( sum ( P ) - M + M / 2 ) ) NEW_LINE",
"import sys NEW_LINE INF = float ( \" inf \" ) NEW_LINE def solve ( N : int , p : \" List [ int ] \" ) : NEW_LINE INDENT print ( sum ( p ) - max ( p ) // 2 ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE p = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , p ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"S = 0 NEW_LINE N = int ( input ( ) ) NEW_LINE P = [ ] NEW_LINE for num in range ( N ) : NEW_LINE INDENT P . append ( int ( input ( ) ) ) NEW_LINE DEDENT P . sort ( reverse = True , key = int ) NEW_LINE P [ 0 ] = P [ 0 ] // 2 NEW_LINE for num in range ( N ) : NEW_LINE INDENT S += P [ num ] NEW_LINE DEDENT print ( S ) NEW_LINE",
"import sys NEW_LINE def main ( inp ) : NEW_LINE INDENT N = int ( next ( inp ) ) NEW_LINE P = sorted ( [ int ( next ( inp ) ) for _ in range ( N ) ] , reverse = True ) NEW_LINE P [ 0 ] = int ( P [ 0 ] / 2 ) NEW_LINE return sum ( P ) NEW_LINE DEDENT print ( main ( sys . stdin ) ) NEW_LINE",
"n = int ( input ( ) ) NEW_LINE l = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT p = int ( input ( ) ) NEW_LINE l [ i ] = p NEW_LINE DEDENT max_p = max ( l ) // 2 NEW_LINE ans = sum ( l ) - max_p NEW_LINE print ( ans ) NEW_LINE"
] |
atcoder_arc049_B | [
"import java . math . BigInteger ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { class Person { double x ; double y ; double c ; Person ( double x , double y , double c ) { super ( ) ; this . x = x ; this . y = y ; this . c = c ; } } try ( Scanner scan = new Scanner ( System . in ) ) { int n = scan . nextInt ( ) ; Person [ ] persons = new Person [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { persons [ i ] = new Person ( scan . nextDouble ( ) , scan . nextDouble ( ) , scan . nextDouble ( ) ) ; } double maxTime = BigInteger . TEN . pow ( 5 + 3 ) . multiply ( BigInteger . valueOf ( 2L ) ) . doubleValue ( ) ; double minTime = 0D ; double midTime = ( maxTime + minTime ) / 2 ; while ( maxTime - minTime > 0.0001 ) { final double mid = midTime ; double xMax = Arrays . stream ( persons ) . mapToDouble ( p -> p . x + mid / p . c ) . min ( ) . getAsDouble ( ) ; double xMin = Arrays . stream ( persons ) . mapToDouble ( p -> p . x - mid / p . c ) . max ( ) . getAsDouble ( ) ; double yMax = Arrays . stream ( persons ) . mapToDouble ( p -> p . y + mid / p . c ) . min ( ) . getAsDouble ( ) ; double yMin = Arrays . stream ( persons ) . mapToDouble ( p -> p . y - mid / p . c ) . max ( ) . getAsDouble ( ) ; if ( xMax > xMin && yMax > yMin ) { maxTime = midTime ; midTime = ( maxTime + minTime ) / 2 ; } else { minTime = midTime ; midTime = ( maxTime + minTime ) / 2 ; } } System . out . printf ( \" % f \" , midTime ) ; System . out . println ( ) ; } } }",
"import java . util . * ; import java . util . concurrent . SynchronousQueue ; public class Main { public static double f ( int [ ] x , int [ ] c , double p ) { double max = 0 ; int N = x . length ; for ( int i = 0 ; i < N ; i ++ ) { max = Math . max ( max , Math . abs ( p - x [ i ] ) * c [ i ] ) ; } return max ; } public static double search ( int [ ] x , int [ ] c ) { double l = - 100001 , r = 100001 ; int L = 100 ; while ( L -- >= 0 ) { double ll = ( l * 2 + r ) / 3 ; double rr = ( l + r * 2 ) / 3 ; if ( f ( x , c , ll ) > f ( x , c , rr ) ) l = ll ; else r = rr ; } return l ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] x = new int [ N ] ; int [ ] y = new int [ N ] ; int [ ] c = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; c [ i ] = sc . nextInt ( ) ; } double lx = search ( x , c ) ; double ly = search ( y , c ) ; double ans = Math . max ( f ( x , c , lx ) , f ( y , c , ly ) ) ; System . out . println ( ans ) ; } }",
"import java . util . * ; import java . math . * ; public class Main { private static double solve ( int n , double [ ] p , double [ ] c ) { double maxt = 0.0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( p [ i ] > p [ j ] ) { double x = ( c [ i ] * p [ i ] + c [ j ] * p [ j ] ) / ( c [ i ] + c [ j ] ) ; double t = c [ i ] * ( p [ i ] - x ) ; maxt = Math . max ( maxt , t ) ; } } } return maxt ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; double [ ] x = new double [ n ] ; double [ ] y = new double [ n ] ; double [ ] c = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = s . nextDouble ( ) ; y [ i ] = s . nextDouble ( ) ; c [ i ] = s . nextDouble ( ) ; } System . out . println ( Math . max ( solve ( n , x , c ) , solve ( n , y , c ) ) ) ; } }",
"import java . util . Scanner ; public class Main { void solve ( Scanner sc ) throws Throwable { int N = sc . nextInt ( ) ; int [ ] [ ] mans = new int [ N ] [ 3 ] ; for ( int i = 0 ; i < mans . length ; i ++ ) { mans [ i ] [ 0 ] = sc . nextInt ( ) ; mans [ i ] [ 1 ] = sc . nextInt ( ) ; mans [ i ] [ 2 ] = sc . nextInt ( ) ; } double ans = calcMax ( mans , true ) ; System . out . println ( Math . max ( ans , calcMax ( mans , false ) ) ) ; } private double calcMax ( int [ ] [ ] mans , boolean isSearchWidth ) { double maxTimeLeft = 0 ; double maxTimeRight = 0 ; double l = 1e5 ; double r = - 1e5 ; int x = isSearchWidth ? 0 : 1 ; for ( int i = 0 ; i < 100 ; i ++ ) { double targetL = ( l * 2 + r ) / 3 ; double targetR = ( l + r * 2 ) / 3 ; maxTimeLeft = 0 ; maxTimeRight = 0 ; for ( int j = 0 ; j < mans . length ; j ++ ) { maxTimeLeft = Math . max ( maxTimeLeft , ( Math . abs ( targetL - mans [ j ] [ x ] ) * mans [ j ] [ 2 ] ) ) ; maxTimeRight = Math . max ( maxTimeRight , ( Math . abs ( targetR - mans [ j ] [ x ] ) * mans [ j ] [ 2 ] ) ) ; } if ( maxTimeLeft > maxTimeRight ) { l = targetL ; } else { r = targetR ; } } return Math . max ( maxTimeLeft , maxTimeRight ) ; } public static void main ( String [ ] args ) throws Throwable { try ( Scanner sc = new Scanner ( System . in ) ) { new Main ( ) . solve ( sc ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Coordinate [ ] coordinate = new Coordinate [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { coordinate [ i ] = new Coordinate ( sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) ) ; } double maxX = 0 ; double maxY = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { double x1 = coordinate [ i ] . x ; double y1 = coordinate [ i ] . y ; double cost1 = coordinate [ i ] . cost ; for ( int j = i ; j < n ; j ++ ) { double x2 = coordinate [ j ] . x ; double y2 = coordinate [ j ] . y ; double cost2 = coordinate [ j ] . cost ; double midX = Math . abs ( x1 - x2 ) * cost1 / ( cost1 + cost2 ) * cost2 ; double midY = Math . abs ( y1 - y2 ) * cost1 / ( cost1 + cost2 ) * cost2 ; maxX = Math . max ( maxX , midX ) ; maxY = Math . max ( maxY , midY ) ; } } System . out . println ( Math . max ( maxX , maxY ) ) ; } } class Coordinate { double x ; double y ; double cost ; Coordinate ( double x , double y , double cost ) { this . x = x ; this . y = y ; this . cost = cost ; } }"
] | [
"import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = I ( ) NEW_LINE a = [ LI ( ) for _ in range ( n ) ] NEW_LINE mm = 0 NEW_LINE mi = 0 NEW_LINE mj = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT ai = a [ i ] NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT aj = a [ j ] NEW_LINE t = max ( abs ( ai [ 0 ] - aj [ 0 ] ) , abs ( ai [ 1 ] - aj [ 1 ] ) ) / ( 1 / ai [ 2 ] + 1 / aj [ 2 ] ) NEW_LINE if mm < t : NEW_LINE INDENT mm = t NEW_LINE mi = i NEW_LINE mj = j NEW_LINE DEDENT DEDENT DEDENT return mm NEW_LINE DEDENT print ( main ( ) ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE norumu_kun = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * N ] NEW_LINE lb , ub = 0 , 10 ** 10 NEW_LINE while ub - lb > 1e-5 : NEW_LINE INDENT mid = ( lb + ub ) / 2 NEW_LINE lx = ly = - 10 ** 10 NEW_LINE ux = uy = 10 ** 10 NEW_LINE for x , y , c in norumu_kun : NEW_LINE INDENT dist = mid / c NEW_LINE _lx , _ux = x - dist , x + dist NEW_LINE _ly , _uy = y - dist , y + dist NEW_LINE lx = _lx if _lx > lx else lx NEW_LINE ly = _ly if _ly > ly else ly NEW_LINE ux = _ux if ux > _ux else ux NEW_LINE uy = _uy if uy > _uy else uy NEW_LINE DEDENT if lx > ux or ly > uy : NEW_LINE INDENT lb = mid NEW_LINE DEDENT else : NEW_LINE INDENT ub = mid NEW_LINE DEDENT DEDENT print ( lb ) NEW_LINE",
"print ( max ( [ c1 * max ( abs ( x2 - x1 ) * c2 / ( c1 + c2 ) , abs ( y2 - y1 ) * c2 / ( c1 + c2 ) ) for ( x1 , y1 , c1 ) , ( x2 , y2 , c2 ) in __import__ ( \" itertools \" ) . combinations ( [ list ( map ( int , input ( ) . split ( ) ) ) for x in range ( int ( input ( ) ) ) ] , 2 ) ] ) ) NEW_LINE",
"from operator import itemgetter NEW_LINE n = int ( input ( ) ) NEW_LINE info = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE def solve ( ans ) : NEW_LINE INDENT x = [ [ info [ i ] [ 0 ] - ans / info [ i ] [ 2 ] , info [ i ] [ 0 ] + ans / info [ i ] [ 2 ] ] for i in range ( n ) ] NEW_LINE y = [ [ info [ i ] [ 1 ] - ans / info [ i ] [ 2 ] , info [ i ] [ 1 ] + ans / info [ i ] [ 2 ] ] for i in range ( n ) ] NEW_LINE x = sorted ( x , key = itemgetter ( 1 ) ) NEW_LINE y = sorted ( y , key = itemgetter ( 1 ) ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if x [ 0 ] [ 1 ] < x [ i ] [ 0 ] : NEW_LINE INDENT return False NEW_LINE DEDENT if y [ 0 ] [ 1 ] < y [ i ] [ 0 ] : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT ok = 10000000000 NEW_LINE ng = 0 NEW_LINE while abs ( ok - ng ) > 10 ** ( - 6 ) : NEW_LINE INDENT mid = ( ok + ng ) / 2 NEW_LINE if solve ( mid ) : NEW_LINE INDENT ok = mid NEW_LINE DEDENT else : NEW_LINE INDENT ng = mid NEW_LINE DEDENT DEDENT print ( mid ) NEW_LINE",
"from collections import defaultdict , Counter NEW_LINE from itertools import product , groupby , count , permutations , combinations NEW_LINE from math import pi , sqrt NEW_LINE from collections import deque NEW_LINE from bisect import bisect , bisect_left , bisect_right NEW_LINE INF = float ( \" inf \" ) NEW_LINE def ok ( t , x_y_c_list ) : NEW_LINE INDENT max_x_l , min_x_r , max_y_l , min_y_r = - INF , INF , - INF , INF NEW_LINE for x , y , c in x_y_c_list : NEW_LINE INDENT half = t / c NEW_LINE x_l , x_r = x - half , x + half NEW_LINE y_l , y_r = y - half , y + half NEW_LINE max_x_l = max ( max_x_l , x_l ) NEW_LINE min_x_r = min ( min_x_r , x_r ) NEW_LINE max_y_l = max ( max_y_l , y_l ) NEW_LINE min_y_r = min ( min_y_r , y_r ) NEW_LINE DEDENT return max_x_l <= min_x_r and max_y_l <= min_y_r NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE x_y_c_list = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT x , y , c = map ( int , input ( ) . split ( ) ) NEW_LINE x_y_c_list . append ( ( x , y , c ) ) NEW_LINE DEDENT low , high , ans = - 1 , int ( 1e14 ) - 1 , - 1 NEW_LINE while high - low > 0.00001 : NEW_LINE INDENT middle = ( low + high ) / 2 NEW_LINE if ok ( middle , x_y_c_list ) : NEW_LINE INDENT ans = middle NEW_LINE high = middle NEW_LINE DEDENT else : NEW_LINE INDENT low = middle NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT"
] |
atcoder_abc103_C | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; int [ ] a = new int [ N ] ; int ans = 0 ; int [ ] M = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { ans += reader . nextInt ( ) - 1 ; } reader . close ( ) ; System . out . print ( ans ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; public class Main { static int a ; static int b ; static int c ; static int n ; static int l [ ] ; public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; PrintWriter out = new PrintWriter ( System . out ) ; String s ; String sl [ ] ; s = r . readLine ( ) ; sl = s . split ( \" β \" ) ; n = Integer . parseInt ( sl [ 0 ] ) ; s = r . readLine ( ) ; sl = s . split ( \" β \" ) ; int v = 0 ; for ( int i = 0 ; i < n ; i ++ ) { v += Integer . parseInt ( sl [ i ] ) - 1 ; } out . println ( v ) ; out . flush ( ) ; } }",
"import java . util . Scanner ; import java . util . Collections ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Queue ; import java . util . ArrayDeque ; import java . util . Deque ; import java . util . PriorityQueue ; import java . util . Set ; import java . util . HashMap ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] a = new int [ n ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; ans += a [ i ] - 1 ; } System . out . println ( ans ) ; } public static int upperBound ( long [ ] a , long val ) { return upperBound ( a , 0 , a . length , val ) ; } public static int upperBound ( long [ ] a , int l , int r , long val ) { if ( r - l == 1 ) { if ( a [ l ] > val ) return l ; return r ; } int mid = ( l + r ) / 2 ; if ( a [ mid ] > val ) { return upperBound ( a , l , mid , val ) ; } else { return upperBound ( a , mid , r , val ) ; } } public static int lowerBound ( long [ ] a , long val ) { return lowerBound ( a , 0 , a . length , val ) ; } public static int lowerBound ( long [ ] a , int l , int r , long val ) { if ( r - l == 1 ) { if ( a [ l ] < val ) return r ; return l ; } int mid = ( l + r ) / 2 ; if ( a [ mid ] < val ) { return lowerBound ( a , mid , r , val ) ; } else { return lowerBound ( a , l , mid , val ) ; } } }",
"import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; long [ ] values = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { values [ i ] = sc . nextLong ( ) ; } long ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ans += ( values [ i ] - 1 ) ; } System . out . println ( ans ) ; } }",
"import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ans += a [ i ] - 1 ; } out . println ( ans ) ; } }"
] | [
"import sys NEW_LINE import itertools NEW_LINE import collections NEW_LINE import functools NEW_LINE import math NEW_LINE from queue import Queue NEW_LINE INF = float ( \" inf \" ) NEW_LINE def solve ( N : int , a : \" List [ int ] \" ) : NEW_LINE INDENT print ( sum ( [ v - 1 for v in a ] ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE a = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , a ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"print ( - int ( input ( ) ) + sum ( list ( map ( int , input ( ) . split ( ) ) ) ) ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE a_list = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT return gcd ( b , a % b ) NEW_LINE DEDENT def lcm ( a , b ) : NEW_LINE INDENT return ( a * b ) // gcd ( a , b ) NEW_LINE DEDENT s = a_list [ 0 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT s = lcm ( s , a_list [ i ] ) NEW_LINE DEDENT def f ( m ) : NEW_LINE INDENT c = 0 NEW_LINE for a in a_list : NEW_LINE INDENT c += m % a NEW_LINE DEDENT return c NEW_LINE DEDENT print ( f ( s - 1 ) ) NEW_LINE",
"import fractions NEW_LINE from functools import reduce NEW_LINE def lcm_base ( x , y ) : NEW_LINE INDENT return ( x * y ) // fractions . gcd ( x , y ) NEW_LINE DEDENT def lcm_list ( numbers ) : NEW_LINE INDENT return reduce ( lcm_base , numbers , 1 ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE lcm = lcm_list ( A ) NEW_LINE ans = 0 NEW_LINE for i in A : NEW_LINE INDENT ans += ( lcm - 1 ) % i NEW_LINE DEDENT print ( ans ) NEW_LINE",
"from functools import reduce NEW_LINE from operator import mul NEW_LINE from sys import stdin NEW_LINE n = int ( stdin . readline ( ) . rstrip ( ) ) NEW_LINE al = [ int ( _ ) for _ in stdin . readline ( ) . rstrip ( ) . split ( ) ] NEW_LINE m = reduce ( mul , al ) - 1 NEW_LINE print ( sum ( m % a for a in al ) ) NEW_LINE"
] |
atcoder_arc075_A | [
"import java . io . * ; import java . util . * ; public class Main implements Runnable { private void solve ( ) throws IOException { int N = nextInt ( ) ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) arr [ i ] = nextInt ( ) ; Arrays . sort ( arr ) ; int s = 0 ; for ( int i : arr ) s += i ; if ( s % 10 != 0 ) { writer . println ( s ) ; } else { for ( int i = 0 ; i < arr . length ; ++ i ) { if ( ( arr [ i ] % 10 != 0 ) ) { writer . println ( ( s - arr [ i ] ) ) ; return ; } } writer . println ( 0 ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run ( ) { try { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; tokenizer = null ; writer = new PrintWriter ( System . out ) ; solve ( ) ; reader . close ( ) ; writer . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } } int nextInt ( ) throws IOException { return Integer . parseInt ( nextToken ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( nextToken ( ) ) ; } double nextDouble ( ) throws IOException { return Double . parseDouble ( nextToken ( ) ) ; } short nextShort ( ) throws IOException { return Short . parseShort ( nextToken ( ) ) ; } String nextToken ( ) throws IOException { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } }",
"import java . util . LinkedList ; import java . util . List ; import java . util . OptionalInt ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < Integer > ls = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) ls . add ( sc . nextInt ( ) ) ; int sum = ls . stream ( ) . mapToInt ( e -> e ) . sum ( ) ; if ( sum % 10 != 0 ) System . out . println ( sum ) ; else { OptionalInt tmp = ls . stream ( ) . mapToInt ( e -> e ) . filter ( e -> e % 10 != 0 ) . min ( ) ; if ( tmp . isPresent ( ) ) System . out . println ( sum - tmp . getAsInt ( ) ) ; else System . out . println ( 0 ) ; } } }",
"import java . io . BufferedReader ; import java . io . File ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStream ; 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 ) throws IOException { MyScanner sc = new MyScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) , sum = 0 ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; if ( sum % 10 == 0 ) for ( int i = 0 ; i < n ; i ++ ) if ( ( sum - a [ i ] ) % 10 != 0 ) { sum -= a [ i ] ; break ; } out . println ( sum % 10 == 0 ? 0 : sum ) ; out . flush ( ) ; out . close ( ) ; } static class MyScanner { StringTokenizer st ; BufferedReader br ; public MyScanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public MyScanner ( String file ) throws IOException { br = new BufferedReader ( new FileReader ( new File ( file ) ) ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; } } }",
"import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? \" Yes \" : \" No \" ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int n = nextInt ( ) ; int [ ] ar = nextIntArray ( n ) ; Arrays . sort ( ar ) ; long sum = 0 ; long notTenMultiple = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { sum += ar [ i ] ; if ( ar [ i ] % 10 != 0 ) { notTenMultiple = ar [ i ] ; } } if ( notTenMultiple == - 1 ) System . out . println ( 0 ) ; else if ( sum % 10 != 0 ) System . out . println ( sum ) ; else System . out . println ( sum - notTenMultiple ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] a = new int [ 101 ] ; int s1 = 0 , s2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; a [ k ] ++ ; if ( k % 10 == 0 ) s2 += k ; else s1 += k ; } if ( s1 == 0 ) { System . out . println ( 0 ) ; return ; } if ( s1 % 10 != 0 ) { System . out . println ( s1 + s2 ) ; return ; } for ( int i = 1 ; i <= 100 ; i ++ ) { if ( a [ i ] == 0 || i % 10 == 0 ) continue ; s1 -= i ; break ; } System . out . println ( s1 + s2 ) ; } }"
] | [
"def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntLines ( n ) : return [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE def genBits ( n ) : NEW_LINE INDENT bits = zeros ( n ) NEW_LINE for i in range ( 2 ** n ) : NEW_LINE INDENT for k in range ( n ) : NEW_LINE INDENT bits [ k ] = i % 2 NEW_LINE i //= 2 NEW_LINE DEDENT yield bits NEW_LINE DEDENT DEDENT def dmp ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def probC_TLE ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE S = getIntLines ( N ) NEW_LINE dmp ( ( N , S ) ) NEW_LINE maxPoint = 0 NEW_LINE for bit in genBits ( N ) : NEW_LINE INDENT point = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT point += S [ i ] * bit [ i ] NEW_LINE DEDENT if point % 10 == 0 : NEW_LINE INDENT point = 0 NEW_LINE DEDENT maxPoint = max ( point , maxPoint ) NEW_LINE dmp ( ( point , maxPoint ) ) NEW_LINE DEDENT return maxPoint NEW_LINE DEDENT def probC ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE S = getIntLines ( N ) NEW_LINE dmp ( ( N , S ) ) NEW_LINE tens = [ ] NEW_LINE nonTens = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] % 10 == 0 : NEW_LINE INDENT tens . append ( S [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT nonTens . append ( S [ i ] ) NEW_LINE DEDENT DEDENT total = sum ( nonTens ) NEW_LINE dmp ( total ) NEW_LINE if total > 0 and total % 10 == 0 : NEW_LINE INDENT total -= min ( nonTens ) NEW_LINE DEDENT dmp ( total ) NEW_LINE if total > 0 : NEW_LINE INDENT total += sum ( tens ) NEW_LINE DEDENT dmp ( total ) NEW_LINE return total NEW_LINE DEDENT debug = False NEW_LINE print ( probC ( ) ) NEW_LINE",
"import numpy as np NEW_LINE a = int ( input ( ) ) NEW_LINE k = [ ] NEW_LINE k10 = [ ] NEW_LINE s = 0 NEW_LINE for j in range ( a ) : NEW_LINE INDENT i = int ( input ( ) ) NEW_LINE if i % 10 == 0 : NEW_LINE INDENT k10 . append ( i ) NEW_LINE s += i NEW_LINE DEDENT else : NEW_LINE INDENT k . append ( i ) NEW_LINE DEDENT DEDENT k . sort ( ) NEW_LINE c = np . array ( k ) NEW_LINE l = c . sum ( ) NEW_LINE if l % 10 == 0 and len ( k ) != 0 : NEW_LINE INDENT l = l - c [ 0 ] NEW_LINE s = s + l NEW_LINE DEDENT elif len ( k ) == 0 : NEW_LINE INDENT s = 0 NEW_LINE DEDENT else : NEW_LINE INDENT s = s + l NEW_LINE DEDENT print ( s ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE S = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE score = { 0 } NEW_LINE for s in S : NEW_LINE INDENT tmp = set ( ) NEW_LINE for i in score : NEW_LINE INDENT tmp . add ( s + i ) NEW_LINE DEDENT score |= tmp NEW_LINE DEDENT for i in range ( 10 , 10010 , 10 ) : NEW_LINE INDENT if i in score : NEW_LINE INDENT score . remove ( i ) NEW_LINE DEDENT DEDENT print ( max ( score ) ) NEW_LINE",
"import sys NEW_LINE N = int ( input ( ) ) NEW_LINE scores = list ( map ( int , sys . stdin ) ) NEW_LINE perfect = sum ( scores ) NEW_LINE dp = [ 1 ] + [ 0 ] * perfect NEW_LINE for s in scores : NEW_LINE INDENT for i in range ( perfect - s , - 1 , - 1 ) : NEW_LINE INDENT dp [ i + s ] |= dp [ i ] NEW_LINE DEDENT DEDENT for s in range ( perfect , 0 , - 1 ) : NEW_LINE INDENT if dp [ s ] and s % 10 : NEW_LINE INDENT print ( s ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT",
"from collections import defaultdict NEW_LINE H = defaultdict ( lambda : 0 ) NEW_LINE H [ 0 ] = 1 NEW_LINE N = int ( input ( ) ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT i = int ( input ( ) ) NEW_LINE for ni , nv in H . copy ( ) . items ( ) : NEW_LINE INDENT H [ ni + i ] = 1 NEW_LINE DEDENT DEDENT K = reversed ( sorted ( list ( H . keys ( ) ) ) ) NEW_LINE ans = 0 NEW_LINE for j in K : NEW_LINE INDENT if j % 10 != 0 : NEW_LINE INDENT ans = j NEW_LINE break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE"
] |
atcoder_agc029_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; long Bcnt = 0 ; long cnt = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == ' W ' ) cnt += Bcnt ; if ( s [ i ] == ' B ' ) Bcnt ++ ; } System . out . println ( cnt ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class A { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . ns ( ) ; int n = s . length ( ) ; int done = 0 ; long ans = 0 ; for ( int dist = 0 ; dist < n ; dist ++ ) { if ( s . charAt ( n - dist - 1 ) == ' B ' ) { ans += dist - done ; done ++ ; } } out . println ( ans ) ; } } static class FastScanner { private BufferedReader in ; private StringTokenizer st ; public FastScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String ns ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl == null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return st . nextToken ( ) ; } } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String S = in . next ( ) ; long ans = 0 ; long tmp = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == ' W ' ) { ans += tmp ; } else { tmp += 1 ; } } out . println ( ans ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }",
"import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; String [ ] str = s . split ( \" \" ) ; Arrays . sort ( str , Comparator . reverseOrder ( ) ) ; long ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( str [ i ] . equals ( \" B \" ) ) { ans += i ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' B ' ) { ans -= i ; } } System . out . println ( ans ) ; } }",
"import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream in = System . in ; final byte [ ] bytes = new byte [ 200001 ] ; int length = 0 ; try { length = in . read ( bytes ) ; } catch ( IOException e ) { } int count = 0 ; long sum = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( bytes [ i ] == ' B ' ) count ++ ; else if ( bytes [ i ] == ' W ' ) sum += count ; } System . out . println ( sum ) ; } }"
] | [
"S = input ( ) NEW_LINE b = 0 NEW_LINE ans = 0 NEW_LINE for c in S : NEW_LINE INDENT if c == ' B ' : NEW_LINE INDENT b += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans += b NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"import numpy as np NEW_LINE s = np . array ( list ( input ( ) ) ) NEW_LINE ind = np . array ( np . where ( s == ' B ' ) ) NEW_LINE len_ind = ind . shape [ 1 ] NEW_LINE len = s . shape [ 0 ] NEW_LINE dist = np . arange ( len - len_ind , len ) NEW_LINE ans = np . sum ( dist - ind ) NEW_LINE print ( ans ) NEW_LINE",
"txt = input ( ) NEW_LINE txt_list = list ( txt ) NEW_LINE count = 0 NEW_LINE n_b = 0 NEW_LINE n_w = 0 NEW_LINE i = 0 NEW_LINE for i in range ( len ( txt_list ) ) : NEW_LINE INDENT if txt_list [ i ] == ' W ' : NEW_LINE INDENT n_w += 1 NEW_LINE DEDENT if ( i >= 1 and txt_list [ i - 1 ] == ' W ' and txt_list [ i ] == ' B ' ) or ( i == len ( txt_list ) - 1 and txt_list [ i ] == ' W ' ) : NEW_LINE INDENT count += n_b * n_w NEW_LINE n_w = 0 NEW_LINE DEDENT if txt_list [ i ] == ' B ' : NEW_LINE INDENT n_b += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE",
"S = list ( input ( ) ) NEW_LINE W_i = [ i for i , j in enumerate ( S ) if j == ' W ' ] NEW_LINE W_n = S . count ( ' W ' ) NEW_LINE cur = 0 NEW_LINE ans = 0 NEW_LINE for i in W_i : NEW_LINE INDENT ans += i - cur NEW_LINE cur += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE",
"S = input ( ) NEW_LINE counter = 0 NEW_LINE ans = 0 NEW_LINE for index , char in enumerate ( S ) : NEW_LINE INDENT if ( char == \" W \" ) : NEW_LINE INDENT ans += index - counter NEW_LINE counter += 1 NEW_LINE DEDENT DEDENT print ( int ( ans ) ) NEW_LINE"
] |
atcoder_abc056_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int W = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans ; if ( a < b ) { ans = b - a - W ; } else { ans = a - b - W ; } System . out . println ( ans > 0 ? ans : 0 ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int W = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; if ( a <= b && b <= a + W || a <= b + W && b + W <= a ) { out . println ( 0 ) ; } else { out . println ( a < b ? b - ( a + W ) : a - ( b + W ) ) ; } } } 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 . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int w = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans ; if ( Math . abs ( b - a ) < w ) { ans = 0 ; } else { ans = Math . abs ( a - b ) - w ; } 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 { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { int w = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Line line1 = new Line ( a , a + w ) ; Line line2 = new Line ( b , b + w ) ; System . out . println ( Math . abs ( line1 . getL ( ) - line2 . getL ( ) ) <= w ? 0 : Math . abs ( line2 . getL ( ) - line1 . getL ( ) ) - w ) ; } } class Line { private int L ; private int R ; Line ( int a , int b ) { L = a ; R = b ; } int getL ( ) { return L ; } int getR ( ) { return R ; } int getLength ( ) { return R - L ; } void setL ( int n ) { L = n ; } void setR ( int n ) { R = n ; } }",
"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int w = sc . nextInt ( ) , a = sc . nextInt ( ) , b = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( b - ( a + w ) , a - ( b + w ) ) , 0 ) ) ; } }"
] | [
"W , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE if a + W < b : NEW_LINE INDENT ans = b - a - W NEW_LINE DEDENT elif b + W < a : NEW_LINE INDENT ans = a - b - W NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT print ( ans ) NEW_LINE",
"import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE W , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE a , b = min ( a , b ) , max ( a , b ) NEW_LINE return max ( 0 , b - ( a + W ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT",
"def narrow_rectangles_easy ( W : int , a : int , b : int ) -> int : NEW_LINE INDENT if a + W < b : NEW_LINE INDENT return b - ( a + W ) NEW_LINE DEDENT if b + W < a : NEW_LINE INDENT return a - ( b + W ) NEW_LINE DEDENT return 0 NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT W , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE ans = narrow_rectangles_easy ( W , a , b ) NEW_LINE print ( ans ) NEW_LINE DEDENT",
"from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT W , a , b = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE if ( a > b ) : NEW_LINE INDENT tmp = a NEW_LINE a = b NEW_LINE b = tmp NEW_LINE DEDENT if b - ( a + W ) <= 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT ans = b - ( a + W ) NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"W , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( max ( 0 , A - B - W , B - A - W ) ) NEW_LINE"
] |
atcoder_arc009_B | [
"import java . util . * ; public class Main { int [ ] numbers = new int [ 10 ] ; int [ ] invers = new int [ 10 ] ; Scanner sc ; void run ( ) { this . initialize ( ) ; int N = sc . nextInt ( ) ; ArrayList < Integer > convertedNum = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { convertedNum . add ( this . convert ( sc . nextInt ( ) ) ) ; } Collections . sort ( convertedNum ) ; for ( int num : convertedNum ) { System . out . println ( this . deconvert ( num ) ) ; } } void initialize ( ) { sc = new Scanner ( System . in ) ; for ( int i = 0 ; i < numbers . length ; i ++ ) { numbers [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < numbers . length ; i ++ ) { invers [ numbers [ i ] ] = i ; } } int convert ( int num ) { int m = num ; int p = num ; int ret = 0 ; for ( int i = 0 ; m > 0 ; i ++ ) { p = m % 10 ; m /= 10 ; ret += invers [ p ] * Math . pow ( 10 , i ) ; } return ret ; } int deconvert ( int num ) { int m = num ; int p = num ; int ret = 0 ; for ( int i = 0 ; m > 0 ; i ++ ) { p = m % 10 ; m /= 10 ; ret += numbers [ p ] * Math . pow ( 10 , i ) ; } return ret ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }",
"import java . util . ArrayList ; import java . util . Comparator ; import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static IntStream REPS ( int v ) { return IntStream . range ( 0 , v ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INS ( int n ) { return REPS ( n ) . map ( i -> getInt ( ) ) ; } static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static class E { String t ; int i ; public E ( String t , int i ) { this . t = t ; this . i = i ; } public int getI ( ) { return this . i ; } public int getL ( ) { return this . t . length ( ) ; } public String getT ( ) { return this . t ; } } public static void main ( String [ ] $ ) { int [ ] order = new int [ 10 ] ; REPS ( 10 ) . forEach ( i -> order [ getInt ( ) ] = i ) ; ArrayList < E > m = new ArrayList < > ( ) ; for ( int i = getInt ( ) ; i > 0 ; -- i ) { String in = s . next ( ) ; char [ ] c = in . toCharArray ( ) ; for ( int j = 0 ; j < c . length ; ++ j ) { c [ j ] = ( char ) ( order [ c [ j ] - '0' ] + '0' ) ; } m . add ( new E ( in , Integer . parseInt ( String . valueOf ( c ) ) ) ) ; } m . stream ( ) . sorted ( Comparator . comparingInt ( E :: getL ) . thenComparingInt ( E :: getI ) ) . map ( E :: getT ) . forEach ( System . out :: println ) ; } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] b = Arrays . asList ( br . readLine ( ) . split ( \" β \" ) ) . stream ( ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int [ ] x = new int [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) x [ b [ i ] ] = i ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String s = br . readLine ( ) ; a [ i ] = 0 ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { a [ i ] *= 10 ; a [ i ] += x [ s . charAt ( j ) - '0' ] ; } } Arrays . sort ( a ) ; for ( int i = 0 ; i < n ; i ++ ) { StringBuilder sb = new StringBuilder ( ) ; int t = a [ i ] ; if ( t == 0 ) { System . out . println ( 0 ) ; continue ; } while ( t > 0 ) { sb . append ( b [ t % 10 ] ) ; t /= 10 ; } sb . reverse ( ) ; System . out . println ( sb . toString ( ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] change = new String [ 10 ] ; String [ ] dec = new String [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { int b = sc . nextInt ( ) ; change [ b ] = String . valueOf ( i ) ; dec [ i ] = String . valueOf ( b ) ; } int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String d = String . valueOf ( sc . nextInt ( ) ) ; String num = \" \" ; for ( int j = 0 ; j < d . length ( ) ; j ++ ) { num += change [ Integer . parseInt ( String . valueOf ( d . charAt ( j ) ) ) ] ; } a [ i ] = Integer . parseInt ( num ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < N ; i ++ ) { String d = String . valueOf ( a [ i ] ) ; String num = \" \" ; for ( int j = 0 ; j < d . length ( ) ; j ++ ) { num += dec [ Integer . parseInt ( String . valueOf ( d . charAt ( j ) ) ) ] ; } System . out . println ( num ) ; } } }",
"import java . io . * ; import java . math . * ; import java . text . * ; import java . util . * ; import java . util . regex . * ; public class Main { private static final Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] digit = new int [ 10 ] ; Map < Integer , Integer > map = new HashMap < > ( ) ; Map < Integer , Integer > reverseMap = new HashMap < > ( ) ; for ( int i = 0 ; i < digit . length ; i ++ ) { digit [ i ] = scan . nextInt ( ) ; map . put ( i , digit [ i ] ) ; reverseMap . put ( digit [ i ] , i ) ; } int n = scan . nextInt ( ) ; List < Integer > valueString = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String next = scan . next ( ) ; String res = \" \" ; for ( int j = 0 ; j < next . length ( ) ; j ++ ) { res += Character . toString ( ( char ) ( reverseMap . get ( next . charAt ( j ) - '0' ) + '0' ) ) ; } valueString . add ( Integer . parseInt ( res ) ) ; } valueString . sort ( Comparator . comparingInt ( o -> o ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String next = \" \" + valueString . get ( i ) ; String res = \" \" ; for ( int j = 0 ; j < next . length ( ) ; j ++ ) { res += Character . toString ( ( char ) ( map . get ( next . charAt ( j ) - '0' ) + '0' ) ) ; } System . out . println ( res ) ; } } }"
] | [
"d = { } NEW_LINE B = input ( ) . split ( ) NEW_LINE for i in range ( 10 ) : NEW_LINE INDENT d [ B [ i ] ] = str ( i ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE a = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT t = input ( ) NEW_LINE u = ' ' NEW_LINE for i in t : NEW_LINE INDENT u += d [ i ] NEW_LINE DEDENT a . append ( [ int ( u ) , t ] ) NEW_LINE DEDENT a . sort ( key = lambda x : x [ 0 ] ) NEW_LINE for v in a : NEW_LINE INDENT print ( v [ 1 ] ) NEW_LINE DEDENT",
"d = { str ( j ) : str ( i ) for i , j in enumerate ( map ( int , input ( ) . split ( ) ) ) } NEW_LINE e = { j : i for i , j in d . items ( ) } NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ input ( ) for _ in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a [ i ] = int ( a [ i ] . translate ( str . maketrans ( d ) ) ) NEW_LINE DEDENT a . sort ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( str ( a [ i ] ) . translate ( str . maketrans ( e ) ) ) NEW_LINE DEDENT",
"rule = input ( ) . split ( ) NEW_LINE N = int ( input ( ) ) NEW_LINE inputs = [ str ( input ( ) ) for _ in range ( N ) ] NEW_LINE ans = [ ] NEW_LINE for item in inputs : NEW_LINE INDENT ans . append ( ( item , int ( ' ' . join ( str ( rule . index ( key ) ) for key in item ) ) ) ) NEW_LINE DEDENT for item in sorted ( ans , key = lambda x : x [ 1 ] ) : NEW_LINE INDENT print ( item [ 0 ] ) NEW_LINE DEDENT",
"sbef = list ( \"0123456789\" ) NEW_LINE d = str . maketrans ( input ( ) . replace ( \" β \" , \" \" ) , \"0123456789\" ) NEW_LINE def tr ( n ) : NEW_LINE INDENT global d NEW_LINE return ( int ( n . translate ( d ) ) ) NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE a = [ input ( ) for _ in range ( n ) ] NEW_LINE a . sort ( key = tr ) NEW_LINE for i in a : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT",
"z , n , a , b = input ( ) . split ( ) , int ( input ( ) ) , [ ] , [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT m = input ( ) NEW_LINE x = 0 NEW_LINE for j in range ( len ( m ) ) : x += ( z . index ( m [ len ( m ) - j - 1 ] ) ) * ( 10 ** j ) NEW_LINE a . append ( x ) NEW_LINE b . append ( m ) NEW_LINE DEDENT def swap ( ab , ba , X ) : NEW_LINE INDENT abc = X [ ab ] NEW_LINE X [ ab ] = X [ ba ] NEW_LINE X [ ba ] = abc NEW_LINE DEDENT h = n NEW_LINE while 1 : NEW_LINE INDENT hh = a [ : ] NEW_LINE if h > 1 : h = round ( h // 1.3 ) NEW_LINE for i in range ( n - h ) : NEW_LINE INDENT if a [ i ] > a [ i + h ] : NEW_LINE INDENT swap ( i , i + h , a ) NEW_LINE swap ( i , i + h , b ) NEW_LINE DEDENT DEDENT if hh == a and h == 1 : break NEW_LINE DEDENT for i in b : print ( i ) NEW_LINE"
] |
atcoder_arc010_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int [ ] c = new int [ M + 1 ] ; for ( int i = 1 ; i <= M ; i ++ ) { c [ i ] = scanner . nextInt ( ) ; } int cards = N ; int index = - 1 ; boolean flag = true ; for ( int i = 1 ; i <= M ; i ++ ) { if ( cards <= A ) { cards += B ; } if ( cards < c [ i ] ) { index = i ; flag = false ; break ; } cards -= c [ i ] ; } if ( flag ) { System . out . println ( \" complete \" ) ; } else { System . out . println ( index ) ; } } }",
"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 M = in . nextInt ( ) ; int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; for ( int i = 1 ; i <= M ; i ++ ) { if ( N <= A ) { N += B ; } N -= in . nextInt ( ) ; if ( N < 0 ) { out . println ( i ) ; break ; } } if ( N >= 0 ) { out . println ( \" complete \" ) ; } } } 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 . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] param = br . readLine ( ) . split ( \" β \" ) ; Integer defo = Integer . valueOf ( param [ 0 ] ) ; Integer nissu = Integer . valueOf ( param [ 1 ] ) ; Integer limit = Integer . valueOf ( param [ 2 ] ) ; Integer hojuu = Integer . valueOf ( param [ 3 ] ) ; Integer tmpMaisu = defo ; if ( tmpMaisu <= limit ) { tmpMaisu += hojuu ; } for ( int i = 0 ; i < nissu ; i ++ ) { tmpMaisu -= Integer . valueOf ( br . readLine ( ) ) ; if ( tmpMaisu < 0 ) { System . out . println ( i + 1 ) ; return ; } if ( tmpMaisu <= limit ) { tmpMaisu += hojuu ; } } System . out . println ( \" complete \" ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader bfr = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = \" \" ; str = bfr . readLine ( ) ; StringTokenizer stk = new StringTokenizer ( str , \" β \" ) ; int meisi = Integer . parseInt ( stk . nextToken ( ) ) ; int nisuu = Integer . parseInt ( stk . nextToken ( ) ) ; int hoju_min = Integer . parseInt ( stk . nextToken ( ) ) ; int hmi = Integer . parseInt ( stk . nextToken ( ) ) ; int heru = 0 ; boolean kubari = true ; for ( int i = 0 ; i < nisuu ; i ++ ) { str = bfr . readLine ( ) ; if ( meisi <= hoju_min ) { meisi += hmi ; } heru = Integer . parseInt ( str ) ; meisi -= heru ; if ( meisi < 0 ) { System . out . println ( i + 1 ) ; kubari = false ; System . exit ( 0 ) ; } } if ( kubari == true ) { System . out . println ( \" complete \" ) ; } } }",
"import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , a = sc . nextInt ( ) , b = sc . nextInt ( ) ; int [ ] c = new int [ m + 1 ] ; for ( int i = 1 ; i <= m ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= m ; i ++ ) { if ( n <= a ) n += b ; n -= c [ i ] ; if ( n < 0 ) { out . println ( i ) ; exit ( 0 ) ; } } out . println ( \" complete \" ) ; } }"
] | [
"n , m , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE cnt = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT if n <= a : NEW_LINE INDENT n += b NEW_LINE DEDENT cnt += 1 NEW_LINE c = int ( input ( ) ) NEW_LINE n -= c NEW_LINE if n < 0 : NEW_LINE INDENT print ( cnt ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( \" complete \" ) NEW_LINE",
"N , M , A , B = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE c = [ int ( input ( ) ) for i in range ( M ) ] NEW_LINE result = \" complete \" NEW_LINE x = N NEW_LINE for i in range ( M ) : NEW_LINE INDENT if x <= A : NEW_LINE INDENT x += B NEW_LINE DEDENT x -= c [ i ] NEW_LINE if x < 0 : NEW_LINE INDENT result = i + 1 NEW_LINE break NEW_LINE DEDENT DEDENT print ( result ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT n , m , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE cc = [ int ( input ( ) ) for _ in range ( m ) ] NEW_LINE for i , c in enumerate ( cc ) : NEW_LINE INDENT if n <= a : NEW_LINE INDENT n += b NEW_LINE DEDENT if n < c : NEW_LINE INDENT print ( i + 1 ) NEW_LINE return NEW_LINE DEDENT n -= c NEW_LINE DEDENT print ( \" complete \" ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"from sys import stdin NEW_LINE input = stdin . readline NEW_LINE n , m , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( 1 , m + 1 ) : NEW_LINE INDENT c = int ( input ( ) ) NEW_LINE if n <= a : NEW_LINE INDENT n += b NEW_LINE DEDENT n -= c NEW_LINE if n < 0 : NEW_LINE INDENT print ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( \" complete \" ) NEW_LINE DEDENT",
"N , M , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE res = N NEW_LINE c = [ ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT c . append ( int ( input ( ) ) ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT if res <= A : res += B NEW_LINE if res < c [ i ] : NEW_LINE INDENT print ( i + 1 ) NEW_LINE break NEW_LINE DEDENT else : res -= c [ i ] NEW_LINE DEDENT else : print ( ' complete ' ) NEW_LINE"
] |
atcoder_abc016_D | [
"import java . util . * ; class Main { static final double E = 1.0e-9 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double ax = scan . nextDouble ( ) ; double ay = scan . nextDouble ( ) ; double dx = scan . nextDouble ( ) - ax ; double dy = scan . nextDouble ( ) - ay ; int n = scan . nextInt ( ) ; double [ ] x = new double [ n ] , y = new double [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { double u = scan . nextDouble ( ) - ax ; double v = scan . nextDouble ( ) - ay ; x [ i ] = ( dx * u + dy * v ) / ( dx * dx + dy * dy ) ; y [ i ] = ( - dy * u + dx * v ) / ( dx * dx + dy * dy ) ; } int k = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( y [ i ] * y [ ( i + 1 ) % n ] >= 0 ) continue ; double z = x [ i ] * y [ ( i + 1 ) % n ] - x [ ( i + 1 ) % n ] * y [ i ] ; z /= - y [ i ] + y [ ( i + 1 ) % n ] ; if ( z > E && z < 1 - E ) k ++ ; } System . out . println ( k / 2 + 1 ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D solver = new D ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ax = in . nextInt ( ) , ay = in . nextInt ( ) , bx = in . nextInt ( ) , by = in . nextInt ( ) ; int n = in . nextInt ( ) ; int ans = 0 ; int [ ] x = new int [ n ] ; int [ ] y = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = in . nextInt ( ) ; y [ i ] = in . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { long cx = x [ i ] , cy = y [ i ] , dx = x [ ( i + 1 ) % n ] , dy = y [ ( i + 1 ) % n ] ; long ta = ( cx - dx ) * ( ay - cy ) + ( cy - dy ) * ( cx - ax ) ; long tb = ( cx - dx ) * ( by - cy ) + ( cy - dy ) * ( cx - bx ) ; long tc = ( ax - bx ) * ( cy - ay ) + ( ay - by ) * ( ax - cx ) ; long td = ( ax - bx ) * ( dy - ay ) + ( ay - by ) * ( ax - dx ) ; if ( tc * td < 0 && ta * tb < 0 ) { ans ++ ; } } if ( ans % 2 == 1 ) { System . exit ( 1 ) ; } out . println ( ans / 2 + 1 ) ; } } }",
"import java . awt . geom . Line2D ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; int Ax = sc . nextInt ( ) ; int Ay = sc . nextInt ( ) ; int Bx = sc . nextInt ( ) ; int By = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] X = new int [ N ] ; int [ ] Y = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { X [ i ] = sc . nextInt ( ) ; Y [ i ] = sc . nextInt ( ) ; } int intersects = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( Line2D . linesIntersect ( Ax , Ay , Bx , By , X [ i ] , Y [ i ] , X [ i + 1 ] , Y [ i + 1 ] ) ) { intersects ++ ; } } if ( Line2D . linesIntersect ( Ax , Ay , Bx , By , X [ 0 ] , Y [ 0 ] , X [ N - 1 ] , Y [ N - 1 ] ) ) { intersects ++ ; } System . out . println ( intersects / 2 + 1 ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final Coord A = new Coord ( sc . nextInt ( ) , sc . nextInt ( ) ) ; final Coord B = new Coord ( sc . nextInt ( ) , sc . nextInt ( ) ) ; final int N = sc . nextInt ( ) ; Coord [ ] c = new Coord [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { c [ i ] = new Coord ( sc . nextInt ( ) , sc . nextInt ( ) ) ; } sc . close ( ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( isIntersect ( A . x , A . y , B . x , B . y , c [ i ] . x , c [ i ] . y , c [ ( i + 1 ) % N ] . x , c [ ( i + 1 ) % N ] . y ) ) { count ++ ; } } System . out . println ( count / 2 + 1 ) ; } static boolean isIntersect ( double ax , double ay , double bx , double by , double cx , double cy , double dx , double dy ) { double ta = ( cx - dx ) * ( ay - cy ) + ( cy - dy ) * ( cx - ax ) ; double tb = ( cx - dx ) * ( by - cy ) + ( cy - dy ) * ( cx - bx ) ; double tc = ( ax - bx ) * ( cy - ay ) + ( ay - by ) * ( ax - cx ) ; double td = ( ax - bx ) * ( dy - ay ) + ( ay - by ) * ( ax - dx ) ; return tc * td < 0 && ta * tb < 0 ; } ; static class Coord { int x ; int y ; Coord ( final int x , final int y ) { this . x = x ; this . y = y ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ax = sc . nextLong ( ) ; long ay = sc . nextLong ( ) ; long bx = sc . nextLong ( ) ; long by = sc . nextLong ( ) ; int N = sc . nextInt ( ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { long abx = bx - ax ; long aby = by - ay ; long px = x [ i ] - ax ; long py = y [ i ] - ay ; long qx = x [ 0 ] - ax ; long qy = y [ 0 ] - ay ; if ( i < N - 1 ) { qx = x [ i + 1 ] - ax ; qy = y [ i + 1 ] - ay ; } long ex = x [ 0 ] - x [ N - 1 ] ; long ey = y [ 0 ] - y [ N - 1 ] ; if ( i < N - 1 ) { ex = x [ i + 1 ] - x [ i ] ; ey = y [ i + 1 ] - y [ i ] ; } long rx = ax - x [ i ] ; long ry = ay - y [ i ] ; long sx = bx - x [ i ] ; long sy = by - y [ i ] ; if ( ( ( abx * py - aby * px ) * ( abx * qy - aby * qx ) <= 0 ) && ( ( ex * ry - ey * rx ) * ( ex * sy - ey * sx ) <= 0 ) ) count ++ ; } System . out . println ( count / 2 + 1 ) ; } }"
] | [
"Ax , Ay , Bx , By = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE num = 0 NEW_LINE def calc ( x0 , y0 , x1 , y1 , x2 , y2 , x3 , y3 ) : NEW_LINE INDENT P0 = ( x0 - x1 ) * ( y2 - y0 ) + ( y0 - y1 ) * ( x0 - x2 ) NEW_LINE Q0 = ( x0 - x1 ) * ( y3 - y0 ) + ( y0 - y1 ) * ( x0 - x3 ) NEW_LINE P1 = ( x2 - x3 ) * ( y0 - y2 ) + ( y2 - y3 ) * ( x2 - x0 ) NEW_LINE Q1 = ( x2 - x3 ) * ( y1 - y2 ) + ( y2 - y3 ) * ( x2 - x1 ) NEW_LINE return P0 * Q0 < 0 and P1 * Q1 < 0 NEW_LINE DEDENT num = 0 NEW_LINE preX0 , preY0 = map ( int , input ( ) . split ( ) ) NEW_LINE preX , preY = preX0 , preY0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if calc ( Ax , Ay , Bx , By , preX , preY , x , y ) : NEW_LINE INDENT num += 1 NEW_LINE DEDENT preX , preY = x , y NEW_LINE DEDENT if calc ( Ax , Ay , Bx , By , preX , preY , preX0 , preY0 ) : NEW_LINE INDENT num += 1 NEW_LINE DEDENT print ( num // 2 + 1 ) NEW_LINE",
"import math NEW_LINE def input_parse ( ) : NEW_LINE INDENT return tuple ( int ( c ) for c in input ( ) . split ( ) ) NEW_LINE DEDENT def sort_linePoint ( Ax , Ay , Bx , By ) : NEW_LINE INDENT if Ax > Bx or ( Ax == By and Ay > By ) : NEW_LINE INDENT tmpx = Ax NEW_LINE tmpy = Ay NEW_LINE Ax = Bx NEW_LINE Ay = By NEW_LINE Bx = tmpx NEW_LINE By = tmpy NEW_LINE DEDENT return Ax , Ay , Bx , By NEW_LINE DEDENT Ax , Ay , Bx , By = input_parse ( ) NEW_LINE Ax , Ay , Bx , By = sort_linePoint ( Ax , Ay , Bx , By ) NEW_LINE Bx_dash = Bx - Ax NEW_LINE By_dash = By - Ay NEW_LINE if By_dash == 0 : NEW_LINE INDENT sin_theta = 0 NEW_LINE cos_theta = 1 NEW_LINE Bx_dash_rot = Bx_dash NEW_LINE By_dash_rot = 0 NEW_LINE DEDENT elif Bx_dash == 0 : NEW_LINE INDENT sin_theta = - 1 NEW_LINE cos_theta = 0 NEW_LINE Bx_dash_rot = By_dash NEW_LINE By_dash_rot = 0 NEW_LINE DEDENT else : NEW_LINE INDENT theta = math . atan2 ( By_dash , Bx_dash ) NEW_LINE sin_theta = math . sin ( - theta ) NEW_LINE cos_theta = math . cos ( - theta ) NEW_LINE Bx_dash_rot = Bx_dash * cos_theta - By_dash * sin_theta NEW_LINE By_dash_rot = 0 NEW_LINE DEDENT def transCoordinate ( x , y ) : NEW_LINE INDENT x = x - Ax NEW_LINE y = y - Ay NEW_LINE x_rot = x * cos_theta - y * sin_theta NEW_LINE y_rot = x * sin_theta + y * cos_theta NEW_LINE return x_rot , y_rot NEW_LINE DEDENT N , = input_parse ( ) NEW_LINE vertices = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y = input_parse ( ) NEW_LINE vertices . append ( transCoordinate ( x , y ) ) NEW_LINE DEDENT pre_x , pre_y = vertices [ - 1 ] NEW_LINE inter_count = 0 NEW_LINE for ( x , y ) in vertices : NEW_LINE INDENT if pre_y * y >= 0 : NEW_LINE INDENT pre_x , pre_y = x , y NEW_LINE continue NEW_LINE DEDENT if pre_x == x : NEW_LINE INDENT intersection_x = x NEW_LINE DEDENT else : NEW_LINE INDENT intersection_x = ( pre_y * x - y * pre_x ) / ( pre_y - y ) NEW_LINE DEDENT if 0 <= intersection_x and intersection_x <= Bx_dash_rot : NEW_LINE INDENT inter_count += 1 NEW_LINE DEDENT pre_x , pre_y = x , y NEW_LINE DEDENT print ( int ( inter_count / 2 + 1 ) ) NEW_LINE",
"import sys NEW_LINE input = sys . stdin . readline NEW_LINE Ax , Ay , Bx , By = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE aXY = [ [ int ( _ ) for _ in sLine . split ( ) ] for sLine in sys . stdin . readlines ( ) ] NEW_LINE def ? ? ? ? ( x1 : int , y1 : int , x2 : int , y2 : int , x3 : int , y3 : int , x4 : int , y4 : int ) -> bool : NEW_LINE INDENT tc = ( x1 - x2 ) * ( y3 - y1 ) + ( y1 - y2 ) * ( x1 - x3 ) NEW_LINE td = ( x1 - x2 ) * ( y4 - y1 ) + ( y1 - y2 ) * ( x1 - x4 ) NEW_LINE ta = ( x3 - x4 ) * ( y1 - y3 ) + ( y3 - y4 ) * ( x3 - x1 ) NEW_LINE tb = ( x3 - x4 ) * ( y2 - y3 ) + ( y3 - y4 ) * ( x3 - x2 ) NEW_LINE if tc * td < 0 and ta * tb < 0 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT iC = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT x0 , y0 = aXY [ i - 1 ] NEW_LINE x1 , y1 = aXY [ i ] NEW_LINE if ? ? ? ? ( Ax , Ay , Bx , By , x0 , y0 , x1 , y1 ) : NEW_LINE INDENT iC += 1 NEW_LINE DEDENT DEDENT print ( iC // 2 + 1 ) NEW_LINE",
"class Vector ( object ) : NEW_LINE INDENT def __init__ ( self , pos1 , pos2 ) : NEW_LINE INDENT self . point1 = pos1 NEW_LINE self . point2 = pos2 NEW_LINE self . size_x = pos2 [ 0 ] - pos1 [ 0 ] NEW_LINE self . size_y = pos2 [ 1 ] - pos1 [ 1 ] NEW_LINE DEDENT def get_cross ( self , other : \" Vector \" ) : NEW_LINE INDENT return self . size_x * other . size_y - self . size_y * other . size_x NEW_LINE DEDENT def check_crossing ( self , other : \" Vector \" ) : NEW_LINE INDENT vec1 , vec2 = Vector ( self . point1 , other . point1 ) , Vector ( self . point1 , other . point2 ) NEW_LINE vec3 , vec4 = Vector ( other . point1 , self . point1 ) , Vector ( other . point1 , self . point2 ) NEW_LINE return self . get_cross ( vec1 ) * self . get_cross ( vec2 ) < 0 and other . get_cross ( vec3 ) * other . get_cross ( vec4 ) < 0 NEW_LINE DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT pos = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE line = Vector ( pos [ 0 : 2 ] , pos [ 2 : ] ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * N ] NEW_LINE a += [ a [ 0 ] ] NEW_LINE count = 0 NEW_LINE for p1 , p2 in zip ( a , a [ 1 : ] ) : NEW_LINE INDENT if Vector ( p1 , p2 ) . check_crossing ( line ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count // 2 + 1 ) NEW_LINE DEDENT",
"def intersect ( p1 , p2 , p3 , p4 ) : NEW_LINE INDENT t1 = ( p1 [ 0 ] - p2 [ 0 ] ) * ( p3 [ 1 ] - p1 [ 1 ] ) + ( p1 [ 1 ] - p2 [ 1 ] ) * ( p1 [ 0 ] - p3 [ 0 ] ) NEW_LINE t2 = ( p1 [ 0 ] - p2 [ 0 ] ) * ( p4 [ 1 ] - p1 [ 1 ] ) + ( p1 [ 1 ] - p2 [ 1 ] ) * ( p1 [ 0 ] - p4 [ 0 ] ) NEW_LINE t3 = ( p3 [ 0 ] - p4 [ 0 ] ) * ( p1 [ 1 ] - p3 [ 1 ] ) + ( p3 [ 1 ] - p4 [ 1 ] ) * ( p3 [ 0 ] - p1 [ 0 ] ) NEW_LINE t4 = ( p3 [ 0 ] - p4 [ 0 ] ) * ( p2 [ 1 ] - p3 [ 1 ] ) + ( p3 [ 1 ] - p4 [ 1 ] ) * ( p3 [ 0 ] - p2 [ 0 ] ) NEW_LINE return t1 * t2 < 0 and t3 * t4 < 0 NEW_LINE DEDENT ax , ay , bx , by = map ( int , input ( ) . split ( ) ) NEW_LINE point1 = [ ax , ay ] NEW_LINE point2 = [ bx , by ] NEW_LINE n = int ( input ( ) ) NEW_LINE info = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE info . append ( info [ 0 ] ) NEW_LINE count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if intersect ( point1 , point2 , info [ i ] , info [ i + 1 ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count // 2 + 1 ) NEW_LINE"
] |
atcoder_arc041_C | [
"import java . util . * ; class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; ArrayDeque < Integer > rq = new ArrayDeque < Integer > ( ) ; ArrayDeque < Integer > lq = new ArrayDeque < Integer > ( ) ; long ans = 0 ; long sumi_cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; char direction = sc . next ( ) . charAt ( 0 ) ; if ( direction == ' L ' ) { if ( rq . isEmpty ( ) ) { long cnt = x - 1 - sumi_cnt ; ans += cnt ; sumi_cnt ++ ; } else { lq . addLast ( x ) ; } } else { if ( lq . isEmpty ( ) ) { rq . addLast ( x ) ; } else { long cnt = calc ( rq , lq ) ; ans += cnt ; rq . push ( x ) ; } } } if ( lq . isEmpty ( ) ) { sumi_cnt = 0 ; while ( rq . size ( ) > 0 ) { int x = rq . pollLast ( ) ; long cnt = l - x - sumi_cnt ; ans += cnt ; sumi_cnt ++ ; } } else { ans += calc ( rq , lq ) ; } System . out . println ( ans ) ; } static long calc ( ArrayDeque < Integer > rq , ArrayDeque < Integer > lq ) { int rx = rq . pollLast ( ) ; int rcount = 1 ; long ans = 0 ; while ( rq . size ( ) > 0 ) { int x = rq . pollLast ( ) ; long cnt = rx - x - rcount ; ans += cnt ; rcount ++ ; } int lx = lq . pollFirst ( ) ; int lcount = 1 ; while ( lq . size ( ) > 0 ) { int x = lq . pollFirst ( ) ; long cnt = x - lx - lcount ; ans += cnt ; lcount ++ ; } long max_cnt = Math . max ( rcount , lcount ) ; long cnt = max_cnt * ( lx - rx - 1 ) ; ans += cnt ; return ans ; } }"
] | [
"def solve ( n , l , lst ) : NEW_LINE INDENT ans = 0 NEW_LINE np = 1 NEW_LINE while len ( lst ) : NEW_LINE INDENT x , d = lst [ 0 ] NEW_LINE if d == 0 : NEW_LINE INDENT ans += x - np NEW_LINE np += 1 NEW_LINE lst . pop ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT np = l NEW_LINE while len ( lst ) : NEW_LINE INDENT x , d = lst [ - 1 ] NEW_LINE if d == 1 : NEW_LINE INDENT ans += np - x NEW_LINE np -= 1 NEW_LINE lst . pop ( ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT while len ( lst ) : NEW_LINE INDENT rlist = [ ] NEW_LINE llist = [ ] NEW_LINE while len ( lst ) : NEW_LINE INDENT x , d = lst [ 0 ] NEW_LINE if d == 1 : NEW_LINE INDENT rlist . append ( x ) NEW_LINE lst . pop ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT while len ( lst ) : NEW_LINE INDENT x , d = lst [ 0 ] NEW_LINE if d == 0 : NEW_LINE INDENT llist . append ( x ) NEW_LINE lst . pop ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT rc = len ( rlist ) NEW_LINE rx = rlist [ - 1 ] NEW_LINE lc = len ( llist ) NEW_LINE lx = llist [ 0 ] NEW_LINE for i , x in enumerate ( rlist ) : NEW_LINE INDENT ans += rx - x - i NEW_LINE DEDENT for i , x in enumerate ( llist ) : NEW_LINE INDENT ans += x - lx - i NEW_LINE DEDENT ans += ( lx - rx - 1 ) * max ( rc , lc ) NEW_LINE DEDENT return ans NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n , l = input ( ) . split ( ) NEW_LINE n = int ( n ) NEW_LINE l = int ( l ) NEW_LINE lst = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT x , d = input ( ) . split ( ) NEW_LINE x = int ( x ) NEW_LINE lst . append ( ( x , 0 if d == ' L ' else 1 ) ) NEW_LINE DEDENT print ( solve ( n , l , lst ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"def count_jump ( right_list , left_list , L ) : NEW_LINE INDENT jump_count = 0 NEW_LINE if len ( right_list ) == 0 : NEW_LINE INDENT for i , p in enumerate ( left_list ) : NEW_LINE INDENT jump_count += p - i - 1 NEW_LINE DEDENT DEDENT elif len ( left_list ) == 0 : NEW_LINE INDENT for i , p in enumerate ( right_list ) : NEW_LINE INDENT jump_count += L - p - i NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i , p in enumerate ( right_list ) : NEW_LINE INDENT jump_count += right_list [ - 1 ] - p - i NEW_LINE DEDENT for i , p in enumerate ( left_list ) : NEW_LINE INDENT jump_count += p - left_list [ 0 ] - i NEW_LINE DEDENT head_diff = left_list [ 0 ] - right_list [ - 1 ] - 1 NEW_LINE max_cnt = max ( len ( right_list ) , len ( left_list ) ) NEW_LINE jump_count += head_diff * max_cnt NEW_LINE DEDENT return jump_count NEW_LINE DEDENT def solve ( rabbits , L ) : NEW_LINE INDENT jump_count = 0 NEW_LINE bef_d = ' R ' NEW_LINE right_list = [ ] NEW_LINE left_list = [ ] NEW_LINE for n_pos , n_d in rabbits : NEW_LINE INDENT if bef_d == ' L ' and n_d == ' R ' : NEW_LINE INDENT jump_count += count_jump ( right_list , left_list , L ) NEW_LINE right_list = [ ] NEW_LINE left_list = [ ] NEW_LINE DEDENT if n_d == ' R ' : NEW_LINE INDENT right_list . append ( n_pos ) NEW_LINE DEDENT else : NEW_LINE INDENT left_list . append ( n_pos ) NEW_LINE DEDENT bef_d = n_d NEW_LINE DEDENT jump_count += count_jump ( right_list , left_list , L ) NEW_LINE return jump_count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N , L = map ( int , input ( ) . split ( ) ) NEW_LINE rabbits = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT pos , direction = input ( ) . split ( ) NEW_LINE rabbits . append ( ( int ( pos ) , direction ) ) NEW_LINE DEDENT result = solve ( rabbits , L ) NEW_LINE print ( result ) NEW_LINE DEDENT",
"n , k = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE p , ln , rn , l , r , ans = [ ] , 0 , 0 , 0 , 0 , 0 NEW_LINE for _ in range ( n ) : NEW_LINE INDENT x , d = ( i for i in input ( ) . split ( ) ) NEW_LINE p . append ( ( int ( x ) , d == \" L \" ) ) NEW_LINE DEDENT if p [ 0 ] [ 1 ] : l = p [ 0 ] [ 0 ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if p [ i ] [ 1 ] and p [ i + 1 ] [ 1 ] : NEW_LINE INDENT ln += 1 NEW_LINE ans += p [ i + 1 ] [ 0 ] - l - ln NEW_LINE DEDENT elif p [ i ] [ 1 ] : NEW_LINE INDENT ans += ( l - r - 1 ) * max ( ln + 1 , rn ) NEW_LINE ln , rn = 0 , 0 NEW_LINE DEDENT elif p [ i + 1 ] [ 1 ] : NEW_LINE INDENT l , r = p [ i + 1 ] [ 0 ] , p [ i ] [ 0 ] NEW_LINE rn += 1 NEW_LINE DEDENT else : NEW_LINE INDENT rn += 1 NEW_LINE ans += ( p [ i + 1 ] [ 0 ] - p [ i ] [ 0 ] - 1 ) * rn NEW_LINE DEDENT DEDENT if n - 1 : NEW_LINE INDENT if p [ - 1 ] [ 1 ] and p [ - 2 ] [ 1 ] : ans += ( l - r - 1 ) * max ( ln + 1 , rn ) NEW_LINE elif p [ - 1 ] [ 1 ] : ans += ( p [ - 1 ] [ 0 ] - r - 1 ) * max ( rn , 1 ) NEW_LINE else : ans += ( k - p [ - 1 ] [ 0 ] ) * ( rn + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT if p [ 0 ] [ 1 ] : ans = p [ 0 ] [ 0 ] - 1 NEW_LINE else : ans = k - p [ 0 ] [ 0 ] NEW_LINE DEDENT print ( ans ) NEW_LINE",
"import sys NEW_LINE N , L = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ ( - 1 , 0 ) , ( 0 , 1 ) ] + [ ( int ( x ) , 0 if d == \" R \" else 1 ) for x , d in ( l . split ( ) for l in sys . stdin ) ] + [ ( L + 1 , 0 ) , ( L + 2 , 1 ) ] NEW_LINE jumps = 0 NEW_LINE l_rabbit , r_rabbit , l_mid , r_mid = 0 , 0 , 0 , 0 NEW_LINE for ( current_pos , current_dir ) , ( next_pos , next_dir ) in zip ( a , a [ 1 : ] ) : NEW_LINE INDENT if current_dir == 0 : NEW_LINE INDENT l_rabbit += 1 NEW_LINE if current_dir == next_dir : NEW_LINE INDENT jumps += ( next_pos - current_pos - 1 ) * l_rabbit NEW_LINE DEDENT else : NEW_LINE INDENT l_mid , r_mid = current_pos , next_pos NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT jumps += current_pos - r_mid - r_rabbit NEW_LINE r_rabbit += 1 NEW_LINE if current_dir != next_dir : NEW_LINE INDENT jumps += max ( l_rabbit , r_rabbit ) * ( r_mid - l_mid - 1 ) NEW_LINE l_rabbit , r_rabbit = 0 , 0 NEW_LINE DEDENT DEDENT DEDENT print ( jumps ) NEW_LINE",
"import sys NEW_LINE def bunny ( L , R ) : NEW_LINE INDENT L = L [ : : - 1 ] NEW_LINE gap = l - L [ 0 ] if not R else R [ 0 ] - 1 if not L else R [ 0 ] - L [ 0 ] - 1 NEW_LINE len_L , len_R = len ( L ) , len ( R ) NEW_LINE gap_L = sum ( L [ 0 ] - L [ i ] - i for i in range ( 1 , len_L ) ) NEW_LINE gap_R = sum ( R [ i ] - R [ 0 ] - i for i in range ( 1 , len_R ) ) NEW_LINE return gap_L + gap * max ( len_L , len_R ) + gap_R NEW_LINE DEDENT N , l = map ( int , input ( ) . split ( ) ) NEW_LINE rabbit , b2b = [ [ ] , [ ] ] , 0 NEW_LINE ans = 0 NEW_LINE for e in sys . stdin : NEW_LINE INDENT x , d = int ( e [ : - 3 ] ) , e [ - 2 ] NEW_LINE if b2b == 0 or d == ' L ' : NEW_LINE INDENT rabbit [ d == ' L ' ] += [ x ] NEW_LINE b2b = d == ' L ' NEW_LINE DEDENT else : NEW_LINE INDENT ans += bunny ( * rabbit ) NEW_LINE rabbit , b2b = [ [ x ] , [ ] ] , 0 NEW_LINE DEDENT DEDENT ans += bunny ( * rabbit ) NEW_LINE print ( ans ) NEW_LINE"
] |
atcoder_agc013_C | [
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , l = sc . nextInt ( ) , t = sc . nextInt ( ) ; int temp , cnt = 0 , d ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; d = sc . nextInt ( ) ; if ( d == 1 ) { temp = a [ i ] + t ; a [ i ] = temp % l ; cnt += temp / l ; } else { temp = a [ i ] - t ; a [ i ] = temp % l ; cnt += temp / l ; if ( a [ i ] < 0 ) { a [ i ] += l ; cnt -- ; } } } Arrays . sort ( a ) ; cnt %= n ; if ( cnt < 0 ) cnt += n ; cnt %= n ; for ( int i = cnt ; i < cnt + n ; i ++ ) { int j = i % n ; System . out . println ( a [ j ] ) ; } sc . close ( ) ; } }",
"import java . io . * ; import java . util . * ; class MyInputStream extends InputStream { public BufferedInputStream bis = new BufferedInputStream ( System . in ) ; public int read ( ) throws IOException { int i ; while ( ( i = bis . read ( ) ) < 48 ) if ( i == - 1 ) return - 1 ; int temp = 0 ; while ( i > 47 ) { temp = temp * 10 + i - 48 ; i = bis . read ( ) ; } return temp ; } } public class Main { static final int N = 100005 ; static final int inf = 0x3f3f3f3f ; static final double eps = 1e-6 ; static int a [ ] = new int [ N ] ; public static void main ( String [ ] args ) throws IOException { MyInputStream cin = new MyInputStream ( ) ; int n = cin . read ( ) , l = cin . read ( ) , t = cin . read ( ) ; int tmp , cnt = 0 , d ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = cin . read ( ) ; d = cin . read ( ) ; if ( d == 1 ) { tmp = a [ i ] + t ; a [ i ] = tmp % l ; cnt += tmp / l ; } else { tmp = a [ i ] - t ; a [ i ] = tmp % l ; cnt += tmp / l ; if ( a [ i ] < 0 ) { a [ i ] += l ; cnt -- ; } } } Arrays . sort ( a , 0 , n ) ; cnt %= n ; if ( cnt < 0 ) cnt += n ; cnt %= n ; StringBuilder ans = new StringBuilder ( \" \" ) ; for ( int i = cnt ; i < cnt + n ; i ++ ) { int j = i % n ; System . out . println ( a [ j ] ) ; } } }",
"import java . io . IOException ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long l = sc . nextLong ( ) ; long t = sc . nextLong ( ) ; long [ ] x = new long [ n ] ; long [ ] w = new long [ n ] ; long [ ] v = new long [ n ] ; long [ ] p = new long [ n ] ; int shift = 0 ; for ( int i = 0 ; i < n ; ++ i ) { x [ i ] = sc . nextLong ( ) ; w [ i ] = sc . nextLong ( ) ; v [ i ] = w [ i ] == 1 ? 1 : - 1 ; p [ i ] = ( x [ i ] + v [ i ] * t % l + l ) % l ; if ( v [ i ] < 0 ) { shift += ( l - x [ i ] + ( - v [ i ] ) * t - 1 ) / l % n ; } else { shift -= ( x [ i ] + v [ i ] * t ) / l % n ; } shift %= n ; } while ( shift < 0 ) shift += n ; Arrays . sort ( p ) ; long [ ] ans = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { ans [ i ] = p [ ( i - shift + n ) % n ] ; } for ( int i = 0 ; i < n ; ++ i ) { System . out . println ( ans [ i ] ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }"
] | [
"N , L , T = map ( int , input ( ) . split ( ) ) NEW_LINE ants = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , w = map ( int , input ( ) . split ( ) ) NEW_LINE ants . append ( ( x , w ) ) NEW_LINE DEDENT ants2 = [ ] NEW_LINE for ant in ants : NEW_LINE INDENT ants2 . append ( ( ant [ 0 ] + T * ( 3 - 2 * ant [ 1 ] ) ) % L ) NEW_LINE DEDENT st = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ants2 . count ( ants2 [ i ] ) == 1 : NEW_LINE INDENT st = i NEW_LINE break NEW_LINE DEDENT DEDENT cl = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ants [ i ] [ 1 ] == ants [ st ] [ 1 ] : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if ants [ st ] [ 1 ] == 1 : NEW_LINE INDENT if ants [ i ] [ 0 ] > ants [ st ] [ 0 ] : NEW_LINE INDENT fc = ( ants [ i ] [ 0 ] - ants [ st ] [ 0 ] ) / 2 NEW_LINE DEDENT else : NEW_LINE INDENT fc = ( ( L - ants [ st ] [ 0 ] ) + ants [ i ] [ 0 ] ) / 2 NEW_LINE DEDENT cl += ( 2 * ( T - fc ) ) // L + 1 NEW_LINE DEDENT else : NEW_LINE INDENT if ants [ i ] [ 0 ] > ants [ st ] [ 0 ] : NEW_LINE INDENT fc = ( ( L - ants [ i ] [ 0 ] ) + ants [ st ] [ 0 ] ) / 2 NEW_LINE DEDENT else : NEW_LINE INDENT fc = ( ants [ st ] [ 0 ] - ants [ i ] [ 0 ] ) / 2 NEW_LINE DEDENT cl -= ( 2 * ( T - fc ) ) // L + 1 NEW_LINE DEDENT DEDENT DEDENT stant = ants2 [ st ] NEW_LINE ants2 . sort ( ) NEW_LINE idx = ants2 . index ( stant ) - int ( cl ) - st NEW_LINE for i in range ( N ) : NEW_LINE INDENT print ( ants2 [ ( i + idx ) % N ] ) NEW_LINE DEDENT",
"( lambda N , L , T : ( lambda a , m : ( lambda X , W : ( lambda n : ( lambda b : ( lambda c : any ( map ( print , b [ c : ] + b [ : c ] ) ) ) ( b . index ( ( X + [ - T , T ] [ W < 2 ] ) % L ) - [ N - n , n ] [ W < 2 ] ) ) ( sorted ( ( x + [ - T , T ] [ w < 2 ] ) % L for x , w in a ) ) ) ( sum ( T // L * 2 + sum ( [ X - x + L + i <= m , x - X + i < m ] [ W < 2 ] for i in [ 0 , L ] ) for x , w in a if w != W ) % N ) ) ( * a [ 0 ] ) ) ( [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * N ] , T % L * 2 ) ) ( * map ( int , input ( ) . split ( ) ) ) NEW_LINE",
"from bisect import bisect_left , bisect NEW_LINE n , l , t = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE x , y , c = [ [ int ( i ) for i in input ( ) . split ( ) ] ] , [ 0 ] , 0 NEW_LINE ans = [ ( x [ 0 ] [ 0 ] - t ) % l if x [ 0 ] [ 1 ] - 1 else ( x [ 0 ] [ 0 ] + t ) % l ] NEW_LINE ans2 = ans [ 0 ] NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE x . append ( [ a , b ] ) NEW_LINE if b != x [ 0 ] [ 1 ] : c += 1 NEW_LINE y . append ( c ) NEW_LINE if b - 1 : ans . append ( ( a - t ) % l ) NEW_LINE else : ans . append ( ( a + t ) % l ) NEW_LINE DEDENT ans . sort ( ) NEW_LINE if x [ 0 ] [ 1 ] - 1 : ans3 = bisect_left ( ans , ans2 ) NEW_LINE else : ans3 = bisect ( ans , ans2 ) - 1 NEW_LINE num = int ( t / ( l / 2 ) ) NEW_LINE if x [ 0 ] [ 1 ] - 1 : NEW_LINE INDENT p = ( - ( t - num * ( l / 2 ) ) * 2 + x [ 0 ] [ 0 ] ) % l NEW_LINE d = ( y [ - 1 ] * num + y [ - 1 ] - y [ bisect_left ( x , [ p , 0 ] ) - 1 ] ) % n NEW_LINE DEDENT else : NEW_LINE INDENT p = ( ( t - num * ( l / 2 ) ) * 2 + x [ 0 ] [ 0 ] ) NEW_LINE d = ( y [ - 1 ] * num + y [ bisect_left ( x , [ p , 3 ] ) - 1 ] ) % n NEW_LINE DEDENT if x [ 0 ] [ 1 ] - 1 : d = - d NEW_LINE for i in range ( n ) : print ( ans [ ( ans3 - d + i ) % n ] ) NEW_LINE",
"from bisect import bisect , bisect_left NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , L , T = inpl ( ) NEW_LINE Fants = [ ] NEW_LINE Bants = [ ] NEW_LINE A = [ [ 0 , 0 ] for _ in range ( N ) ] NEW_LINE P = [ - 1 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , w = inpl ( ) NEW_LINE A [ i ] = ( x , w ) NEW_LINE if w == 1 : NEW_LINE INDENT Fants . append ( x ) NEW_LINE P [ i ] = ( x + T ) % L NEW_LINE DEDENT else : NEW_LINE INDENT Bants . append ( x ) NEW_LINE P [ i ] = ( x - T ) % L NEW_LINE DEDENT DEDENT B = Bants + [ b + L for b in Bants ] + [ b + 2 * L for b in Bants ] NEW_LINE F = [ f - 2 * L for f in Fants ] + [ f - L for f in Fants ] + Fants NEW_LINE d , m = divmod ( T , L ) NEW_LINE ans = [ - 1 ] * N NEW_LINE for i , ( x , w ) in enumerate ( A ) : NEW_LINE INDENT if w == 1 : NEW_LINE INDENT j = i + 2 * d * len ( Bants ) + ( bisect ( B , x + 2 * m ) - bisect ( B , x ) ) NEW_LINE ans [ j % N ] = P [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT j = i - 2 * d * len ( Fants ) - ( bisect_left ( F , x ) - bisect_left ( F , x - 2 * m ) ) NEW_LINE ans [ j % N ] = P [ i ] NEW_LINE DEDENT DEDENT print ( * ans , sep = \" \\n \" ) NEW_LINE",
"N , L , T = map ( int , input ( ) . split ( ) ) NEW_LINE src = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE xs = [ ] NEW_LINE for x , w in src : NEW_LINE INDENT dx = T if w == 1 else - T NEW_LINE xs . append ( ( x + dx ) % L ) NEW_LINE DEDENT xs . sort ( ) NEW_LINE if N == 1 : NEW_LINE INDENT print ( xs [ 0 ] ) NEW_LINE exit ( ) NEW_LINE DEDENT x0 , w0 = src [ 0 ] NEW_LINE k0 = 0 NEW_LINE for x , w in src : NEW_LINE INDENT if x == x0 : continue NEW_LINE if w == w0 : continue NEW_LINE if w0 == 1 : NEW_LINE INDENT dist = ( x - x0 ) % L NEW_LINE DEDENT else : NEW_LINE INDENT dist = ( x0 - x ) % L NEW_LINE DEDENT if 2 * T >= dist : NEW_LINE INDENT k0 += 1 + ( 2 * T - dist ) // L NEW_LINE DEDENT DEDENT newx0 = ( x0 + T ) % L if w0 == 1 else ( x0 - T ) % L NEW_LINE i0 = xs . index ( newx0 ) NEW_LINE if w0 == 1 and i0 + 1 < N and xs [ i0 ] == xs [ i0 + 1 ] : NEW_LINE INDENT i0 += 1 NEW_LINE DEDENT i0 += ( k0 if w0 == 2 else - k0 ) NEW_LINE i0 %= N NEW_LINE for i in range ( i0 , i0 + N ) : NEW_LINE INDENT print ( xs [ i % N ] ) NEW_LINE DEDENT"
] |
atcoder_abc110_B | [
"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) , m = sc . nextInt ( ) , x = sc . nextInt ( ) , y = sc . nextInt ( ) ; int max = x , min = y ; for ( int i = 0 ; i < n ; i ++ ) { max = Math . max ( max , sc . nextInt ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { min = Math . min ( min , sc . nextInt ( ) ) ; } System . out . println ( max >= min ? \" War \" : \" No β War \" ) ; } }",
"import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int xa [ ] = new int [ n ] ; int ya [ ] = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { xa [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { ya [ i ] = sc . nextInt ( ) ; } boolean ans = false ; for ( int i = x + 1 ; i <= y ; i ++ ) { boolean flag = false ; for ( int j = 0 ; j < n ; j ++ ) { if ( xa [ j ] >= i ) { flag = true ; } } for ( int j = 0 ; j < m ; j ++ ) { if ( ya [ j ] < i ) flag = true ; } if ( flag == false ) { ans = true ; break ; } } if ( ans ) { System . out . print ( \" No β War \" ) ; } else { System . out . print ( \" War \" ) ; } } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int n , m , X , Y ; n = Integer . parseInt ( sc . next ( ) ) ; m = Integer . parseInt ( sc . next ( ) ) ; X = Integer . parseInt ( sc . next ( ) ) ; Y = Integer . parseInt ( sc . next ( ) ) ; int [ ] x = new int [ n ] , y = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { y [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( x ) ; Arrays . sort ( y ) ; if ( Math . max ( X , x [ n - 1 ] ) < Math . min ( Y , y [ 0 ] ) ) { System . out . println ( \" No β War \" ) ; } else { System . out . println ( \" War \" ) ; } } catch ( Exception e ) { System . out . println ( \" out \" ) ; } } }",
"import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; List < Integer > xList = new ArrayList < > ( ) ; List < Integer > yList = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { xList . add ( sc . nextInt ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { yList . add ( sc . nextInt ( ) ) ; } Collections . sort ( xList ) ; Collections . sort ( yList ) ; for ( int i = xList . get ( n - 1 ) + 1 ; i <= yList . get ( 0 ) ; i ++ ) { if ( i > x && i <= y ) { System . out . println ( \" No β War \" ) ; return ; } } System . out . println ( \" War \" ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; int M = reader . nextInt ( ) ; int X = reader . nextInt ( ) ; int Y = reader . nextInt ( ) ; int [ ] xn = new int [ N ] ; int [ ] ym = new int [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { xn [ i ] = reader . nextInt ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { ym [ i ] = reader . nextInt ( ) ; } int Z = X + 1 ; while ( Z < Y ) { boolean isWar = false ; for ( int i = 0 ; i < N ; i ++ ) { if ( xn [ i ] >= Z ) { isWar = true ; } } for ( int i = 0 ; i < M ; i ++ ) { if ( ym [ i ] < Z ) { isWar = true ; } } if ( ! isWar ) { System . out . print ( \" No β War \" ) ; return ; } Z ++ ; } System . out . print ( \" War \" ) ; } }"
] | [
"n , m , X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE y = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE x . append ( X ) NEW_LINE y . append ( Y ) NEW_LINE if max ( x ) < min ( y ) : NEW_LINE INDENT print ( ' No β War ' ) NEW_LINE DEDENT else : print ( ' War ' ) NEW_LINE",
"import sys NEW_LINE n , m , x , y = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE xl = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE yl = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( x + 1 , y + 1 ) : NEW_LINE INDENT if ( max ( xl ) < i and min ( yl ) >= i ) : NEW_LINE INDENT print ( \" No β War \" ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT print ( \" War \" ) NEW_LINE",
"import sys NEW_LINE n , m , X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE y = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for z in range ( 101 ) : NEW_LINE INDENT if X < z <= Y and all ( x [ i ] < z for i in range ( n ) ) and all ( y [ j ] >= z for j in range ( m ) ) : NEW_LINE INDENT print ( ' No β War ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT for z in range ( 1 , 101 ) : NEW_LINE INDENT if X < z * ( - 1 ) <= Y and all ( x [ i ] < z * ( - 1 ) for i in range ( n ) ) and all ( y [ j ] >= z * ( - 1 ) for j in range ( m ) ) : NEW_LINE INDENT print ( ' No β War ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT print ( ' War ' ) NEW_LINE",
"n , m , x , y = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE x_li = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE y_li = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans_f = 0 NEW_LINE for z in range ( x + 1 , y + 1 ) : NEW_LINE INDENT x_not_f = 0 NEW_LINE y_not_f = 0 NEW_LINE for i in x_li : NEW_LINE INDENT if z <= i : NEW_LINE INDENT x_not_f = 1 NEW_LINE DEDENT DEDENT for i in y_li : NEW_LINE INDENT if z > i : NEW_LINE INDENT y_not_f = 1 NEW_LINE DEDENT DEDENT if x_not_f == 0 and y_not_f == 0 : NEW_LINE INDENT ans_f = 1 NEW_LINE break NEW_LINE DEDENT DEDENT if ans_f == 1 : NEW_LINE INDENT print ( \" No β War \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" War \" ) NEW_LINE DEDENT",
"N , M , X , Y = map ( int , input ( ) . split ( ) ) NEW_LINE x = input ( ) . split ( ) NEW_LINE xls = [ ] NEW_LINE for n in range ( 0 , N ) : NEW_LINE INDENT xls . append ( int ( x [ n ] ) ) NEW_LINE DEDENT y = input ( ) . split ( ) NEW_LINE yls = [ ] NEW_LINE for n in range ( 0 , M ) : NEW_LINE INDENT yls . append ( int ( y [ n ] ) ) NEW_LINE DEDENT xls . sort ( ) NEW_LINE yls . sort ( ) NEW_LINE if xls [ len ( xls ) - 1 ] >= yls [ 0 ] : NEW_LINE INDENT print ( \" War \" ) NEW_LINE DEDENT elif yls [ 0 ] <= X : NEW_LINE INDENT print ( \" War \" ) NEW_LINE DEDENT elif xls [ len ( xls ) - 1 ] >= Y : NEW_LINE INDENT print ( \" War \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" No β War \" ) NEW_LINE DEDENT"
] |
atcoder_abc111_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; if ( N % 111 == 0 ) { System . out . println ( N ) ; } else { int a = N / 111 + 1 ; System . out . println ( a * 100 + a * 10 + a ) ; } } }",
"import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; for ( int i = 1 ; i < 10 ; i ++ ) { if ( i * 111 >= n ) { out . println ( i * 111 ) ; break ; } } } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( \" End β of β Input \" ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }",
"import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { private static final int ALL_DIGITS_SAME = 111 ; public static String process ( TestCase testCase ) { final int N = testCase . N ; return String . valueOf ( IntStream . range ( 1 , 10 ) . map ( i -> i * ALL_DIGITS_SAME ) . filter ( contestNum -> contestNum >= N ) . findFirst ( ) . orElseThrow ( ( ) -> new IllegalArgumentException ( \" N β is β too β large : β \" + N ) ) ) ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final String result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; return new TestCase ( N ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final int N ; public TestCase ( int N ) { this . N = N ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; if ( 100 <= N && N <= 111 ) { System . out . println ( 111 ) ; } else if ( 112 <= N && N <= 222 ) { System . out . println ( 222 ) ; } else if ( 223 <= N && N <= 333 ) { System . out . println ( 333 ) ; } else if ( 334 <= N && N <= 444 ) { System . out . println ( 444 ) ; } else if ( 445 <= N && N <= 555 ) { System . out . println ( 555 ) ; } else if ( 556 <= N && N <= 666 ) { System . out . println ( 666 ) ; } else if ( 667 <= N && N <= 777 ) { System . out . println ( 777 ) ; } else if ( 778 <= N && N <= 888 ) { System . out . println ( 888 ) ; } else if ( 889 <= N && N <= 999 ) { System . out . println ( 999 ) ; } } }",
"import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; while ( ! isAllSame ( N ) ) { N ++ ; } System . out . println ( N ) ; } private static boolean isAllSame ( int N ) { String str = String . valueOf ( N ) ; char [ ] chars = str . toCharArray ( ) ; char c = chars [ 0 ] ; for ( int i = 0 ; i < chars . length ; i ++ ) { if ( chars [ i ] != c ) return false ; } return true ; } }"
] | [
"n = int ( input ( ) ) NEW_LINE num = [ 111 , 222 , 333 , 444 , 555 , 666 , 777 , 888 , 999 ] NEW_LINE min_ = 111 NEW_LINE ans = 0 NEW_LINE for i in num : NEW_LINE INDENT if i - n < 0 : NEW_LINE INDENT None NEW_LINE DEDENT else : NEW_LINE INDENT if min_ > i - n : NEW_LINE INDENT ans = i NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE",
"from math import ceil NEW_LINE print ( 111 * ceil ( int ( input ( ) ) / 111 ) ) NEW_LINE",
"import sys NEW_LINE import copy NEW_LINE from bisect import bisect_left NEW_LINE def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE for i in range ( N , 1000 ) : NEW_LINE INDENT tmp = i % 10 NEW_LINE ans = \" \" NEW_LINE tugi = 0 NEW_LINE isOK = True NEW_LINE for j in range ( len ( str ( i ) ) ) : NEW_LINE INDENT if j == 0 : NEW_LINE INDENT tugi = i NEW_LINE DEDENT tmp2 = tugi % 10 NEW_LINE tugi = tugi // 10 NEW_LINE ans += str ( tmp ) NEW_LINE if tmp != tmp2 : NEW_LINE INDENT isOK = False NEW_LINE break NEW_LINE DEDENT DEDENT if isOK == True : NEW_LINE INDENT print ( ans ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"n = input ( ) NEW_LINE m = n [ 0 ] NEW_LINE for i in range ( len ( n ) - 1 ) : NEW_LINE INDENT m += n [ 0 ] NEW_LINE DEDENT if int ( n ) > int ( m ) : NEW_LINE INDENT if n [ 0 ] != str ( 9 ) : NEW_LINE INDENT a = str ( int ( n [ 0 ] ) + 1 ) NEW_LINE for j in range ( len ( n ) - 1 ) : NEW_LINE INDENT a += str ( int ( n [ 0 ] ) + 1 ) NEW_LINE DEDENT print ( a ) NEW_LINE DEDENT else : NEW_LINE INDENT b = str ( 1 ) NEW_LINE for k in range ( len ( n ) ) : NEW_LINE INDENT b += str ( 1 ) NEW_LINE DEDENT print ( b ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( m ) NEW_LINE DEDENT",
"n = int ( input ( ) ) NEW_LINE x = n NEW_LINE while True : NEW_LINE INDENT flag = False NEW_LINE first_s = str ( x ) [ 0 ] NEW_LINE if all ( s == first_s for s in str ( x ) ) : NEW_LINE INDENT print ( x ) NEW_LINE exit ( ) NEW_LINE DEDENT x += 1 NEW_LINE DEDENT"
] |
atcoder_arc051_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; int x3 = sc . nextInt ( ) ; int y3 = sc . nextInt ( ) ; double w1 = Math . pow ( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) , 0.5 ) ; double w2 = Math . pow ( ( x1 - x3 ) * ( x1 - x3 ) + ( y1 - y2 ) * ( y1 - y2 ) , 0.5 ) ; double w3 = Math . pow ( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y3 ) * ( y1 - y3 ) , 0.5 ) ; double w4 = Math . pow ( ( x1 - x3 ) * ( x1 - x3 ) + ( y1 - y3 ) * ( y1 - y3 ) , 0.5 ) ; if ( w1 <= r && w2 <= r && w3 <= r && w4 <= r ) { System . out . println ( \" YES \" ) ; System . out . println ( \" NO \" ) ; } else if ( x2 <= x1 - r && x1 + r <= x3 && y2 <= y1 - r && y1 + r <= y3 ) { System . out . println ( \" NO \" ) ; System . out . println ( \" YES \" ) ; } else { System . out . println ( \" YES \" ) ; System . out . println ( \" YES \" ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String red = \" YES \" ; String blue = \" YES \" ; int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int x1_left = x1 - r ; int x1_right = x1 + r ; int y1_up = y1 + r ; int y1_down = y1 - r ; int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; int x3 = sc . nextInt ( ) ; int y3 = sc . nextInt ( ) ; if ( x2 <= x1_left && x1_right <= x3 && y2 <= y1_down && y1_up <= y3 ) { red = \" NO \" ; } if ( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) <= r * r && ( x3 - x1 ) * ( x3 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) <= r * r && ( x3 - x1 ) * ( x3 - x1 ) + ( y3 - y1 ) * ( y3 - y1 ) <= r * r && ( x2 - x1 ) * ( x2 - x1 ) + ( y3 - y1 ) * ( y3 - y1 ) <= r * r ) { blue = \" NO \" ; } System . out . println ( red ) ; System . out . println ( blue ) ; } }",
"import java . awt . geom . Ellipse2D ; import java . awt . geom . Rectangle2D ; import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] __ ) { int x = getInt ( ) , y = getInt ( ) , r = getInt ( ) ; Ellipse2D . Double red = new Ellipse2D . Double ( x - r , y - r , r * 2 , r * 2 ) ; x = getInt ( ) ; y = getInt ( ) ; int xx = getInt ( ) , yy = getInt ( ) ; Rectangle2D . Double blue = new Rectangle2D . Double ( x , y , xx - x , yy - y ) ; System . out . println ( blue . contains ( red . getBounds2D ( ) ) ? \" NO \" : \" YES \" ) ; System . out . println ( red . contains ( blue ) ? \" NO \" : \" YES \" ) ; } }",
"import java . util . * ; import java . math . * ; public class Main { private static boolean blueVisible ( double x , double y , double x1 , double y1 , double r ) { double dx = x - x1 ; double dy = y - y1 ; return dx * dx + dy * dy > r * r ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; double x1 = s . nextDouble ( ) ; double y1 = s . nextDouble ( ) ; double r = s . nextDouble ( ) ; double x2 = s . nextDouble ( ) ; double y2 = s . nextDouble ( ) ; double x3 = s . nextDouble ( ) ; double y3 = s . nextDouble ( ) ; System . out . println ( ( x1 + r > x3 || x1 - r < x2 || y1 + r > y3 || y1 - r < y2 ) ? \" YES \" : \" NO \" ) ; System . out . println ( ( blueVisible ( x2 , y2 , x1 , y1 , r ) || blueVisible ( x2 , y3 , x1 , y1 , r ) || blueVisible ( x3 , y3 , x1 , y1 , r ) || blueVisible ( x3 , y2 , x1 , y1 , r ) ) ? \" YES \" : \" NO \" ) ; } }",
"import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; Point [ ] p = new Point [ 3 ] ; p [ 0 ] = new Point ( sc . nextInt ( ) , sc . nextInt ( ) ) ; int r = sc . nextInt ( ) ; for ( int i = 1 ; i < 3 ; i ++ ) p [ i ] = new Point ( sc . nextInt ( ) , sc . nextInt ( ) ) ; if ( c ( p , r ) ) { out . println ( \" YES \" ) ; out . println ( \" NO \" ) ; } else if ( d ( p , r ) ) { out . println ( \" NO \" ) ; out . println ( \" YES \" ) ; } else { out . println ( \" YES \" ) ; out . println ( \" YES \" ) ; } } static boolean c ( Point [ ] p , int r ) { r *= r ; int d1 = g ( p [ 0 ] , p [ 1 ] ) ; int d2 = g ( p [ 0 ] , p [ 2 ] ) ; int d3 = g ( p [ 0 ] , new Point ( p [ 1 ] . x , p [ 2 ] . y ) ) ; int d4 = g ( p [ 0 ] , new Point ( p [ 2 ] . x , p [ 1 ] . y ) ) ; return d1 <= r && d2 <= r && d3 <= r && d4 <= r ; } static boolean d ( Point [ ] p , int r ) { return p [ 1 ] . y <= p [ 0 ] . y - r && p [ 0 ] . y + r <= p [ 2 ] . y && p [ 1 ] . x <= p [ 0 ] . x - r && p [ 1 ] . x + r <= p [ 2 ] . x ; } static int g ( Point p1 , Point p2 ) { return ( p1 . x - p2 . x ) * ( p1 . x - p2 . x ) + ( p1 . y - p2 . y ) * ( p1 . y - p2 . y ) ; } }"
] | [
"import math NEW_LINE def caldistance ( x , y , s , t ) : NEW_LINE INDENT return math . sqrt ( ( x - s ) ** 2 + ( y - t ) ** 2 ) NEW_LINE DEDENT x1 , y1 , r = map ( int , input ( ) . split ( ) ) NEW_LINE x2 , y2 , x3 , y3 = map ( int , input ( ) . split ( ) ) NEW_LINE if x2 <= x1 - r and x3 >= x1 + r and y2 <= y1 - r and y3 >= y1 + r : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT if caldistance ( x2 , y2 , x1 , y1 ) <= r and caldistance ( x2 , y3 , x1 , y1 ) <= r and caldistance ( x3 , y2 , x1 , y1 ) <= r and caldistance ( x3 , y3 , x1 , y1 ) <= r : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT",
"def a_paint ( X1 , Y1 , R , X2 , Y2 , X3 , Y3 ) : NEW_LINE INDENT is_rectangle_include_circle = all ( [ X2 <= X1 - R , X1 + R <= X3 , Y2 <= Y1 - R , Y1 + R <= Y3 ] ) NEW_LINE is_circle_include_rectangle = all ( [ ( X1 - X2 ) ** 2 + ( Y1 - Y2 ) ** 2 <= R ** 2 , ( X1 - X3 ) ** 2 + ( Y1 - Y3 ) ** 2 <= R ** 2 , ( X1 - X2 ) ** 2 + ( Y1 - Y3 ) ** 2 <= R ** 2 , ( X1 - X3 ) ** 2 + ( Y1 - Y2 ) ** 2 <= R ** 2 ] ) NEW_LINE if is_rectangle_include_circle : NEW_LINE INDENT ans = ' NO β YES ' NEW_LINE DEDENT elif is_circle_include_rectangle : NEW_LINE INDENT ans = ' YES β NO ' NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' YES β YES ' NEW_LINE DEDENT return ans NEW_LINE DEDENT X1 , Y1 , R = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE X2 , Y2 , X3 , Y3 = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( a_paint ( X1 , Y1 , R , X2 , Y2 , X3 , Y3 ) ) NEW_LINE",
"X1 , Y1 , R = map ( int , input ( ) . split ( \" β \" ) ) NEW_LINE X2 , Y2 , X3 , Y3 = map ( int , input ( ) . split ( \" β \" ) ) NEW_LINE min_x , max_x = sorted ( [ X2 , X3 ] ) NEW_LINE min_y , max_y = sorted ( [ Y2 , Y3 ] ) NEW_LINE is_red = False NEW_LINE for x , y in [ ( X1 + R , Y1 ) , ( X1 - R , Y1 ) , ( X1 , Y1 + R ) , ( X1 , Y1 - R ) ] : NEW_LINE INDENT if min_x <= x <= max_x and min_y <= y <= max_y : NEW_LINE INDENT continue NEW_LINE DEDENT is_red = True NEW_LINE break NEW_LINE DEDENT is_blue = False NEW_LINE for x , y in [ ( X2 , Y2 ) , ( X2 , Y3 ) , ( X3 , Y2 ) , ( X3 , Y3 ) ] : NEW_LINE INDENT if ( abs ( X1 - x ) ** 2 + abs ( Y1 - y ) ** 2 ) ** ( 1 / 2 ) <= R : NEW_LINE INDENT continue NEW_LINE DEDENT is_blue = True NEW_LINE break NEW_LINE DEDENT print ( [ \" NO \" , \" YES \" ] [ is_red ] ) NEW_LINE print ( [ \" NO \" , \" YES \" ] [ is_blue ] ) NEW_LINE",
"x , y , r = map ( int , input ( ) . split ( ) ) NEW_LINE x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) NEW_LINE def f ( i ) : NEW_LINE INDENT p , q , n , m = i NEW_LINE return ( ( p - n ) ** 2 + ( q - m ) ** 2 ) ** 0.5 < r NEW_LINE DEDENT e = [ f ( [ x , y ] + i ) for i in [ [ x1 , y1 ] , [ x1 , y2 ] , [ x2 , y1 ] , [ x2 , y2 ] ] ] NEW_LINE f = [ x1 <= s <= x2 and y1 <= t <= y2 for ( s , t ) in [ [ x + r , y + r ] , [ x - r , y + r ] , [ x + r , y - r ] , [ x - r , y - r ] ] ] NEW_LINE if any ( e ) == 0 and any ( f ) == 0 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE print ( \" YES \" ) NEW_LINE DEDENT elif all ( e ) and any ( f ) == 0 : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE print ( \" NO \" ) NEW_LINE DEDENT elif any ( e ) == 0 and all ( f ) : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE print ( \" YES \" ) NEW_LINE DEDENT",
"x1 , y1 , r = map ( int , input ( ) . split ( ) ) NEW_LINE x2 , y2 , x3 , y3 = map ( int , input ( ) . split ( ) ) NEW_LINE if ( x2 <= ( x1 - r ) and x3 >= ( x1 + r ) and y2 <= ( y1 - r ) and y3 >= ( y1 + r ) ) : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT r1 = ( ( x1 - x2 ) ** 2 + ( y1 - y2 ) ** 2 ) NEW_LINE r2 = ( ( x1 - x3 ) ** 2 + ( y1 - y3 ) ** 2 ) NEW_LINE r3 = ( ( x1 - x2 ) ** 2 + ( y1 - y3 ) ** 2 ) NEW_LINE r4 = ( ( x1 - x3 ) ** 2 + ( y1 - y2 ) ** 2 ) NEW_LINE if ( r1 > r ** 2 or r2 > r ** 2 or r3 > r ** 2 or r4 > r ** 2 ) : NEW_LINE INDENT print ( \" YES \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" NO \" ) NEW_LINE DEDENT"
] |
atcoder_agc004_A | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; if ( a % 2 == 0 || b % 2 == 0 || c % 2 == 0 ) { System . out . println ( 0 ) ; return ; } long ans = Math . min ( a * b , Math . min ( b * c , c * a ) ) ; System . out . println ( ans ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ADivideACuboid solver = new ADivideACuboid ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ADivideACuboid { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long a = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) ; out . println ( a * b * c % 2 == 0 ? 0 : Math . min ( a * b , Math . min ( b * c , c * a ) ) ) ; } } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] arr = new long [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; if ( arr [ i ] % 2 == 0 ) { System . out . println ( 0 ) ; return ; } } Arrays . sort ( arr ) ; System . out . println ( arr [ 0 ] * arr [ 1 ] ) ; } }",
"import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; if ( a % 2 * b % 2 * c % 2 == 0 ) { out . println ( 0 ) ; } else { long x = a * b ; long y = c * b ; long z = a * c ; out . println ( min ( x , min ( y , z ) ) ) ; } } }",
"import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] hen = new long [ 3 ] ; long wa = 1 ; for ( int i = 0 ; i < 3 ; i ++ ) { hen [ i ] = sc . nextLong ( ) ; wa *= hen [ i ] % 2 ; } if ( wa == 0 ) { System . out . println ( 0 ) ; } else { Arrays . sort ( hen ) ; System . out . println ( hen [ 0 ] * hen [ 1 ] ) ; } } }"
] | [
"l = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( l [ 0 ] * l [ 1 ] * ( l [ 2 ] % 2 ) ) NEW_LINE",
"a , b , c = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE one = abs ( ( a // 2 ) * b * c - ( a - a // 2 ) * b * c ) NEW_LINE two = abs ( a * ( b // 2 ) * c - a * ( b - b // 2 ) * c ) NEW_LINE thr = abs ( a * b * ( c // 2 ) - a * b * ( c - c // 2 ) ) NEW_LINE print ( min ( one , two , thr ) ) NEW_LINE",
"a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE d = sorted ( [ a , b , c ] ) NEW_LINE if ( a % 2 + b % 2 + c % 2 ) == 3 : NEW_LINE INDENT print ( d [ 0 ] * d [ 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT",
"A , B , C = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE c1 = 0 if C % 2 == 0 else A * B NEW_LINE c2 = 0 if B % 2 == 0 else A * C NEW_LINE c3 = 0 if A % 2 == 0 else B * C NEW_LINE ans = min ( c1 , c2 , c3 ) NEW_LINE print ( ans ) NEW_LINE",
"a = list ( map ( int , input ( ) . split ( ) ) ) ; a . sort ( ) ; s = a [ 0 ] * a [ 1 ] NEW_LINE if ( a [ 2 ] * s ) % 2 == 0 : print ( 0 ) NEW_LINE else : print ( s ) NEW_LINE"
] |
atcoder_agc002_E | [
"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 ( ) ; if ( firstWin ( N , a ) ) System . out . println ( \" First \" ) ; else System . out . println ( \" Second \" ) ; sc . close ( ) ; } static boolean firstWin ( int N , int [ ] a ) { Arrays . sort ( a ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( N - i <= a [ i ] ) { boolean win = ( a [ i ] - ( N - i ) ) % 2 == 1 ; int sameSize = 0 ; for ( int j = i - 1 ; j >= 0 && a [ j ] == N - i ; j -- ) sameSize ++ ; win |= sameSize % 2 == 1 ; return win ; } } return false ; } }"
] | [
"import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def f ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a . sort ( ) NEW_LINE a . reverse ( ) NEW_LINE i = j = 0 NEW_LINE while i + 1 < n and a [ i + 1 ] > j + 1 : NEW_LINE INDENT i += 1 NEW_LINE j += 1 NEW_LINE DEDENT if ( a [ i ] - j - 1 ) % 2 == 1 : NEW_LINE INDENT return ' First ' NEW_LINE DEDENT k = 0 NEW_LINE while i + 1 < n and a [ i + 1 ] > j : NEW_LINE INDENT i += 1 NEW_LINE k += 1 NEW_LINE DEDENT if k % 2 == 1 : NEW_LINE INDENT return ' First ' NEW_LINE DEDENT return ' Second ' NEW_LINE DEDENT print ( f ( ) ) NEW_LINE"
] |
atcoder_arc060_A | [
"import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] num = new int [ n + 1 ] ; long ans = 0 ; long [ ] [ ] [ ] dp = new long [ n + 1 ] [ n + 1 ] [ n * a + 1 ] ; num [ 0 ] = 1000000007 ; for ( int i = 1 ; i <= n ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { for ( int k = 0 ; k <= n * a ; k ++ ) { if ( i == 0 && j == 0 && k == 0 ) { dp [ i ] [ j ] [ k ] = 1 ; } else if ( i >= 1 && k < num [ i ] ) { dp [ i ] [ j ] [ k ] = dp [ i - 1 ] [ j ] [ k ] ; } else if ( i >= 1 && j >= 1 && k >= num [ i ] ) { dp [ i ] [ j ] [ k ] = dp [ i - 1 ] [ j ] [ k ] + dp [ i - 1 ] [ j - 1 ] [ k - num [ i ] ] ; } else { dp [ i ] [ j ] [ k ] = 0 ; } } } } for ( int i = 1 ; i <= n ; i ++ ) { ans += dp [ n ] [ i ] [ i * a ] ; } System . out . println ( ans ) ; sc . close ( ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader rd = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String str = rd . readLine ( ) ; String [ ] sl = str . split ( \" β \" ) ; int n = Integer . parseInt ( sl [ 0 ] ) ; int a = Integer . parseInt ( sl [ 1 ] ) ; str = rd . readLine ( ) ; sl = str . split ( \" β \" ) ; int x [ ] = new int [ 51 ] ; long v [ ] [ ] [ ] = new long [ 51 ] [ 51 ] [ 2501 ] ; for ( int i = 1 ; i <= n ; i ++ ) { x [ i ] = Integer . parseInt ( sl [ i - 1 ] ) ; } v [ 1 ] [ 1 ] [ x [ 1 ] ] = 1 ; v [ 1 ] [ 0 ] [ 0 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { for ( int k = 0 ; k <= 50 * i ; k ++ ) { v [ i ] [ j ] [ k ] += v [ i - 1 ] [ j ] [ k ] ; } } for ( int j = 1 ; j <= i ; j ++ ) { for ( int k = x [ i ] ; k <= 50 * i ; k ++ ) { v [ i ] [ j ] [ k ] += v [ i - 1 ] [ j - 1 ] [ k - x [ i ] ] ; } } } long ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { ans += v [ i ] [ j ] [ a * j ] - v [ i - 1 ] [ j ] [ a * j ] ; } } 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 ( ) ) ; } static int n = gInt ( ) , a = gInt ( ) , v [ ] = IntStream . range ( 0 , n ) . map ( i -> gInt ( ) - a ) . sorted ( ) . toArray ( ) ; static long [ ] [ ] memo = new long [ n ] [ 2501 ] ; static { for ( int i = 0 ; i < n ; ++ i ) Arrays . fill ( memo [ i ] , - 1 ) ; } static long solve ( int i , int j ) { if ( j > 0 ) return 0 ; if ( i == n ) { return j == 0 ? 1 : 0 ; } if ( memo [ i ] [ - j ] != - 1 ) { return memo [ i ] [ - j ] ; } memo [ i ] [ - j ] = 0 ; memo [ i ] [ - j ] += solve ( i + 1 , j + v [ i ] ) ; memo [ i ] [ - j ] += solve ( i + 1 , j ) ; return memo [ i ] [ - j ] ; } public static void main ( String [ ] $ ) { solve ( 0 , 0 ) ; System . out . println ( memo [ 0 ] [ 0 ] - 1 ) ; } }",
"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] d = new int [ 51 ] ; for ( int i = 0 ; i < n ; i ++ ) d [ i ] = sc . nextInt ( ) ; long [ ] [ ] [ ] dp = new long [ 60 ] [ 60 ] [ 2510 ] ; dp [ 0 ] [ 0 ] [ 0 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int x = d [ i ] ; for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < 2500 ; k ++ ) { if ( dp [ i ] [ j ] [ k ] > 0 ) { dp [ i + 1 ] [ j ] [ k ] += dp [ i ] [ j ] [ k ] ; dp [ i + 1 ] [ j + 1 ] [ k + x ] += dp [ i ] [ j ] [ k ] ; } } } } long ret = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= 2500 ; j ++ ) { if ( i * a == j && dp [ n ] [ i ] [ j ] > 0 ) { ret += dp [ n ] [ i ] [ j ] ; } } } System . out . println ( ret ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String text [ ] = line . split ( \" β \" ) ; int N , A ; N = Integer . parseInt ( text [ 0 ] ) ; A = Integer . parseInt ( text [ 1 ] ) ; line = br . readLine ( ) ; text = line . split ( \" β \" ) ; int [ ] x = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = Integer . parseInt ( text [ i ] ) - A ; } long dp [ ] [ ] = new long [ N ] [ N * 50 * 2 + 1 ] ; int dpl = 50 * N ; dp [ 0 ] [ x [ 0 ] + dpl ] = 1 ; for ( int j = 1 ; j < N ; j ++ ) { for ( int k = - 1 * N * 50 ; k < N * 50 + 1 ; k ++ ) { if ( k + dpl - x [ j ] >= 0 && k + dpl - x [ j ] <= 50 * N * 2 ) { dp [ j ] [ k + dpl ] = dp [ j - 1 ] [ k + dpl ] + dp [ j - 1 ] [ k + dpl - x [ j ] ] ; } else { dp [ j ] [ k + dpl ] = dp [ j - 1 ] [ k + dpl ] ; } if ( x [ j ] == k ) dp [ j ] [ k + dpl ] ++ ; } } System . out . println ( dp [ N - 1 ] [ dpl ] ) ; } }"
] | [
"import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE N , A = map ( int , input ( ) . split ( ) ) NEW_LINE Xs = list ( sorted ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE lower = [ ] NEW_LINE same = 0 NEW_LINE upper = [ ] NEW_LINE for x in Xs : NEW_LINE INDENT if x < A : NEW_LINE INDENT lower . append ( A - x ) NEW_LINE DEDENT elif x == A : NEW_LINE INDENT same += 1 NEW_LINE DEDENT else : NEW_LINE INDENT upper . append ( x - A ) NEW_LINE DEDENT DEDENT def make_counter ( nums ) : NEW_LINE INDENT counter = Counter ( { 0 : 1 } ) NEW_LINE for n in nums : NEW_LINE INDENT new_counter = Counter ( ) NEW_LINE for k , v in counter . items ( ) : NEW_LINE INDENT new_counter [ k ] += v NEW_LINE new_counter [ k + n ] += v NEW_LINE DEDENT counter = new_counter NEW_LINE DEDENT return counter NEW_LINE DEDENT lower_counter = make_counter ( lower ) NEW_LINE upper_counter = make_counter ( upper ) NEW_LINE ans = 0 NEW_LINE for lk , lv in lower_counter . items ( ) : NEW_LINE INDENT if lk == 0 : NEW_LINE INDENT ans += 2 ** same - 1 NEW_LINE DEDENT else : NEW_LINE INDENT if lk in upper_counter : NEW_LINE INDENT ans += ( 2 ** same ) * lv * upper_counter [ lk ] NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE",
"def makelist2 ( n , m ) : NEW_LINE INDENT return [ [ 0 for k in range ( m ) ] for i in range ( n ) ] NEW_LINE DEDENT n , a = map ( int , input ( ) . split ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE X = max ( x ) NEW_LINE X = max ( X , a ) NEW_LINE b = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT b . append ( x [ i ] - a ) NEW_LINE DEDENT dp = makelist2 ( n + 1 , 2 * n * X + 1 ) NEW_LINE dp [ 0 ] [ n * X ] = 1 NEW_LINE for j in range ( n + 1 ) : NEW_LINE INDENT for t in range ( 2 * n * X + 1 ) : NEW_LINE INDENT if j >= 1 and ( t - b [ j - 1 ] < 0 or t - b [ j - 1 ] > 2 * n * X ) : NEW_LINE INDENT dp [ j ] [ t ] = dp [ j - 1 ] [ t ] NEW_LINE DEDENT elif j >= 1 : NEW_LINE INDENT dp [ j ] [ t ] = dp [ j - 1 ] [ t ] + dp [ j - 1 ] [ t - b [ j - 1 ] ] NEW_LINE DEDENT DEDENT DEDENT print ( dp [ n ] [ n * X ] - 1 ) NEW_LINE",
"import bisect NEW_LINE from collections import Counter , deque NEW_LINE from itertools import combinations , accumulate NEW_LINE from math import factorial NEW_LINE from operator import neg NEW_LINE n , a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE xs = list ( map ( lambda x : int ( x ) - a , input ( ) . split ( ) ) ) NEW_LINE xs . sort ( ) NEW_LINE l , r = bisect . bisect_left ( xs , 0 ) , bisect . bisect_right ( xs , 0 ) NEW_LINE low , n0 , high = list ( map ( neg , xs [ : l ] [ : : - 1 ] ) ) , r - l , xs [ r : ] NEW_LINE def sums ( arr ) : NEW_LINE INDENT cntr = Counter ( [ 0 ] ) NEW_LINE for v in arr : NEW_LINE INDENT tmps = tuple ( cntr . items ( ) ) NEW_LINE for u , cnt in tmps : NEW_LINE INDENT cntr [ u + v ] += cnt NEW_LINE DEDENT DEDENT del cntr [ 0 ] NEW_LINE return cntr NEW_LINE DEDENT lsums = sums ( low ) NEW_LINE hsums = sums ( high ) NEW_LINE ans = sum ( hsums [ a ] * b for a , b in lsums . items ( ) ) NEW_LINE ans *= 2 ** n0 NEW_LINE ans += 2 ** n0 - 1 NEW_LINE print ( ans ) NEW_LINE",
"II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE def sumcnt ( values ) : NEW_LINE INDENT sc = [ 0 ] * ( 50 * 50 + 1 ) NEW_LINE sc [ 0 ] = 1 NEW_LINE max_sc = 0 NEW_LINE for v in values : NEW_LINE INDENT for i in range ( max_sc , - 1 , - 1 ) : NEW_LINE INDENT sc [ i + v ] += sc [ i ] NEW_LINE DEDENT max_sc += v NEW_LINE DEDENT return sc , max_sc NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT N , A = MI ( ) NEW_LINE ds = [ x - A for x in MI ( ) ] NEW_LINE count0 = 0 NEW_LINE dp , dm = [ ] , [ ] NEW_LINE for d in ds : NEW_LINE INDENT if d == 0 : count0 += 1 NEW_LINE elif d > 0 : dp . append ( d ) NEW_LINE else : dm . append ( - d ) NEW_LINE DEDENT dp . sort ( ) NEW_LINE dm . sort ( ) NEW_LINE scp , scpmax = sumcnt ( dp ) NEW_LINE scm , scmmax = sumcnt ( dm ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , min ( scpmax , scmmax ) + 1 ) : NEW_LINE INDENT ans += scp [ i ] * scm [ i ] NEW_LINE DEDENT ans = ans * ( 2 ** count0 ) + 2 ** count0 - 1 NEW_LINE return ans NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT",
"N , A = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ int ( x ) - A for x in input ( ) . split ( ) ] NEW_LINE d = { 0 : 1 } NEW_LINE for x in X : NEW_LINE INDENT d_tmp = d . copy ( ) NEW_LINE for k in d_tmp : NEW_LINE INDENT d [ k + x ] = d . get ( k + x , 0 ) + d_tmp [ k ] NEW_LINE DEDENT DEDENT print ( d [ 0 ] - 1 ) NEW_LINE"
] |
atcoder_abc114_B | [
"import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; String S = reader . next ( ) ; int [ ] X = new int [ 10 ] ; for ( int k = 0 ; k < S . length ( ) ; k ++ ) { X [ k ] = Integer . parseInt ( Character . toString ( S . charAt ( k ) ) ) ; } int [ ] nearSevenDG = new int [ 10 ] ; int minGap = 1000 ; for ( int i = 0 ; i < S . length ( ) - 2 ; i ++ ) { int gap = Math . abs ( ( X [ i ] * 100 + X [ i + 1 ] * 10 + X [ i + 2 ] ) - 753 ) ; if ( gap < minGap ) { minGap = gap ; } } System . out . print ( minGap ) ; } }",
"import java . util . Scanner ; public class Main { private static final int FAVOURITE_NUMBER = 753 ; public static int process ( TestCase testCase ) { String S = testCase . S ; int min = Integer . MAX_VALUE ; for ( int i = 2 , length = S . length ( ) ; i < length ; ++ i ) { final int num = Integer . valueOf ( S . substring ( i - 2 , i + 1 ) ) ; min = Math . min ( min , diff ( num ) ) ; } return min ; } private static int diff ( int num ) { return Math . abs ( FAVOURITE_NUMBER - num ) ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final int result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; return new TestCase ( S ) ; } private static void output ( int result ) { System . out . println ( result ) ; } public static class TestCase { final String S ; public TestCase ( String S ) { this . S = S ; } } }",
"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; String s ; s = sc . next ( ) ; int ans = 1000 ; for ( int i = 2 ; i < s . length ( ) ; i ++ ) { if ( Math . abs ( Integer . parseInt ( s . substring ( i - 2 , i + 1 ) ) - 753 ) < ans ) { ans = Math . abs ( Integer . parseInt ( s . substring ( i - 2 , i + 1 ) ) - 753 ) ; } } System . out . println ( ans ) ; } catch ( Exception e ) { System . out . println ( \" out \" ) ; } } }",
"import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int min = 753 ; for ( int i = 0 ; i < s . length ( ) - 2 ; i ++ ) { String num = s . substring ( i , i + 3 ) ; int n = Integer . parseInt ( num ) ; min = Math . min ( min , Math . abs ( 753 - n ) ) ; } System . out . println ( min ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int length = str . length ( ) ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < length - 2 ; i ++ ) { int tmp = Integer . parseInt ( str . substring ( i , i + 3 ) ) ; min = Math . min ( min , Math . abs ( 753 - tmp ) ) ; } System . out . println ( min ) ; } }"
] | [
"n = input ( ) NEW_LINE a = [ ] NEW_LINE for i in range ( len ( n ) - 2 ) : NEW_LINE INDENT a . append ( abs ( int ( n [ i : i + 3 ] ) - 753 ) ) NEW_LINE DEDENT print ( min ( a ) ) NEW_LINE",
"import sys NEW_LINE INF = float ( \" inf \" ) NEW_LINE def solve ( S : int ) : NEW_LINE INDENT S = str ( S ) NEW_LINE print ( min ( [ abs ( int ( S [ i : i + 3 ] ) - 753 ) for i in range ( len ( S ) - 2 ) ] ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE S = int ( next ( tokens ) ) NEW_LINE solve ( S ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"S = [ int ( i ) for i in input ( ) ] NEW_LINE ans = 0 NEW_LINE for i in range ( len ( S ) - 2 ) : NEW_LINE INDENT dog_cup = 100 * S [ i ] + 10 * S [ i + 1 ] + S [ i + 2 ] NEW_LINE if abs ( 753 - ans ) > abs ( 753 - dog_cup ) : NEW_LINE INDENT ans = dog_cup NEW_LINE DEDENT DEDENT print ( abs ( 753 - ans ) ) NEW_LINE",
"S = str ( input ( ) ) NEW_LINE M = 753 NEW_LINE min = 10000 NEW_LINE for i in range ( len ( S ) - 2 ) : NEW_LINE INDENT a = 100 * int ( S [ i ] ) + 10 * int ( S [ i + 1 ] ) + int ( S [ i + 2 ] ) NEW_LINE b = abs ( a - M ) NEW_LINE if b < min : NEW_LINE INDENT min = b NEW_LINE DEDENT DEDENT print ( min ) NEW_LINE",
"S = input ( ) NEW_LINE print ( min ( abs ( int ( S [ i : i + 3 ] ) - 753 ) for i in range ( len ( S ) - 2 ) ) ) NEW_LINE"
] |
atcoder_arc009_A | [
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int number = Integer . parseInt ( br . readLine ( ) ) ; int sum = 0 ; for ( int i = 0 ; i < number ; i ++ ) { String [ ] setting = br . readLine ( ) . split ( \" β \" ) ; int num = Integer . parseInt ( setting [ 0 ] ) ; int price = Integer . parseInt ( setting [ 1 ] ) ; sum = sum + num * price ; } System . out . println ( ( int ) ( sum * 1.05 ) ) ; } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += in . nextInt ( ) * in . nextInt ( ) ; out . println ( sum * 105 / 100 ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' β ' || c == ' \\n ' || c == ' \\r ' || c == ' \\t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }",
"import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; double [ ] a = new double [ n ] ; double [ ] b = new double [ n ] ; double ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextDouble ( ) ; b [ i ] = sc . nextDouble ( ) ; ans += a [ i ] * b [ i ] ; } out . println ( ( int ) ( floor ( ans * 1.05 ) ) ) ; } }",
"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 total = 0 ; for ( int i = 0 ; i < N ; i ++ ) { total += in . nextInt ( ) * in . nextInt ( ) ; } out . println ( ( int ) ( total * 1.05 ) ) ; } } 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; long sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += sc . nextLong ( ) * sc . nextLong ( ) ; } pl ( ( sum * 21 / 20 ) ) ; } 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 ; } } }"
] | [
"print ( eval ( \" + eval ( input ( ) . replace ( ' β ' , ' * ' ) ) \" * int ( input ( ) ) ) * 105 // 100 ) NEW_LINE",
"import sys NEW_LINE import copy NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ 0 ] * N NEW_LINE b = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT a [ i ] , b [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT sum = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT sum += a [ i ] * b [ i ] NEW_LINE DEDENT print ( int ( sum * 1.05 ) ) NEW_LINE",
"N = int ( input ( ) ) NEW_LINE ab = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE import math NEW_LINE result = math . floor ( sum ( a * b for a , b in ab ) * 1.05 ) NEW_LINE print ( result ) NEW_LINE",
"def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE res = 0 NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE res += a * b NEW_LINE DEDENT print ( int ( res * 1.05 ) ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"N = int ( input ( ) ) NEW_LINE src = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE ans = 0 NEW_LINE for a , b in src : NEW_LINE INDENT ans += a * b NEW_LINE DEDENT ans *= 1.05 NEW_LINE print ( int ( ans ) ) NEW_LINE"
] |
atcoder_abc113_B | [
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double minSub = 1000.0 ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int h = sc . nextInt ( ) ; double sub = Math . abs ( a - ( t - h * 0.006 ) ) ; if ( sub < minSub ) { minSub = sub ; ans = i ; } } System . out . println ( ans ) ; sc . close ( ) ; } }",
"import java . io . * ; import java . util . Scanner ; import java . lang . Math ; import java . util . Arrays ; import java . util . List ; import java . util . stream . Collectors ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; double T = scanner . nextDouble ( ) ; int A = scanner . nextInt ( ) ; double H [ ] = new double [ N ] ; double tmp [ ] = new double [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { H [ i ] = scanner . nextDouble ( ) ; tmp [ i ] = Math . abs ( A - ( T - H [ i ] * 0.006 ) ) ; } double min = tmp [ 0 ] ; int imin = 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( min >= tmp [ i ] ) { min = tmp [ i ] ; imin = i + 1 ; } } System . out . println ( imin ) ; scanner . close ( ) ; } }",
"import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int ans = 0 ; double minDiff = Double . MAX_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { int h = sc . nextInt ( ) ; double temp = ( double ) T - ( ( ( double ) h ) * 0.006 ) ; double diff = Math . abs ( ( double ) A - temp ) ; if ( minDiff > diff ) { minDiff = diff ; ans = i + 1 ; } } System . out . println ( ans ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; double nearOndo = 0 ; int nearIndex = 26 ; for ( int index = 0 ; index < N ; index ++ ) { int temp = scanner . nextInt ( ) ; double ondo = T - ( temp * 0.006 ) ; if ( index == 0 ) { nearOndo = ondo ; nearIndex = index ; } else if ( Math . abs ( ondo - A ) < Math . abs ( nearOndo - A ) ) { nearOndo = ondo ; nearIndex = index ; } } System . out . println ( nearIndex + 1 ) ; } }",
"import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int T = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int [ ] H = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { H [ i ] = scan . nextInt ( ) ; } double [ ] t = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { t [ i ] = T - 0.006 * H [ i ] ; } double rest = Math . abs ( t [ 0 ] - A ) ; int key = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( rest > Math . abs ( t [ i ] - A ) ) { rest = Math . abs ( t [ i ] - A ) ; key = i ; } } System . out . print ( key + 1 ) ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE T , A = map ( int , input ( ) . split ( ) ) NEW_LINE H = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE d = 10 ** 4 NEW_LINE n = 0 NEW_LINE for j in range ( N ) : NEW_LINE INDENT dj = abs ( A - ( T - H [ j ] * 0.006 ) ) NEW_LINE if dj < d : NEW_LINE INDENT d = dj NEW_LINE n = j NEW_LINE DEDENT DEDENT print ( n + 1 ) NEW_LINE",
"import sys NEW_LINE INF = float ( \" inf \" ) NEW_LINE def argmin ( a ) : NEW_LINE INDENT m , n = INF , - 1 NEW_LINE for i , v in enumerate ( a ) : NEW_LINE INDENT if m > v : NEW_LINE INDENT m , n = v , i NEW_LINE DEDENT DEDENT return m , n NEW_LINE DEDENT def solve ( N : int , T : int , A : int , H : \" List [ int ] \" ) : NEW_LINE INDENT print ( argmin ( [ abs ( T - h * 0.006 - A ) for h in H ] ) [ 1 ] + 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 T = int ( next ( tokens ) ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE H = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , T , A , H ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT",
"candidate = int ( input ( ) ) NEW_LINE ave_temp , ide_temp = map ( float , input ( ) . split ( ' β ' ) ) NEW_LINE ls_candidate = [ abs ( ( ave_temp - ( float ( x ) * 0.006 ) - ide_temp ) ) for x in input ( ) . split ( ' β ' ) ] NEW_LINE for x , i in enumerate ( ls_candidate ) : NEW_LINE INDENT if ls_candidate [ x ] == min ( ls_candidate ) : NEW_LINE INDENT print ( x + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT",
"import sys NEW_LINE diff = sys . maxsize NEW_LINE ans = \" \" NEW_LINE N = int ( input ( ) ) NEW_LINE T , A = map ( int , input ( ) . split ( ) ) NEW_LINE H = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT t = T - H [ i ] * .006 NEW_LINE d = abs ( A - t ) NEW_LINE if diff > d : NEW_LINE INDENT ans = i + 1 NEW_LINE diff = d NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"n = int ( input ( ) ) NEW_LINE base_t , a = map ( int , input ( ) . split ( ) ) NEW_LINE hs = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE t = [ base_t - 0.006 * x for x in hs ] NEW_LINE dif = [ abs ( ti - a ) for ti in t ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if dif [ i ] == min ( dif ) : NEW_LINE INDENT print ( i + 1 ) NEW_LINE DEDENT DEDENT"
] |
atcoder_abc025_B | [
"import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; int now = 0 ; for ( int i = 0 ; i < N ; i ++ ) { String a = sc . next ( ) ; int id = sc . nextInt ( ) ; if ( id < min ) { id = min ; } else if ( id > max ) { id = max ; } if ( a . charAt ( 0 ) == ' E ' ) { now += id ; } else if ( a . charAt ( 0 ) == ' W ' ) { now -= id ; } } if ( now > 0 ) { System . out . println ( \" East β \" + now ) ; } else if ( now < 0 ) { System . out . println ( \" West β \" + ( now * - 1 ) ) ; } else { System . out . println ( 0 ) ; } } }",
"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) , a = in . ints ( ) , b = in . ints ( ) ; int x = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String s = in . string ( ) ; int d = Math . max ( a , Math . min ( b , in . ints ( ) ) ) ; if ( s . equals ( \" East \" ) ) { x += d ; } else { x -= d ; } } if ( x == 0 ) { out . println ( 0 ) ; } else if ( x > 0 ) { out . println ( \" East β \" + x ) ; } else { out . println ( \" West β \" + ( - x ) ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }",
"import java . util . * ; public class Main { public static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . nextLine ( ) . split ( \" β \" ) ; int N = Integer . parseInt ( s [ 0 ] ) ; int A = Integer . parseInt ( s [ 1 ] ) ; int B = Integer . parseInt ( s [ 2 ] ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { String [ ] t = sc . nextLine ( ) . split ( \" β \" ) ; int M = Integer . parseInt ( t [ 1 ] ) ; if ( t [ 0 ] . equals ( \" East \" ) ) { if ( M < A ) { count += A ; } else if ( M > B ) { count += B ; } else { count += M ; } } else { if ( M < A ) { count -= A ; } else if ( M > B ) { count -= B ; } else { count -= M ; } } } if ( count == 0 ) { System . out . println ( 0 ) ; } else if ( count > 0 ) { System . out . println ( \" East β \" + Math . abs ( count ) ) ; } else { System . out . println ( \" West β \" + Math . abs ( count ) ) ; } } }",
"import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; String [ ] s = new String [ N ] ; int [ ] d = new int [ N ] ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { s [ i ] = scanner . next ( ) ; d [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] . equals ( \" East \" ) ) { if ( d [ i ] < A ) { ans += A ; } else if ( A <= d [ i ] && d [ i ] <= B ) { ans += d [ i ] ; } else if ( d [ i ] > B ) { ans += B ; } } if ( s [ i ] . equals ( \" West \" ) ) { if ( d [ i ] < A ) { ans -= A ; } else if ( A <= d [ i ] && d [ i ] <= B ) { ans -= d [ i ] ; } else if ( d [ i ] > B ) { ans -= B ; } } } if ( ans == 0 ) { System . out . println ( 0 ) ; } else if ( ans > 0 ) { System . out . println ( \" East \" + \" β \" + ans ) ; } else if ( ans < 0 ) { System . out . println ( \" West \" + \" β \" + Math . abs ( ans ) ) ; } } }",
"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] line = scanner . nextLine ( ) . split ( \" β \" , 3 ) ; int n = Integer . parseInt ( line [ 0 ] ) ; int a = Integer . parseInt ( line [ 1 ] ) ; int b = Integer . parseInt ( line [ 2 ] ) ; int position = 0 ; for ( int i = 0 ; i < n ; i ++ ) { line = scanner . nextLine ( ) . split ( \" β \" , 2 ) ; int distance = Integer . parseInt ( line [ 1 ] ) ; if ( distance < a ) { distance = a ; } else if ( distance > b ) { distance = b ; } String direction = line [ 0 ] ; if ( direction . equals ( \" West \" ) ) { position += distance ; } else { position -= distance ; } } if ( position == 0 ) { System . out . println ( \"0\" ) ; } else if ( position > 0 ) { System . out . printf ( \" West β % d \\n \" , position ) ; } else { System . out . printf ( \" East β % d \\n \" , position * - 1 ) ; } } }"
] | [
"N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE now = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT s , d = input ( ) . split ( ) NEW_LINE if s == \" East \" : NEW_LINE INDENT if int ( d ) < A : NEW_LINE INDENT now += A NEW_LINE DEDENT elif int ( d ) > B : NEW_LINE INDENT now += B NEW_LINE DEDENT else : NEW_LINE INDENT now += int ( d ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if int ( d ) < A : NEW_LINE INDENT now -= A NEW_LINE DEDENT elif int ( d ) > B : NEW_LINE INDENT now -= B NEW_LINE DEDENT else : NEW_LINE INDENT now -= int ( d ) NEW_LINE DEDENT DEDENT DEDENT if now > 0 : NEW_LINE INDENT print ( \" East \" + \" β \" + str ( now ) ) NEW_LINE DEDENT elif now < 0 : NEW_LINE INDENT print ( \" West \" + \" β \" + str ( abs ( now ) ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT",
"def twin_and_watermellon ( N : int , A : int , B : int , command : list ) -> tuple : NEW_LINE INDENT WEST = ' West ' NEW_LINE EAST = ' East ' NEW_LINE x = 0 NEW_LINE for s , d in command : NEW_LINE INDENT dx = d NEW_LINE if d < A : NEW_LINE INDENT dx = A NEW_LINE DEDENT elif B < d : NEW_LINE INDENT dx = B NEW_LINE DEDENT if s == WEST : NEW_LINE INDENT x -= dx NEW_LINE DEDENT else : NEW_LINE INDENT x += dx NEW_LINE DEDENT DEDENT direction = ' ' NEW_LINE if x < 0 : NEW_LINE INDENT direction = WEST NEW_LINE DEDENT elif x > 0 : NEW_LINE INDENT direction = EAST NEW_LINE DEDENT return direction , abs ( x ) NEW_LINE DEDENT if __name__ == \" _ _ main _ _ \" : NEW_LINE INDENT N = 0 NEW_LINE N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE command = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT s , d = input ( ) . split ( ) NEW_LINE command . append ( ( s , int ( d ) ) ) NEW_LINE DEDENT d , x = twin_and_watermellon ( N , A , B , command ) NEW_LINE if x == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( d , x ) NEW_LINE DEDENT DEDENT",
"N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE sd = [ input ( ) . split ( ) for i in range ( N ) ] NEW_LINE pos = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT step = min ( max ( int ( sd [ i ] [ 1 ] ) , A ) , B ) NEW_LINE if sd [ i ] [ 0 ] == ' West ' : NEW_LINE INDENT step *= - 1 NEW_LINE DEDENT pos += step NEW_LINE DEDENT if pos == 0 : NEW_LINE INDENT print ( pos ) NEW_LINE DEDENT else : NEW_LINE INDENT dest = ' East ' if pos > 0 else ' West ' NEW_LINE print ( \" { 0 } β { 1 } \" . format ( dest , abs ( pos ) ) ) NEW_LINE DEDENT",
"n , c , b = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a . append ( list ( input ( ) . split ( ) ) ) NEW_LINE DEDENT for j in range ( n ) : NEW_LINE INDENT if int ( a [ j ] [ 1 ] ) < c : NEW_LINE INDENT a [ j ] [ 1 ] = c NEW_LINE DEDENT elif int ( a [ j ] [ 1 ] ) > b : NEW_LINE INDENT a [ j ] [ 1 ] = b NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for k in range ( n ) : NEW_LINE INDENT if a [ k ] [ 0 ] == ' East ' : NEW_LINE INDENT ans += int ( a [ k ] [ 1 ] ) NEW_LINE DEDENT elif a [ k ] [ 0 ] == ' West ' : NEW_LINE INDENT ans -= int ( a [ k ] [ 1 ] ) NEW_LINE DEDENT DEDENT if ans > 0 : NEW_LINE INDENT print ( ' East ' , ans ) NEW_LINE DEDENT if ans == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT if ans < 0 : NEW_LINE INDENT print ( ' West ' , - ans ) NEW_LINE DEDENT",
"n , lower , upper = map ( int , input ( ) . split ( ) ) NEW_LINE res = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT step = input ( ) . split ( ) NEW_LINE if step [ 0 ] == \" West \" : NEW_LINE INDENT offset = - 1 NEW_LINE DEDENT elif step [ 0 ] == \" East \" : NEW_LINE INDENT offset = 1 NEW_LINE DEDENT if int ( step [ 1 ] ) < lower : NEW_LINE INDENT res += lower * offset NEW_LINE DEDENT elif int ( step [ 1 ] ) > upper : NEW_LINE INDENT res += upper * offset NEW_LINE DEDENT else : NEW_LINE INDENT res += int ( step [ 1 ] ) * offset NEW_LINE DEDENT DEDENT if res == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT elif res > 1 : NEW_LINE INDENT print ( \" East β % s \" % str ( res ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" West β % s \" % str ( abs ( res ) ) ) NEW_LINE DEDENT"
] |
atcoder_abc067_B | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] l = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { l [ i ] = sc . nextInt ( ) ; } Arrays . sort ( l ) ; int sum = 0 ; for ( int i = n - 1 ; n - k <= i ; i -- ) { sum += l [ i ] ; } System . out . println ( sum ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] l = new int [ N ] ; for ( int i = 0 ; i < l . length ; i ++ ) { l [ i ] = in . nextInt ( ) ; } Arrays . sort ( l ) ; int ans = 0 ; for ( int i = l . length - 1 ; i >= l . length - K ; i -- ) { ans += l [ i ] ; } out . println ( ans ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int n = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int m = Integer . parseInt ( tokenizer . nextToken ( ) ) ; tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } Arrays . sort ( values ) ; long sum = 0 ; for ( int i = n - 1 ; i >= n - m ; i -- ) { sum += values [ i ] ; } System . out . println ( sum ) ; } }",
"import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int numberOfStickUsed = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list , Comparator . reverseOrder ( ) ) ; int sum = 0 ; for ( int i = 0 ; i < numberOfStickUsed ; i ++ ) { sum += list . get ( i ) ; } System . out . println ( sum ) ; } }",
"import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Integer [ ] ar = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) ar [ i ] = sc . nextInt ( ) ; Arrays . sort ( ar , Collections . reverseOrder ( ) ) ; int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += ar [ i ] ; } System . out . println ( sum ) ; } }"
] | [
"t , l = open ( 0 ) ; print ( sum ( sorted ( map ( int , l . split ( ) ) ) [ - int ( t [ 2 : ] ) : ] ) ) NEW_LINE",
"import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE n , k = nm ( ) NEW_LINE l = nl ( ) NEW_LINE l . sort ( reverse = True ) NEW_LINE ans = 0 NEW_LINE for i in range ( k ) : NEW_LINE INDENT ans += l [ i ] NEW_LINE DEDENT print ( ans ) NEW_LINE",
"N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE L = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE L . sort ( reverse = True ) NEW_LINE print ( sum ( L [ : K ] ) ) NEW_LINE",
"N , K = map ( int , input ( ) . split ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( K ) : NEW_LINE INDENT m = max ( l ) NEW_LINE ans += m NEW_LINE l [ l . index ( m ) ] = 0 NEW_LINE DEDENT print ( ans ) NEW_LINE",
"n , k = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE ls = sorted ( [ int ( item ) for item in input ( ) . split ( ) ] , reverse = True ) NEW_LINE print ( sum ( ls [ : k ] ) ) NEW_LINE"
] |
atcoder_arc062_A | [
"import java . math . * ; import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] rate = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; ++ i ) { rate [ i ] [ 0 ] = sc . nextInt ( ) ; rate [ i ] [ 1 ] = sc . nextInt ( ) ; } long [ ] count = new long [ 2 ] ; count [ 0 ] = rate [ 0 ] [ 0 ] ; count [ 1 ] = rate [ 0 ] [ 1 ] ; for ( int i = 1 ; i < n ; ++ i ) { count = nextCount ( rate [ i ] , count ) ; } System . out . println ( count [ 0 ] + count [ 1 ] ) ; } private static long [ ] nextCount ( int [ ] rate , long [ ] count ) { int r0 = rate [ 0 ] ; int r1 = rate [ 1 ] ; long n = Math . max ( ( count [ 0 ] + r0 - 1 ) / r0 , ( count [ 1 ] + r1 - 1 ) / r1 ) ; count [ 0 ] = r0 * n ; count [ 1 ] = r1 * n ; return count ; } private static int gcd ( int v1 , int v2 ) { BigInteger b1 = BigInteger . valueOf ( v1 ) ; BigInteger b2 = BigInteger . valueOf ( v2 ) ; return b1 . gcd ( b2 ) . intValue ( ) ; } }",
"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { int n = sc . nextInt ( ) ; long numOfT = 1 ; long numOfA = 1 ; for ( int i = 0 ; i < n ; i ++ ) { long t = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long xt = numOfT % t == 0 ? numOfT / t : numOfT / t + 1 ; long xa = numOfA % a == 0 ? numOfA / a : numOfA / a + 1 ; long x = Math . max ( xt , xa ) ; numOfT = t * x ; numOfA = a * x ; } System . out . println ( numOfT + numOfA ) ; } }",
"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner cin = new Scanner ( System . in ) ; while ( cin . hasNext ( ) ) { int n = cin . nextInt ( ) ; int [ ] [ ] vote = readMatrix ( cin , n , 2 ) ; System . out . println ( getNum ( vote , n ) ) ; } } public static long getNum ( int [ ] [ ] vote , int n ) { long [ ] result = { vote [ 0 ] [ 0 ] , vote [ 0 ] [ 1 ] } ; long result1 ; for ( int i = 1 ; i < n ; i ++ ) { result1 = result [ 1 ] ; if ( result [ 0 ] > vote [ i ] [ 0 ] ) { if ( result [ 0 ] % vote [ i ] [ 0 ] != 0 ) result [ 0 ] += vote [ i ] [ 0 ] - result [ 0 ] % vote [ i ] [ 0 ] ; } else { result [ 0 ] = vote [ i ] [ 0 ] ; } result [ 1 ] = result [ 0 ] / vote [ i ] [ 0 ] * vote [ i ] [ 1 ] ; if ( result1 > result [ 1 ] ) { result [ 1 ] = result1 ; if ( result [ 1 ] % vote [ i ] [ 1 ] != 0 ) result [ 1 ] += vote [ i ] [ 1 ] - result [ 1 ] % vote [ i ] [ 1 ] ; result [ 0 ] = result [ 1 ] / vote [ i ] [ 1 ] * vote [ i ] [ 0 ] ; } } return result [ 0 ] + result [ 1 ] ; } public static int [ ] [ ] readMatrix ( Scanner in , int n , int m ) { int [ ] [ ] mtx = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { mtx [ i ] [ j ] = in . nextInt ( ) ; } } return mtx ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; long t_pre = 1 , a_pre = 1 ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] str = br . readLine ( ) . split ( \" β \" ) ; long t = Integer . parseInt ( str [ 0 ] ) ; long a = Integer . parseInt ( str [ 1 ] ) ; long rate = Math . max ( t_pre / t + ( t_pre % t == 0 ? 0 : 1 ) , a_pre / a + ( a_pre % a == 0 ? 0 : 1 ) ) ; t_pre = rate * t ; a_pre = rate * a ; } System . out . println ( t_pre + a_pre ) ; } }",
"import java . util . Scanner ; class Main { static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { int n = gInt ( ) ; long a = gInt ( ) , b = gInt ( ) ; for ( int i = 1 ; i < n ; ++ i ) { int A = gInt ( ) , B = gInt ( ) ; if ( a * 1.0 / A < b * 1.0 / B ) { b = ( b + B - 1 ) / B * B ; a = b / B * A ; } else { a = ( a + A - 1 ) / A * A ; b = a / A * B ; } } System . out . println ( a + b ) ; } }"
] | [
"N = int ( input ( ) ) NEW_LINE P = [ list ( map ( int , input ( ) . split ( ' β ' ) ) ) for i in range ( N ) ] NEW_LINE T = [ P [ i ] [ 0 ] for i in range ( N ) ] NEW_LINE A = [ P [ i ] [ 1 ] for i in range ( N ) ] NEW_LINE t = T [ 0 ] NEW_LINE a = A [ 0 ] NEW_LINE k = 1 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT k1 = int ( ( T [ i - 1 ] * k - 1 ) // T [ i ] + 1 ) NEW_LINE k2 = int ( ( A [ i - 1 ] * k - 1 ) // A [ i ] + 1 ) NEW_LINE k = max ( k1 , k2 ) NEW_LINE DEDENT print ( k * ( T [ - 1 ] + A [ - 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 gcd ( x , y ) : NEW_LINE INDENT m = max ( x , y ) NEW_LINE n = min ( x , y ) NEW_LINE while m % n != 0 : NEW_LINE INDENT w = m % n NEW_LINE m = n NEW_LINE n = w NEW_LINE DEDENT return n NEW_LINE DEDENT def lcm ( x , y ) : return x * y // gcd ( x , y ) NEW_LINE def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : print ( x ) NEW_LINE DEDENT debug = False NEW_LINE N = getInt ( ) NEW_LINE TA = zeros ( N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT TA [ i ] = getIntList ( ) NEW_LINE DEDENT db ( TA ) NEW_LINE real = TA [ 0 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if real [ 0 ] / TA [ i ] [ 0 ] > real [ 1 ] / TA [ i ] [ 1 ] : NEW_LINE INDENT lc = ( real [ 0 ] + TA [ i ] [ 0 ] - 1 ) // TA [ i ] [ 0 ] * TA [ i ] [ 0 ] NEW_LINE real [ 0 ] = lc NEW_LINE real [ 1 ] = lc * TA [ i ] [ 1 ] // TA [ i ] [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT lc = ( real [ 1 ] + TA [ i ] [ 1 ] - 1 ) // TA [ i ] [ 1 ] * TA [ i ] [ 1 ] NEW_LINE real [ 1 ] = lc NEW_LINE real [ 0 ] = lc * TA [ i ] [ 0 ] // TA [ i ] [ 1 ] NEW_LINE DEDENT db ( ( lc , real ) ) NEW_LINE DEDENT print ( sum ( real ) ) NEW_LINE",
"import math NEW_LINE from decimal import * NEW_LINE n = int ( input ( ) ) NEW_LINE t_prev , a_prev = 1 , 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT t , a = map ( int , input ( ) . split ( ) ) NEW_LINE n_koho1 = math . ceil ( Decimal ( t_prev ) / Decimal ( t ) ) NEW_LINE n_koho2 = math . ceil ( Decimal ( a_prev ) / Decimal ( a ) ) NEW_LINE n = max ( n_koho1 , n_koho2 ) NEW_LINE t = n * t NEW_LINE a = n * a NEW_LINE t_prev = t NEW_LINE a_prev = a NEW_LINE DEDENT print ( t_prev + a_prev ) NEW_LINE",
"def floor ( a , b ) : NEW_LINE INDENT return ( ( - a ) // b ) * - 1 NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE ratio = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT ratio . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT v_T = ratio [ 0 ] [ 0 ] NEW_LINE v_A = ratio [ 0 ] [ 1 ] NEW_LINE for t , a in ratio [ 1 : ] : NEW_LINE INDENT diff_t = t - v_T NEW_LINE diff_a = a - v_A NEW_LINE if diff_t < 0 and diff_a < 0 : NEW_LINE INDENT d = max ( floor ( v_T , t ) , floor ( v_A , a ) ) NEW_LINE v_T = d * t NEW_LINE v_A = d * a NEW_LINE DEDENT elif diff_t < 0 : NEW_LINE INDENT d = floor ( v_T , t ) NEW_LINE v_T = d * t NEW_LINE v_A = d * a NEW_LINE DEDENT elif diff_a < 0 : NEW_LINE INDENT d = floor ( v_A , a ) NEW_LINE v_T = d * t NEW_LINE v_A = d * a NEW_LINE DEDENT elif diff_t >= 0 and diff_a >= 0 : NEW_LINE INDENT m = max ( diff_t , diff_a ) NEW_LINE v_T = t NEW_LINE v_A = a NEW_LINE DEDENT DEDENT print ( v_T + v_A ) NEW_LINE",
"def inpl ( ) : NEW_LINE INDENT return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE TA = [ inpl ( ) for i in range ( N ) ] NEW_LINE a , b = TA [ 0 ] [ 0 ] , TA [ 0 ] [ 1 ] NEW_LINE for ta , ao in TA [ 1 : ] : NEW_LINE INDENT if ta >= a and ao >= b : NEW_LINE INDENT a = ta NEW_LINE b = ao NEW_LINE DEDENT else : NEW_LINE INDENT tmp_a = - ( - 1 * a // ta ) NEW_LINE tmp_b = - ( - 1 * b // ao ) NEW_LINE tmp = max ( tmp_a , tmp_b ) NEW_LINE a = ta * tmp NEW_LINE b = ao * tmp NEW_LINE DEDENT DEDENT print ( a + b ) NEW_LINE"
] |
atcoder_abc026_B | [
"import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] r = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { r [ i ] = sc . nextInt ( ) ; } Arrays . sort ( r ) ; long R = 0 ; boolean red = true ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( red ) { R += r [ i ] * r [ i ] ; } else { R -= r [ i ] * r [ i ] ; } red = ! red ; } sc . close ( ) ; System . out . println ( R * Math . PI ) ; } }",
"import java . util . * ; public class Main { public static final double PI = 3.1415926535 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int R = sc . nextInt ( ) ; list . add ( R ) ; } Collections . sort ( list , Comparator . reverseOrder ( ) ) ; double ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { ans += PI * list . get ( i ) * list . get ( i ) ; } else { ans -= PI * list . get ( i ) * list . get ( i ) ; } } System . out . println ( ans ) ; } }",
"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . * ; 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 ( in , out ) ; out . close ( ) ; } static class Task { void solve ( InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; Integer R [ ] = new Integer [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { R [ i ] = in . nextInt ( ) ; } Arrays . sort ( R , Collections . reverseOrder ( ) ) ; double ans = 0 ; int sign = 1 ; for ( int r : R ) { ans += sign * r * r ; sign *= - 1 ; } out . println ( ans * Math . PI ) ; } } static class InputReader { BufferedReader reader ; StringTokenizer tokenizer ; InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; tokenizer = null ; } String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }",
"import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int [ ] radius = new int [ N ] ; double pi = Math . PI ; double area = 0 ; for ( int i = 0 ; i < N ; i ++ ) { radius [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( radius ) ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( N % 2 == 0 ) { if ( i % 2 == 0 ) { area -= pi * radius [ i ] * radius [ i ] ; } else if ( i % 2 == 1 ) { area += pi * radius [ i ] * radius [ i ] ; } } if ( N % 2 == 1 ) { if ( i % 2 == 0 ) { area += pi * radius [ i ] * radius [ i ] ; } else if ( i % 2 == 1 ) { area -= pi * radius [ i ] * radius [ i ] ; } } } System . out . println ( area ) ; } }",
"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; double ans = 3.1415926535897932384626433832795028841971693993751058209 ; double ans2 = 0 ; int c [ ] = new int [ a ] ; for ( int i = 0 ; i != a ; i ++ ) { c [ i ] = scan . nextInt ( ) ; } Arrays . sort ( c ) ; for ( int i = 0 ; i != a ; i ++ ) { if ( i % 2 == 0 ) { ans2 += c [ i ] * c [ i ] ; } else { ans2 -= c [ i ] * c [ i ] ; } } ans *= ans2 ; if ( ans <= 0 ) { System . out . println ( ans * - 1 ) ; } else if ( ans > 0 ) { System . out . println ( ans ) ; } } }"
] | [
"from math import pi NEW_LINE N = int ( input ( ) ) NEW_LINE r = sorted ( [ int ( input ( ) ) for _ in range ( N ) ] , reverse = True ) NEW_LINE ans = 0 NEW_LINE for i , n in enumerate ( r ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT ans += n ** 2 * pi NEW_LINE DEDENT else : NEW_LINE INDENT ans -= n ** 2 * pi NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE",
"from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE import collections NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( \" Yay ! \" ) NEW_LINE else : print ( \" : ( \" ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( \" + \" ) NEW_LINE elif ( x < y ) : print ( \" - \" ) NEW_LINE else : print ( \" ? \" ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def printrow ( a ) : NEW_LINE INDENT for i in range ( len ( a ) ) : NEW_LINE INDENT print ( a [ i ] ) NEW_LINE DEDENT DEDENT def combinations ( n , r ) : NEW_LINE INDENT if n < r : return 0 NEW_LINE return math . factorial ( n ) // ( math . factorial ( n - r ) * math . factorial ( r ) ) NEW_LINE DEDENT def permutations ( n , r ) : NEW_LINE INDENT if n < r : return 0 NEW_LINE return math . factorial ( n ) // math . factorial ( n - r ) NEW_LINE DEDENT n = ip ( ) NEW_LINE a = [ ip ( ) for i in range ( n ) ] NEW_LINE a . sort ( reverse = True ) NEW_LINE s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT s += a [ i ] * a [ i ] * math . pi NEW_LINE DEDENT else : s -= a [ i ] * a [ i ] * math . pi NEW_LINE DEDENT print ( s ) NEW_LINE",
"_ , * t = open ( 0 ) ; r = sorted ( int ( i ) ** 2 for i in t ) ; print ( ( sum ( r [ : : - 2 ] ) - sum ( r [ - 2 : : - 2 ] ) ) * 355 / 113 ) NEW_LINE",
"import math NEW_LINE PI = math . pi NEW_LINE N = int ( input ( ) ) NEW_LINE R = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT R . append ( int ( input ( ) ) ) NEW_LINE DEDENT R = sorted ( R ) NEW_LINE ans = 0 NEW_LINE if len ( R ) % 2 == 1 : NEW_LINE INDENT ans += R [ 0 ] * R [ 0 ] * PI NEW_LINE for i in range ( 1 , len ( R ) ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT ans += R [ i ] * R [ i ] * PI NEW_LINE ans -= R [ i - 1 ] * R [ i - 1 ] * PI NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 0 , len ( R ) ) : NEW_LINE INDENT if i % 2 == 1 : NEW_LINE INDENT ans += R [ i ] * R [ i ] * PI NEW_LINE ans -= R [ i - 1 ] * R [ i - 1 ] * PI NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE",
"r = [ int ( input ( ) ) for _ in range ( int ( input ( ) ) ) ] NEW_LINE r . sort ( reverse = True ) NEW_LINE ans = 0 NEW_LINE for i in range ( len ( r ) ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT if i == len ( r ) - 1 : NEW_LINE INDENT ans += r [ i ] ** 2 NEW_LINE DEDENT else : NEW_LINE INDENT ans += r [ i ] ** 2 - r [ i + 1 ] ** 2 NEW_LINE DEDENT DEDENT DEDENT import math NEW_LINE print ( ans * math . pi ) NEW_LINE"
] |
atcoder_abc049_A | [
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( sc . next ( ) . matches ( \" [ aiueo ] \" ) ? \" vowel \" : \" consonant \" ) ; } }",
"import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { out . println ( \" aeiou \" . contains ( in . next ( ) ) ? \" vowel \" : \" consonant \" ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( \" End β of β Input \" ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }",
"import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; if ( input . equals ( \" a \" ) || input . equals ( \" e \" ) || input . equals ( \" i \" ) || input . equals ( \" o \" ) || input . equals ( \" u \" ) ) { System . out . println ( \" vowel \" ) ; } else { System . out . println ( \" consonant \" ) ; } } }",
"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 ) { char c = in . nextChar ( ) ; if ( c == ' a ' || c == ' e ' || c == ' i ' || c == ' o ' || c == ' u ' ) { out . println ( \" vowel \" ) ; } else { out . println ( \" consonant \" ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }",
"import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String c = scan . next ( ) ; if ( c . equals ( \" a \" ) ) { System . out . println ( \" vowel \" ) ; } else if ( c . equals ( \" i \" ) ) { System . out . println ( \" vowel \" ) ; } else if ( c . equals ( \" u \" ) ) { System . out . println ( \" vowel \" ) ; } else if ( c . equals ( \" e \" ) ) { System . out . println ( \" vowel \" ) ; } else if ( c . equals ( \" o \" ) ) { System . out . println ( \" vowel \" ) ; } else { System . out . println ( \" consonant \" ) ; } } }"
] | [
"c = str ( input ( ) ) NEW_LINE L = [ \" a \" , \" i \" , \" u \" , \" e \" , \" o \" ] NEW_LINE if c in L : NEW_LINE INDENT print ( \" vowel \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" consonant \" ) NEW_LINE DEDENT",
"import sys , re NEW_LINE from collections import deque , defaultdict , Counter NEW_LINE from math import ceil , sqrt , hypot , factorial , pi , sin , cos , radians NEW_LINE from itertools import permutations , combinations , product NEW_LINE from operator import itemgetter , mul NEW_LINE from copy import deepcopy NEW_LINE from string import ascii_lowercase , ascii_uppercase , digits NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def INT ( ) : return int ( input ( ) ) NEW_LINE def MAP ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE c = input ( ) NEW_LINE boin = [ \" a \" , \" i \" , \" u \" , \" e \" , \" o \" ] NEW_LINE if c in boin : NEW_LINE INDENT print ( \" vowel \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" consonant \" ) NEW_LINE DEDENT",
"import sys NEW_LINE import math NEW_LINE input = sys . stdin . readline NEW_LINE a = input ( ) . rstrip ( ) NEW_LINE vowel = [ ' a ' , ' i ' , ' u ' , ' e ' , ' o ' ] NEW_LINE flag = False NEW_LINE for i in vowel : NEW_LINE INDENT if ( i == a ) : NEW_LINE INDENT flag = True NEW_LINE DEDENT DEDENT if ( flag == True ) : NEW_LINE INDENT print ( ' vowel ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' consonant ' ) NEW_LINE DEDENT",
"c = input ( ) NEW_LINE vowels = [ \" a \" , \" i \" , \" u \" , \" e \" , \" o \" ] NEW_LINE if c in vowels : NEW_LINE INDENT print ( \" vowel \" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( \" consonant \" ) NEW_LINE DEDENT",
"print ( \" vowel \" ) if input ( ) in [ \" a \" , \" i \" , \" u \" , \" e \" , \" o \" ] else print ( \" consonant \" ) NEW_LINE"
] |
atcoder_abc086_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 ( ) ; sc . close ( ) ; String ab = a + b ; int value = Integer . parseInt ( ab ) ; String ans = \" No \" ; for ( int i = 4 ; i <= Math . sqrt ( value ) ; i ++ ) { if ( i * i == value ) { ans = \" Yes \" ; break ; } } System . out . println ( ans ) ; } }",
"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int number = Integer . parseInt ( tokenizer . nextToken ( ) + tokenizer . nextToken ( ) ) ; double result = Math . sqrt ( number ) ; int round = ( int ) result ; System . out . println ( result == round ? \" Yes \" : \" No \" ) ; } }",
"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; String c = a + b ; Double num = Double . parseDouble ( c ) ; if ( Math . sqrt ( num ) % 1 == 0 ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } sc . close ( ) ; } }",
"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int num = Integer . parseInt ( a + b ) ; int s = ( int ) Math . sqrt ( num ) ; if ( s * s == num ) { System . out . println ( \" Yes \" ) ; } else { System . out . println ( \" No \" ) ; } } }",
"import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( stdin . readLine ( ) . replaceAll ( \" β \" , \" \" ) ) ; int r = ( int ) Math . floor ( Math . sqrt ( n ) ) ; String ans = n == r * r ? \" Yes \" : \" No \" ; System . out . println ( ans ) ; } }"
] | [
"heihousuu = [ i * i for i in range ( int ( 100100 ** 0.5 ) ) ] NEW_LINE a , b = input ( ) . split ( ) NEW_LINE ab = int ( a + b ) NEW_LINE print ( ' Yes ' if ab in heihousuu else ' No ' ) NEW_LINE",
"a , b = input ( ) . split ( ) NEW_LINE c = int ( a + b ) NEW_LINE def try_square_root_naive ( n ) : NEW_LINE INDENT m = int ( n ** .5 ) NEW_LINE return m if abs ( m * m - n ) < 1e-6 else None NEW_LINE DEDENT if try_square_root_naive ( c ) == None : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT",
"import math NEW_LINE s = input ( ) NEW_LINE s = int ( s . replace ( ' β ' , ' ' ) ) NEW_LINE if ( math . sqrt ( s ) == math . floor ( math . sqrt ( s ) ) ) : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT",
"def main ( ) : NEW_LINE INDENT print ( ' YNeos ' [ not ( int ( ' ' . join ( input ( ) . split ( ) ) ) ** 0.5 ) . is_integer ( ) : : 2 ] ) NEW_LINE DEDENT main ( ) NEW_LINE",
"a , b = map ( int , input ( ) . split ( ) ) NEW_LINE num = int ( str ( a ) + str ( b ) ) NEW_LINE flag = False NEW_LINE for i in range ( 1000 ) : NEW_LINE INDENT if i ** 2 == num : NEW_LINE INDENT flag = True NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT"
] |