import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } long nn = n ; long consume = nn * ( nn + 1 ) / 2 ; if ( sum % consume != 0 ) { System . out . println ( " NO " ) ; return ; } long sump = sum / consume ; long cnt = 0 ; boolean isok = true ; for ( int i = 0 ; i < n ; i ++ ) { long chil = ( a [ ( i - 1 + n ) % n ] + sump - a [ i ] ) ; if ( chil < 0 || chil % n != 0 ) isok = false ; long p = chil / n ; if ( a [ ( i - 1 + n ) % n ] + ( sump - p ) != a [ i ] + ( n - 1 ) * p ) isok = false ; if ( p < 0 ) isok = false ; cnt += p ; } if ( isok && sump == cnt ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } return ; } }

import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Main { private void solve ( Scanner in , PrintWriter out ) { int N = in . nextInt ( ) ; long [ ] a = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = in . nextInt ( ) ; } long [ ] d = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { d [ i ] = a [ ( i + 1 ) % N ] - a [ i ] ; } long sum = Arrays . stream ( a ) . sum ( ) ; if ( sum % ( ( long ) N * ( ( long ) N + 1 ) / 2 ) != 0 ) { out . println ( " NO " ) ; return ; } long k = sum / ( ( long ) N * ( ( long ) N + 1 ) / 2 ) ; long count = 0 ; for ( long e : d ) { e -= k ; if ( e > 0 || ( - e ) % ( long ) N != 0 ) { out . println ( " NO " ) ; return ; } else { count += ( - e ) / ( long ) N ; } } if ( count != k ) { out . println ( " NO " ) ; } else { out . println ( " YES " ) ; } } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( in , out ) ; in . close ( ) ; out . close ( ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Main { public static void main ( String args [ ] ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Solver solver = new Solver ( ) ; solver . init ( ) ; solver . readHead ( in . readLine ( ) ) ; for ( ; solver . hasNext ( ) ; ) { solver . readBody ( in . readLine ( ) ) ; } } } class Solver { int N ; int cnt ; public void init ( ) { N = 0 ; cnt = 0 ; } public void readHead ( String str ) { String [ ] strArr = str . split ( " ▁ " ) ; N = Integer . parseInt ( strArr [ 0 ] ) ; } public boolean hasNext ( ) { return cnt < 1 ; } public void readBody ( String str ) { cnt ++ ; String [ ] strArr = str . split ( " ▁ " ) ; long sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += Long . parseLong ( strArr [ i ] ) ; } if ( sum % ( ( long ) N * ( ( long ) N + 1 ) / 2 ) != 0 ) { System . out . println ( " NO " ) ; return ; } long k = sum / ( ( long ) N * ( ( long ) N + 1 ) / 2 ) ; boolean able = true ; long edge = 0 ; for ( int i = 0 ; i < N ; i ++ ) { long d = - Long . parseLong ( strArr [ i ] ) - k ; if ( i == N - 1 ) d += Long . parseLong ( strArr [ 0 ] ) ; else d += Long . parseLong ( strArr [ i + 1 ] ) ; if ( d > 0 ) { able = false ; break ; } if ( d < 0 ) { if ( d % N != 0 ) { able = false ; break ; } edge -= d ; } } if ( able ) { able = ( edge == N * k ) ; } if ( able ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] A = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) A [ i ] = sc . nextLong ( ) ; String ans = help ( n , A ) ; System . out . println ( ans ) ; } static String help ( int n , long [ ] A ) { if ( n == 1 ) return " YES " ; long sum = A [ 1 ] ; for ( int i = 2 ; i <= n ; i ++ ) sum += A [ i ] ; long temp = ( ( long ) n ) * ( ( long ) n + 1 ) / 2 ; if ( sum % temp != 0 ) return " NO " ; long K = sum / temp ; long [ ] x = new long [ n + 1 ] ; long sumx = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { long dif = i == n ? ( A [ 1 ] - A [ i ] ) : ( A [ i + 1 ] - A [ i ] ) ; if ( K == dif ) continue ; if ( ( K - dif ) % n != 0 || K < dif ) return " NO " ; x [ i ] = ( K - dif ) / n ; sumx += x [ i ] ; } if ( sumx != K ) return " NO " ; else return " YES " ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } System . out . println ( check ( a ) ? " YES " : " NO " ) ; } static boolean check ( long [ ] a ) { int n = a . length ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } if ( sum % ( ( long ) n * ( n + 1 ) / 2 ) != 0 ) { return false ; } else { long step = sum / ( ( long ) n * ( n + 1 ) / 2 ) ; long count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( ( a [ i ] - a [ i + 1 ] + step ) % n != 0 || a [ i ] - a [ i + 1 ] + step < 0 ) { return false ; } count += ( a [ i ] - a [ i + 1 ] + step ) / n ; } if ( ( a [ n - 1 ] - a [ 0 ] + step ) % n != 0 || a [ n - 1 ] - a [ 0 ] + step < 0 ) { return false ; } else { count += ( a [ n - 1 ] - a [ 0 ] + step ) / n ; } return count == step ; } } }

N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE s = sum ( A ) NEW_LINE K = s // ( N * ( N + 1 ) // 2 ) NEW_LINE if N == 1 : NEW_LINE INDENT print ( " YES " ) NEW_LINE exit ( ) NEW_LINE DEDENT if s % ( N * ( N + 1 ) // 2 ) != 0 : NEW_LINE INDENT print ( " NO " ) NEW_LINE exit ( ) NEW_LINE DEDENT d = [ 0 ] * ( N - 1 ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT d [ i ] = A [ i + 1 ] - A [ i ] - K NEW_LINE DEDENT for i in range ( N - 1 ) : NEW_LINE INDENT if d [ i ] > 0 or abs ( d [ i ] ) % N != 0 : NEW_LINE INDENT print ( " NO " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( " YES " ) NEW_LINE

def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT ret_ng = ' NO ' NEW_LINE ret_ok = ' YES ' NEW_LINE n = int ( io ( ) ) NEW_LINE l = list ( map ( int , io ( ) . split ( ) ) ) NEW_LINE v_one_act = n * ( n + 1 ) / 2 NEW_LINE if sum ( l ) % v_one_act != 0 : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT act_num = sum ( l ) // v_one_act NEW_LINE st_num = 0 NEW_LINE for a , b in zip ( l , l [ 1 : ] + l ) : NEW_LINE INDENT diff = b - a NEW_LINE if ( act_num - diff ) % ( n ) != 0 : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT if ( act_num - diff ) < 0 : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT st = ( act_num - diff ) // ( n ) NEW_LINE st_num += st NEW_LINE DEDENT if act_num != st_num : NEW_LINE INDENT return ret_ng NEW_LINE DEDENT return ret_ok NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE print ( main ( io ) ) NEW_LINE DEDENT

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE A = LI ( ) NEW_LINE k , mod = divmod ( sum ( A ) , ( n * ( n + 1 ) // 2 ) ) NEW_LINE if mod : NEW_LINE INDENT return ' NO ' NEW_LINE DEDENT A . append ( A [ 0 ] ) NEW_LINE diff = [ ] NEW_LINE for a1 , a2 in zip ( A [ : - 1 ] , A [ 1 : ] ) : NEW_LINE INDENT diff . append ( a2 - a1 ) NEW_LINE DEDENT return ' YES ' if not any ( [ ( d - k ) % n or d > k for d in diff ] ) else ' NO ' NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE one2n = sum ( [ i for i in range ( 1 , n + 1 ) ] ) NEW_LINE ok = True NEW_LINE if sum ( a ) % one2n > 0 : NEW_LINE INDENT ok = False NEW_LINE DEDENT if ok : NEW_LINE INDENT b = a + [ a [ 0 ] ] NEW_LINE end = 0 NEW_LINE kire = sum ( a ) // one2n NEW_LINE for idx in range ( n ) : NEW_LINE INDENT dif = b [ idx + 1 ] - b [ idx ] NEW_LINE if ( kire - dif ) % n > 0 : NEW_LINE INDENT ok = False NEW_LINE break NEW_LINE DEDENT elif ( kire - dif ) // n < 0 : NEW_LINE INDENT ok = False NEW_LINE break NEW_LINE DEDENT end += ( kire - dif ) // n NEW_LINE DEDENT if end != kire : NEW_LINE INDENT ok = False NEW_LINE DEDENT DEDENT print ( " YES " ) if ok else print ( " NO " ) NEW_LINE

N = int ( input ( ) ) NEW_LINE A = [ int ( a ) for a in input ( ) . split ( ) ] NEW_LINE RejectStones = N * ( N + 1 ) // 2 NEW_LINE if sum ( A ) % RejectStones != 0 : print ( " NO " ) NEW_LINE else : NEW_LINE INDENT TotalOperation = sum ( A ) // RejectStones NEW_LINE sumcheck = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if ( TotalOperation - A [ i + 1 ] + A [ i ] ) % N != 0 or TotalOperation < A [ i + 1 ] - A [ i ] : NEW_LINE INDENT print ( " NO " ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT sumcheck += ( TotalOperation - A [ i + 1 ] + A [ i ] ) // N NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( TotalOperation - A [ 0 ] + A [ - 1 ] ) % N != 0 or TotalOperation < A [ 0 ] - A [ - 1 ] : print ( " NO " ) NEW_LINE else : NEW_LINE INDENT sumcheck += ( TotalOperation - A [ 0 ] + A [ - 1 ] ) // N NEW_LINE if sumcheck == TotalOperation : print ( " YES " ) NEW_LINE else : print ( " NO " ) NEW_LINE DEDENT DEDENT DEDENT


import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] ball = new long [ n ] ; long [ ] ruisekiball = new long [ n ] ; int ans = 1 ; int ite = n - 1 ; for ( int i = 0 ; i < n ; i ++ ) { ball [ i ] = sc . nextInt ( ) ; } Arrays . sort ( ball ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { ruisekiball [ i ] = ball [ i ] ; } else { ruisekiball [ i ] = ruisekiball [ i - 1 ] + ball [ i ] ; } } while ( true ) { ite -- ; if ( ruisekiball [ ite ] * 2 >= ball [ ite + 1 ] ) { ans ++ ; } else { break ; } if ( ite == 0 ) { break ; } } System . out . println ( ans ) ; sc . close ( ) ; } }

import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { long pos = - 1 ; long n = in . nextLong ( ) ; long [ ] a = new long [ ( int ) n ] ; for ( int i = 0 ; i < n ; ++ i ) a [ i ] = in . nextLong ( ) ; Arrays . sort ( a ) ; for ( int i = 0 ; i < n - 1 ; ++ i ) { a [ i + 1 ] += a [ i ] ; if ( a [ i ] * 3 < a [ i + 1 ] ) { pos = i ; } } System . out . println ( n - pos - 1 ) ; } } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { String line = null ; long sum = 0 ; int answer = 0 ; ArrayList < Integer > aList = new ArrayList < Integer > ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; line = br . readLine ( ) ; line = br . readLine ( ) ; String data [ ] = line . split ( " ▁ " ) ; for ( int i = 0 ; i < data . length ; i ++ ) { int num = Integer . parseInt ( data [ i ] ) ; aList . add ( num ) ; } Collections . sort ( aList ) ; for ( int i = 0 ; i < aList . size ( ) ; i ++ ) { int num = aList . get ( i ) ; if ( 2 * sum >= num ) { answer = answer + 1 ; } else { answer = 0 ; } sum = sum + num ; } answer = answer + 1 ; System . out . println ( answer ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] A = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) A [ i ] = sc . nextLong ( ) ; Arrays . sort ( A ) ; sc . close ( ) ; long [ ] sum = new long [ n ] ; sum [ 0 ] = A [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) sum [ i ] = sum [ i - 1 ] + A [ i ] ; int res = 1 ; for ( int i = n - 1 ; i >= 1 ; i -- ) { if ( A [ i ] <= 2 * sum [ i - 1 ] ) res ++ ; else break ; } System . out . println ( res ) ; } }

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

N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A . sort ( ) NEW_LINE c = 0 NEW_LINE kind = N NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if c * 2 < a : NEW_LINE INDENT kind = N - i NEW_LINE DEDENT c += a NEW_LINE DEDENT print ( kind ) NEW_LINE

import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE from itertools import accumulate NEW_LINE n = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE a . sort ( ) NEW_LINE acc = list ( accumulate ( a ) ) NEW_LINE ans = 0 NEW_LINE for ai , acci in zip ( a [ - 1 : 0 : - 1 ] , acc [ - 2 : : - 1 ] ) : NEW_LINE INDENT if 2 * acci >= ai : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans + 1 ) NEW_LINE

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE A = LI ( ) NEW_LINE A . sort ( ) NEW_LINE C = [ 0 ] NEW_LINE for a in A : NEW_LINE INDENT C . append ( C [ - 1 ] + a ) NEW_LINE DEDENT t = 0 NEW_LINE for i , ( a , c ) in enumerate ( zip ( A [ 1 : ] , C [ 1 : - 1 ] ) ) : NEW_LINE INDENT if a > 2 * c : NEW_LINE INDENT t = i + 1 NEW_LINE DEDENT DEDENT return n - t NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

from itertools import accumulate NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = sorted ( A ) NEW_LINE a_acc = list ( accumulate ( A ) ) NEW_LINE ans = N NEW_LINE seq = 1 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if a_acc [ i ] * 2 >= A [ i + 1 ] : NEW_LINE INDENT seq += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans -= seq NEW_LINE seq = 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT a = int ( io ( ) ) NEW_LINE l = list ( map ( int , io ( ) . split ( ) ) ) NEW_LINE l . sort ( reverse = True ) NEW_LINE m = sum ( l [ 1 : ] ) NEW_LINE pre = l [ 0 ] NEW_LINE num = 1 NEW_LINE for val in l [ 1 : ] : NEW_LINE INDENT if pre > m * 2 : NEW_LINE INDENT break NEW_LINE DEDENT else : NEW_LINE INDENT num += 1 NEW_LINE pre = val NEW_LINE m = m - val NEW_LINE DEDENT DEDENT return num NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE print ( main ( io ) ) NEW_LINE DEDENT


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; long mod = 1000000007 ; long [ ] cnt = new long [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { cnt [ S . charAt ( i ) - ' a ' ] ++ ; } long ans = 1 ; for ( long i : cnt ) { ans = ( i + 1 ) * ans % mod ; } ans -= 1 ; System . out . println ( ans ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int MOD = ( int ) 1e9 + 7 ; void solve ( ) { int n = in . nextInt ( ) ; char [ ] s = in . nextToken ( ) . toCharArray ( ) ; int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; } long ans = 1 ; for ( int i = 0 ; i < 26 ; i ++ ) { ans = ans * ( cnt [ i ] + 1 ) % MOD ; } ans = ( ans - 1 + MOD ) % MOD ; out . println ( ans ) ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }

import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . nextLine ( ) ; String s = sc . nextLine ( ) ; HashMap < String , String > alpha = new HashMap < String , String > ( ) ; long count = 1 ; for ( int i = 0 ; i < Integer . parseInt ( n ) ; i ++ ) { char mark = s . charAt ( i ) ; if ( alpha . containsKey ( String . valueOf ( mark ) ) ) { } else { alpha . put ( String . valueOf ( mark ) , " " ) ; int sum = 0 ; for ( int j = i ; j < Integer . parseInt ( n ) ; j ++ ) { if ( s . charAt ( j ) == mark ) { sum ++ ; } } count = count % 1000000007 ; count *= sum + 1 ; } } System . out . println ( ( count - 1 ) % 1000000007 ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { static final long MOD = 1000000007 ; public static void main ( String [ ] args ) throws IOException { MyScanner sc = new MyScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; char [ ] vals = sc . next ( ) . toCharArray ( ) ; long [ ] cant = new long [ 26 ] ; for ( int i = 0 ; i < vals . length ; i ++ ) { cant [ vals [ i ] - ' a ' ] ++ ; } long ans = 1 ; for ( int i = 0 ; i < cant . length ; i ++ ) { ans *= 1 + cant [ i ] ; ans %= MOD ; } ans += MOD - 1 ; ans %= MOD ; out . println ( ans ) ; out . flush ( ) ; } static class MyScanner { private BufferedReader br ; private StringTokenizer tokenizer ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . util . HashMap ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String t = s . substring ( i , i + 1 ) ; if ( map . containsKey ( t ) ) { map . put ( t , map . get ( t ) + 1 ) ; } else { map . put ( t , 1 ) ; } } long mod = 1000000007 ; long sum = 1l ; for ( Entry < String , Integer > entry : map . entrySet ( ) ) { long c = entry . getValue ( ) ; sum *= ( long ) ( c + 1 ) % mod ; sum %= ( long ) mod ; } System . out . println ( sum - 1 ) ; } }

import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE from collections import Counter NEW_LINE n = ni ( ) NEW_LINE s = ns ( ) NEW_LINE cnt = Counter ( s ) NEW_LINE ans = 1 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE for k , v in cnt . items ( ) : NEW_LINE INDENT ans *= ( v + 1 ) NEW_LINE ans %= mod NEW_LINE DEDENT ans -= 1 NEW_LINE if ans < 0 : NEW_LINE INDENT ans += mod NEW_LINE DEDENT print ( ans ) NEW_LINE

_ , s = open ( 0 ) ; a = 1 NEW_LINE for i in set ( s ) : a *= s . count ( i ) + 1 NEW_LINE print ( a // 2 % ( 10 ** 9 + 7 ) - 1 ) NEW_LINE

import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE eps = 1.0 / 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE dd = [ ( - 1 , 0 ) , ( 0 , 1 ) , ( 1 , 0 ) , ( 0 , - 1 ) ] NEW_LINE ddn = [ ( - 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) , ( 1 , 1 ) , ( 1 , 0 ) , ( 1 , - 1 ) , ( 0 , - 1 ) , ( - 1 , - 1 ) ] NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def pf ( s ) : return print ( s , flush = True ) NEW_LINE def main ( ) : NEW_LINE INDENT n = I ( ) NEW_LINE s = S ( ) NEW_LINE c = collections . Counter ( s ) NEW_LINE r = 1 NEW_LINE for k , v in c . items ( ) : NEW_LINE INDENT r *= v + 1 NEW_LINE r %= mod NEW_LINE DEDENT return ( r - 1 ) % mod NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE memo = [ 1 ] * 26 NEW_LINE for i in range ( N ) : NEW_LINE INDENT k = ord ( s [ i ] ) - ord ( ' a ' ) NEW_LINE memo [ k ] += 1 NEW_LINE DEDENT ans = 1 NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT ans = ans * memo [ i ] % ( 1000000007 ) NEW_LINE DEDENT print ( ans - 1 ) NEW_LINE

import sys NEW_LINE from collections import Counter NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def list2d ( a , b , c ) : return [ [ c ] * b for i in range ( a ) ] NEW_LINE def list3d ( a , b , c , d ) : return [ [ [ d ] * c for j in range ( b ) ] for i in range ( a ) ] NEW_LINE def ceil ( x , y = 1 ) : return int ( - ( - x // y ) ) NEW_LINE def INT ( ) : return int ( input ( ) ) NEW_LINE def MAP ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def Yes ( ) : print ( ' Yes ' ) NEW_LINE def No ( ) : print ( ' No ' ) NEW_LINE def YES ( ) : print ( ' YES ' ) NEW_LINE def NO ( ) : print ( ' NO ' ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE N = INT ( ) NEW_LINE S = input ( ) NEW_LINE C = Counter ( S ) NEW_LINE ans = 1 NEW_LINE for v in C . values ( ) : NEW_LINE INDENT ans *= v + 1 NEW_LINE ans %= MOD NEW_LINE DEDENT ans -= 1 NEW_LINE print ( ans ) NEW_LINE


import java . util . Scanner ; public class Main { static final long M = 998244353L ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; long K = scanner . nextLong ( ) ; System . out . println ( solve ( N , A , B , K ) ) ; } private static long solve ( int N , long A , long B , long K ) { if ( A > B ) return solve ( N , B , A , K ) ; long [ ] fact = new long [ N + 1 ] ; fact [ 0 ] = 1 ; for ( int i = 0 ; i < N ; i ++ ) { fact [ i + 1 ] = fact [ i ] * ( N - i ) % M ; } long [ ] factinv = new long [ N + 1 ] ; factinv [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { factinv [ i ] = factinv [ i - 1 ] * inverse ( i , M ) % M ; } long res = 0 ; for ( int i = 0 ; i <= Math . min ( N , K / B ) ; i ++ ) { if ( ( K - B * i ) % A == 0 ) { long j = ( K - B * i ) / A ; if ( j > N ) continue ; int jj = ( int ) j ; long c = fact [ i ] * factinv [ i ] % M ; c *= fact [ jj ] * factinv [ jj ] % M ; res += c % M ; res %= M ; } } return res ; } public static long inverse ( long a , long mod ) { return modpow ( a , mod - 2 , mod ) ; } public static long modpow ( long a , long n , long mod ) { long res = 1 ; while ( n > 0 ) { if ( n % 2 == 1 ) res = ( res * a ) % mod ; a = ( a * a ) % mod ; n >>= 1 ; } return res % mod ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; long A = Long . parseLong ( sc . next ( ) ) ; long B = Long . parseLong ( sc . next ( ) ) ; long K = Long . parseLong ( sc . next ( ) ) ; final long p = 998244353 ; combination nC = new combination ( N , p ) ; long ans = 0 ; long b = 0 ; for ( int a = 0 ; a <= N ; a ++ ) { b = ( K - A * a ) / B ; if ( A * a > K ) { break ; } else if ( ( K - A * a ) % B != 0 || b > ( long ) N ) { continue ; } else { ans += ( nC . C ( a , p ) * nC . C ( ( int ) b , p ) ) % p ; } } System . out . println ( ans % p ) ; } static class combination { public int n ; public long nfact ; public long reverceTable [ ] ; public combination ( int n , long p ) { this . n = n ; reverceTable = new long [ n + 1 ] ; reverceTable [ 0 ] = 1 ; nfact = 1 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { nfact = nfact * i % p ; } long sum = 1 ; long x = nfact ; long m = p - 2 ; while ( m > 0 ) { if ( ( m & 1 ) == 1 ) { sum = sum * x % p ; } x = x * x % p ; m >>= 1 ; } reverceTable [ n ] = sum ; for ( int i = n - 1 ; i > 0 ; i -- ) { reverceTable [ i ] = reverceTable [ i + 1 ] * ( i + 1 ) % p ; } } public long C ( int r , long p ) { if ( r < 0 || r > n ) { return 0 ; } else { return ( nfact * reverceTable [ r ] % p ) * reverceTable [ n - r ] % p ; } } } }

import java . util . * ; import java . io . * ; import java . math . BigInteger ; class Main { public static long comb ( long a , long b , long mod , long [ ] pw , long [ ] ipw ) { return ( ( ( pw [ ( int ) a ] * ipw [ ( int ) a - ( int ) b ] ) % mod ) * ipw [ ( int ) b ] ) % mod ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int max = 400000 ; int mod = 998244353 ; long [ ] pw = new long [ max ] ; pw [ 0 ] = 1 ; long [ ] ipw = new long [ max ] ; BigInteger modb = new BigInteger ( String . valueOf ( mod ) ) ; for ( int i = 1 ; i < max ; i ++ ) { pw [ i ] = ( i * pw [ i - 1 ] ) % mod ; } for ( int i = 0 ; i < max ; i ++ ) { ipw [ i ] = new BigInteger ( String . valueOf ( pw [ i ] ) ) . modInverse ( modb ) . longValue ( ) ; } long n = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long ans = 0 ; for ( int A = 0 ; A <= n ; A ++ ) { if ( ( k - A * a ) % b != 0 ) continue ; long B = ( k - A * a ) / b ; if ( B > n || B < 0 ) continue ; ans += ( comb ( n , A , mod , pw , ipw ) * comb ( n , B , mod , pw , ipw ) ) % mod ; ans %= mod ; } System . out . println ( ans ) ; } }

import java . util . * ; class Main { static int MOD = 998244353 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long ans = 0 ; long [ ] comb = new long [ n + 1 ] ; comb [ 0 ] = 1 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { comb [ i ] = comb [ i - 1 ] * ( n - i + 1 ) % MOD * pow ( i , MOD - 2 ) % MOD ; } long q = K + A ; for ( int x = 0 ; x <= n ; x ++ ) { q -= A ; if ( q % B == 0 ) { long y = q / B ; if ( y > n ) continue ; if ( y < 0 ) break ; ans = ( ans + comb [ x ] * comb [ ( int ) y ] % MOD ) % MOD ; } } System . out . println ( ans ) ; } static long calc ( int n , long a ) { long MulSumN = 1 ; long MulSumA = 1 ; for ( int i = 1 ; i <= a ; i ++ ) { MulSumN *= n - i + 1 ; MulSumN %= MOD ; MulSumA *= i ; MulSumA %= MOD ; } return MulSumN * pow ( MulSumA , MOD - 2 ) % MOD ; } public static long pow ( long a , int b ) { if ( b == 1 ) return a ; if ( b % 2 == 0 ) { long d = pow ( a , b / 2 ) ; return d * d % MOD ; } return a * pow ( a , b - 1 ) % MOD ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; long a = Integer . parseInt ( sc . next ( ) ) ; long b = Integer . parseInt ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; int mod = 998244353 ; int max = 300_003 ; Mod_nCr mn = new Mod_nCr ( mod , max ) ; long ans = 0 ; for ( int red = 0 ; red <= n ; red ++ ) { int blue = ( int ) ( ( k - red * a ) / b ) ; if ( red * a + blue * b == k && 0 <= blue ) { ans += mn . nCr ( n , red ) * mn . nCr ( n , blue ) ; ans %= mod ; } } System . out . println ( ans ) ; } } class Mod_nCr { int mod ; long [ ] fact ; long [ ] rfact ; public Mod_nCr ( int mod , int max ) { this . mod = mod ; fact = new long [ max ] ; rfact = new long [ max ] ; fact [ 0 ] = 1 ; rfact [ 0 ] = 1 ; for ( int i = 1 ; i < max ; i ++ ) { fact [ i ] = ( fact [ i - 1 ] * i ) % mod ; rfact [ i ] = mod_inverse ( fact [ i ] , mod ) ; } } private long mod_pow ( long x , long p , long m ) { long a = 1 ; while ( p > 0 ) { if ( p % 2 == 1 ) { a = a * x % m ; } x = x * x % m ; p /= 2 ; } return a ; } private long mod_inverse ( long a , long m ) { return mod_pow ( a , m - 2 , m ) ; } public long nCr ( int n , int r ) { if ( n < r ) return 0 ; return fact [ n ] * rfact [ r ] % mod * rfact [ n - r ] % mod ; } }

n , a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE m = 998244353 NEW_LINE I = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT I [ i ] = pow ( i + 1 , m - 2 , m ) NEW_LINE DEDENT c = [ 0 ] * ( n + 1 ) NEW_LINE c [ 0 ] = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT c [ i ] = ( c [ i - 1 ] * ( n - i + 1 ) * I [ i - 1 ] ) % m NEW_LINE DEDENT q = 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT j = ( k - i * a ) // b NEW_LINE if ( k - i * a ) % b or j < 0 or j > n : continue NEW_LINE q = ( q + c [ i ] * c [ j ] ) % m NEW_LINE DEDENT print ( q % m ) NEW_LINE

import sys NEW_LINE MOD = 998244353 NEW_LINE def solve ( N : int , A : int , B : int , K : int ) : NEW_LINE INDENT N_max = 3 * 10 ** 5 NEW_LINE g1 = [ 1 , 1 ] NEW_LINE g2 = [ 1 , 1 ] NEW_LINE inv = [ 0 , 1 ] NEW_LINE for i in range ( 2 , N_max + 1 ) : NEW_LINE INDENT g1 . append ( ( g1 [ - 1 ] * i ) % MOD ) NEW_LINE inv . append ( ( - inv [ MOD % i ] * ( MOD // i ) ) % MOD ) NEW_LINE g2 . append ( ( g2 [ - 1 ] * inv [ - 1 ] ) % MOD ) NEW_LINE DEDENT ans = 0 NEW_LINE for x in range ( N + 1 ) : NEW_LINE INDENT if ( K - A * x ) % B == 0 : NEW_LINE INDENT y = ( K - A * x ) // B NEW_LINE if y < 0 or y > N : NEW_LINE INDENT continue NEW_LINE DEDENT ans += g1 [ N ] * g2 [ x ] * g2 [ N - x ] * g1 [ N ] * g2 [ y ] * g2 [ N - y ] NEW_LINE ans %= MOD NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE K = int ( next ( tokens ) ) NEW_LINE solve ( N , A , B , K ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

N , A , B , K = map ( int , input ( ) . split ( ) ) NEW_LINE P = 998244353 NEW_LINE def egcd ( a , b ) : NEW_LINE INDENT ( x , lastx ) = ( 0 , 1 ) NEW_LINE ( y , lasty ) = ( 1 , 0 ) NEW_LINE while b != 0 : NEW_LINE INDENT q = a // b NEW_LINE ( a , b ) = ( b , a % b ) NEW_LINE ( x , lastx ) = ( lastx - q * x , x ) NEW_LINE ( y , lasty ) = ( lasty - q * y , y ) NEW_LINE DEDENT return ( lastx , lasty , a ) NEW_LINE DEDENT def inv ( x ) : NEW_LINE INDENT return egcd ( x , P ) [ 0 ] NEW_LINE DEDENT Fact = [ 0 for i in range ( N + 1 ) ] NEW_LINE Finv = [ 0 for i in range ( N + 1 ) ] NEW_LINE Fact [ 0 ] = 1 NEW_LINE Finv [ 0 ] = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT Fact [ i ] = ( i * Fact [ i - 1 ] ) % P NEW_LINE Finv [ i ] = ( Finv [ i - 1 ] * inv ( i ) ) % P NEW_LINE DEDENT ans = 0 NEW_LINE def NC ( k ) : NEW_LINE INDENT tmp = ( Finv [ k ] * Finv [ N - k ] ) % P NEW_LINE return ( Fact [ N ] * tmp ) % P NEW_LINE DEDENT for x in range ( N + 1 ) : NEW_LINE INDENT y = ( K - x * A ) // B NEW_LINE if x * A + y * B == K and 0 <= y <= N : NEW_LINE INDENT ans += ( NC ( x ) * NC ( y ) ) % P NEW_LINE DEDENT DEDENT print ( ans % P ) NEW_LINE

class BigCombination ( object ) : NEW_LINE INDENT __slots__ = [ " mod " , " factorial " , " inverse " ] NEW_LINE def __init__ ( self , mod : int = 10 ** 9 + 7 , max_n : int = 10 ** 6 ) : NEW_LINE INDENT from itertools import accumulate NEW_LINE self . mod = mod NEW_LINE self . factorial = [ 1 ] + list ( accumulate ( range ( 1 , max_n + 1 ) , lambda x , y : x * y % mod ) ) NEW_LINE max_inv , x = 1 , self . factorial [ - 1 ] NEW_LINE for bit in bin ( mod - 2 ) [ : 1 : - 1 ] : NEW_LINE INDENT if bit == "1" : NEW_LINE INDENT max_inv = max_inv * x % mod NEW_LINE DEDENT x = x * x % mod NEW_LINE DEDENT self . inverse = ( list ( accumulate ( [ max_inv ] + list ( range ( max_n , 0 , - 1 ) ) , lambda x , y : x * y % mod ) ) ) [ : : - 1 ] NEW_LINE DEDENT def get_combination ( self , n , r ) : NEW_LINE INDENT return self . factorial [ n ] * self . inverse [ r ] * self . inverse [ n - r ] % self . mod NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N , A , B , K = map ( int , input ( ) . split ( ) ) NEW_LINE mod = 998244353 NEW_LINE big_comb = BigCombination ( mod , N ) NEW_LINE get_comb = big_comb . get_combination NEW_LINE answer = 0 NEW_LINE for a_count in range ( N + 1 ) : NEW_LINE INDENT if ( K - a_count * A ) % B == 0 and 0 <= ( K - a_count * A ) // B <= N : NEW_LINE INDENT b_count = ( K - a_count * A ) // B NEW_LINE answer = ( answer + get_comb ( N , a_count ) * get_comb ( N , b_count ) ) % mod NEW_LINE DEDENT DEDENT print ( answer ) NEW_LINE DEDENT

p = 998244353 NEW_LINE def getinv ( n ) : NEW_LINE INDENT inv = [ 0 ] * ( n + 1 ) NEW_LINE inv [ 1 ] = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT inv [ i ] = ( - ( p // i ) * inv [ p % i ] ) % p NEW_LINE DEDENT return inv NEW_LINE DEDENT def getCmb ( n ) : NEW_LINE INDENT inv = getinv ( n ) NEW_LINE nCr = [ 0 ] * ( n + 1 ) NEW_LINE nCr [ 0 ] = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT nCr [ i ] = ( nCr [ i - 1 ] * ( n - i + 1 ) * inv [ i ] ) % p NEW_LINE DEDENT return nCr NEW_LINE DEDENT def solve ( n , a , b , k ) : NEW_LINE INDENT nCr = getCmb ( n ) NEW_LINE ans = 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT j = ( k - a * i ) // b NEW_LINE if a * i + b * j == k and 0 <= j <= n : NEW_LINE INDENT ans += ( nCr [ i ] * nCr [ j ] ) % p NEW_LINE ans %= p NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n , a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( n , a , b , k ) ) NEW_LINE


import java . util . ArrayList ; import java . util . LinkedList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; List < ArrayList < Integer > > connect = new ArrayList < ArrayList < Integer > > ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) { connect . add ( new ArrayList < Integer > ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; connect . get ( a ) . add ( b ) ; connect . get ( b ) . add ( a ) ; } boolean taken [ ] = new boolean [ n + 1 ] ; taken [ 1 ] = true ; LinkedList < Integer > ans = new LinkedList < Integer > ( ) ; ans . add ( 1 ) ; extend ( ans , connect , taken , false ) ; extend ( ans , connect , taken , true ) ; System . out . println ( ans . size ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; for ( Integer i : ans ) { sb . append ( i ) ; sb . append ( ' ▁ ' ) ; } sb . deleteCharAt ( sb . length ( ) - 1 ) ; System . out . println ( sb ) ; } static void extend ( LinkedList < Integer > ans , List < ArrayList < Integer > > connect , boolean [ ] taken , boolean right ) { while ( true ) { Integer tmp = right ? ans . getLast ( ) : ans . getFirst ( ) ; boolean found = false ; for ( Integer i : connect . get ( tmp ) ) { if ( ! taken [ i ] ) { taken [ i ] = true ; if ( right ) { ans . addLast ( i ) ; } else { ans . addFirst ( i ) ; } found = true ; break ; } } if ( ! found ) { break ; } } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; ArrayList < Integer > [ ] graph = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { graph [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; graph [ a ] . add ( b ) ; graph [ b ] . add ( a ) ; } HashSet < Integer > set = new HashSet < > ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int idx = 1 ; boolean flag = false ; list . add ( idx ) ; set . add ( idx ) ; while ( ! flag ) { flag = true ; for ( int x : graph [ idx ] ) { if ( ! set . contains ( x ) ) { flag = false ; idx = x ; list . add ( idx ) ; set . add ( idx ) ; break ; } } } flag = false ; idx = 1 ; while ( ! flag ) { flag = true ; for ( int x : graph [ idx ] ) { if ( ! set . contains ( x ) ) { flag = false ; idx = x ; list . add ( 0 , idx ) ; set . add ( idx ) ; break ; } } } StringBuilder sb = new StringBuilder ( ) ; sb . append ( list . size ( ) ) . append ( " \n " ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( i != 0 ) { sb . append ( " ▁ " ) ; } sb . append ( list . get ( i ) ) ; } System . out . println ( sb ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { static ArrayList < Integer > [ ] graph ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; graph = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) graph [ i ] = new ArrayList < > ( ) ; for ( int j = 0 ; j < m ; j ++ ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; graph [ a ] . add ( b ) ; graph [ b ] . add ( a ) ; } LinkedList < Integer > ans = helper ( n ) ; PrintWriter out = new PrintWriter ( System . out ) ; out . println ( ans . size ( ) ) ; while ( ans . size ( ) > 0 ) { out . print ( ans . poll ( ) ) ; out . print ( " ▁ " ) ; } out . flush ( ) ; } static LinkedList < Integer > helper ( int n ) { boolean [ ] vis = new boolean [ n + 1 ] ; LinkedList < Integer > ans = new LinkedList < > ( ) ; ans . add ( 1 ) ; ans . add ( graph [ 1 ] . get ( 0 ) ) ; vis [ 1 ] = true ; vis [ ans . peekLast ( ) ] = true ; boolean flag = true ; while ( flag ) { flag = false ; for ( int w : graph [ ans . peek ( ) ] ) { if ( ! vis [ w ] ) { ans . addFirst ( w ) ; vis [ w ] = true ; flag = true ; break ; } } } flag = true ; while ( flag ) { flag = false ; for ( int w : graph [ ans . peekLast ( ) ] ) { if ( ! vis [ w ] ) { ans . addLast ( w ) ; vis [ w ] = true ; flag = true ; break ; } } } return ans ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( m ) ] NEW_LINE d = { } NEW_LINE for i , j in a : NEW_LINE INDENT d [ i ] = d . get ( i , set ( ) ) | { j } NEW_LINE d [ j ] = d . get ( j , set ( ) ) | { i } NEW_LINE DEDENT path = a [ 0 ] [ : ] NEW_LINE sp = set ( path ) NEW_LINE while d [ path [ - 1 ] ] - sp : NEW_LINE INDENT t = d [ path [ - 1 ] ] - sp NEW_LINE t = t . pop ( ) NEW_LINE path . append ( t ) NEW_LINE sp . add ( t ) NEW_LINE DEDENT path = path [ : : - 1 ] NEW_LINE while d [ path [ - 1 ] ] - sp : NEW_LINE INDENT t = d [ path [ - 1 ] ] - sp NEW_LINE t = t . pop ( ) NEW_LINE path . append ( t ) NEW_LINE sp . add ( t ) NEW_LINE DEDENT print ( len ( path ) ) NEW_LINE print ( * path ) NEW_LINE

def dfs ( ) : NEW_LINE INDENT ans = [ ] NEW_LINE vNow = 0 NEW_LINE while True : NEW_LINE INDENT useds [ vNow ] = True NEW_LINE ans . append ( vNow + 1 ) NEW_LINE for v2 in adjL [ vNow ] : NEW_LINE INDENT if not useds [ v2 ] : NEW_LINE INDENT vNow = v2 NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE adjL = [ [ ] for v in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE adjL [ a - 1 ] . append ( b - 1 ) NEW_LINE adjL [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT useds = [ False ] * N NEW_LINE ans1 = dfs ( ) NEW_LINE ans2 = dfs ( ) NEW_LINE print ( len ( ans1 ) + len ( ans2 ) - 1 ) NEW_LINE print ( ' ▁ ' . join ( map ( str , ans1 [ : : - 1 ] + ans2 [ 1 : ] ) ) ) NEW_LINE

import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE I = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE n , m = I ( ) NEW_LINE g = [ set ( ) for _ in range ( n + 1 ) ] NEW_LINE v = [ 1 for _ in range ( n + 1 ) ] NEW_LINE v [ 1 ] = 0 NEW_LINE for _ in range ( m ) : NEW_LINE INDENT a , b = I ( ) NEW_LINE g [ a ] . add ( b ) NEW_LINE g [ b ] . add ( a ) NEW_LINE DEDENT def dfs ( x ) : NEW_LINE INDENT for j in g [ x ] : NEW_LINE INDENT if v [ j ] : NEW_LINE INDENT v [ j ] = 0 NEW_LINE l = dfs ( j ) NEW_LINE l . append ( j ) NEW_LINE return l NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return [ ] NEW_LINE DEDENT DEDENT z = dfs ( 1 ) + [ 1 ] + dfs ( 1 ) [ : : - 1 ] NEW_LINE print ( len ( z ) ) NEW_LINE print ( * z ) NEW_LINE

import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE from collections import deque NEW_LINE n , m = li ( ) NEW_LINE graph = [ [ ] for _ in range ( n ) ] NEW_LINE for _ in range ( m ) : NEW_LINE INDENT a , b = li_ ( ) NEW_LINE graph [ a ] . append ( b ) NEW_LINE graph [ b ] . append ( a ) NEW_LINE path = deque ( [ a , b ] ) NEW_LINE DEDENT path_set = set ( path ) NEW_LINE ed = b NEW_LINE satisfied = False NEW_LINE while not satisfied : NEW_LINE INDENT satisfied = True NEW_LINE for nex in graph [ ed ] : NEW_LINE INDENT if nex in path_set : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT path_set . add ( nex ) NEW_LINE path . append ( nex ) NEW_LINE ed = nex NEW_LINE satisfied = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT ed = a NEW_LINE satisfied = False NEW_LINE while not satisfied : NEW_LINE INDENT satisfied = True NEW_LINE for nex in graph [ ed ] : NEW_LINE INDENT if nex in path_set : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT path_set . add ( nex ) NEW_LINE path . appendleft ( nex ) NEW_LINE ed = nex NEW_LINE satisfied = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT path = [ pi + 1 for pi in path ] NEW_LINE print ( len ( path ) ) NEW_LINE print ( * path ) NEW_LINE

N , M = map ( int , input ( ) . split ( ) ) NEW_LINE Edge = [ [ ] for i in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE Edge [ a - 1 ] . append ( b - 1 ) NEW_LINE Edge [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT Used = [ False for i in range ( N ) ] NEW_LINE Path = [ 1 , Edge [ 0 ] [ 0 ] + 1 ] NEW_LINE Used [ 0 ] , Used [ Edge [ 0 ] [ 0 ] ] = True , True NEW_LINE AFin , BFin = False , False NEW_LINE Anext , Bnext = 0 , Edge [ 0 ] [ 0 ] NEW_LINE for node in Edge [ 0 ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Anext = node NEW_LINE Used [ Anext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : AFin = True NEW_LINE for node in Edge [ Bnext ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Bnext = node NEW_LINE Used [ Bnext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : BFin = True NEW_LINE while not AFin or not BFin : NEW_LINE INDENT if not AFin : NEW_LINE INDENT Path . insert ( 0 , Anext + 1 ) NEW_LINE for node in Edge [ Anext ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Anext = node NEW_LINE Used [ Anext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : AFin = True NEW_LINE DEDENT if not BFin : NEW_LINE INDENT Path . append ( Bnext + 1 ) NEW_LINE for node in Edge [ Bnext ] : NEW_LINE INDENT if not Used [ node ] : NEW_LINE INDENT Bnext = node NEW_LINE Used [ Bnext ] = True NEW_LINE break NEW_LINE DEDENT DEDENT else : BFin = True NEW_LINE DEDENT DEDENT print ( len ( Path ) ) NEW_LINE print ( " ▁ " . join ( map ( str , Path ) ) ) 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 [ ] x = new int [ N ] ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextInt ( ) ; a [ i ] = sc . nextInt ( ) - x [ i ] ; } PriorityQueue < Long > lset = new PriorityQueue < > ( new Comparator < Long > ( ) { public int compare ( Long l1 , Long l2 ) { return - Long . compare ( l1 , l2 ) ; } } ) ; lset . add ( ( long ) x [ 0 ] ) ; long ladd = 0 ; PriorityQueue < Long > rset = new PriorityQueue < > ( ) ; rset . add ( ( long ) x [ 0 ] ) ; long radd = 0 ; long min = 0 ; for ( int i = 1 ; i < N ; i ++ ) { ladd -= a [ i ] ; radd += a [ i - 1 ] ; if ( x [ i ] < lset . peek ( ) + ladd ) { min = min + ( lset . peek ( ) + ladd - x [ i ] ) ; lset . add ( x [ i ] - ladd ) ; lset . add ( x [ i ] - ladd ) ; rset . add ( lset . poll ( ) + ladd - radd ) ; } else if ( rset . peek ( ) + radd < x [ i ] ) { min = min + ( x [ i ] - ( rset . peek ( ) + radd ) ) ; rset . add ( x [ i ] - radd ) ; rset . add ( x [ i ] - radd ) ; lset . add ( rset . poll ( ) + radd - ladd ) ; } else { lset . add ( x [ i ] - ladd ) ; rset . add ( x [ i ] - radd ) ; } } System . out . println ( min ) ; sc . close ( ) ; } }

import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; long lbase = 0 ; long rbase = 0 ; PriorityQueue < Long > lindex = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; PriorityQueue < Long > rindex = new PriorityQueue < > ( ) ; long [ ] l = new long [ N ] ; long [ ] w = new long [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { l [ i ] = scan . nextLong ( ) ; w [ i ] = scan . nextLong ( ) - l [ i ] ; } lindex . add ( l [ 0 ] ) ; rindex . add ( l [ 0 ] ) ; long ans = 0 ; for ( int i = 1 ; i < N ; ++ i ) { lbase += w [ i ] ; rbase += w [ i - 1 ] ; if ( lindex . peek ( ) >= ( l [ i ] + lbase ) ) { lindex . add ( l [ i ] + lbase ) ; lindex . add ( l [ i ] + lbase ) ; ans += Math . abs ( lindex . peek ( ) - ( l [ i ] + lbase ) ) ; rindex . add ( lindex . poll ( ) - lbase - rbase ) ; } else if ( rindex . peek ( ) <= ( l [ i ] - rbase ) ) { rindex . add ( l [ i ] - rbase ) ; rindex . add ( l [ i ] - rbase ) ; ans += Math . abs ( rindex . peek ( ) - ( l [ i ] - rbase ) ) ; lindex . add ( rindex . poll ( ) + lbase + rbase ) ; } else { lindex . add ( l [ i ] + lbase ) ; rindex . add ( l [ i ] - rbase ) ; } } System . out . println ( ans ) ; } }

N = int ( input ( ) ) NEW_LINE P = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE from heapq import heappush , heappop NEW_LINE l0 , r0 = P [ 0 ] NEW_LINE L = [ - l0 + 1 ] NEW_LINE R = [ l0 - 1 ] NEW_LINE s = t = 0 NEW_LINE res = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT l0 , r0 = P [ i ] NEW_LINE l1 , r1 = P [ i + 1 ] NEW_LINE s += ( r1 - l1 ) ; t += ( r0 - l0 ) NEW_LINE if - s - L [ 0 ] <= l1 - 1 <= t + R [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE DEDENT elif l1 - 1 < - s - L [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( L , - l1 + 1 - s ) NEW_LINE p = - heappop ( L ) - s NEW_LINE heappush ( R , p - t ) NEW_LINE res += ( p - ( l1 - 1 ) ) NEW_LINE DEDENT elif t + R [ 0 ] < l1 - 1 : NEW_LINE INDENT heappush ( R , l1 - 1 - t ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE p = heappop ( R ) + t NEW_LINE heappush ( L , - p - s ) NEW_LINE res += ( ( l1 - 1 ) - p ) NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE

N = int ( input ( ) ) NEW_LINE P = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE INF = 10 ** 18 NEW_LINE from heapq import heappush , heappop NEW_LINE l0 , r0 = P [ 0 ] NEW_LINE L = [ - l0 + 1 ] NEW_LINE R = [ l0 - 1 ] NEW_LINE s = t = 0 NEW_LINE res = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT l0 , r0 = P [ i ] NEW_LINE l1 , r1 = P [ i + 1 ] NEW_LINE s += ( r1 - l1 ) ; t += ( r0 - l0 ) NEW_LINE if - s - L [ 0 ] <= l1 - 1 <= t + R [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE DEDENT elif l1 - 1 < - s - L [ 0 ] : NEW_LINE INDENT heappush ( L , - l1 + 1 - s ) NEW_LINE heappush ( L , - l1 + 1 - s ) NEW_LINE p = - heappop ( L ) - s NEW_LINE heappush ( R , p - t ) NEW_LINE res += ( p - ( l1 - 1 ) ) NEW_LINE DEDENT elif t + R [ 0 ] < l1 - 1 : NEW_LINE INDENT heappush ( R , l1 - 1 - t ) NEW_LINE heappush ( R , l1 - 1 - t ) NEW_LINE p = heappop ( R ) + t NEW_LINE heappush ( L , - p - s ) NEW_LINE res += ( l1 - 1 - p ) NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE


import java . util . * ; import java . io . * ; public class Main { public static void ask ( String number ) { System . out . println ( " ? ▁ " + number ) ; } public static void ask ( long number ) { System . out . println ( " ? ▁ " + number ) ; } public static void answer ( String number ) { System . out . println ( " ! ▁ " + number ) ; } public static void answer ( long number ) { System . out . println ( " ! ▁ " + number ) ; } public static long dec ( int k ) { long a = 1 ; for ( int i = 0 ; i < k ; i ++ ) a *= 10 ; return a ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int digit = - 1 ; for ( int i = 0 ; i <= 10 ; i ++ ) { ask ( dec ( i ) ) ; if ( sc . nextLine ( ) . equals ( " N " ) ) { digit = i ; break ; } } if ( digit == - 1 ) { for ( int i = 0 ; i <= 10 ; i ++ ) { ask ( 2 * dec ( i ) ) ; if ( sc . nextLine ( ) . equals ( " Y " ) ) { answer ( dec ( i ) ) ; System . exit ( 0 ) ; } } } else { long min = dec ( digit - 1 ) ; long max = dec ( digit ) - 1 ; while ( min < max ) { long next = ( min + max ) / 2 ; ask ( next * 10 ) ; if ( sc . nextLine ( ) . equals ( " Y " ) ) { max = next ; } else { min = next + 1 ; } } answer ( min ) ; System . exit ( 0 ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; Main main = new Main ( ) ; int l ; int N = 0 ; for ( l = 1 ; l < 11 ; l ++ ) { main . output ( false , ( int ) Math . pow ( 10 , l ) ) ; if ( main . input ( scan ) == 0 ) { break ; } } if ( l != 11 ) { int nMin = ( int ) Math . pow ( 10 , l - 1 ) ; int nMax = ( int ) Math . pow ( 10 , l ) - 1 ; while ( nMin != nMax ) { int n = ( nMin + nMax ) / 2 ; main . output ( false , ( n * 10L ) ) ; if ( main . input ( scan ) == 0 ) { nMin = n + 1 ; } else { nMax = n ; } } N = nMin ; } else { for ( l = 0 ; l < 10 ; l ++ ) { main . output ( false , ( int ) Math . pow ( 10 , l ) * 2 ) ; if ( main . input ( scan ) == 1 ) { N = ( int ) Math . pow ( 10 , l ) ; break ; } } } main . output ( true , N ) ; } private void output ( boolean answerFlag , long n ) { if ( answerFlag ) { System . out . println ( " ! ▁ " + n ) ; } else { System . out . println ( " ? ▁ " + n ) ; } System . out . flush ( ) ; } private int input ( Scanner scan ) throws Exception { String input = scan . next ( ) ; if ( " Y " . equals ( input ) ) { return 1 ; } else if ( " N " . equals ( input ) ) { return 0 ; } else { throw new Exception ( ) ; } } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( " ? ▁ " + ( long ) 1e10 ) ; String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { int cnt = 0 ; while ( true ) { System . out . println ( " ? ▁ " + ( long ) ( 2 * Math . pow ( 10 , cnt ) ) ) ; s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { System . out . println ( " ! ▁ " + ( long ) Math . pow ( 10 , cnt ) ) ; return ; } ++ cnt ; } } else { int cnt = 9 ; while ( true ) { System . out . println ( " ? ▁ " + ( long ) Math . pow ( 10 , cnt ) ) ; s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { break ; } -- cnt ; } long left = ( long ) Math . pow ( 10 , cnt ) ; long right = ( long ) Math . pow ( 10 , cnt + 1 ) - 1 ; while ( right - left > 1 ) { long middle = ( right + left ) / 2 ; System . out . println ( " ? ▁ " + middle * 10 ) ; s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { right = middle ; } else { left = middle ; } } System . out . println ( " ! ▁ " + right ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

def binsearch ( l , r , pred ) : NEW_LINE INDENT assert l < r NEW_LINE l -= 1 NEW_LINE while r - l > 1 : NEW_LINE INDENT m = ( l + r ) // 2 NEW_LINE if pred ( m ) : NEW_LINE INDENT r = m NEW_LINE DEDENT else : NEW_LINE INDENT l = m NEW_LINE DEDENT DEDENT return r NEW_LINE DEDENT import sys NEW_LINE def pred ( n ) : NEW_LINE INDENT assert 1 <= n and n <= 10 ** 18 NEW_LINE print ( ' ? ' , n ) NEW_LINE sys . stdout . flush ( ) NEW_LINE return input ( ) == ' Y ' NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT s = ' ' NEW_LINE s += str ( binsearch ( 1 , 9 + 1 , lambda c : not pred ( int ( s + str ( c ) ) ) ) - 1 ) NEW_LINE if s == '9' : NEW_LINE INDENT f = lambda k : pred ( int ( '1' + '0' * k ) ) NEW_LINE DEDENT else : NEW_LINE INDENT f = lambda k : not pred ( int ( '9' * k ) ) NEW_LINE DEDENT k = 1 NEW_LINE while f ( k ) : NEW_LINE INDENT k += 1 NEW_LINE if k >= 13 : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT if k == 1 : NEW_LINE INDENT s = ' ' NEW_LINE DEDENT for _ in range ( k - 2 ) : NEW_LINE INDENT s += str ( binsearch ( 0 , 9 + 1 , lambda c : not pred ( int ( s + str ( c ) ) ) ) - 1 ) NEW_LINE DEDENT s += str ( binsearch ( 0 , 9 + 1 , lambda c : pred ( int ( s + str ( c ) + '0' ) ) ) ) NEW_LINE return int ( s ) NEW_LINE DEDENT print ( ' ! ' , solve ( ) ) NEW_LINE

for k in range ( 1 , 10 ) : NEW_LINE INDENT print ( ' ? ' , 10 ** k , flush = True ) NEW_LINE if input ( ) == ' N ' : NEW_LINE INDENT i = 10 ** ( k - 1 ) + 1 NEW_LINE j = 10 ** k - 1 NEW_LINE while i < j : NEW_LINE INDENT m = ( i + j ) // 2 NEW_LINE print ( ' ? ' , m * 10 , flush = True ) NEW_LINE if input ( ) == ' Y ' : NEW_LINE INDENT j = m NEW_LINE DEDENT else : NEW_LINE INDENT i = m + 1 NEW_LINE DEDENT DEDENT print ( ' ! ' , i , flush = True ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for k in range ( 10 ) : NEW_LINE INDENT print ( ' ? ' , 10 ** ( k + 1 ) - 1 , flush = True ) NEW_LINE if input ( ) == ' Y ' : NEW_LINE INDENT print ( ' ! ' , 10 ** k , flush = True ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT

def query ( val ) : NEW_LINE INDENT print ( ' ? ' , val ) NEW_LINE ans = input ( ) NEW_LINE if ans == ' Y ' : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT LIMIT = 10 ** 9 NEW_LINE import sys NEW_LINE if __name__ == " _ _ main _ _ " : NEW_LINE INDENT if ( query ( LIMIT ) ) : NEW_LINE INDENT res = 1 NEW_LINE while ( True ) : NEW_LINE INDENT if ( query ( 2 * res ) ) : NEW_LINE INDENT print ( ' ! ' , res ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT res *= 10 NEW_LINE DEDENT DEDENT digit = 10 NEW_LINE res = LIMIT NEW_LINE while ( True ) : NEW_LINE INDENT if ( query ( res ) ) : NEW_LINE INDENT break NEW_LINE DEDENT res = res // 10 NEW_LINE digit -= 1 NEW_LINE DEDENT query = 10 ** ( digit ) NEW_LINE keta = 0 NEW_LINE while ( keta < digit ) : NEW_LINE INDENT low = query NEW_LINE high = query * 10 NEW_LINE left = - 1 NEW_LINE right = 10 NEW_LINE while ( right - left > 1 ) : NEW_LINE INDENT med = ( right + left ) // 2 NEW_LINE if med < 0 : NEW_LINE INDENT left = med NEW_LINE continue NEW_LINE DEDENT if med > 9 : NEW_LINE INDENT right = med NEW_LINE continue NEW_LINE DEDENT if keta == 0 and med == 0 : NEW_LINE INDENT left = med NEW_LINE continue NEW_LINE DEDENT val1 = list ( str ( low ) ) NEW_LINE val1 [ keta ] = str ( med ) NEW_LINE val1 = int ( " " . join ( val1 ) ) NEW_LINE print ( " ? ▁ % d " % ( val1 ) ) NEW_LINE ans = input ( ) NEW_LINE if ( ans == " Y " ) : NEW_LINE INDENT if ( keta == digit - 1 ) : NEW_LINE INDENT query = val1 NEW_LINE DEDENT right = med NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT if ( keta < digit - 1 ) : NEW_LINE INDENT query = val1 NEW_LINE DEDENT left = med NEW_LINE continue NEW_LINE DEDENT DEDENT keta += 1 NEW_LINE DEDENT query = query // 10 NEW_LINE print ( " ! ▁ % d " % ( query ) ) NEW_LINE DEDENT

import sys NEW_LINE ans = None NEW_LINE for idx in range ( 0 , 11 , 1 ) : NEW_LINE INDENT print ( ' ? ▁ 1' + '0' * idx ) NEW_LINE sys . stdout . flush ( ) NEW_LINE kekka = input ( ) NEW_LINE if kekka == ' N ' : NEW_LINE INDENT digits = idx NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for idx in range ( 1 , 11 , 1 ) : NEW_LINE INDENT print ( ' ? ▁ ' + '9' * idx ) NEW_LINE sys . stdout . flush ( ) NEW_LINE kekka = input ( ) NEW_LINE if kekka == ' Y ' : NEW_LINE INDENT c = idx - 1 NEW_LINE break NEW_LINE DEDENT DEDENT ans = ' ! ▁ 1' + '0' * c NEW_LINE DEDENT if ans == None : NEW_LINE INDENT kagen = 10 ** ( digits - 1 ) NEW_LINE jogen = 10 ** ( digits ) - 1 NEW_LINE while jogen - kagen > 1 : NEW_LINE INDENT miru = ( jogen + kagen ) // 2 NEW_LINE print ( ' ? ▁ ' + str ( miru ) + '0' ) NEW_LINE sys . stdout . flush ( ) NEW_LINE kekka = input ( ) NEW_LINE if kekka == ' Y ' : NEW_LINE INDENT jogen = miru NEW_LINE DEDENT else : NEW_LINE INDENT kagen = miru NEW_LINE DEDENT DEDENT ans = ' ! ▁ ' + str ( jogen ) NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE def read_int_list ( ) : NEW_LINE INDENT return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT def read_int ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def read_str_list ( ) : NEW_LINE INDENT return input ( ) . split ( ) NEW_LINE DEDENT def read_str ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT debug = False NEW_LINE N = 5600070 NEW_LINE if debug : NEW_LINE INDENT print ( ) NEW_LINE print ( ' N : ' , N ) NEW_LINE print ( ) NEW_LINE DEDENT def ask ( n ) : NEW_LINE INDENT if debug : NEW_LINE INDENT res = ( n <= N and str ( n ) <= str ( N ) ) or ( n >= N and str ( n ) >= str ( N ) ) NEW_LINE print ( ' ? ' , n , ' \t ' , res ) NEW_LINE return res NEW_LINE DEDENT print ( ' ? ' , n , flush = True ) NEW_LINE return input ( ) in [ ' y ' , ' Y ' ] NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT if ask ( 10 ** 9 ) : NEW_LINE INDENT for k in range ( 10 ) : NEW_LINE INDENT if ask ( 2 * 10 ** k ) : NEW_LINE INDENT return 10 ** k NEW_LINE DEDENT DEDENT DEDENT l = 1 NEW_LINE while ask ( 10 ** l ) : NEW_LINE INDENT l += 1 NEW_LINE DEDENT d = [ 9 ] * l NEW_LINE for p in range ( l ) : NEW_LINE INDENT a = 0 NEW_LINE if p == 0 : NEW_LINE INDENT a = 1 NEW_LINE DEDENT b = 9 NEW_LINE d [ p ] = a NEW_LINE n = int ( ' ' . join ( map ( str , d ) ) ) NEW_LINE if ask ( 10 * n ) : NEW_LINE INDENT continue NEW_LINE DEDENT while b - a > 1 : NEW_LINE INDENT m = ( a + b ) // 2 NEW_LINE d [ p ] = m NEW_LINE n = int ( ' ' . join ( map ( str , d ) ) ) NEW_LINE if ask ( 10 * n ) : NEW_LINE INDENT b = m NEW_LINE DEDENT else : NEW_LINE INDENT a = m NEW_LINE DEDENT DEDENT d [ p ] = b NEW_LINE DEDENT n = int ( ' ' . join ( map ( str , d ) ) ) NEW_LINE return n NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT res = solve ( ) NEW_LINE print ( ' ! ' , res , flush = True ) NEW_LINE 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 ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = br . readLine ( ) . split ( " ▁ " , 2 ) ; int n = Integer . parseInt ( arr [ 0 ] ) ; int k = Integer . parseInt ( arr [ 1 ] ) ; int prev = 0 ; int count = 0 ; int sum = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = Integer . parseInt ( br . readLine ( ) ) ; if ( i == 0 ) { count = 1 ; } else if ( prev >= a ) { count = 1 ; } else { count ++ ; } if ( count >= k ) { sum ++ ; } prev = a ; } System . out . println ( sum ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] ary = new int [ N ] ; int [ ] dp = new int [ N ] ; Arrays . fill ( dp , 0 ) ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; } dp [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( ary [ i ] > ary [ i - 1 ] ) { dp [ i ] = dp [ i - 1 ] + 1 ; } else { dp [ i ] = 1 ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( dp [ i ] >= K ) { sum ++ ; } } pl ( sum ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }

import java . util . * ; public class Main { private static int n ; private static int k ; private static int a [ ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; k = scan . nextInt ( ) ; a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = scan . nextInt ( ) ; } public static void main ( String args [ ] ) { input ( ) ; boolean b [ ] = new boolean [ n - 1 ] ; int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) b [ i ] = true ; else b [ i ] = false ; if ( b [ i ] ) { count ++ ; if ( count >= k - 1 ) ans ++ ; } else count = 0 ; } if ( k == 1 ) System . out . println ( n ) ; else System . out . println ( ans ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) , k = s . nextInt ( ) , b = 0 , c = 0 , r = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( b < ( b = s . nextInt ( ) ) ) ++ c ; else { r += c >= k ? c - k + 1 : 0 ; c = 1 ; } } System . out . println ( c >= k ? r + c - k + 1 : r ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int a [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int up = 1 ; int count = 0 ; for ( int i = 0 ; i <= N - 1 ; i ++ ) { if ( i > 0 && a [ i - 1 ] < a [ i ] ) { up ++ ; } else { up = 1 ; } if ( up >= K ) { count ++ ; } } System . out . println ( count ) ; } }

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE prev = 0 NEW_LINE l = 0 NEW_LINE r = 0 NEW_LINE seq = 1 NEW_LINE ans = 0 NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE while r < N : NEW_LINE INDENT if A [ r ] > prev : NEW_LINE INDENT prev = A [ r ] NEW_LINE r += 1 NEW_LINE if r - l == K : NEW_LINE INDENT ans += 1 NEW_LINE l += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT prev = 0 NEW_LINE l = r NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

N , K = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE conti = 1 NEW_LINE previous = int ( input ( ) ) NEW_LINE count = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT current = int ( input ( ) ) NEW_LINE if current > previous : NEW_LINE INDENT conti += 1 NEW_LINE DEDENT else : NEW_LINE INDENT conti = 1 NEW_LINE DEDENT if conti >= K : NEW_LINE INDENT count += 1 NEW_LINE DEDENT previous = current NEW_LINE DEDENT if K == 1 : NEW_LINE INDENT print ( N ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( count ) NEW_LINE DEDENT

n , k , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE l = [ ] NEW_LINE t = 0 NEW_LINE for i , j in zip ( a , a [ 1 : ] ) : NEW_LINE INDENT if j > i : NEW_LINE INDENT t += 1 NEW_LINE DEDENT else : NEW_LINE INDENT l . append ( t ) NEW_LINE t = 0 NEW_LINE DEDENT DEDENT l . append ( t ) NEW_LINE print ( sum ( max ( 0 , t + 2 - k ) for t in l ) ) NEW_LINE

def b_low_resolution ( N , K , A ) : NEW_LINE INDENT increasing_length = 1 NEW_LINE increasing_interval = [ ] NEW_LINE for j in range ( 1 , N ) : NEW_LINE INDENT if A [ j ] > A [ j - 1 ] : NEW_LINE INDENT increasing_length += 1 NEW_LINE DEDENT else : NEW_LINE INDENT increasing_interval . append ( increasing_length ) NEW_LINE increasing_length = 1 NEW_LINE DEDENT DEDENT if increasing_length != 1 : NEW_LINE INDENT increasing_interval . append ( increasing_length ) NEW_LINE DEDENT ans = sum ( [ max ( i - K + 1 , 0 ) for i in increasing_interval ] ) NEW_LINE return ans NEW_LINE DEDENT N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE A = [ int ( input ( ) ) for _ in [ 0 ] * N ] NEW_LINE print ( b_low_resolution ( N , K , A ) ) NEW_LINE

import sys NEW_LINE input = sys . stdin . readline NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def solve ( ) : NEW_LINE INDENT N , K = inpl ( ) NEW_LINE A = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE if K == 1 : return N NEW_LINE prev = A [ 0 ] NEW_LINE ans , cnt = 0 , 1 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT cnt += 1 NEW_LINE if A [ i ] <= prev : NEW_LINE INDENT cnt = 1 NEW_LINE DEDENT if cnt >= K : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT prev = A [ i ] NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( solve ( ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ans = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { ans += sc . nextInt ( ) * sc . nextInt ( ) / 10 ; } System . out . println ( ans ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int s1 = in . nextInt ( ) ; double e1 = in . nextInt ( ) ; int s2 = in . nextInt ( ) ; double e2 = in . nextInt ( ) ; int s3 = in . nextInt ( ) ; double e3 = in . nextInt ( ) ; out . println ( ( int ) ( s1 * ( e1 / 10 ) + s2 * ( e2 / 10 ) + s3 * ( e3 / 10 ) ) ) ; } } 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 a1 = sc . nextInt ( ) ; int b2 = sc . nextInt ( ) ; int c3 = sc . nextInt ( ) ; System . out . println ( a * b / 10 + c * a1 / 10 + b2 * c3 / 10 ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int total = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) total += in . nextInt ( ) * in . nextInt ( ) / 10 ; out . println ( total ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( ( int ) ( sc . nextDouble ( ) * sc . nextDouble ( ) * 0.1 + sc . nextDouble ( ) * sc . nextDouble ( ) * 0.1 + sc . nextDouble ( ) * sc . nextDouble ( ) * 0.1 ) ) ; } }

s1 , e1 = map ( int , input ( ) . split ( ) ) NEW_LINE s2 , e2 = map ( int , input ( ) . split ( ) ) NEW_LINE s3 , e3 = map ( int , input ( ) . split ( ) ) NEW_LINE print ( int ( ( s1 * e1 + s2 * e2 + s3 * e3 ) / 10 ) ) NEW_LINE

p = 0.0 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE p += l [ 0 ] * l [ 1 ] * 0.1 NEW_LINE DEDENT print ( int ( p ) ) NEW_LINE

print ( int ( sum ( [ eval ( '0.1 * ' + input ( ) . replace ( ' ▁ ' , ' * ' ) ) for _ in range ( 3 ) ] ) ) ) NEW_LINE

A = input ( ) . split ( ) NEW_LINE B = input ( ) . split ( ) NEW_LINE C = input ( ) . split ( ) NEW_LINE s1 = int ( A [ 0 ] ) NEW_LINE e1 = int ( A [ 1 ] ) NEW_LINE s2 = int ( B [ 0 ] ) NEW_LINE e2 = int ( B [ 1 ] ) NEW_LINE s3 = int ( C [ 0 ] ) NEW_LINE e3 = int ( C [ 1 ] ) NEW_LINE if 10 <= s1 and s2 and s3 <= 990 : NEW_LINE INDENT if 1 <= e1 and e2 and e3 <= 10 : NEW_LINE INDENT if s1 % 10 == 0 and s2 % 10 == 0 and s3 % 10 == 0 : NEW_LINE INDENT print ( int ( s1 / 10 * e1 + s2 / 10 * e2 + s3 / 10 * e3 ) ) NEW_LINE DEDENT DEDENT DEDENT

a , b = map ( int , input ( ) . split ( ) ) NEW_LINE c , d = map ( int , input ( ) . split ( ) ) NEW_LINE e , f = map ( int , input ( ) . split ( ) ) NEW_LINE A = a * b // 10 NEW_LINE B = c * d // 10 NEW_LINE C = e * f // 10 NEW_LINE print ( A + B + C ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; long I = sc . nextLong ( ) ; long O = sc . nextLong ( ) ; long T = sc . nextLong ( ) ; long J = sc . nextLong ( ) ; long L = sc . nextLong ( ) ; long S = sc . nextLong ( ) ; long Z = sc . nextLong ( ) ; long ans = 0 ; long tmp = 0 ; if ( I > 0 ) { ans += ( ( I - 1 ) / 2 ) * 2 ; } ans += O ; if ( J > 0 ) { ans += ( ( J - 1 ) / 2 ) * 2 ; } if ( L > 0 ) { ans += ( ( L - 1 ) / 2 ) * 2 ; } if ( I > 0 && J > 0 && L > 0 ) { ans += 3 ; } tmp += I / 2 * 2 ; tmp += O ; tmp += J / 2 * 2 ; tmp += L / 2 * 2 ; pl ( Math . max ( ans , tmp ) ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }

import java . io . * ; import java . util . * ; public class Main { private static boolean debug = false ; private static boolean elapsed = false ; private static PrintWriter _err = new PrintWriter ( System . err ) ; private void solve ( Scanner sc , PrintWriter out ) { long ai = sc . nextInt ( ) ; long ao = sc . nextInt ( ) ; long at = sc . nextInt ( ) ; long aj = sc . nextInt ( ) ; long al = sc . nextInt ( ) ; long as = sc . nextInt ( ) ; long az = sc . nextInt ( ) ; long size = 0 ; size = ( ai / 2 + aj / 2 + al / 2 ) * 2 + ao ; if ( ai > 0 && aj > 0 && al > 0 ) { size = Math . max ( size , 3 + ( ( ai - 1 ) / 2 + ( aj - 1 ) / 2 + ( al - 1 ) / 2 ) * 2 + ao ) ; } out . println ( size ) ; } private long C ( long n , long r ) { long res = 1 ; for ( long i = n ; i > n - r ; -- i ) { res *= i ; } for ( long i = r ; i > 1 ; -- i ) { res /= i ; } return res ; } private long P ( long n , long r ) { long res = 1 ; for ( long i = n ; i > n - r ; -- i ) { res *= i ; } return res ; } public static void main ( String [ ] args ) { long S = System . currentTimeMillis ( ) ; Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( sc , out ) ; out . flush ( ) ; long G = System . currentTimeMillis ( ) ; if ( elapsed ) { _err . println ( ( G - S ) + " ms " ) ; } _err . flush ( ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] a = new long [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) a [ i ] = sc . nextLong ( ) ; long ans = 0 ; ans += a [ 1 ] ; if ( a [ 0 ] == 0 || a [ 3 ] == 0 || a [ 4 ] == 0 ) { System . out . println ( ans + ( a [ 0 ] / 2 + a [ 3 ] / 2 + a [ 4 ] / 2 ) * 2 ) ; System . exit ( 0 ) ; } long res1 = ( a [ 0 ] / 2 + a [ 3 ] / 2 + a [ 4 ] / 2 ) * 2 ; long temp = Math . min ( Math . min ( a [ 0 ] , a [ 3 ] ) , a [ 4 ] ) ; long res2 = temp * 3 + ( ( a [ 0 ] - temp ) / 2 + ( a [ 3 ] - temp ) / 2 + ( a [ 4 ] - temp ) / 2 ) * 2 ; long res3 = a [ 0 ] + a [ 3 ] + a [ 4 ] - 1 ; ans += Math . max ( Math . max ( res1 , res2 ) , res3 ) ; System . out . println ( ans ) ; } }

import java . io . * ; 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 ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int i = in . nextInt ( ) ; int o = in . nextInt ( ) ; int t = in . nextInt ( ) ; int j = in . nextInt ( ) ; int l = in . nextInt ( ) ; int s = in . nextInt ( ) ; int z = in . nextInt ( ) ; long res = o ; int modCnt = i % 2 + j % 2 + l % 2 ; if ( modCnt > 1 && i > 0 && j > 0 && l > 0 ) { i -- ; j -- ; l -- ; res += 3 ; } res += ( i / 2 ) * 2 ; res += ( j / 2 ) * 2 ; res += ( l / 2 ) * 2 ; out . println ( res ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . util . * ; class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { long i = g ( ) , o = g ( ) , t = g ( ) , j = g ( ) , l = g ( ) , r = l / 2 * 2 + j / 2 * 2 + i / 2 * 2 ; if ( l > 0 && j > 0 && i > 0 ) r = Math . max ( r , 3 + ( l - 1 ) / 2 * 2 + ( j - 1 ) / 2 * 2 + ( i - 1 ) / 2 * 2 ) ; System . out . println ( r + o ) ; } static long g ( ) { return s . nextLong ( ) ; } }

i , o , t , j , l , s , z = map ( int , input ( ) . split ( ) ) NEW_LINE a = 0 NEW_LINE b = 0 NEW_LINE if i > 0 and j > 0 and l > 0 : NEW_LINE INDENT a += 3 NEW_LINE for k in [ i - 1 , j - 1 , l - 1 ] : NEW_LINE INDENT if k % 2 == 1 : NEW_LINE INDENT a += k - 1 NEW_LINE DEDENT else : NEW_LINE INDENT a += k NEW_LINE DEDENT DEDENT DEDENT for k in [ i , j , l ] : NEW_LINE INDENT if k % 2 == 1 : NEW_LINE INDENT b += k - 1 NEW_LINE DEDENT else : NEW_LINE INDENT b += k NEW_LINE DEDENT DEDENT print ( o + max ( a , b ) ) NEW_LINE

from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( " YES " ) NEW_LINE else : print ( " NO " ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( " + " ) NEW_LINE elif ( x < y ) : print ( " - " ) NEW_LINE else : print ( " ? " ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a . pop ( 6 ) NEW_LINE a . pop ( 5 ) NEW_LINE a . pop ( 2 ) NEW_LINE s = sum ( a ) NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT if i != 1 and a [ i ] % 2 : s -= 1 NEW_LINE DEDENT if s + 3 == sum ( a ) : s = sum ( a ) NEW_LINE if s + 2 == sum ( a ) and a [ 0 ] and a [ 2 ] and a [ 3 ] > 3 : s = sum ( a ) - 1 NEW_LINE print ( s ) NEW_LINE

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT A = LI ( ) NEW_LINE res = 0 NEW_LINE for e in ( 0 , 3 , 4 ) : NEW_LINE INDENT res += A [ e ] // 2 * 2 NEW_LINE DEDENT if all ( [ A [ 0 ] , A [ 3 ] , A [ 4 ] ] ) : NEW_LINE INDENT tmp = 3 NEW_LINE for e in ( 0 , 3 , 4 ) : NEW_LINE INDENT tmp += ( A [ e ] - 1 ) // 2 * 2 NEW_LINE DEDENT if res < tmp : NEW_LINE INDENT res = tmp NEW_LINE DEDENT DEDENT return res + A [ 1 ] NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

a , square , qqq , b , c , qqqq , qqqqq = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a_ = a % 2 NEW_LINE b_ = b % 2 NEW_LINE c_ = c % 2 NEW_LINE b_sub = b - b_ NEW_LINE c_sub = c - c_ NEW_LINE if b_ == 1 and c_ == 1 and a > 0 : NEW_LINE INDENT a = a - 1 NEW_LINE a_ = a % 2 NEW_LINE a_sub = a - a_ NEW_LINE print ( a_sub + b_sub + c_sub + 3 + square ) NEW_LINE DEDENT elif a_ == 1 and c_ == 1 and b > 0 : NEW_LINE INDENT a_sub = a - a_ NEW_LINE b = b - 1 NEW_LINE b_ = b % 2 NEW_LINE b_sub = b - b_ NEW_LINE print ( a_sub + b_sub + c_sub + 3 + square ) NEW_LINE DEDENT elif a_ == 1 and b_ == 1 and c > 0 : NEW_LINE INDENT a_sub = a - a_ NEW_LINE c = c - 1 NEW_LINE c_ = c % 2 NEW_LINE c_sub = c - c_ NEW_LINE print ( a_sub + b_sub + c_sub + 3 + square ) NEW_LINE DEDENT else : NEW_LINE INDENT a_ = a % 2 NEW_LINE a_sub = a - a_ NEW_LINE print ( a_sub + b_sub + c_sub + square ) NEW_LINE DEDENT

import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE i , o , t , j , l , s , z = map ( int , input ( ) . split ( ) ) NEW_LINE ans = o NEW_LINE odd_num = ( i % 2 ) + ( j % 2 ) + ( l % 2 ) NEW_LINE if odd_num >= 2 and i > 0 and j > 0 and l > 0 : NEW_LINE INDENT ans += 3 NEW_LINE i -= 1 NEW_LINE j -= 1 NEW_LINE l -= 1 NEW_LINE DEDENT ans += ( i // 2 ) * 2 NEW_LINE ans += ( j // 2 ) * 2 NEW_LINE ans += ( l // 2 ) * 2 NEW_LINE print ( ans ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , InputReader in , PrintWriter out ) { long n = in . nextLong ( ) ; long m = in . nextLong ( ) ; if ( Math . abs ( n - m ) >= 2 ) { out . println ( 0 ) ; return ; } long ans = 1 ; long MOD = 1_000_000_007 ; for ( int i = 1 ; i <= n ; i ++ ) { ans = ( ans * i ) % MOD ; } for ( int i = 1 ; i <= m ; i ++ ) { ans = ( ans * i ) % MOD ; } if ( n == m ) ans = ( ans * 2 ) % MOD ; out . println ( ans ) ; } } static class InputReader { BufferedReader in ; StringTokenizer tok ; public String nextString ( ) { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) , " ▁ " ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return tok . nextToken ( ) ; } public long nextLong ( ) { return Long . parseLong ( nextString ( ) ) ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( " " ) ; } } }

import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long ans = 1 ; long mod = ( long ) Math . pow ( 10 , 9 ) + 7 ; if ( n == m ) { for ( int i = n ; i > 0 ; i -- ) { ans = ( ( ans * ( long ) i ) % mod ) * ( long ) i % mod ; } ans = ( ans * 2 ) % mod ; } else if ( ( int ) Math . abs ( n - m ) == 1 ) { for ( int i = ( int ) Math . min ( n , m ) ; i > 0 ; i -- ) { ans = ( ( ans * ( long ) i ) % mod ) * ( long ) i % mod ; } ans = ( ans * ( long ) Math . max ( n , m ) ) % mod ; } else { ans = 0 ; } System . out . println ( ans ) ; } }

import java . util . * ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; Long facN = this . calcfac ( N ) ; Long facM = this . calcfac ( M ) ; if ( N == M ) { System . out . println ( 2 * facN * facM % 1000000007 ) ; } else if ( N + 1 == M || N == M + 1 ) { System . out . println ( facN * facM % 1000000007 ) ; } else { System . out . println ( 0 ) ; } } Long calcfac ( int num ) { Long sum = new Long ( 1 ) ; for ( int i = num ; i > 0 ; i -- ) { sum *= i ; sum %= 1000000007 ; } return sum ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }

import java . util . Scanner ; public class Main { public static long frac [ ] = new long [ 100020 ] ; public static final int ZYY = 1000000007 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; scan . close ( ) ; if ( Math . abs ( x - y ) > 1 ) { System . out . println ( '0' ) ; return ; } frac [ 0 ] = 1 ; for ( int i = 1 ; i <= 100000 ; i ++ ) frac [ i ] = frac [ i - 1 ] * i % ZYY ; long ans = frac [ x ] * frac [ y ] % ZYY ; if ( x == y ) ans = ans * 2 % ZYY ; System . out . println ( ans ) ; return ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; long base = ( long ) 1e9 + 7 ; long ans = 1 ; if ( Math . abs ( n - m ) == 0 ) { ans *= 2 ; ans %= base ; } else if ( Math . abs ( n - m ) > 1 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } for ( int i = 1 ; i <= n ; i ++ ) { ans *= i ; ans %= base ; } for ( int i = 1 ; i <= m ; i ++ ) { ans *= i ; ans %= base ; } System . out . println ( ans ) ; } }

N , M = map ( int , input ( ) . split ( ' ▁ ' ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE if abs ( N - M ) > 1 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT ans = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans = ans * ( i + 1 ) % MOD NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT ans = ans * ( i + 1 ) % MOD NEW_LINE DEDENT if N == M : NEW_LINE INDENT ans = ans * 2 % MOD NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE import collections NEW_LINE import math NEW_LINE from collections import Counter NEW_LINE from collections import deque NEW_LINE N , M = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE D = 10 ** 9 + 7 NEW_LINE if abs ( N - M ) >= 2 : NEW_LINE INDENT print ( 0 ) NEW_LINE sys . exit ( 0 ) NEW_LINE DEDENT ret = math . factorial ( N ) * math . factorial ( M ) NEW_LINE if N == M : NEW_LINE INDENT ret *= 2 NEW_LINE DEDENT print ( ret % D ) NEW_LINE

import math NEW_LINE INF , MOD = float ( " inf " ) , 10 ** 9 + 7 NEW_LINE MAX , MIN = - INF , INF NEW_LINE dx1 , dy1 , dx2 , dy2 = [ - 1 , 0 , 1 , 0 ] , [ 0 , - 1 , 0 , 1 ] , [ - 1 , 0 , 1 , - 1 , 1 , - 1 , 0 , 1 ] , [ - 1 , - 1 , - 1 , 0 , 0 , 1 , 1 , 1 ] NEW_LINE def get_int ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def get_int_list ( ) : NEW_LINE INDENT return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT def mins ( x , y ) : NEW_LINE INDENT x = min ( x , y ) NEW_LINE DEDENT def maxs ( x , y ) : NEW_LINE INDENT x = max ( x , y ) NEW_LINE DEDENT def fact ( n ) : NEW_LINE INDENT tmp = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT tmp = int ( tmp * i % MOD ) NEW_LINE DEDENT return tmp NEW_LINE DEDENT while ( True ) : NEW_LINE INDENT try : NEW_LINE INDENT n , m = get_int_list ( ) NEW_LINE if ( n == m ) : NEW_LINE INDENT print ( int ( fact ( n ) ** 2 * 2 % MOD ) ) NEW_LINE DEDENT elif ( abs ( n - m ) == 1 ) : NEW_LINE INDENT print ( int ( fact ( n ) * fact ( m ) % MOD ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT except EOFError : NEW_LINE INDENT exit ( ) NEW_LINE DEDENT DEDENT

class FactMod ( ) : NEW_LINE INDENT def __init__ ( self , n , mod ) : NEW_LINE INDENT self . f = [ 1 ] * ( n + 1 ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT self . f [ i ] = self . f [ i - 1 ] * i % mod NEW_LINE DEDENT self . inv = [ pow ( self . f [ - 1 ] , mod - 2 , mod ) ] NEW_LINE for i in range ( 1 , n + 1 ) [ : : - 1 ] : NEW_LINE INDENT self . inv . append ( self . inv [ - 1 ] * i % mod ) NEW_LINE DEDENT self . inv . reverse ( ) NEW_LINE DEDENT def fact ( self , n ) : NEW_LINE INDENT return self . f [ n ] NEW_LINE DEDENT DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE ans = 0 NEW_LINE F = FactMod ( max ( N , M ) , mod ) NEW_LINE if abs ( N - M ) == 1 : NEW_LINE INDENT ans = F . fact ( N ) * F . fact ( M ) % mod NEW_LINE DEDENT elif N == M : NEW_LINE INDENT ans = F . fact ( N ) * F . fact ( N ) * 2 % mod NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT print ( ans ) NEW_LINE

import math NEW_LINE def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def dmp ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def probC ( ) : NEW_LINE INDENT N , M = getIntList ( ) NEW_LINE N1097 = 10 ** 9 + 7 NEW_LINE dmp ( ( N , M ) ) NEW_LINE if N == M : NEW_LINE INDENT times = 2 NEW_LINE DEDENT elif abs ( N - M ) == 1 : NEW_LINE INDENT times = 1 NEW_LINE DEDENT else : NEW_LINE INDENT times = 0 NEW_LINE DEDENT dmp ( times ) NEW_LINE count = math . factorial ( N ) * math . factorial ( M ) * times % N1097 NEW_LINE return count NEW_LINE DEDENT debug = False NEW_LINE print ( probC ( ) ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ; public class Main { static int c [ ] ; static int n ; static int lowbit ( int x ) { return x & ( - x ) ; } static void add ( int i , int val ) { while ( i <= n ) { c [ i ] += val ; i += lowbit ( i ) ; } } static int sum ( int i ) { int sum = 0 ; while ( i > 0 ) { sum += c [ i ] ; i -= lowbit ( i ) ; } return sum ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; int p = in . nextInt ( ) ; c = new int [ n ] ; while ( p -- > 0 ) { int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; int k = in . nextInt ( ) ; Arrays . fill ( c , l - 1 , r , k ) ; } for ( int i : c ) { System . out . println ( i ) ; } } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] nq = scanner . nextLine ( ) . split ( " ▁ " , 2 ) ; int n = Integer . parseInt ( nq [ 0 ] ) ; int q = Integer . parseInt ( nq [ 1 ] ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < q ; i ++ ) { String [ ] lrt = scanner . nextLine ( ) . split ( " ▁ " , 3 ) ; int l = Integer . parseInt ( lrt [ 0 ] ) ; int r = Integer . parseInt ( lrt [ 1 ] ) ; int t = Integer . parseInt ( lrt [ 2 ] ) ; for ( int j = l - 1 ; j < r ; j ++ ) { arr [ j ] = t ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( arr [ i ] ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] ary = new int [ sc . nextInt ( ) ] ; int count = sc . nextInt ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int f = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int num = sc . nextInt ( ) ; for ( int e = 0 ; e < ary . length ; e ++ ) { if ( f <= ( e + 1 ) && l > e ) ary [ e ] = num ; } } for ( int i : ary ) { System . out . println ( i ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < > ( ) ; int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) list . add ( 0 ) ; for ( int i = 0 ; i < Q ; i ++ ) { int L = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; L -- ; R -- ; for ( int j = L ; j <= R ; j ++ ) list . set ( j , T ) ; } for ( Iterator it = list . iterator ( ) ; it . hasNext ( ) ; ) { System . out . println ( it . next ( ) ) ; } } }

import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int n = stdIn . nextInt ( ) , q = stdIn . nextInt ( ) , l , r , t , i , j , a [ ] = new int [ 100 ] ; for ( i = 0 ; i < q ; i ++ ) { l = stdIn . nextInt ( ) ; r = stdIn . nextInt ( ) ; t = stdIn . nextInt ( ) ; for ( j = l - 1 ; j < r ; j ++ ) a [ j ] = t ; } for ( i = 0 ; i < n ; i ++ ) System . out . println ( a [ i ] ) ; } }

n , q = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ 0 ] * n NEW_LINE for i in range ( q ) : NEW_LINE INDENT l , r , t = map ( int , input ( ) . split ( ) ) NEW_LINE for x in range ( l - 1 , r ) : NEW_LINE INDENT a [ x ] = t NEW_LINE DEDENT DEDENT print ( * a , sep = " \n " ) NEW_LINE

N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE row = [ 0 for _ in range ( N ) ] NEW_LINE lines = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( Q ) ] NEW_LINE for line in lines : NEW_LINE INDENT for ind in range ( line [ 0 ] - 1 , line [ 1 ] ) : NEW_LINE INDENT row [ ind ] = line [ 2 ] NEW_LINE DEDENT DEDENT for i in row : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT

def editorial ( N : int , Q : int , queries : list ) -> list : NEW_LINE INDENT a = [ 0 ] * N NEW_LINE for l , r , t in queries : NEW_LINE INDENT for i in range ( l - 1 , r ) : NEW_LINE INDENT a [ i ] = t NEW_LINE DEDENT DEDENT return a NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT Q = 0 NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( Q ) ] NEW_LINE ans = editorial ( N , Q , queries ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT

I = lambda : map ( int , input ( ) . split ( ) ) ; n , q = I ( ) ; a = [ 0 ] * n ; exec ( ' l , r , t = I ( ) ; a [ l - 1 : r ] = [ t ] * ( r - l + 1 ) ; ' * q ) ; print ( * a , sep = ' \n ' ) NEW_LINE

import numpy as np NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE ans = np . zeros ( N , dtype = np . int64 ) NEW_LINE for i in range ( Q ) : NEW_LINE INDENT L , R , T = map ( int , input ( ) . split ( ) ) NEW_LINE ans [ L - 1 : R ] = T NEW_LINE DEDENT for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT