import java . io . * ; import java . util . * ; import static java . lang . System . in ; class Main { static long mod = 1000000000 + 7 ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; long ans = help ( a ) ; System . out . println ( ans ) ; } static long help ( int [ ] a ) { if ( a [ 0 ] != 0 ) return 0 ; int maxDist = 0 ; for ( int w : a ) maxDist = Math . max ( maxDist , w ) ; int [ ] rec = new int [ maxDist + 1 ] ; for ( int w : a ) rec [ w ] ++ ; if ( rec [ 0 ] != 1 ) return 0 ; for ( int i = 1 ; i <= maxDist ; i ++ ) { if ( rec [ i ] < 1 ) return 0 ; } long [ ] dp = new long [ maxDist + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= maxDist ; i ++ ) { long base = power ( 2 , rec [ i - 1 ] ) - 1 ; dp [ i ] = power ( base , rec [ i ] ) * dp [ i - 1 ] % mod ; long sameLayer = ( ( long ) rec [ i ] ) * ( ( long ) rec [ i ] - 1 ) / 2 ; dp [ i ] = dp [ i ] * power ( 2 , sameLayer ) % mod ; } return dp [ maxDist ] ; } static long power ( long base , long p ) { long ans = 1 ; while ( p > 0 ) { if ( p % 2 == 1 ) ans = ans * base % mod ; base = base * base % mod ; p /= 2 ; } return ans ; } }

import java . util . * ; public class Main { static final int MOD = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] d = new int [ n ] ; int dmax = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; d [ a [ i ] ] ++ ; dmax = Math . max ( a [ i ] , dmax ) ; } if ( a [ 0 ] != 0 || d [ 0 ] != 1 ) { System . out . println ( 0 ) ; return ; } for ( int i = 0 ; i <= dmax ; i ++ ) { if ( d [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } long ans = 1L ; for ( int i = 1 ; i <= dmax ; i ++ ) { long tmp = pow ( 2 , d [ i - 1 ] ) ; tmp = ( tmp + MOD - 1 ) % MOD ; ans = ( ans * pow ( tmp , d [ i ] ) ) % MOD ; ans = ( ans * pow ( 2 , ( long ) ( d [ i ] - 1 ) * d [ i ] / 2 ) ) % MOD ; } System . out . println ( ans ) ; } public static long pow ( long a , long n ) { long x = 1 ; while ( n > 0 ) { if ( n % 2 == 1 ) { x = x * a % MOD ; } a = a * a % MOD ; n >>= 1 ; } return x ; } }

def main ( ) : NEW_LINE INDENT R = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) NEW_LINE if a [ 0 ] != 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT amax = max ( a ) NEW_LINE h = [ 0 ] * ( amax + 1 ) NEW_LINE for i in a : NEW_LINE INDENT h [ i ] += 1 NEW_LINE DEDENT if h [ 0 ] != 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT for i in h : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE b = 1 NEW_LINE for i in h [ 1 : ] : NEW_LINE INDENT if i > 1 : NEW_LINE INDENT ans *= pow ( 2 , i * ( i - 1 ) // 2 , R ) NEW_LINE ans %= R NEW_LINE DEDENT ans *= pow ( pow ( 2 , b , R ) - 1 , i , R ) NEW_LINE ans %= R NEW_LINE b = i NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT

def powmod ( a , b , P ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT stk = [ ] NEW_LINE while b > 1 : NEW_LINE INDENT stk . append ( b % 2 ) NEW_LINE b //= 2 NEW_LINE DEDENT c = a % P NEW_LINE while len ( stk ) > 0 : NEW_LINE INDENT t = stk . pop ( ) NEW_LINE c = ( c * c ) % P NEW_LINE if t == 1 : NEW_LINE INDENT c = ( c * a ) % P NEW_LINE DEDENT DEDENT return c NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE P = 10 ** 9 + 7 NEW_LINE def count ( A ) : NEW_LINE INDENT S = [ 0 for _ in range ( max ( A ) + 1 ) ] NEW_LINE for a in A : NEW_LINE INDENT S [ a ] += 1 NEW_LINE DEDENT if A [ 0 ] != 0 or S [ 0 ] != 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT cnt = 1 NEW_LINE for i in range ( 1 , len ( S ) ) : NEW_LINE INDENT if S [ i ] == 0 : return 0 NEW_LINE path1 = powmod ( ( powmod ( 2 , S [ i - 1 ] , P ) - 1 ) % P , S [ i ] , P ) NEW_LINE path2 = powmod ( 2 , S [ i ] * ( S [ i ] - 1 ) // 2 , P ) % P NEW_LINE cnt = cnt * path1 * path2 % P NEW_LINE DEDENT return cnt NEW_LINE DEDENT print ( count ( A ) ) NEW_LINE

from collections import defaultdict NEW_LINE def mod_pow ( x , n , mod ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT res = mod_pow ( x * x % mod , n // 2 , mod ) NEW_LINE if n & 1 : NEW_LINE INDENT res = res * x % mod NEW_LINE DEDENT return res NEW_LINE DEDENT MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ok = True NEW_LINE zeros = 0 NEW_LINE cnt = defaultdict ( int ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT if A [ i ] != 0 : NEW_LINE INDENT ok = False NEW_LINE DEDENT DEDENT if A [ i ] == 0 : NEW_LINE INDENT zeros += 1 NEW_LINE DEDENT cnt [ A [ i ] ] += 1 NEW_LINE DEDENT maxn = max ( cnt . keys ( ) ) NEW_LINE if zeros != 1 : NEW_LINE INDENT ok = False NEW_LINE DEDENT res = 1 NEW_LINE if ok == True : NEW_LINE INDENT for i in range ( 0 , maxn + 1 ) : NEW_LINE INDENT if i != 0 and cnt [ i ] == 0 : NEW_LINE INDENT ok = False ; NEW_LINE break NEW_LINE DEDENT K = cnt [ i ] NEW_LINE res = ( res * mod_pow ( 2 , K * ( K - 1 ) // 2 , MOD ) ) % MOD NEW_LINE if i != 0 : NEW_LINE INDENT t = cnt [ i - 1 ] NEW_LINE curr = mod_pow ( 2 , t , MOD ) NEW_LINE s = cnt [ i ] NEW_LINE curr2 = mod_pow ( curr - 1 + MOD , s , MOD ) NEW_LINE res = ( res * curr2 ) % MOD NEW_LINE DEDENT DEDENT DEDENT print ( res if ok == True else 0 ) NEW_LINE

import collections NEW_LINE MAX_N = 10 ** 5 + 1 NEW_LINE MOD = 1000000007 NEW_LINE same_dist = [ 0 ] * ( MAX_N + 1 ) NEW_LINE same_dist [ 1 ] = 1 NEW_LINE for i in range ( 2 , MAX_N + 1 ) : NEW_LINE INDENT same_dist [ i ] = same_dist [ i - 1 ] * pow ( 2 , i - 1 , MOD ) NEW_LINE same_dist [ i ] %= MOD NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cnt_num = collections . Counter ( a ) NEW_LINE if not ( cnt_num [ 0 ] == 1 and a [ 0 ] == 0 ) : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT if len ( a ) == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT ans = 1 NEW_LINE cnt = 1 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if cnt_num [ i ] == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT ans *= same_dist [ cnt_num [ i ] ] NEW_LINE ans %= MOD NEW_LINE ans *= pow ( ( 2 ** cnt_num [ i - 1 ] - 1 ) , cnt_num [ i ] , MOD ) NEW_LINE ans %= MOD NEW_LINE DEDENT cnt += cnt_num [ i ] NEW_LINE if cnt == len ( a ) : NEW_LINE INDENT print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT

from collections import Counter NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def power ( n , k ) : NEW_LINE INDENT if k == 0 : return 1 NEW_LINE elif k == 1 : return n NEW_LINE elif k % 2 == 0 : return power ( ( n ** 2 ) % mod , k // 2 ) NEW_LINE else : return ( n * power ( n , k - 1 ) ) % mod NEW_LINE DEDENT if a [ 0 ] != 0 or a . count ( 0 ) != 1 : print ( 0 ) NEW_LINE else : NEW_LINE INDENT c , ans , num , mod = Counter ( a ) , 1 , 1 , 10 ** 9 + 7 NEW_LINE for i in range ( 1 , max ( a ) + 1 ) : NEW_LINE INDENT if c [ i ] == 0 : NEW_LINE INDENT ans = 0 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( ans * power ( ( power ( 2 , num ) - 1 ) , c [ i ] ) * power ( 2 , c [ i ] * ( c [ i ] - 1 ) // 2 ) ) % mod NEW_LINE num = c [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; UnionFind uf = new UnionFind ( N ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; uf . union ( a , b ) ; } System . out . println ( uf . count ( N ) - 1 ) ; } private static class UnionFind { int parent [ ] ; int rank [ ] ; public UnionFind ( int n ) { parent = new int [ n ] ; rank = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { parent [ i ] = i ; rank [ i ] = 0 ; } } boolean same ( int x , int y ) { return find ( x ) == find ( y ) ; } public int find ( int x ) { if ( parent [ x ] == x ) return x ; else return parent [ x ] = find ( parent [ x ] ) ; } public void union ( int x , int y ) { x = find ( x ) ; y = find ( y ) ; if ( x != y ) { if ( rank [ x ] > rank [ y ] ) { parent [ y ] = x ; } else { parent [ x ] = y ; if ( rank [ x ] == rank [ y ] ) { rank [ y ] ++ ; } } } return ; } public int count ( int n ) { int ret = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == find ( i ) ) ret ++ ; } return ret ; } } }

import java . util . * ; public class Main { public static class Node { ArrayList < Integer > to ; boolean visit ; Node ( ) { to = new ArrayList < Integer > ( ) ; visit = false ; } } static Scanner sc = new Scanner ( System . in ) ; static int N = sc . nextInt ( ) ; static int M = sc . nextInt ( ) ; static Node [ ] node = new Node [ 100000 ] ; public static void main ( String [ ] args ) { for ( int i = 0 ; i < N ; i ++ ) node [ i ] = new Node ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; node [ a - 1 ] . to . add ( b - 1 ) ; node [ b - 1 ] . to . add ( a - 1 ) ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( node [ i ] . visit ) continue ; node [ i ] . visit = true ; solve ( node [ i ] ) ; count ++ ; } System . out . println ( count - 1 ) ; } public static void solve ( Node n ) { for ( int i = 0 ; i < n . to . size ( ) ; i ++ ) { int next = n . to . get ( i ) ; if ( node [ next ] . visit ) continue ; node [ next ] . visit = true ; solve ( node [ next ] ) ; } } }

import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; UnionFind uf = new UnionFind ( N ) ; uf . init ( N ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; uf . unite ( a , b ) ; } for ( int i = 0 ; i < N ; i ++ ) { uf . find ( i ) ; } boolean [ ] used = new boolean [ N ] ; int ans = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! used [ uf . parent [ i ] ] ) { used [ uf . parent [ i ] ] = true ; ans ++ ; } } System . out . println ( ans ) ; } } class UnionFind { public int [ ] parent ; public int [ ] rank ; public UnionFind ( int MAX_SIZE ) { parent = new int [ MAX_SIZE ] ; rank = new int [ MAX_SIZE ] ; } public void init ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { parent [ i ] = i ; rank [ i ] = 0 ; } } public int find ( int x ) { if ( parent [ x ] == x ) { return x ; } else { return parent [ x ] = find ( parent [ x ] ) ; } } public void unite ( int x , int y ) { x = find ( x ) ; y = find ( y ) ; if ( x == y ) return ; if ( rank [ x ] < rank [ y ] ) parent [ x ] = y ; else parent [ y ] = x ; if ( rank [ x ] == rank [ y ] ) rank [ x ] ++ ; } public boolean same ( int x , int y ) { return find ( x ) == find ( y ) ; } }

import java . util . * ; public class Main { public static class Node { ArrayList < Integer > to ; boolean visit ; Node ( ) { to = new ArrayList < Integer > ( ) ; visit = false ; } } static Node [ ] node = new Node [ 100000 ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) node [ i ] = new Node ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; node [ a - 1 ] . to . add ( b - 1 ) ; node [ b - 1 ] . to . add ( a - 1 ) ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( node [ i ] . visit ) continue ; node [ i ] . visit = true ; solve ( node [ i ] ) ; count ++ ; } System . out . println ( count - 1 ) ; } public static void solve ( Node n ) { for ( int i = 0 ; i < n . to . size ( ) ; i ++ ) { int next = n . to . get ( i ) ; if ( node [ next ] . visit ) continue ; node [ next ] . visit = true ; solve ( node [ next ] ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; UnionFindTree uft = new UnionFindTree ( n ) ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; uft . union ( a - 1 , b - 1 ) ; } System . out . println ( uft . countBlock ( ) - 1 ) ; } static class UnionFindTree { int [ ] parent ; int [ ] rank ; public UnionFindTree ( int size ) { parent = new int [ size ] ; rank = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { parent [ i ] = i ; } } public int find ( int x ) { if ( parent [ x ] == x ) { return x ; } else { int v = find ( parent [ x ] ) ; parent [ x ] = v ; return v ; } } public boolean same ( int x , int y ) { return find ( x ) == find ( y ) ; } public void union ( int x , int y ) { int rootX = find ( x ) ; int rootY = find ( y ) ; if ( rank [ rootX ] > rank [ rootY ] ) { parent [ rootY ] = rootX ; } else if ( rank [ rootX ] < rank [ rootY ] ) { parent [ rootX ] = rootY ; } else if ( rootX != rootY ) { parent [ rootX ] = rootY ; rank [ rootX ] ++ ; } } public int countBlock ( ) { int count = 0 ; for ( int i = 0 ; i < parent . length ; i ++ ) { if ( parent [ i ] == i ) { count ++ ; } } return count ; } } }

import sys NEW_LINE input = sys . stdin . readline NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE par = [ ] NEW_LINE rank = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT par . append ( i ) NEW_LINE rank . append ( 0 ) NEW_LINE DEDENT def find ( x , par ) : NEW_LINE INDENT if par [ x ] == x : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return find ( par [ x ] , par ) NEW_LINE DEDENT DEDENT def unite ( x , y , par , rank ) : NEW_LINE INDENT x = find ( x , par ) NEW_LINE y = find ( y , par ) NEW_LINE if x != y : NEW_LINE INDENT if rank [ x ] < rank [ y ] : NEW_LINE INDENT par [ x ] = y NEW_LINE DEDENT else : NEW_LINE INDENT par [ y ] = x NEW_LINE if rank [ x ] == rank [ y ] : NEW_LINE INDENT rank [ x ] += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT def same ( x , y , par ) : NEW_LINE INDENT return find ( x , par ) == find ( y , par ) NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT a , b = map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) NEW_LINE unite ( a , b , par , rank ) NEW_LINE DEDENT res = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if par [ i ] == i : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE

class UnionFind ( ) : NEW_LINE INDENT def __init__ ( self , size ) : NEW_LINE INDENT self . table = [ - 1 ] * size NEW_LINE DEDENT def root ( self , x ) : NEW_LINE INDENT while self . table [ x ] >= 0 : NEW_LINE INDENT x = self . table [ x ] NEW_LINE DEDENT return x NEW_LINE DEDENT def unite ( self , x , y ) : NEW_LINE INDENT s1 = self . root ( x ) NEW_LINE s2 = self . root ( y ) NEW_LINE if s1 != s2 : NEW_LINE INDENT if self . table [ s1 ] > self . table [ s2 ] : NEW_LINE INDENT s1 , s2 = s2 , s1 NEW_LINE DEDENT self . table [ s1 ] += self . table [ s2 ] NEW_LINE self . table [ s2 ] = s1 NEW_LINE DEDENT return NEW_LINE DEDENT def same ( self , x , y ) : NEW_LINE INDENT return self . root ( x ) == self . root ( y ) NEW_LINE DEDENT def size ( self , x ) : NEW_LINE INDENT return - self . table [ self . root ( x ) ] NEW_LINE DEDENT DEDENT ( n , m ) , * e = [ map ( int , t . split ( ) ) for t in open ( 0 ) . readlines ( ) ] NEW_LINE u = UnionFind ( n ) NEW_LINE for x , y in e : NEW_LINE INDENT u . unite ( x - 1 , y - 1 ) NEW_LINE DEDENT print ( sum ( i < 0 for i in u . table ) - 1 ) NEW_LINE

from collections import defaultdict NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( sys . getrecursionlimit ( ) * 10000 ) NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE g = defaultdict ( list ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE g [ a ] . append ( b ) NEW_LINE g [ b ] . append ( a ) NEW_LINE DEDENT visited = set ( ) NEW_LINE def dfs ( v ) : NEW_LINE INDENT visited . add ( v ) NEW_LINE for c in g [ v ] : NEW_LINE INDENT if not c in visited : NEW_LINE INDENT dfs ( c ) NEW_LINE DEDENT DEDENT DEDENT connected_component = 0 NEW_LINE for v in range ( 1 , N + 1 ) : NEW_LINE INDENT if not v in visited : NEW_LINE INDENT dfs ( v ) NEW_LINE connected_component += 1 NEW_LINE DEDENT DEDENT print ( connected_component - 1 ) NEW_LINE

def b_construction ( N , M , Road ) : NEW_LINE INDENT class UnionFind ( object ) : NEW_LINE INDENT def __init__ ( self , N ) : NEW_LINE INDENT self . p = list ( range ( N ) ) NEW_LINE self . rank = [ 0 ] * N NEW_LINE self . size = [ 1 ] * N NEW_LINE DEDENT def union ( self , x , y ) : NEW_LINE INDENT u = self . find ( x ) NEW_LINE v = self . find ( y ) NEW_LINE if u == v : NEW_LINE INDENT return NEW_LINE DEDENT if self . rank [ u ] < self . rank [ v ] : NEW_LINE INDENT self . p [ u ] = v NEW_LINE self . size [ v ] += self . size [ u ] NEW_LINE self . size [ u ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT self . p [ v ] = u NEW_LINE self . size [ u ] += self . size [ v ] NEW_LINE self . size [ v ] = 0 NEW_LINE if self . rank [ u ] == self . rank [ v ] : NEW_LINE INDENT self . rank [ u ] += 1 NEW_LINE DEDENT DEDENT DEDENT def find ( self , x ) : NEW_LINE INDENT if self . p [ x ] != x : NEW_LINE INDENT self . p [ x ] = self . find ( self . p [ x ] ) NEW_LINE DEDENT return self . p [ x ] NEW_LINE DEDENT def __str__ ( self ) : NEW_LINE INDENT return ' [ { } ] ' . format ( ' , ▁ ' . join ( map ( str , self . p ) ) ) NEW_LINE DEDENT DEDENT uf = UnionFind ( N ) NEW_LINE for a , b in Road : NEW_LINE INDENT uf . union ( a - 1 , b - 1 ) NEW_LINE DEDENT ans = len ( [ 1 for v in range ( N ) if uf . find ( v ) == v ] ) - 1 NEW_LINE return ans NEW_LINE DEDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE Road = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( M ) ] NEW_LINE print ( b_construction ( N , M , Road ) ) NEW_LINE

class DisjointSet : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . rank = { } NEW_LINE self . p = { } NEW_LINE DEDENT def makeSet ( self , x ) : NEW_LINE INDENT self . p [ x ] = x NEW_LINE self . rank [ x ] = 0 NEW_LINE DEDENT def same ( self , x , y ) : NEW_LINE INDENT return self . findSet ( x ) == self . findSet ( y ) NEW_LINE DEDENT def unite ( self , x , y ) : NEW_LINE INDENT self . link ( self . findSet ( x ) , self . findSet ( y ) ) NEW_LINE DEDENT def link ( self , x , y ) : NEW_LINE INDENT if x == y : NEW_LINE INDENT return NEW_LINE DEDENT if ( self . rank [ x ] > self . rank [ y ] ) : NEW_LINE INDENT self . p [ y ] = x NEW_LINE DEDENT else : NEW_LINE INDENT self . p [ x ] = y NEW_LINE if ( self . rank [ x ] == self . rank [ y ] ) : NEW_LINE INDENT self . rank [ y ] += 1 NEW_LINE DEDENT DEDENT DEDENT def findSet ( self , x ) : NEW_LINE INDENT if ( x != self . p [ x ] ) : NEW_LINE INDENT self . p [ x ] = self . findSet ( self . p [ x ] ) NEW_LINE DEDENT return self . p [ x ] NEW_LINE DEDENT DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE ds = DisjointSet ( ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT ds . makeSet ( i ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE ds . unite ( a , b ) NEW_LINE DEDENT connected_component = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if i == ds . findSet ( i ) : NEW_LINE INDENT connected_component += 1 NEW_LINE DEDENT DEDENT print ( connected_component - 1 ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) , m = sc . next ( ) ; if ( n . length ( ) > m . length ( ) ) System . out . println ( n ) ; else System . out . println ( m ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; String t = in . next ( ) ; out . println ( s . length ( ) > t . length ( ) ? s : t ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String s = sc . next ( ) ; String s1 = sc . next ( ) ; int a = s . length ( ) ; int b = s1 . length ( ) ; System . out . println ( a > b ? s : s1 ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { String a = sc . next ( ) , b = sc . next ( ) ; out . println ( a . length ( ) > b . length ( ) ? a : b ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String A = in . next ( ) ; String B = in . next ( ) ; if ( A . length ( ) > B . length ( ) ) { out . println ( A ) ; } else { out . println ( B ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

s1 = input ( ) NEW_LINE s2 = input ( ) NEW_LINE if len ( s1 ) > len ( s2 ) : NEW_LINE INDENT print ( s1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( s2 ) NEW_LINE DEDENT

print ( max ( open ( 0 ) , key = len ) ) NEW_LINE

a = input ( ) NEW_LINE b = input ( ) NEW_LINE print ( a if len ( a ) >= len ( b ) else b ) NEW_LINE

A = input ( ) NEW_LINE B = input ( ) NEW_LINE if A . islower ( ) and B . islower ( ) : NEW_LINE INDENT C = len ( A ) NEW_LINE D = len ( B ) NEW_LINE if C > D : NEW_LINE INDENT print ( A ) NEW_LINE DEDENT elif D > C : NEW_LINE INDENT print ( B ) NEW_LINE DEDENT DEDENT

print ( max ( input ( ) , input ( ) , key = len ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; int [ ] c = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a ) ; Arrays . sort ( b ) ; Arrays . sort ( c ) ; long ans = 0 ; long [ ] cnum = new long [ n + 1 ] ; int pos = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( c [ pos ] <= b [ i ] ) { pos ++ ; if ( pos >= n ) { pos = n ; break ; } } if ( pos >= n ) break ; cnum [ i ] = n - pos ; } for ( int i = 1 ; i < n ; i ++ ) { cnum [ n - i - 1 ] = cnum [ n - i ] + cnum [ n - i - 1 ] ; } pos = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( b [ pos ] <= a [ i ] ) { pos ++ ; if ( pos >= n ) { pos = n ; break ; } } if ( pos >= n ) break ; ans += cnum [ pos ] ; } System . out . println ( ans ) ; } }

import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; Integer [ ] A = new Integer [ n ] , B = new Integer [ n ] , C = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) B [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) C [ i ] = sc . nextInt ( ) ; Arrays . sort ( A ) ; Arrays . sort ( C ) ; long ans = 0L ; for ( int i = 0 ; i < n ; i ++ ) { long a = ~ Arrays . binarySearch ( A , B [ i ] , ( x , y ) -> x . compareTo ( y ) >= 0 ? 1 : - 1 ) ; long c = n - ~ Arrays . binarySearch ( C , B [ i ] , ( x , y ) -> x . compareTo ( y ) > 0 ? 1 : - 1 ) ; ans += a * c ; } System . out . println ( ans ) ; } }

import java . util . Arrays ; import java . util . Scanner ; import java . util . stream . IntStream ; class Main { static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { int n = gInt ( ) ; int [ ] a = in ( n ) , b = in ( n ) , c = in ( n ) ; long [ ] v1 = new long [ n ] , v2 = new long [ n ] ; { int v = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( ; v < n && a [ v ] < b [ i ] ; ++ v ) { } v1 [ i ] = v ; } } Arrays . parallelPrefix ( v1 , Long :: sum ) ; { int v = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( ; v < n && b [ v ] < c [ i ] ; ++ v ) { } v2 [ i ] = v == 0 ? 0 : v1 [ v - 1 ] ; } } System . out . println ( Arrays . stream ( v2 ) . sum ( ) ) ; } static int [ ] in ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> gInt ( ) ) . sorted ( ) . toArray ( ) ; } }

import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = Integer . parseInt ( sc . next ( ) ) ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) b [ i ] = Integer . parseInt ( sc . next ( ) ) ; int [ ] c = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) c [ i ] = Integer . parseInt ( sc . next ( ) ) ; Arrays . sort ( a ) ; Arrays . sort ( b ) ; Arrays . sort ( c ) ; long ret = 0 ; int s = 0 , t = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { while ( s < n && c [ s ] <= b [ i ] ) s ++ ; while ( t < n - 1 && a [ t + 1 ] < b [ i ] ) t ++ ; ret += ( long ) ( n - s ) * ( t + 1 ) ; } System . out . println ( ret ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { int n = sc . nextInt ( ) ; Integer [ ] as = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextInt ( ) ; } Arrays . sort ( as ) ; Integer [ ] bs = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { bs [ i ] = sc . nextInt ( ) ; } Integer [ ] cs = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { cs [ i ] = sc . nextInt ( ) ; } Arrays . sort ( cs ) ; long ans = 0 ; for ( Integer b : bs ) { long ai = Arrays . binarySearch ( as , b , ( x , y ) -> ( x . compareTo ( y ) >= 0 ) ? 1 : - 1 ) ; ai = ~ ai ; long ci = Arrays . binarySearch ( cs , b , ( x , y ) -> ( x . compareTo ( y ) > 0 ) ? 1 : - 1 ) ; ci = ~ ci ; ans += ai * ( cs . length - ci ) ; } System . out . println ( ans ) ; } }

N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE c = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE sorted_a = sorted ( a ) NEW_LINE sorted_b = sorted ( b ) NEW_LINE sorted_c = sorted ( c ) NEW_LINE ans = 0 NEW_LINE before_a = 0 NEW_LINE before_c = 0 NEW_LINE count_a = 0 NEW_LINE count_c_rest = 0 NEW_LINE for each_b in sorted_b : NEW_LINE INDENT for ai in range ( before_a , len ( sorted_a ) ) : NEW_LINE INDENT if each_b > sorted_a [ ai ] : NEW_LINE INDENT count_a += 1 NEW_LINE before_a += 1 NEW_LINE DEDENT else : NEW_LINE INDENT before_a = ai NEW_LINE break NEW_LINE DEDENT DEDENT for ci in range ( before_c , len ( sorted_c ) ) : NEW_LINE INDENT if sorted_c [ ci ] <= each_b : NEW_LINE INDENT count_c_rest += 1 NEW_LINE before_c += 1 NEW_LINE DEDENT else : NEW_LINE INDENT before_c = ci NEW_LINE break NEW_LINE DEDENT DEDENT ans += count_a * ( len ( sorted_c ) - count_c_rest ) NEW_LINE DEDENT print ( ans ) NEW_LINE

def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE import bisect NEW_LINE N = int ( input ( ) ) NEW_LINE A = sorted ( inpl ( ) ) NEW_LINE B = inpl ( ) NEW_LINE C = sorted ( inpl ( ) ) NEW_LINE ans = 0 NEW_LINE for b in B : NEW_LINE INDENT ans += bisect . bisect_left ( A , b ) * ( N - bisect . bisect_right ( C , b ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE

II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE A , B , C = sorted ( list ( MI ( ) ) ) , sorted ( list ( MI ( ) ) ) , sorted ( list ( MI ( ) ) ) NEW_LINE s = [ i for i in range ( 1 , N + 1 ) ] NEW_LINE ia = N - 1 NEW_LINE ns = [ None ] * N NEW_LINE for ib in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT while ia >= 0 and A [ ia ] >= B [ ib ] : NEW_LINE INDENT ia -= 1 NEW_LINE DEDENT if ia >= 0 : NEW_LINE INDENT ns [ ib ] = s [ ia ] NEW_LINE DEDENT else : NEW_LINE INDENT ns [ ib ] = 0 NEW_LINE DEDENT DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT ns [ i ] += ns [ i - 1 ] NEW_LINE DEDENT s = ns NEW_LINE ib = N - 1 NEW_LINE ns = [ None ] * N NEW_LINE for ic in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT while ib >= 0 and B [ ib ] >= C [ ic ] : NEW_LINE INDENT ib -= 1 NEW_LINE DEDENT if ib >= 0 : NEW_LINE INDENT ns [ ic ] = s [ ib ] NEW_LINE DEDENT else : NEW_LINE INDENT ns [ ic ] = 0 NEW_LINE DEDENT DEDENT return sum ( ns ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT

from itertools import accumulate NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE B = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE C = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = sorted ( A ) NEW_LINE B = sorted ( B ) NEW_LINE C = sorted ( C ) NEW_LINE acc_a = [ 0 ] * N NEW_LINE acc_c = [ 0 ] * N NEW_LINE i_a = 0 NEW_LINE i_c = N - 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT b = B [ i ] NEW_LINE while i_a < N and A [ i_a ] < b : NEW_LINE INDENT acc_a [ i ] += 1 NEW_LINE i_a += 1 NEW_LINE DEDENT DEDENT for i in reversed ( range ( N ) ) : NEW_LINE INDENT b = B [ i ] NEW_LINE while i_c >= 0 and C [ i_c ] > b : NEW_LINE INDENT acc_c [ i ] += 1 NEW_LINE i_c -= 1 NEW_LINE DEDENT DEDENT acc_a = list ( accumulate ( acc_a ) ) NEW_LINE acc_c = list ( accumulate ( acc_c [ : : - 1 ] ) ) NEW_LINE acc_c = acc_c [ : : - 1 ] NEW_LINE ans = 0 NEW_LINE for a , c in zip ( acc_a , acc_c ) : NEW_LINE INDENT ans += a * c NEW_LINE DEDENT print ( ans ) NEW_LINE

N = int ( input ( ) ) NEW_LINE A = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE B = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE C = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE A = sorted ( A ) NEW_LINE B = sorted ( B ) NEW_LINE C = sorted ( C ) NEW_LINE ans = 0 NEW_LINE midnum = [ ] NEW_LINE index = 0 NEW_LINE for i in B : NEW_LINE INDENT while True : NEW_LINE INDENT if index == N or A [ index ] >= i : NEW_LINE INDENT midnum . append ( index ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT index += 1 NEW_LINE DEDENT DEDENT DEDENT index = 0 NEW_LINE midCnum = [ ] NEW_LINE tmp = 0 NEW_LINE for i in midnum : NEW_LINE INDENT tmp += i NEW_LINE midCnum . append ( tmp ) NEW_LINE DEDENT for i in C : NEW_LINE INDENT while True : NEW_LINE INDENT if index == N : NEW_LINE INDENT ans += midCnum [ index - 1 ] NEW_LINE break NEW_LINE DEDENT elif i <= B [ index ] : NEW_LINE INDENT if index != 0 : NEW_LINE INDENT ans += midCnum [ index - 1 ] NEW_LINE DEDENT break NEW_LINE DEDENT else : NEW_LINE INDENT index += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; System . out . println ( sc . next ( ) . replaceAll ( a , " " ) ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String c = in . next ( ) ; out . println ( in . next ( ) . replaceAll ( c , " " ) ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String X = in . next ( ) ; String s = in . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! X . equals ( s . substring ( i , i + 1 ) ) ) { out . print ( s . charAt ( i ) ) ; } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . io . * ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 <= args . length ; debug2 = 2 <= args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; final String X = in . readLine ( ) ; System . out . println ( in . readLine ( ) . replaceAll ( X , " " ) ) ; } }

import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; char x = sc . next ( ) . charAt ( 0 ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != x ) out . print ( s . charAt ( i ) ) ; } out . println ( ) ; } }

X = input ( ) NEW_LINE s = input ( ) NEW_LINE result = " " . join ( [ c for c in s if c not in X ] ) NEW_LINE print ( result ) NEW_LINE

x , c = input ( ) , input ( ) NEW_LINE ans = " " NEW_LINE for i in range ( len ( c ) ) : NEW_LINE INDENT if c [ i ] != x : ans += c [ i ] NEW_LINE DEDENT print ( ans ) NEW_LINE

s = input ( ) ; print ( input ( ) . replace ( s , " " ) ) NEW_LINE

X = input ( ) NEW_LINE s = [ str ( _ ) for _ in input ( ) ] NEW_LINE Res = [ ] NEW_LINE for i in s : NEW_LINE INDENT if X == i : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT Res . append ( i ) NEW_LINE DEDENT DEDENT print ( " " . join ( Res ) ) NEW_LINE

import sys NEW_LINE import copy NEW_LINE input = sys . stdin . readline NEW_LINE c = input ( ) . rstrip ( ) NEW_LINE s = input ( ) . rstrip ( ) NEW_LINE print ( s . replace ( c , " " ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; String s = " EQUAL " ; if ( a . length ( ) > b . length ( ) ) { System . out . println ( " GREATER " ) ; System . exit ( 0 ) ; } if ( a . length ( ) < b . length ( ) ) { System . out . println ( " LESS " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) > b . charAt ( i ) ) { s = " GREATER " ; break ; } if ( a . charAt ( i ) < b . charAt ( i ) ) { s = " LESS " ; break ; } } System . out . println ( s ) ; System . exit ( 0 ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { BigInteger A = new BigInteger ( in . next ( ) ) ; BigInteger B = new BigInteger ( in . next ( ) ) ; out . println ( A . compareTo ( B ) > 0 ? " GREATER " : A . compareTo ( B ) == 0 ? " EQUAL " : " LESS " ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter out = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; String a = input . readLine ( ) ; String b = input . readLine ( ) ; String s = null ; if ( a . length ( ) < b . length ( ) ) s = " LESS " ; else if ( a . length ( ) > b . length ( ) ) s = " GREATER " ; else { for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) > b . charAt ( i ) ) { s = " GREATER " ; break ; } else if ( a . charAt ( i ) < b . charAt ( i ) ) { s = " LESS " ; break ; } } } if ( s == null ) s = " EQUAL " ; out . write ( s ) ; out . write ( " \n " ) ; out . close ( ) ; } }

