id
stringlengths 2
6
| java
stringlengths 48
5.92k
| python
stringlengths 33
11.1k
|
---|---|---|
T100 | 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 , " " ) ) ; } }
| 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
|
T101 | 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 , " " ) ) ; } }
| 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
|
T102 | 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 , " " ) ) ; } }
| s = input ( ) ; print ( input ( ) . replace ( s , " " ) ) NEW_LINE
|
T103 | 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 , " " ) ) ; } }
| 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
|
T104 | 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 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
|
T105 | 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
|
T106 | 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 , 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
|
T107 | 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 ( ) ; } }
| s = input ( ) ; print ( input ( ) . replace ( s , " " ) ) NEW_LINE
|
T108 | 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 = [ 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
|
T109 | 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 ( ) ; } }
| 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
|
T110 | 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 ) ; } }
| a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( " GREATER " if a > b else " LESS " if a < b else " EQUAL " ) NEW_LINE
|
T111 | 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 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
|
T112 | 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 ) ; } }
| a , b = map ( int , open ( 0 ) ) ; print ( [ ' ELQEUSASL ' [ a < b : : 2 ] , ' GREATER ' ] [ a > b ] ) NEW_LINE
|
T113 | 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 ) ; } }
| 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
|
T114 | 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 ) ; } }
| 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
|
T115 | 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 ( ) ) ; } } }
| a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( " GREATER " if a > b else " LESS " if a < b else " EQUAL " ) NEW_LINE
|
T116 | 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 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
|
T117 | 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 ( ) ) ; } } }
| a , b = map ( int , open ( 0 ) ) ; print ( [ ' ELQEUSASL ' [ a < b : : 2 ] , ' GREATER ' ] [ a > b ] ) NEW_LINE
|
T118 | 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 ( ) ) ; } } }
| 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
|
T119 | 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 ( ) ) ; } } }
| 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
|
T120 | 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 ( ) ; } }
| a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( " GREATER " if a > b else " LESS " if a < b else " EQUAL " ) NEW_LINE
|
T121 | 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 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
|
T122 | 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 ( ) ; } }
| a , b = map ( int , open ( 0 ) ) ; print ( [ ' ELQEUSASL ' [ a < b : : 2 ] , ' GREATER ' ] [ a > b ] ) NEW_LINE
|
T123 | 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 ( ) ; } }
| 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
|
T124 | 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 ( ) ; } }
| 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
|
T125 | 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 " ) ; } } }
| a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( " GREATER " if a > b else " LESS " if a < b else " EQUAL " ) NEW_LINE
|
T126 | 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 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
|
T127 | 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 " ) ; } } }
| a , b = map ( int , open ( 0 ) ) ; print ( [ ' ELQEUSASL ' [ a < b : : 2 ] , ' GREATER ' ] [ a > b ] ) NEW_LINE
|
T128 | 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 " ) ; } } }
| 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
|
T129 | 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 " ) ; } } }
| 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
|
T130 | 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
|
T131 | 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 ; } } }
| 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
|
T132 | 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 , b = map ( int , open ( 0 ) ) ; print ( [ ' ELQEUSASL ' [ a < b : : 2 ] , ' GREATER ' ] [ a > b ] ) NEW_LINE
|
T133 | 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 , 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
|
T134 | 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 ; } } }
| 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
|
T135 | 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 ( ) ; } }
| 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
|
T136 | 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 ( ) ; } }
| input ( ) ; print ( ' TFhoruere ' [ ' Y ' in input ( ) : : 2 ] ) NEW_LINE
|
T137 | 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 ( ) ; } }
| 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
|
T138 | 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 ( ) ; } }
| 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
|
T139 | 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 ( ) ; } }
| n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE print ( ' Four ' if ' Y ' in s else ' Three ' ) NEW_LINE
|
T140 | 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 ) ; } }
| 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
|
T141 | 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 ) ; } }
| input ( ) ; print ( ' TFhoruere ' [ ' Y ' in input ( ) : : 2 ] ) NEW_LINE
|
T142 | 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 ) ; } }
| 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
|
T143 | 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 ) ; } }
| 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
|
T144 | 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 ) ; } }
| n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE print ( ' Four ' if ' Y ' in s else ' Three ' ) NEW_LINE
|
T145 | 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 " ) ; } }
| 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
|
T146 | 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 " ) ; } }
| input ( ) ; print ( ' TFhoruere ' [ ' Y ' in input ( ) : : 2 ] ) NEW_LINE
|
T147 | 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 " ) ; } }
| 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
|
T148 | 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 " ) ; } }
| 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
|
T149 | 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 " ) ; } }
| n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE print ( ' Four ' if ' Y ' in s else ' Three ' ) NEW_LINE
|
T150 | 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 ( ) ; } }
| 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
|
T151 | 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 ( ) ; } }
| input ( ) ; print ( ' TFhoruere ' [ ' Y ' in input ( ) : : 2 ] ) NEW_LINE
|
T152 | 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 ( ) ; } }
| 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
|
T153 | 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 ( ) ; } }
| 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
|
T154 | 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 ( ) ; } }
| n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE print ( ' Four ' if ' Y ' in s else ' Three ' ) NEW_LINE
|
T155 | 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
|
T156 | 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 " ) ; } }
| input ( ) ; print ( ' TFhoruere ' [ ' Y ' in input ( ) : : 2 ] ) NEW_LINE
|
T157 | 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 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
|
T158 | 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 = 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
|
T159 | 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 s = input ( ) NEW_LINE print ( ' Four ' if ' Y ' in s else ' Three ' ) NEW_LINE
|
T160 | 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 ) ; } }
| 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
|
T161 | 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 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
|
T162 | 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 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
|
T163 | 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 ) ; } }
| 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
|
T164 | 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 ) ; } }
| 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
|
T165 | 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 ; } }
| 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
|
T166 | 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 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
|
T167 | 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 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
|
T168 | 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 ; } }
| 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
|
T169 | 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 ; } }
| 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
|
T170 | 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 ( ) ; } }
| 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
|
T171 | 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 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
|
T172 | 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 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
|
T173 | 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 ( ) ; } }
| 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
|
T174 | 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 ( ) ; } }
| 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
|
T175 | 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 ) ; } }
| 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
|
T176 | 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 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
|
T177 | 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 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
|
T178 | 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 ) ; } }
| 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
|
T179 | 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 ) ; } }
| 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
|
T180 | 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
|
T181 | 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 ) ; } }
| 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
|
T182 | 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 ) ; } }
| 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
|
T183 | 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 ) ; } }
| 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
|
T184 | 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 ) ; } }
| 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
|
T185 | 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 ) ; } }
| N = int ( input ( ) ) NEW_LINE print ( int ( ( 1 + N ) * N / 2 ) ) NEW_LINE
|
T186 | 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 ) ; } }
| 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
|
T187 | 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 ) ; } }
| 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
|
T188 | 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 ) ; } }
| print ( sum ( [ n for n in range ( 1 , int ( input ( ) ) + 1 ) ] ) ) NEW_LINE
|
T189 | 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 ) ; } }
| 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
|
T190 | 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 ( ) ; } }
| N = int ( input ( ) ) NEW_LINE print ( int ( ( 1 + N ) * N / 2 ) ) NEW_LINE
|
T191 | 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 ( ) ; } }
| 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
|
T192 | 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 ( ) ; } }
| 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
|
T193 | 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 ( ) ; } }
| print ( sum ( [ n for n in range ( 1 , int ( input ( ) ) + 1 ) ] ) ) NEW_LINE
|
T194 | 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 ( ) ; } }
| 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
|
T195 | 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 ) ; } }
| N = int ( input ( ) ) NEW_LINE print ( int ( ( 1 + N ) * N / 2 ) ) NEW_LINE
|
T196 | 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 ) ; } }
| 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
|
T197 | 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 ) ; } }
| 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
|
T198 | 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 ) ; } }
| print ( sum ( [ n for n in range ( 1 , int ( input ( ) ) + 1 ) ] ) ) NEW_LINE
|
T199 | 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 ) ; } }
| 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
|