import java . math . BigInteger ; import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String a = sc . next ( ) , b = sc . next ( ) ; int comp = new BigInteger ( a ) . compareTo ( new BigInteger ( b ) ) ; if ( comp < 0 ) { System . out . println ( " LESS " ) ; } else if ( comp == 0 ) { System . out . println ( " EQUAL " ) ; } else { System . out . println ( " GREATER " ) ; } } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; String ans ; int la = a . length ( ) ; int lb = b . length ( ) ; if ( la > lb ) { ans = " GREATER " ; } else if ( la < lb ) { ans = " LESS " ; } else { if ( a . compareTo ( b ) < 0 ) { ans = " LESS " ; } else if ( a . compareTo ( b ) > 0 ) { ans = " GREATER " ; } else { ans = " EQUAL " ; } } System . out . println ( ans ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( " GREATER " if a > b else " LESS " if a < b else " EQUAL " ) NEW_LINE

import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE a = list ( ns ( ) ) NEW_LINE b = list ( ns ( ) ) NEW_LINE if len ( a ) > len ( b ) : NEW_LINE INDENT print ( ' GREATER ' ) NEW_LINE DEDENT elif len ( a ) < len ( b ) : NEW_LINE INDENT print ( ' LESS ' ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( len ( a ) ) : NEW_LINE INDENT if a [ i ] > b [ i ] : NEW_LINE INDENT print ( ' GREATER ' ) NEW_LINE exit ( ) NEW_LINE DEDENT elif a [ i ] < b [ i ] : NEW_LINE INDENT print ( ' LESS ' ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( ' EQUAL ' ) NEW_LINE DEDENT

a , b = map ( int , open ( 0 ) ) ; print ( [ ' ELQEUSASL ' [ a < b : : 2 ] , ' GREATER ' ] [ a > b ] ) NEW_LINE

A , B = int ( input ( ) ) , int ( input ( ) ) NEW_LINE if A == B : NEW_LINE INDENT ans = ' EQUAL ' NEW_LINE DEDENT elif A < B : NEW_LINE INDENT ans = ' LESS ' NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' GREATER ' NEW_LINE DEDENT print ( ans ) NEW_LINE

from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a = int ( input ( ) . rstrip ( ) ) NEW_LINE b = int ( input ( ) . rstrip ( ) ) NEW_LINE if a > b : NEW_LINE INDENT print ( ' GREATER ' ) NEW_LINE DEDENT elif b > a : NEW_LINE INDENT print ( ' LESS ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' EQUAL ' ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; String a [ ] = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . next ( ) ; } Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { set . add ( a [ i ] ) ; } if ( set . size ( ) == 4 ) { System . out . println ( " Four " ) ; } else { System . out . println ( " Three " ) ; } sc . close ( ) ; } }

import java . io . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; stdin . readLine ( ) ; long cnt = Arrays . stream ( stdin . readLine ( ) . split ( " ▁ " ) ) . sorted ( ) . distinct ( ) . count ( ) ; String ans = cnt == 3 ? " Three " : " Four " ; System . out . println ( ans ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { boolean P = false ; boolean W = false ; boolean G = false ; boolean Y = false ; int n = sc . nextInt ( ) ; String s ; for ( int i = 0 ; i < n ; i ++ ) { s = sc . next ( ) ; if ( s . equals ( " P " ) ) { P = true ; } else if ( s . equals ( " W " ) ) { W = true ; } else if ( s . equals ( " G " ) ) { G = true ; } else { Y = true ; } } int count = 0 ; if ( P == true ) { count ++ ; } if ( W == true ) { count ++ ; } if ( G == true ) { count ++ ; } if ( Y == true ) { count ++ ; } out . println ( count == 4 ? " Four " : " Three " ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; String ans = " Three " ; for ( int i = 0 ; i < N ; i ++ ) { char ch = reader . next ( ) . charAt ( 0 ) ; if ( ch == ' Y ' ) { ans = " Four " ; } } System . out . print ( ans ) ; reader . close ( ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; String [ ] charac = { " P " , " W " , " G " , " Y " } ; boolean [ ] state = new boolean [ 4 ] ; String h ; for ( int i = 0 ; i < n ; i ++ ) { h = tokenizer . nextToken ( ) ; for ( int j = 0 ; j < 4 ; j ++ ) { if ( h . equals ( charac [ j ] ) ) { state [ j ] = true ; break ; } } } System . out . println ( state [ 3 ] ? " Four " : " Three " ) ; } }

N = int ( input ( ) ) NEW_LINE a = list ( input ( ) . split ( ) ) NEW_LINE if ( " Y " in a ) : NEW_LINE INDENT print ( " Four " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " Three " ) NEW_LINE DEDENT

input ( ) ; print ( ' TFhoruere ' [ ' Y ' in input ( ) : : 2 ] ) NEW_LINE

n = int ( input ( ) ) NEW_LINE arr = list ( map ( str , input ( ) . split ( ) ) ) NEW_LINE count = 0 NEW_LINE if arr . count ( ' P ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if arr . count ( ' Y ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if arr . count ( ' W ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if arr . count ( ' G ' ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if count == 3 : NEW_LINE INDENT print ( ' Three ' ) NEW_LINE DEDENT if count == 4 : NEW_LINE INDENT print ( ' Four ' ) NEW_LINE DEDENT

N = input ( ) NEW_LINE S = list ( set ( list ( input ( ) . split ( ) ) ) ) NEW_LINE ans = len ( S ) NEW_LINE if ( ans == 3 ) : NEW_LINE INDENT print ( " Three " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " Four " ) NEW_LINE DEDENT

n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE print ( ' Four ' if ' Y ' in s else ' Three ' ) NEW_LINE


import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; int [ ] sum = new int [ n + 1 ] ; long ans = 0 ; sum [ 0 ] = 0 ; map . put ( 0 , 1 ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) { sum [ i ] = ( sum [ i - 1 ] + sc . nextInt ( ) ) % m ; if ( ! map . containsKey ( sum [ i ] ) ) { map . put ( sum [ i ] , 1 ) ; } else { map . put ( sum [ i ] , map . get ( sum [ i ] ) + 1 ) ; } ans += map . get ( sum [ i ] ) - 1 ; } System . out . println ( ans ) ; } }

import java . util . HashMap ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long [ ] sum = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { sum [ i ] = a [ i ] + sum [ i - 1 ] ; } HashMap < Long , Integer > map = new HashMap < Long , Integer > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { map . put ( sum [ i ] % m , 0 ) ; } for ( int i = 1 ; i <= n ; i ++ ) { int x = map . get ( sum [ i ] % m ) ; map . put ( sum [ i ] % m , x + 1 ) ; } long ans = 0 ; if ( map . containsKey ( 0l ) ) { ans = map . get ( 0l ) ; } for ( long i : map . keySet ( ) ) { if ( map . get ( i ) >= 2 ) { for ( int j = map . get ( i ) ; j > 1 ; j -- ) { ans += j - 1 ; } } } System . out . println ( ans ) ; } } class Pair implements Comparable { int from ; int end ; int num ; int bango ; @ Override public int compareTo ( Object other ) { Pair otherpair = ( Pair ) other ; return from - otherpair . from ; } }

import java . util . * ; import java . io . * ; class Main { public static void main ( String ... args ) { int N = IN . nextInt ( ) ; int M = IN . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = IN . nextInt ( ) ; } HashMap < Integer , Integer > B = new HashMap < > ( ) ; B . put ( 0 , 1 ) ; long ans = 0 ; int tot = 0 ; for ( int a : A ) { tot = ( tot + a ) % M ; int tmp = B . getOrDefault ( tot , 0 ) ; ans += ( long ) tmp ; B . put ( tot , tmp + 1 ) ; } puts ( ans ) ; flush ( ) ; } static final Scanner IN = new Scanner ( System . in ) ; static final PrintWriter OUT = new PrintWriter ( System . out ) ; static < T > void puts ( T arg ) { OUT . println ( arg ) ; } static void flush ( ) { OUT . flush ( ) ; } }

import java . util . Scanner ; import java . util . HashMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long m = sc . nextLong ( ) ; long [ ] a = new long [ n ] ; HashMap < Long , Integer > map = new HashMap < > ( ) ; long ans = 0 ; a [ 0 ] = sc . nextLong ( ) ; for ( int i = 1 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) + a [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( map . containsKey ( a [ i ] % m ) ) { map . put ( a [ i ] % m , map . get ( a [ i ] % m ) + 1 ) ; } else { map . put ( a [ i ] % m , 1 ) ; } } for ( long i : map . keySet ( ) ) { long q = map . get ( i ) ; if ( i == 0 ) { ans += q ; } ans += ( q * ( q - 1 ) ) / 2 ; } System . out . println ( ans ) ; } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; long sum [ ] = new long [ N + 1 ] ; int A [ ] = new int [ N + 1 ] ; A [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; sum [ 0 ] = 0 ; sum [ 1 ] = A [ 1 ] ; map . put ( ( int ) ( sum [ 1 ] % M ) , 1 ) ; for ( int i = 2 ; i <= N ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; sum [ i ] = sum [ i - 1 ] + A [ i ] ; int mod = ( int ) ( sum [ i ] % M ) ; if ( map . containsKey ( mod ) ) { map . put ( mod , map . get ( mod ) + 1 ) ; } else { map . put ( mod , 1 ) ; } } long ans = 0 ; Iterator < Map . Entry < Integer , Integer > > it = map . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Map . Entry < Integer , Integer > mapEntry = it . next ( ) ; long temp = 0 ; if ( mapEntry . getKey ( ) == 0 ) { for ( long i = mapEntry . getValue ( ) ; i > 0 ; i -- ) { temp += i ; } } else { for ( long i = mapEntry . getValue ( ) - 1 ; i > 0 ; i -- ) { temp += i ; } } if ( temp != 0 || mapEntry . getKey ( ) == 0 ) { ans += temp ; } } System . out . println ( ans ) ; } }

from itertools import accumulate as ac NEW_LINE from collections import Counter as c NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = 0 NEW_LINE for i in c ( [ i % m for i in [ 0 ] + list ( ac ( list ( map ( int , input ( ) . split ( ) ) ) ) ) ] ) . values ( ) : NEW_LINE INDENT a += i * ( i - 1 ) // 2 NEW_LINE DEDENT print ( a ) NEW_LINE

import sys NEW_LINE import heapq NEW_LINE input = sys . stdin . readline NEW_LINE N , M = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE SUM = [ 0 ] NEW_LINE mp = { } NEW_LINE res = 0 NEW_LINE for i in range ( len ( A ) ) : NEW_LINE INDENT SUM . append ( A [ i ] + SUM [ i ] ) NEW_LINE DEDENT for i in range ( len ( SUM ) ) : NEW_LINE INDENT SUM [ i ] = SUM [ i ] % M NEW_LINE if not SUM [ i ] in mp : NEW_LINE INDENT mp . update ( { SUM [ i ] : 0 } ) NEW_LINE DEDENT else : NEW_LINE INDENT mp . update ( { SUM [ i ] : mp [ SUM [ i ] ] + 1 } ) NEW_LINE DEDENT res = res + mp [ SUM [ i ] ] NEW_LINE DEDENT print ( res ) NEW_LINE

import sys NEW_LINE import itertools NEW_LINE import collections NEW_LINE import functools NEW_LINE import math NEW_LINE from queue import Queue NEW_LINE INF = float ( " inf " ) NEW_LINE from operator import mul NEW_LINE from functools import reduce NEW_LINE def cmb ( n , r ) : NEW_LINE INDENT r = min ( n - r , r ) NEW_LINE if r == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT numer = reduce ( mul , range ( n , n - r , - 1 ) ) NEW_LINE denom = reduce ( mul , range ( 1 , r + 1 ) ) NEW_LINE return numer // denom NEW_LINE DEDENT def solve ( N : int , M : int , A : " List [ int ] " ) : NEW_LINE INDENT B = itertools . accumulate ( A ) NEW_LINE c = collections . Counter ( ) NEW_LINE for b in B : NEW_LINE INDENT c [ b % M ] += 1 NEW_LINE DEDENT print ( c [ 0 ] + sum ( [ cmb ( c [ k ] , 2 ) for k in c if c [ k ] > 1 ] ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE M = int ( next ( tokens ) ) NEW_LINE A = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , M , A ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

def main ( ) : NEW_LINE INDENT N , M = [ int ( n ) for n in input ( ) . split ( ) ] NEW_LINE A = [ int ( n ) for n in input ( ) . split ( ) ] NEW_LINE B = [ 0 ] * ( N + 1 ) NEW_LINE B [ 0 ] = 0 NEW_LINE d = { } NEW_LINE accum = 0 NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT B [ i ] = accum NEW_LINE if i != N : NEW_LINE INDENT accum += A [ i ] NEW_LINE DEDENT DEDENT for i , b in enumerate ( B ) : NEW_LINE INDENT x = b % M NEW_LINE if x in d . keys ( ) : NEW_LINE INDENT d [ x ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT d [ x ] = 1 NEW_LINE DEDENT DEDENT print ( sum ( [ i * ( i - 1 ) // 2 for i in d . values ( ) ] ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

def d_candy_distribution ( N , M , A ) : NEW_LINE INDENT import itertools NEW_LINE import collections NEW_LINE remainders = collections . defaultdict ( int ) NEW_LINE for t in [ 0 ] + list ( itertools . accumulate ( A ) ) : NEW_LINE INDENT remainders [ t % M ] += 1 NEW_LINE DEDENT return sum ( [ v * ( v - 1 ) // 2 for v in remainders . values ( ) if v >= 2 ] ) NEW_LINE DEDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( d_candy_distribution ( N , M , A ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int total = scanner . nextInt ( ) ; int sum = 0 ; for ( int ix = 1 ; ix <= total ; ix ++ ) { sum += ix ; } System . out . println ( sum ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int N = keyboard . nextInt ( ) ; int ame = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { ame += i ; } System . out . println ( ame ) ; keyboard . close ( ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; System . out . println ( N * ( 1 + N ) / 2 ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; long res = 0 ; for ( int i = 1 ; i <= n ; i ++ ) res += i ; System . out . println ( res ) ; sc . close ( ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; System . out . println ( n * ( n + 1 ) / 2 ) ; } } }

N = int ( input ( ) ) NEW_LINE print ( int ( ( 1 + N ) * N / 2 ) ) NEW_LINE

def children_and_candies ( N : int ) -> int : NEW_LINE INDENT return N * ( N + 1 ) // 2 NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ans = children_and_candies ( N ) NEW_LINE print ( ans ) NEW_LINE DEDENT

from sys import stdin NEW_LINE n = int ( stdin . readline ( ) . rstrip ( ) ) NEW_LINE total = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT total += i NEW_LINE DEDENT print ( total ) NEW_LINE

print ( sum ( [ n for n in range ( 1 , int ( input ( ) ) + 1 ) ] ) ) NEW_LINE

n = input ( ) NEW_LINE n = int ( n ) NEW_LINE a = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT a = a + i NEW_LINE DEDENT print ( a ) NEW_LINE


import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] p = { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 } ; int [ ] pTotal = new int [ p . length ] ; for ( int i = 0 ; i < p . length ; i ++ ) pTotal [ i ] = legendre ( N , p [ i ] ) ; int ans = 0 ; for ( int i = 0 ; i < p . length ; i ++ ) { if ( pTotal [ i ] >= 74 ) ans ++ ; } for ( int i = 0 ; i < p . length ; i ++ ) { for ( int j = 0 ; j < p . length ; j ++ ) { if ( i != j && pTotal [ i ] >= 2 && pTotal [ j ] >= 24 ) ans ++ ; } } for ( int i = 0 ; i < p . length ; i ++ ) { for ( int j = 0 ; j < p . length ; j ++ ) { if ( i != j && pTotal [ i ] >= 4 && pTotal [ j ] >= 14 ) ans ++ ; } } int plus = 0 ; for ( int i = 0 ; i < p . length ; i ++ ) { for ( int j = 0 ; j < p . length ; j ++ ) { for ( int k = 0 ; k < p . length ; k ++ ) { if ( i != j && j != k && k != i && pTotal [ i ] >= 2 && pTotal [ j ] >= 4 && pTotal [ k ] >= 4 ) plus ++ ; } } } ans += plus / 2 ; System . out . println ( ans ) ; } static int legendre ( int n , int p ) { int c = 0 ; int m = p ; while ( m <= n ) { c += n / m ; m *= p ; } return c ; } }

import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . HashMap ; @ SuppressWarnings ( " unchecked " ) public class Main { static HashMap < Integer , Integer > pf ; static void primeFactor ( int n ) { int a = 2 ; while ( a * a <= n ) { if ( n % a == 0 ) { pf . merge ( a , 1 , Integer :: sum ) ; n = n / a ; } else { a ++ ; } } pf . merge ( n , 1 , Integer :: sum ) ; } static int f ( int x ) { int cnt = 0 ; for ( Integer i : pf . values ( ) ) if ( x - 1 <= i ) cnt ++ ; return cnt ++ ; } public static void main ( String [ ] args ) throws IOException { final String s ; try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { s = reader . readLine ( ) ; } PrintWriter out = new PrintWriter ( System . out ) ; final String [ ] sl = s . split ( " ▁ " ) ; int N = Integer . parseInt ( sl [ 0 ] ) ; pf = new HashMap < > ( ) ; for ( int i = 2 ; i < N + 1 ; i ++ ) primeFactor ( i ) ; int ans = f ( 75 ) + f ( 25 ) * ( f ( 3 ) - 1 ) + f ( 15 ) * ( f ( 5 ) - 1 ) + f ( 5 ) * ( f ( 5 ) - 1 ) * ( f ( 3 ) - 2 ) / 2 ; out . println ( ans ) ; out . flush ( ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; HashMap < Integer , Integer > primeCount = new HashMap < > ( ) ; primeCount . put ( 1 , 1 ) ; for ( int i = 2 ; i <= N ; i ++ ) { int value = i ; for ( int j = 2 ; j <= i ; j ++ ) { while ( value % j == 0 ) { primeCount . put ( j , primeCount . containsKey ( j ) ? primeCount . get ( j ) + 1 : 1 ) ; value = value / j ; } } } int ans = 0 ; for ( Map . Entry < Integer , Integer > entry0 : primeCount . entrySet ( ) ) { for ( Map . Entry < Integer , Integer > entry1 : primeCount . entrySet ( ) ) { for ( Map . Entry < Integer , Integer > entry2 : primeCount . entrySet ( ) ) { if ( entry0 . getKey ( ) == entry1 . getKey ( ) ) continue ; if ( entry0 . getKey ( ) == entry2 . getKey ( ) ) continue ; if ( entry1 . getKey ( ) == entry2 . getKey ( ) ) continue ; if ( entry1 . getKey ( ) > entry2 . getKey ( ) ) continue ; if ( entry0 . getValue ( ) >= 2 && entry1 . getValue ( ) >= 4 && entry2 . getValue ( ) >= 4 ) ans ++ ; } } } for ( Map . Entry < Integer , Integer > entry0 : primeCount . entrySet ( ) ) { for ( Map . Entry < Integer , Integer > entry1 : primeCount . entrySet ( ) ) { if ( entry0 . getKey ( ) == entry1 . getKey ( ) ) continue ; if ( entry0 . getValue ( ) >= 4 && entry1 . getValue ( ) >= 14 ) ans ++ ; if ( entry0 . getValue ( ) >= 2 && entry1 . getValue ( ) >= 24 ) ans ++ ; } } for ( Integer count : primeCount . values ( ) ) { if ( count >= 74 ) ans ++ ; } System . out . println ( ans ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; sc . close ( ) ; int [ ] P = new int [ 48 ] ; int over74 = 0 ; int over24 = 0 ; int over14 = 0 ; int over4 = 0 ; int over2 = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { int x = i ; for ( int j = 2 ; j < Math . min ( N , 48 ) ; j ++ ) { while ( x % j == 0 ) { x /= j ; P [ j ] ++ ; } } } for ( int p : P ) { if ( p > 1 ) over2 ++ ; if ( p > 3 ) over4 ++ ; if ( p > 13 ) over14 ++ ; if ( p > 23 ) over24 ++ ; if ( p > 73 ) over74 ++ ; } int ans = 0 ; ans += over74 ; if ( over14 > 0 && over4 > 1 ) ans += over14 * ( over4 - 1 ) ; if ( over24 > 0 && over2 > 1 ) ans += over24 * ( over2 - 1 ) ; if ( over4 > 1 && over2 > 2 ) ans += ( over4 * ( over4 - 1 ) / 2 ) * ( over2 - 2 ) ; System . out . println ( ans ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean [ ] pr = new boolean [ N + 1 ] ; int count = 0 ; for ( int i = 2 ; i < N + 1 ; i ++ ) pr [ i ] = true ; for ( int i = 2 ; i < N + 1 ; i ++ ) { if ( pr [ i ] ) { count ++ ; for ( int j = 2 * i ; j < N + 1 ; j += i ) pr [ j ] = false ; } } final int C = count ; int [ ] prn = new int [ C ] ; int id = 0 ; for ( int i = 0 ; i < N + 1 ; i ++ ) { if ( pr [ i ] ) { int b = i ; while ( b <= N ) { prn [ id ] += N / b ; b *= i ; } id ++ ; } } int ans = 0 ; for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { for ( int k = j + 1 ; k < C ; k ++ ) { if ( i != j && i != k && prn [ i ] >= 2 && prn [ j ] >= 4 && prn [ k ] >= 4 ) ans ++ ; } } } for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( i != j && prn [ i ] >= 2 && prn [ j ] >= 24 ) ans ++ ; } } for ( int i = 0 ; i < C ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( i != j && prn [ i ] >= 4 && prn [ j ] >= 14 ) ans ++ ; } } if ( C > 0 && prn [ 0 ] >= 74 ) ans ++ ; System . out . println ( ans ) ; } }

import math NEW_LINE from collections import Counter NEW_LINE import itertools NEW_LINE def prime_factors ( n ) : NEW_LINE INDENT i = 2 NEW_LINE factors = [ ] NEW_LINE while i * i <= n : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT n //= i NEW_LINE factors . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT i += 1 NEW_LINE DEDENT DEDENT if n > 1 : NEW_LINE INDENT factors . append ( n ) NEW_LINE DEDENT return factors NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE num = math . factorial ( n ) NEW_LINE factors = prime_factors ( num ) NEW_LINE es = list ( Counter ( factors ) . values ( ) ) NEW_LINE m = len ( es ) NEW_LINE ans = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT if es [ i ] >= 74 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( m ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if i != j and es [ i ] >= 24 and es [ j ] >= 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( m ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if i != j and es [ i ] >= 14 and es [ j ] >= 4 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( m ) : NEW_LINE INDENT for j in range ( i + 1 , m ) : NEW_LINE INDENT for k in range ( m ) : NEW_LINE INDENT if i != k and j != k and es [ i ] >= 4 and es [ j ] >= 4 and es [ k ] >= 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE

import bisect NEW_LINE from math import factorial as fact NEW_LINE import sys NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE prime = [ ] NEW_LINE p_flag = [ False ] * ( 101 ) NEW_LINE p_flag [ 0 ] = p_flag [ 1 ] = True NEW_LINE for i in range ( 2 , 101 ) : NEW_LINE INDENT if not p_flag [ i ] : NEW_LINE INDENT prime . append ( i ) NEW_LINE for j in range ( 2 * i , 101 , i ) : NEW_LINE INDENT p_flag [ j ] = True NEW_LINE DEDENT DEDENT DEDENT M = len ( prime ) NEW_LINE factor = [ 0 ] * M NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT for j in range ( M ) : NEW_LINE INDENT tmp = prime [ j ] NEW_LINE if tmp > i : NEW_LINE INDENT break NEW_LINE DEDENT while i % tmp == 0 : NEW_LINE INDENT factor [ j ] += 1 NEW_LINE tmp *= prime [ j ] NEW_LINE DEDENT DEDENT DEDENT factor = factor [ : : - 1 ] NEW_LINE point74 = M - bisect . bisect_left ( factor , 74 ) NEW_LINE point24 = M - bisect . bisect_left ( factor , 24 ) NEW_LINE point14 = M - bisect . bisect_left ( factor , 14 ) NEW_LINE point4 = M - bisect . bisect_left ( factor , 4 ) NEW_LINE point2 = M - bisect . bisect_left ( factor , 2 ) NEW_LINE if N < 10 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT ans = fact ( point4 ) // ( fact ( point4 - 2 ) * fact ( 2 ) ) * ( point2 - 2 ) NEW_LINE if point14 > 0 : NEW_LINE INDENT ans += point14 * ( point4 - 1 ) NEW_LINE DEDENT if point24 > 0 : NEW_LINE INDENT ans += point24 * ( point2 - 1 ) NEW_LINE DEDENT if point74 > 0 : NEW_LINE INDENT ans += point74 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

primes = [ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 ] NEW_LINE def get_prime ( n , count = { p : 0 for p in primes } ) : NEW_LINE INDENT for p in primes : NEW_LINE INDENT cp = n NEW_LINE while cp != 0 and cp % p == 0 : NEW_LINE INDENT count [ p ] += 1 NEW_LINE cp = cp // p NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT cnt = { p : 0 for p in primes } NEW_LINE for i in range ( 1 , int ( input ( ) ) + 1 ) : NEW_LINE INDENT get_prime ( i , cnt ) NEW_LINE DEDENT res = 0 NEW_LINE for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 4 : NEW_LINE INDENT for p2 in primes : NEW_LINE INDENT if cnt [ p2 ] >= 4 and p1 > p2 : NEW_LINE INDENT for p3 in primes : NEW_LINE INDENT if cnt [ p3 ] >= 2 and p3 != p1 and p3 != p2 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 14 : NEW_LINE INDENT for p2 in primes : NEW_LINE INDENT if cnt [ p2 ] >= 4 and p1 != p2 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 24 : NEW_LINE INDENT for p2 in primes : NEW_LINE INDENT if cnt [ p2 ] >= 2 and p1 != p2 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for p1 in primes : NEW_LINE INDENT if cnt [ p1 ] >= 74 : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def POW ( x , y ) : NEW_LINE INDENT if y == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif y == 1 : NEW_LINE INDENT return x NEW_LINE DEDENT elif y % 2 == 0 : NEW_LINE INDENT return POW ( x , y // 2 ) ** 2 % MOD NEW_LINE DEDENT else : NEW_LINE INDENT return POW ( x , y // 2 ) ** 2 * x % MOD NEW_LINE DEDENT DEDENT def mod_factorial ( x , y ) : return x * POW ( y , MOD - 2 ) % MOD NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from collections import Counter NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE factors = Counter ( ) NEW_LINE for k in range ( 1 , N + 1 ) : NEW_LINE INDENT for i in ( 2 , 3 , 5 , 7 ) : NEW_LINE INDENT while k % i == 0 : NEW_LINE INDENT factors [ i ] += 1 NEW_LINE k //= i NEW_LINE DEDENT DEDENT if k != 1 : NEW_LINE INDENT factors [ k ] += 1 NEW_LINE DEDENT DEDENT nfactors = sorted ( factors . values ( ) ) NEW_LINE ans = 0 NEW_LINE dp = [ 0 ] * 76 NEW_LINE dp [ 1 ] = 1 NEW_LINE for cnt in nfactors : NEW_LINE INDENT pre = dp NEW_LINE dp = [ 0 ] * 76 NEW_LINE for c in range ( 1 , cnt + 2 ) : NEW_LINE INDENT for k in range ( 75 // c + 1 ) : NEW_LINE INDENT dp [ k * c ] += pre [ k ] NEW_LINE DEDENT DEDENT DEDENT ans = dp [ 75 ] NEW_LINE return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

import itertools NEW_LINE from operator import mul NEW_LINE from functools import reduce NEW_LINE N = int ( input ( ) ) NEW_LINE F = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT F = F * i NEW_LINE DEDENT pns = [ ] NEW_LINE for n in range ( 2 , N + 1 ) : NEW_LINE INDENT for pn in pns : NEW_LINE INDENT if n % pn == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT pns . append ( n ) NEW_LINE DEDENT DEDENT c = 0 NEW_LINE for num in pns : NEW_LINE INDENT if F % num ** 74 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for nums in itertools . combinations ( pns , 2 ) : NEW_LINE INDENT y1 = nums [ 0 ] ** 14 * nums [ 1 ] ** 4 NEW_LINE y2 = nums [ 1 ] ** 14 * nums [ 0 ] ** 4 NEW_LINE z1 = nums [ 0 ] ** 24 * nums [ 1 ] ** 2 NEW_LINE z2 = nums [ 1 ] ** 24 * nums [ 0 ] ** 2 NEW_LINE if F % y1 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT if F % y2 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT if F % z1 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT if F % z2 == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT for nums in itertools . combinations ( pns , 3 ) : NEW_LINE INDENT for num in nums : NEW_LINE INDENT num_except = [ n for n in nums if n != num ] NEW_LINE x = num ** 2 * ( num_except [ 0 ] * num_except [ 1 ] ) ** 4 NEW_LINE if F % x == 0 : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT DEDENT print ( c ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String args [ ] ) { ConsoleScanner cin = new ConsoleScanner ( ) ; PrintWriter cout = new PrintWriter ( System . out ) ; solve ( cin , cout ) ; cout . flush ( ) ; } static long now ( ) { return System . currentTimeMillis ( ) ; } static void trace ( Object ... objects ) { assert null != System . out . format ( " trace : % s \n " , Arrays . deepToString ( objects ) ) ; } private static void solve ( ConsoleScanner cin , PrintWriter cout ) { int n = cin . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < a . length ; i ++ ) a [ i ] = cin . nextInt ( ) ; long start = now ( ) ; long ans = solve ( n , a ) ; cout . println ( ans ) ; trace ( " elapsed " , now ( ) - start ) ; } private static long solve ( int n , int [ ] a ) { long total = Arrays . stream ( a ) . mapToLong ( x -> x ) . sum ( ) ; long ans = Long . MAX_VALUE ; long s = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { s += a [ i ] ; ans = Math . min ( ans , Math . abs ( total - 2 * s ) ) ; } return ans ; } static class ConsoleScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { try { while ( ! st . hasMoreElements ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } catch ( IOException e ) { throw new AssertionError ( e ) ; } } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . util . * ; public class Main { private static long solve ( Scanner scanner ) { int N = Integer . parseInt ( scanner . nextLine ( ) ) ; long [ ] a = lineToNums ( scanner . nextLine ( ) ) ; long sumAll = Arrays . stream ( a ) . sum ( ) ; long [ ] xSum = new long [ N ] ; long [ ] ySum = new long [ N ] ; xSum [ 0 ] = a [ 0 ] ; ySum [ 0 ] = sumAll - xSum [ 0 ] ; long ret = Math . abs ( xSum [ 0 ] - ySum [ 0 ] ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { xSum [ i ] = xSum [ i - 1 ] + a [ i ] ; ySum [ i ] = sumAll - xSum [ i ] ; ret = Math . min ( ret , Math . abs ( xSum [ i ] - ySum [ i ] ) ) ; } return ret ; } private static final String ex1 = "6 \n " + "1 ▁ 2 ▁ 3 ▁ 4 ▁ 5 ▁ 6" ; private static final String ex2 = "2 \n " + "10 ▁ - 10" ; public static void main ( String [ ] args ) { System . out . println ( solve ( new Scanner ( System . in ) ) ) ; } private static long [ ] lineToNums ( String line ) { String [ ] strNums = line . split ( " ▁ " ) ; long [ ] ret = new long [ strNums . length ] ; for ( int i = 0 ; i < strNums . length ; i ++ ) { ret [ i ] = Long . parseLong ( strNums [ i ] ) ; } return ret ; } }

import java . io . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String c = stdReader . readLine ( ) ; String vals = stdReader . readLine ( ) ; long [ ] ls = new long [ Integer . valueOf ( c ) ] ; String [ ] ss = vals . split ( " ▁ " ) ; long total = 0 ; long [ ] sunu = new long [ Integer . valueOf ( c ) ] ; for ( int i = 0 ; i < ls . length ; i ++ ) { long v = Long . valueOf ( ss [ i ] ) ; ls [ i ] = v ; total += v ; sunu [ i ] = total ; } long min = 0 ; for ( int i = 0 ; i < ls . length - 1 ; i ++ ) { long arai = total - sunu [ i ] ; long current = Math . abs ( arai - sunu [ i ] ) ; if ( i == 0 ) { min = current ; } min = Math . min ( min , current ) ; } System . out . println ( min ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyReader in = new MyReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , MyReader in , PrintWriter out ) { int N = in . nextInt ( ) ; long [ ] a = new long [ N ] ; long tot = 0 ; long [ ] s = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = in . nextLong ( ) ; tot += a [ i ] ; s [ i ] = tot ; } long d = Long . MAX_VALUE ; for ( int i = 0 ; i < N - 1 ; i ++ ) { d = Math . min ( d , Math . abs ( s [ i ] - ( tot - s [ i ] ) ) ) ; } out . println ( d ) ; } } static class MyReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public MyReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . util . Scanner ; public class Main { private static long x = 0 ; private static long y = 0 ; private static int N ; private static int a [ ] ; private static long ans ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } } public static void main ( String args [ ] ) { input ( ) ; x = a [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { y += a [ i ] ; } ans = Math . abs ( x - y ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { x += a [ i ] ; y -= a [ i ] ; ans = Math . min ( Math . abs ( x - y ) , ans ) ; } System . out . println ( ans ) ; } }

def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE import numpy as np NEW_LINE ans = float ( ' inf ' ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = np . cumsum ( np . array ( inpl ( ) ) ) NEW_LINE suma = a [ - 1 ] NEW_LINE a = np . delete ( a , - 1 ) NEW_LINE for i in a : NEW_LINE INDENT ans = min ( ans , abs ( suma - 2 * i ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE

n = int ( input ( ) ) ; a = list ( map ( int , input ( ) . split ( ) ) ) ; b = [ 0 ] NEW_LINE for i in a : b . append ( b [ - 1 ] + i ) NEW_LINE b = b [ 1 : ] ; s = b [ - 1 ] ; mi = abs ( b [ 0 ] - ( b [ - 1 ] - b [ 0 ] ) ) NEW_LINE for i in range ( n - 1 ) : mi = min ( abs ( b [ i ] - ( b [ - 1 ] - b [ i ] ) ) , mi ) NEW_LINE print ( mi ) NEW_LINE

from numpy import * ; n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; print ( min ( abs ( cumsum ( a [ : : - 1 ] ) [ : : - 1 ] - cumsum ( [ 0 ] + a [ : - 1 ] ) ) [ 1 : ] ) ) NEW_LINE

def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE def getIntLines ( n ) : return [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE def getIntMat ( n ) : NEW_LINE INDENT mat = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT mat . append ( getIntList ( ) ) NEW_LINE DEDENT return mat NEW_LINE DEDENT def zeros2 ( n , m ) : return [ zeros ( m ) ] * n NEW_LINE ALPHABET = [ chr ( i + ord ( ' a ' ) ) for i in range ( 26 ) ] NEW_LINE DIGIT = [ chr ( i + ord ( '0' ) ) for i in range ( 10 ) ] NEW_LINE N1097 = 10 ** 9 + 7 NEW_LINE def dmp ( x , cmt = ' ' ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT print ( cmt , ' : ▁ ▁ ' , end = ' ' ) NEW_LINE DEDENT print ( x ) NEW_LINE DEDENT return x NEW_LINE DEDENT def probC ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE dmp ( ( N , A ) ) NEW_LINE sumFormer = A [ 0 ] NEW_LINE sumLatter = sum ( A [ 1 : ] ) NEW_LINE diff = abs ( sumFormer - sumLatter ) NEW_LINE dmp ( diff , ' init ' ) NEW_LINE for i in range ( 1 , N - 1 ) : NEW_LINE INDENT sumFormer += A [ i ] NEW_LINE sumLatter -= A [ i ] NEW_LINE diff = min ( diff , abs ( sumFormer - sumLatter ) ) NEW_LINE DEDENT return diff NEW_LINE DEDENT def probC_v1 ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE dmp ( ( N , A ) ) NEW_LINE diff = 10 ** ( 9 + 6 ) NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT diff = min ( diff , abs ( sum ( A [ : i ] ) - sum ( A [ i : ] ) ) ) NEW_LINE DEDENT return diff NEW_LINE DEDENT debug = False NEW_LINE ans = probC ( ) NEW_LINE print ( ans ) NEW_LINE NEW_LINE

from itertools import accumulate NEW_LINE N = int ( input ( ) ) NEW_LINE card = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE acc = list ( accumulate ( card ) ) NEW_LINE s = acc [ - 1 ] NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT t = acc [ i ] NEW_LINE a = s - t NEW_LINE ans = min ( ans , abs ( t - a ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int weight = 0 ; int output = 0 ; for ( int i = 0 ; i < n ; i ++ ) { weight += sc . nextInt ( ) ; if ( weight >= s && weight <= t ) { output ++ ; } } System . out . println ( output ) ; } }

import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int n = nextInt ( ) , s = nextInt ( ) , t = nextInt ( ) ; int w = nextInt ( ) ; int ans = 0 ; if ( s <= w && w <= t ) { ans ++ ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { w += nextInt ( ) ; if ( s <= w && w <= t ) { ans ++ ; } } out . println ( ans ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int S = in . nextInt ( ) ; int T = in . nextInt ( ) ; int W = in . nextInt ( ) ; int count = 0 ; if ( S <= W && W <= T ) { count ++ ; } for ( int i = 1 ; i < N ; i ++ ) { W += in . nextInt ( ) ; if ( S <= W && W <= T ) { count ++ ; } } out . println ( count ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int ans = 0 ; int g [ ] = new int [ a ] ; g [ 0 ] = sc . nextInt ( ) ; if ( b <= g [ 0 ] && g [ 0 ] <= c ) { ans ++ ; } for ( int i = 1 ; i < a ; i ++ ) { g [ i ] = g [ i - 1 ] + sc . nextInt ( ) ; if ( b <= g [ i ] && g [ i ] <= c ) { ans ++ ; } } System . out . println ( ans ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { w += a [ i ] ; if ( s <= w && w <= t ) { ans ++ ; } } System . out . println ( ans ) ; } }

ans = 0 NEW_LINE n , s , t = map ( int , input ( ) . split ( ) ) NEW_LINE w = int ( input ( ) ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if s <= w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT w += int ( input ( ) ) NEW_LINE DEDENT if s <= w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE n , s , t = [ int ( i ) for i in sys . stdin . readline ( ) . rstrip ( ) . split ( ) ] NEW_LINE w = 0 NEW_LINE ans = 0 NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a = int ( sys . stdin . readline ( ) . rstrip ( ) ) NEW_LINE w += a NEW_LINE if s <= w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

def solve ( ) : NEW_LINE INDENT n , s , t = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE w = int ( input ( ) ) NEW_LINE if s <= w and w <= t : NEW_LINE INDENT ans = 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE w += a NEW_LINE if s <= w and w <= t : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT solve ( ) NEW_LINE

N , S , T = map ( int , input ( ) . split ( ) ) NEW_LINE W = int ( input ( ) ) NEW_LINE if S <= W <= T : NEW_LINE INDENT daycount = 1 NEW_LINE DEDENT else : NEW_LINE INDENT daycount = 0 NEW_LINE DEDENT for i in range ( N - 1 ) : NEW_LINE INDENT A = int ( input ( ) ) NEW_LINE W += A NEW_LINE if S <= W <= T : NEW_LINE INDENT daycount += 1 NEW_LINE DEDENT DEDENT print ( daycount ) NEW_LINE

n , s , t = map ( int , input ( ) . split ( ) ) NEW_LINE w = int ( input ( ) ) NEW_LINE a_array = [ ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT a_array . append ( int ( input ( ) ) ) NEW_LINE DEDENT cnt = 1 if s <= w <= t else 0 NEW_LINE for a in a_array : NEW_LINE INDENT w += a NEW_LINE if s <= w <= t : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE