import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; ArrayList < Character > chars = new ArrayList < Character > ( ) ; int one = 0 ; int two = 0 ; int n = 0 ; chars . add ( str . toCharArray ( ) [ 0 ] ) ; for ( char x : str . toCharArray ( ) ) { int count = 0 ; boolean flag = true ; for ( int i = 0 ; i < chars . size ( ) ; i ++ ) { if ( chars . get ( i ) == x ) { flag = false ; } } if ( flag || n == 0 ) { chars . add ( x ) ; for ( char y : str . toCharArray ( ) ) { if ( x == y ) count ++ ; } } two += count / 2 ; one += count % 2 ; n ++ ; } int minLength = two ; if ( one != 0 ) minLength = two / one ; minLength *= 2 ; if ( one > 0 ) minLength += 1 ; System . out . println ( minLength ) ; } }


from collections import Counter NEW_LINE a = Counter ( list ( input ( ) . strip ( ) ) ) NEW_LINE x = 0 NEW_LINE y = 0 NEW_LINE for i , j in a . most_common ( ) : NEW_LINE INDENT x += j // 2 NEW_LINE if j % 2 == 1 : NEW_LINE INDENT y += 1 NEW_LINE DEDENT DEDENT print ( x // y * 2 + 1 if y >= 1 else x * 2 ) NEW_LINE


s = input ( ) NEW_LINE lis = [ ] NEW_LINE num = [ ] NEW_LINE cou = 0 NEW_LINE even = 0 NEW_LINE for n in range ( len ( s ) ) : NEW_LINE INDENT if s [ n ] in lis : continue NEW_LINE else : NEW_LINE INDENT num . append ( s . count ( s [ n ] ) ) NEW_LINE lis . append ( s [ n ] ) NEW_LINE DEDENT DEDENT for item in num : NEW_LINE INDENT cou += item % 2 NEW_LINE even += item NEW_LINE DEDENT even -= cou NEW_LINE if cou == 0 : NEW_LINE INDENT print ( int ( len ( s ) ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( even / ( 2 * cou ) ) * 2 + 1 ) NEW_LINE DEDENT


def b_splited_palindrome ( S ) : NEW_LINE INDENT from collections import Counter NEW_LINE num_charactor_appeared = Counter ( S ) NEW_LINE num_appeared_odd_time = len ( [ 1 for v in num_charactor_appeared . values ( ) if v % 2 == 1 ] ) NEW_LINE ans = len ( S ) if num_appeared_odd_time == 0 else 2 * ( ( len ( S ) - num_appeared_odd_time ) // ( 2 * num_appeared_odd_time ) ) + 1 NEW_LINE return ans NEW_LINE DEDENT S = input ( ) NEW_LINE print ( b_splited_palindrome ( S ) ) NEW_LINE


from collections import defaultdict NEW_LINE S = list ( input ( ) ) NEW_LINE N = len ( S ) NEW_LINE cnt = defaultdict ( int ) NEW_LINE for c in S : NEW_LINE INDENT cnt [ c ] += 1 NEW_LINE DEDENT K = 0 NEW_LINE for value in cnt . values ( ) : NEW_LINE INDENT if value % 2 != 0 : NEW_LINE INDENT K += 1 NEW_LINE DEDENT DEDENT res = 0 NEW_LINE if K == 0 : NEW_LINE INDENT res = N NEW_LINE DEDENT else : NEW_LINE INDENT res = 2 * ( ( N - K ) // ( 2 * K ) ) + 1 NEW_LINE DEDENT print ( res ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] count = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count [ s . charAt ( i ) - ' a ' ] ++ ; } int divnum = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( count [ i ] % 2 != 0 ) { divnum ++ ; count [ i ] -- ; } } int sum = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { sum += count [ i ] ; } if ( divnum == 0 ) { divnum = 1 ; System . out . println ( 2 * ( sum / 2 / divnum ) ) ; return ; } else { System . out . println ( 2 * ( sum / 2 / divnum ) + 1 ) ; } } }

S = list ( map ( lambda x : ord ( x ) - ord ( ' a ' ) , list ( input ( ) ) ) ) NEW_LINE c = [ 0 ] * 26 NEW_LINE for s in S : NEW_LINE INDENT c [ s ] += 1 NEW_LINE DEDENT pair = 0 NEW_LINE odd = 0 NEW_LINE for n in c : NEW_LINE INDENT if n % 2 == 1 : NEW_LINE INDENT odd += 1 NEW_LINE DEDENT pair += n // 2 NEW_LINE DEDENT if odd == 0 : NEW_LINE INDENT print ( len ( S ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( pair // odd * 2 + 1 ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . nextLine ( ) . toCharArray ( ) ; int [ ] d = new int [ 26 ] ; for ( int i = 0 ; i < s . length ; i ++ ) { int c = ( int ) s [ i ] - ( int ) ' a ' ; d [ c ] += 1 ; } int odd = 0 ; int eve = 0 ; for ( int i = 0 ; i < d . length ; i ++ ) { int t = d [ i ] ; if ( t > 0 ) { eve += t / 2 ; odd += t % 2 ; } } if ( odd > 0 ) { System . out . println ( eve / odd * 2 + 1 ) ; } else { System . out . println ( s . length ) ; } } }


import java . io . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; long num = sc . nextLong ( ) ; if ( num % 2 == 0 && num % num == 0 ) System . out . println ( num ) ; else System . out . println ( num * 2 ) ; } }

n = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE if n % 2 == 1 : NEW_LINE INDENT ans = n * 2 NEW_LINE DEDENT else : NEW_LINE INDENT ans = n NEW_LINE DEDENT print ( ans ) NEW_LINE


N = int ( input ( ) ) NEW_LINE print ( N if N % 2 == 0 else N * 2 ) NEW_LINE


N = int ( input ( ) ) NEW_LINE import fractions as f NEW_LINE g = f . gcd ( 2 , N ) NEW_LINE print ( int ( 2 * N / g ) ) NEW_LINE


def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE print ( N ) if N % 2 == 0 else print ( N * 2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


n = int ( input ( ) ) NEW_LINE c = 1 NEW_LINE while True : NEW_LINE INDENT if ( n * c ) % 2 == 0 : NEW_LINE INDENT print ( n * c ) NEW_LINE break NEW_LINE DEDENT c += 1 NEW_LINE DEDENT


import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; out . println ( n % 2 == 0 ? n : n * 2 ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( " End ▁ of ▁ Input " ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numN = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; if ( numN % 2 == 0 ) { System . out . println ( numN ) ; } else { System . out . println ( numN * 2 ) ; } System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = input . readLine ( ) ; int n = Integer . parseInt ( line ) ; System . out . println ( ( n % 2 == 0 ) ? n : n * 2 ) ; } }


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n % 2 != 0 ) n *= 2 ; System . out . println ( n ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int m = ( int ) Math . sqrt ( N ) ; int ans = 100 ; for ( int i = m ; i > 0 ; i -- ) { if ( N % i == 0 ) { long A = i ; long B = N / i ; int count = 0 ; while ( A > 0 || B > 0 ) { A /= 10 ; B /= 10 ; count ++ ; } ans = Math . min ( ans , count ) ; break ; } } System . out . println ( ans ) ; } }

def getdigit ( N ) : NEW_LINE INDENT cnt = 0 NEW_LINE while ( N > 0 ) : NEW_LINE INDENT cnt += 1 NEW_LINE N //= 10 NEW_LINE DEDENT return cnt NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE for i in reversed ( range ( 1 , int ( pow ( N , 1 / 2 ) ) + 1 ) ) : NEW_LINE INDENT if ( N % i == 0 ) : NEW_LINE INDENT print ( max ( getdigit ( i ) , getdigit ( N / i ) ) ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT


import math NEW_LINE n = int ( input ( ) ) NEW_LINE A = [ 0 ] NEW_LINE i = 1 NEW_LINE while i <= math . sqrt ( n ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT A . append ( i ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT B = [ 0 ] NEW_LINE s = [ ] NEW_LINE for i in range ( len ( A ) - 1 ) : NEW_LINE INDENT j = int ( n / A [ i + 1 ] ) NEW_LINE B . append ( j ) NEW_LINE a = len ( str ( A [ i + 1 ] ) ) NEW_LINE b = len ( str ( B [ i + 1 ] ) ) NEW_LINE s . append ( max ( a , b ) ) NEW_LINE DEDENT ans = min ( s ) NEW_LINE print ( ans ) NEW_LINE


import math NEW_LINE num = int ( input ( ) ) NEW_LINE num_sqrt = int ( math . sqrt ( num ) ) NEW_LINE ans = 11 NEW_LINE for A in range ( 1 , num_sqrt + 1 ) : NEW_LINE INDENT if num % A == 0 : NEW_LINE INDENT B = int ( num / A ) NEW_LINE A , B = str ( A ) , str ( B ) NEW_LINE now_ans = max ( len ( A ) , len ( B ) ) NEW_LINE ans = min ( ans , now_ans ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import sys NEW_LINE def f ( a , b ) : NEW_LINE INDENT return max ( len ( str ( a ) ) , len ( str ( b ) ) ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE n = int ( N ** 0.5 ) NEW_LINE ans = 11 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if N % i == 0 : NEW_LINE INDENT ans = min ( ans , f ( i , N // i ) ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT


import math NEW_LINE n = int ( input ( ) ) NEW_LINE pf_list = [ ] NEW_LINE min_digit = float ( ' inf ' ) NEW_LINE for i in range ( 1 , int ( math . sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT a = len ( str ( int ( i ) ) ) NEW_LINE b = len ( str ( int ( n / i ) ) ) NEW_LINE tmp_list = [ a , b ] NEW_LINE tmp_list = list ( map ( int , tmp_list ) ) NEW_LINE if min_digit > max ( tmp_list ) : NEW_LINE INDENT min_digit = max ( tmp_list ) NEW_LINE DEDENT DEDENT DEDENT print ( min_digit ) NEW_LINE


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long divide1 = ( long ) Math . sqrt ( N ) ; while ( N % divide1 != 0 ) { divide1 -- ; } long divide2 = N / divide1 ; int len1 = String . valueOf ( divide1 ) . length ( ) ; int len2 = String . valueOf ( divide2 ) . length ( ) ; out . println ( Math . max ( len1 , len2 ) ) ; } }


import java . io . PrintStream ; import java . util . Scanner ; import java . util . stream . LongStream ; public class Main { static int F ( long A , long B ) { return Math . max ( Long . toString ( A ) . length ( ) , Long . toString ( B ) . length ( ) ) ; } static void exec ( Scanner in , PrintStream out ) { long N = in . nextLong ( ) ; int min = LongStream . rangeClosed ( 1 , ( long ) Math . sqrt ( N ) ) . filter ( A -> N % A == 0 ) . mapToInt ( A -> F ( A , N / A ) ) . min ( ) . getAsInt ( ) ; out . println ( min ) ; } public static void main ( String [ ] args ) { exec ( new Scanner ( System . in ) , System . out ) ; } }


import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { long N = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; long rootN = ( long ) Math . sqrt ( N ) ; for ( long i = 1 ; i <= rootN ; i ++ ) { long muti = N / i ; if ( N % i == 0 ) { ans = Math . min ( ans , digit ( muti ) ) ; } } System . out . println ( ans ) ; } private static int digit ( long n ) { return String . valueOf ( n ) . length ( ) ; } }


import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; long n = sc . nextLong ( ) ; long s = ( long ) sqrt ( n ) + 1 ; int ans = 100 ; for ( long i = 1 ; i <= s ; i ++ ) { if ( n % i == 0 ) ans = min ( F ( i , n / i ) , ans ) ; } out . println ( ans ) ; } static int F ( long A , long B ) { return max ( get ( A ) , get ( B ) ) ; } static int get ( long n ) { int c = 1 ; while ( n / 10 > 0 ) { c ++ ; n /= 10 ; } return c ; } }


import java . util . * ; public class Main { static int N ; static ArrayList < Integer > [ ] list ; static int [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; list = new ArrayList [ N ] ; dp = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { list [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 1 ; i < N ; i ++ ) { int x = sc . nextInt ( ) ; list [ x ] . add ( i ) ; } dfs ( 0 ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int ans = N - dp [ i ] ; for ( int item : list [ i ] ) { ans = Math . max ( ans , dp [ item ] ) ; } sb . append ( ans + " \n " ) ; } System . out . print ( sb ) ; } static int dfs ( int now ) { int res = 1 ; for ( int next : list [ now ] ) { res += dfs ( next ) ; } return dp [ now ] = res ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

def solve ( n , p , c ) : NEW_LINE INDENT d = [ 1 ] * n NEW_LINE b = [ 0 ] * n NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if 0 <= p [ i ] : NEW_LINE INDENT d [ p [ i ] ] += d [ i ] NEW_LINE DEDENT if len ( c [ i ] ) : NEW_LINE INDENT m = n - d [ i ] if i != 0 else 0 NEW_LINE for j in c [ i ] : NEW_LINE INDENT m = max ( m , d [ j ] ) NEW_LINE DEDENT b [ i ] = m NEW_LINE DEDENT else : NEW_LINE INDENT b [ i ] = n - 1 NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT print ( b [ i ] ) NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT n = input ( ) NEW_LINE n = int ( n ) NEW_LINE p = [ - 1 ] * n NEW_LINE c = [ [ ] for _ in range ( n ) ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT pi = input ( ) NEW_LINE pi = int ( pi ) NEW_LINE p [ i ] = pi NEW_LINE c [ pi ] . append ( i ) NEW_LINE DEDENT solve ( n , p , c ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import sys NEW_LINE sys . setrecursionlimit ( 200000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE edges = [ [ ] for _ in [ 0 ] * N ] NEW_LINE for i , v in enumerate ( map ( int , sys . stdin ) , start = 1 ) : NEW_LINE INDENT edges [ i ] . append ( v ) NEW_LINE edges [ v ] . append ( i ) NEW_LINE DEDENT balance = [ 0 ] * N NEW_LINE def rec ( v , prev ) : NEW_LINE INDENT total , max_count = 0 , 0 NEW_LINE for to_v in edges [ v ] : NEW_LINE INDENT if to_v != prev : NEW_LINE INDENT part = rec ( to_v , v ) NEW_LINE total , max_count = total + part , max ( max_count , part ) NEW_LINE DEDENT DEDENT balance [ v ] = max ( max_count , N - 1 - total ) NEW_LINE return total + 1 NEW_LINE DEDENT rec ( 0 , - 1 ) NEW_LINE print ( * balance , sep = " \n " ) NEW_LINE


import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { int N ; List < Integer > [ ] rinsetsu ; int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; rinsetsu = new List [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { rinsetsu [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; rinsetsu [ a ] . add ( b ) ; rinsetsu [ b ] . add ( a ) ; } System . out . println ( dfs ( 0 , - 1 ) [ 0 ] ) ; } int [ ] dfs ( int cur , int parent ) { int whole = 1 ; int black = 1 ; for ( int i = 0 ; i < rinsetsu [ cur ] . size ( ) ; i ++ ) { if ( rinsetsu [ cur ] . get ( i ) != parent ) { int [ ] child = dfs ( rinsetsu [ cur ] . get ( i ) , cur ) ; whole = ( int ) ( ( long ) whole * child [ 0 ] % mod ) ; black = ( int ) ( ( long ) black * child [ 1 ] % mod ) ; } } int [ ] ret = new int [ 2 ] ; ret [ 0 ] = ( int ) ( ( ( long ) whole + black ) % mod ) ; ret [ 1 ] = whole ; return ret ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import sys NEW_LINE from collections import defaultdict as dd NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE d = dd ( list ) NEW_LINE mod = 1000000007 NEW_LINE n = int ( input ( ) ) NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE d [ a ] . append ( b ) NEW_LINE d [ b ] . append ( a ) NEW_LINE DEDENT d = dict ( d ) NEW_LINE f = [ None ] * ( n + 1 ) NEW_LINE g = [ None ] * ( n + 1 ) NEW_LINE def dfs ( p , x ) : NEW_LINE INDENT for i in d [ x ] : NEW_LINE INDENT if i != p : NEW_LINE INDENT dfs ( x , i ) NEW_LINE DEDENT DEDENT f [ x ] , g [ x ] = 1 , 1 NEW_LINE for i in d [ x ] : NEW_LINE INDENT if i != p : NEW_LINE INDENT g [ x ] *= f [ i ] NEW_LINE g [ x ] %= mod NEW_LINE f [ x ] *= g [ i ] NEW_LINE f [ x ] %= mod NEW_LINE DEDENT DEDENT f [ x ] += g [ x ] NEW_LINE f [ x ] %= mod NEW_LINE DEDENT dfs ( - 1 , 1 ) NEW_LINE print ( f [ 1 ] ) NEW_LINE


from collections import Counter NEW_LINE def cal ( N , bridges ) : NEW_LINE INDENT mod = 10 ** 9 + 7 NEW_LINE bridge_cnt = Counter ( ) NEW_LINE bw_list = [ [ 1 , 1 ] for _ in range ( N + 1 ) ] NEW_LINE con_list = [ [ ] for _ in range ( N + 1 ) ] NEW_LINE for l , r in bridges : NEW_LINE INDENT bridge_cnt [ r ] += 1 NEW_LINE bridge_cnt [ l ] += 1 NEW_LINE con_list [ l ] . append ( r ) NEW_LINE con_list [ r ] . append ( l ) NEW_LINE DEDENT root = bridges [ 0 ] [ 0 ] NEW_LINE def update ( cur , parent ) : NEW_LINE INDENT for child in con_list [ cur ] : NEW_LINE INDENT if child == parent : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT update ( child , cur ) NEW_LINE DEDENT bw_list [ cur ] [ 0 ] = ( bw_list [ cur ] [ 0 ] * bw_list [ child ] [ 1 ] ) NEW_LINE bw_list [ cur ] [ 1 ] = ( bw_list [ cur ] [ 1 ] * ( bw_list [ child ] [ 0 ] + bw_list [ child ] [ 1 ] ) ) NEW_LINE DEDENT DEDENT update ( root , 0 ) NEW_LINE return max ( [ sum ( bw ) for bw in bw_list ] ) % mod NEW_LINE DEDENT import sys NEW_LINE stdin = sys . stdin 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 td = [ tuple ( li ( ) ) for _ in range ( n - 1 ) ] NEW_LINE print ( cal ( n , td ) ) NEW_LINE


import string NEW_LINE import sys NEW_LINE from collections import defaultdict NEW_LINE from itertools import chain , takewhile NEW_LINE def read ( f , * shape , it = chain . from_iterable ( sys . stdin ) , whitespaces = set ( string . whitespace ) ) : NEW_LINE INDENT def read_word ( ) : NEW_LINE INDENT return f ( " " . join ( takewhile ( lambda c : c not in whitespaces , it ) ) . strip ( ) ) NEW_LINE DEDENT if not shape : NEW_LINE INDENT return read_word ( ) NEW_LINE DEDENT elif len ( shape ) == 1 : NEW_LINE INDENT return [ read_word ( ) for _ in range ( shape [ 0 ] ) ] NEW_LINE DEDENT elif len ( shape ) == 2 : NEW_LINE INDENT return [ [ read_word ( ) for _ in range ( shape [ 1 ] ) ] for _ in range ( shape [ 0 ] ) ] NEW_LINE DEDENT DEDENT def arr ( * shape , fill_value = 0 ) : NEW_LINE INDENT if len ( shape ) == 1 : NEW_LINE INDENT return [ fill_value ] * shape [ fill_value ] NEW_LINE DEDENT elif len ( shape ) == 2 : NEW_LINE INDENT return [ [ fill_value ] * shape [ 1 ] for _ in range ( shape [ 0 ] ) ] NEW_LINE DEDENT DEDENT def debug ( ** kwargs ) : NEW_LINE INDENT print ( " , ▁ " . join ( " { } ▁ = ▁ { } " . format ( k , repr ( v ) ) for k , v in kwargs . items ( ) ) , file = sys . stderr , ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n = read ( int ) NEW_LINE G = defaultdict ( list ) NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b = read ( int , 2 ) NEW_LINE G [ a ] . append ( b ) NEW_LINE G [ b ] . append ( a ) NEW_LINE DEDENT MOD = 1000000000 + 7 NEW_LINE def dfs ( cur , prev ) : NEW_LINE INDENT w , b = 1 , 1 NEW_LINE for node in G [ cur ] : NEW_LINE INDENT if node != prev : NEW_LINE INDENT w_child , b_child = dfs ( node , cur ) NEW_LINE w *= ( w_child + b_child ) % MOD NEW_LINE w %= MOD NEW_LINE b *= w_child NEW_LINE b %= MOD NEW_LINE DEDENT DEDENT return w , b NEW_LINE DEDENT w , b = dfs ( 1 , - 1 ) NEW_LINE print ( ( w + b ) % MOD ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


def draw ( N : int , edges : list ) -> int : NEW_LINE INDENT MOD = 10 ** 9 + 7 NEW_LINE memo_f , memo_g = [ 0 ] * N , [ 0 ] * N NEW_LINE graph = [ [ ] for _ in range ( N ) ] NEW_LINE for u , v in edges : NEW_LINE INDENT graph [ u - 1 ] . append ( v - 1 ) NEW_LINE graph [ v - 1 ] . append ( u - 1 ) NEW_LINE DEDENT def f ( parent : int , v : int ) -> int : NEW_LINE INDENT if memo_f [ v ] : NEW_LINE INDENT return memo_f [ v ] NEW_LINE DEDENT memo_f [ v ] = 1 NEW_LINE for child in graph [ v ] : NEW_LINE INDENT if parent == child : NEW_LINE INDENT continue NEW_LINE DEDENT memo_f [ v ] = ( memo_f [ v ] * g ( v , child ) ) % MOD NEW_LINE DEDENT memo_f [ v ] = ( memo_f [ v ] + g ( parent , v ) ) % MOD NEW_LINE return memo_f [ v ] NEW_LINE DEDENT def g ( parent : int , v : int ) -> int : NEW_LINE INDENT if memo_g [ v ] : NEW_LINE INDENT return memo_g [ v ] NEW_LINE DEDENT memo_g [ v ] = 1 NEW_LINE for child in graph [ v ] : NEW_LINE INDENT if parent == child : NEW_LINE INDENT continue NEW_LINE DEDENT memo_g [ v ] = ( memo_g [ v ] * f ( v , child ) ) % MOD NEW_LINE DEDENT return memo_g [ v ] NEW_LINE DEDENT return f ( - 1 , 0 ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE edges = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( N - 1 ) ] NEW_LINE ans = draw ( N , edges ) NEW_LINE print ( ans ) NEW_LINE DEDENT


N = int ( input ( ) ) NEW_LINE BR = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N - 1 ) ] NEW_LINE mod = 10 ** 9 + 7 NEW_LINE BRLIST = [ [ ] for i in range ( N + 1 ) ] NEW_LINE for x , y in BR : NEW_LINE INDENT BRLIST [ x ] . append ( y ) NEW_LINE BRLIST [ y ] . append ( x ) NEW_LINE DEDENT from collections import deque NEW_LINE QUE = deque ( ) NEW_LINE ANS = [ [ 0 , 0 ] for i in range ( N + 1 ) ] NEW_LINE USED = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if len ( BRLIST [ i ] ) == 1 : NEW_LINE INDENT QUE . append ( i ) NEW_LINE DEDENT DEDENT while QUE : NEW_LINE INDENT x = QUE . pop ( ) NEW_LINE if USED [ x ] == 1 : NEW_LINE INDENT continue NEW_LINE DEDENT NOUSES = 0 NEW_LINE for j in BRLIST [ x ] : NEW_LINE INDENT if USED [ j ] == 0 : NEW_LINE INDENT NOUSES += 1 NEW_LINE DEDENT DEDENT if NOUSES >= 2 : NEW_LINE INDENT QUE . appendleft ( x ) NEW_LINE continue NEW_LINE DEDENT W = 1 NEW_LINE B = 1 NEW_LINE for j in BRLIST [ x ] : NEW_LINE INDENT if USED [ j ] != 0 : NEW_LINE INDENT W = W * ( ANS [ j ] [ 0 ] + ANS [ j ] [ 1 ] ) % mod NEW_LINE B = B * ANS [ j ] [ 0 ] % mod NEW_LINE DEDENT else : NEW_LINE INDENT QUE . appendleft ( j ) NEW_LINE DEDENT DEDENT ANS [ x ] = [ W , B ] NEW_LINE USED [ x ] = 1 NEW_LINE DEDENT print ( sum ( ANS [ x ] ) % mod ) NEW_LINE


import java . util . * ; public class Main { static long mod = 1000000000 + 7 ; static ArrayList < Integer > [ ] map ; static long [ ] white ; static long [ ] black ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; map = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) map [ i ] = new ArrayList < > ( ) ; black = new long [ n + 1 ] ; white = new long [ n + 1 ] ; for ( int i = 1 ; i < n ; i ++ ) { int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; map [ a ] . add ( b ) ; map [ b ] . add ( a ) ; } boolean [ ] vis = new boolean [ n + 1 ] ; long ans = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( vis [ i ] ) continue ; dfs ( i , vis ) ; ans = ans * ( black [ i ] + white [ i ] ) % mod ; } System . out . println ( ans ) ; } static void dfs ( int i , boolean [ ] vis ) { vis [ i ] = true ; black [ i ] = white [ i ] = 1 ; for ( int w : map [ i ] ) { if ( vis [ w ] ) continue ; dfs ( w , vis ) ; white [ i ] = white [ i ] * ( white [ w ] + black [ w ] ) % mod ; black [ i ] = black [ i ] * white [ w ] % mod ; } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .


import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { private static final long M = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; Node [ ] nodes = new Node [ N ] ; for ( int i = 0 ; i < N ; i ++ ) nodes [ i ] = new Node ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = scanner . nextInt ( ) - 1 ; int b = scanner . nextInt ( ) - 1 ; nodes [ a ] . neighbors . add ( nodes [ b ] ) ; nodes [ b ] . neighbors . add ( nodes [ a ] ) ; } long [ ] count = dfs ( nodes [ 0 ] ) ; System . out . println ( ( count [ 0 ] + count [ 1 ] ) % M ) ; } private static long [ ] dfs ( Node node ) { node . visited = true ; long [ ] count = new long [ ] { 1 , 1 } ; for ( Node n : node . neighbors ) { if ( ! n . visited ) { long [ ] c = dfs ( n ) ; count [ 0 ] *= ( c [ 0 ] + c [ 1 ] ) % M ; count [ 0 ] %= M ; count [ 1 ] *= c [ 0 ] ; count [ 1 ] %= M ; } } return count ; } private static class Node { final List < Node > neighbors = new ArrayList < > ( ) ; boolean visited ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String A = sc . next ( ) ; if ( A . equals ( " a " ) ) { System . out . println ( - 1 ) ; } else { System . out . println ( " a " ) ; } } }

a = list ( input ( ) ) NEW_LINE if a [ 0 ] == " a " and len ( a ) == 1 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " a " ) NEW_LINE DEDENT


print ( ' - 1' if input ( ) == ' a ' else ' a ' ) NEW_LINE


a = str ( input ( ) ) NEW_LINE if a == " a " : NEW_LINE INDENT print ( " - 1" ) NEW_LINE DEDENT elif len ( a ) > 1 : NEW_LINE INDENT print ( a [ : len ( a ) - 1 ] ) NEW_LINE DEDENT else : print ( " a " ) NEW_LINE


a = str ( input ( ) ) NEW_LINE if a == ' a ' : NEW_LINE INDENT ans = - 1 NEW_LINE print ( ans ) NEW_LINE DEDENT elif len ( a ) == 1 : NEW_LINE INDENT tmp = ord ( a ) - 1 NEW_LINE ans = chr ( tmp ) NEW_LINE print ( ans ) NEW_LINE DEDENT elif len ( a ) >= 2 : NEW_LINE INDENT ans = a [ : - 1 ] NEW_LINE print ( ans ) NEW_LINE DEDENT


import sys NEW_LINE s = input ( ) NEW_LINE if s == ' a ' : NEW_LINE INDENT print ( - 1 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT if s [ 0 ] != ' a ' : NEW_LINE INDENT print ( ' a ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT print ( s [ : 1 ] ) NEW_LINE


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


import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String a = scanner . nextLine ( ) ; scanner . close ( ) ; String smaller = " - 1" ; if ( a . length ( ) != 1 ) { smaller = a . substring ( 0 , a . length ( ) - 1 ) ; } else { if ( ! a . equals ( " a " ) ) { ArrayList < String > alphabets = new ArrayList < String > ( ) ; int alphaSize = ' z ' - ' a ' ; char alpha = ' a ' ; for ( int i = 0 ; i <= alphaSize ; i ++ ) { alphabets . add ( String . valueOf ( alpha ) ) ; alpha ++ ; } int index = alphabets . indexOf ( a ) - 1 ; smaller = alphabets . get ( index ) ; } } System . out . println ( smaller ) ; } }


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try ( CustomReader in = new CustomReader ( ) ) { new Main ( ) . execute ( in ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } public void execute ( CustomReader in ) throws IOException { final char A = ' a ' ; final String S = in . readLine ( ) ; if ( S . length ( ) == 1 && S . charAt ( 0 ) == A ) { System . out . println ( " - 1" ) ; } else { System . out . println ( A ) ; } } static class CustomReader extends BufferedReader { private static final int DEFAULT_BUF_SIZE = 2048 ; public CustomReader ( ) throws IOException { super ( new InputStreamReader ( System . in ) , DEFAULT_BUF_SIZE ) ; } public int [ ] readLineAsIntArray ( ) throws IOException { String [ ] strArray = this . readLine ( ) . split ( " ▁ " ) ; int [ ] intArray = new int [ strArray . length ] ; for ( int i = 0 , n = strArray . length ; i < n ; i ++ ) { intArray [ i ] = Integer . parseInt ( strArray [ i ] ) ; } return intArray ; } public int [ ] [ ] readAsIntMatrix ( int rows , int columns ) throws IOException { int [ ] [ ] matrix = new int [ rows ] [ columns ] ; for ( int i = 0 ; i < rows ; i ++ ) { String [ ] r = this . readLine ( ) . split ( " ▁ " ) ; for ( int j = 0 ; j < columns ; j ++ ) { matrix [ i ] [ j ] = Integer . parseInt ( r [ j ] ) ; } } return matrix ; } } }


public class Main { public static void main ( String [ ] args ) { System . out . println ( new java . util . Scanner ( System . in ) . next ( ) . equals ( " a " ) ? - 1 : " a " ) ; } }


import java . util . * ; import java . io . * ; import static java . lang . Math . * ; import static java . util . Arrays . * ; import static java . util . Collections . * ; public class Main { static final long mod = 1000000007 ; public static void main ( String [ ] args ) throws Exception , IOException { Reader sc = new Reader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; long r = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long low = 0 , high = min ( r , b ) + 1 , md , s , t ; long c , d , ans = 0 ; for ( int i = 0 ; i < 100 ; i ++ ) { md = ( low + high ) / 2 ; s = ( b - md ) / ( y - 1 ) ; t = ( r - md ) / ( x - 1 ) ; if ( md <= s + t ) { ans = md ; low = md ; } else high = md ; } out . println ( ans ) ; out . flush ( ) ; } static void db ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } } class P implements Comparable < P > { int id , d ; P ( int id , int d ) { this . id = id ; this . d = d ; } public int compareTo ( P p ) { return d - p . d ; } } class Reader { private BufferedReader x ; private StringTokenizer st ; public Reader ( InputStream in ) { x = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; } public String nextString ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( x . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( nextString ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( nextString ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( nextString ( ) ) ; } }

R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if R / x < B / y : NEW_LINE INDENT R , B = B , R NEW_LINE x , y = y , x NEW_LINE DEDENT pmin = R // x NEW_LINE if B <= pmin : NEW_LINE INDENT pmin = B NEW_LINE pmax = B NEW_LINE DEDENT else : NEW_LINE INDENT pmax = pmin + ( B - pmin ) // y NEW_LINE point = ( pmax + pmin ) // 2 NEW_LINE DEDENT while pmin < pmax : NEW_LINE INDENT if ( R - point ) // ( x - 1 ) + ( B - point ) // ( y - 1 ) >= point : NEW_LINE INDENT pmin = point NEW_LINE point = ( pmax + point + 1 ) // 2 NEW_LINE DEDENT else : NEW_LINE INDENT pmax = point - 1 NEW_LINE point = ( pmin + point ) // 2 NEW_LINE DEDENT DEDENT print ( pmin ) NEW_LINE


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE def check ( n : int ) -> bool : NEW_LINE INDENT rR = R - n NEW_LINE rB = B - n NEW_LINE if rR < 0 or rB < 0 : NEW_LINE INDENT return False NEW_LINE DEDENT return rR // ( x - 1 ) + rB // ( y - 1 ) >= n NEW_LINE DEDENT lower = 0 NEW_LINE upper = max ( R , B ) NEW_LINE while lower + 1 < upper : NEW_LINE INDENT mid = ( lower + upper ) // 2 NEW_LINE if check ( mid ) : NEW_LINE INDENT lower = mid NEW_LINE DEDENT else : NEW_LINE INDENT upper = mid NEW_LINE DEDENT DEDENT print ( lower ) NEW_LINE


if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE ans = max ( ans , min ( R // x , B ) ) NEW_LINE ans = max ( ans , min ( R , B // y ) ) ; NEW_LINE if R * y - B >= 0 : NEW_LINE INDENT k = ( R * y - B ) // ( x * y - 1 ) ; NEW_LINE l = min ( R - k * x , ( B - k ) // y ) ; NEW_LINE if l >= 0 : NEW_LINE INDENT ans = max ( ans , k + l ) ; NEW_LINE DEDENT k += 1 NEW_LINE l = min ( R - k * x , ( B - k ) / y ) ; NEW_LINE if l >= 0 : NEW_LINE INDENT ans = max ( ans , k + l ) ; NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT


def judge ( k ) : NEW_LINE INDENT global R , B , x , y NEW_LINE tr , tb , tx , ty = R - k , B - k , x - 1 , y - 1 NEW_LINE return tr // tx + tb // ty >= k NEW_LINE DEDENT R , B = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE l , r = 0 , min ( R , B ) NEW_LINE nxt , prv = 0 , - 1 NEW_LINE while True : NEW_LINE INDENT nxt = ( l + r ) // 2 NEW_LINE if nxt == prv : NEW_LINE INDENT print ( nxt + 1 if judge ( nxt + 1 ) else nxt ) NEW_LINE break NEW_LINE DEDENT if judge ( nxt ) : NEW_LINE INDENT l = nxt NEW_LINE DEDENT else : NEW_LINE INDENT r = nxt NEW_LINE DEDENT prv = nxt NEW_LINE DEDENT


def b_bouquet ( R , B , X , Y ) : NEW_LINE INDENT def can_make_bouquet ( k ) : NEW_LINE INDENT if k > R or k > B : NEW_LINE INDENT return False NEW_LINE DEDENT return ( R - k ) // ( X - 1 ) + ( B - k ) // ( Y - 1 ) >= k NEW_LINE DEDENT lower , upper = 0 , R + B NEW_LINE while upper - lower > 1 : NEW_LINE INDENT mid = ( lower + upper ) // 2 NEW_LINE if can_make_bouquet ( mid ) : NEW_LINE INDENT lower = mid NEW_LINE DEDENT else : NEW_LINE INDENT upper = mid NEW_LINE DEDENT DEDENT return lower NEW_LINE DEDENT R , B = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE X , Y = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( b_bouquet ( R , B , X , Y ) ) NEW_LINE


import java . util . Scanner ; class Main { static long R ; static long B ; static long aka_hon ; static long ao_hon ; static long dekiru_max ; static long min ; static boolean dekiru ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; dekiru = false ; R = sc . nextLong ( ) ; B = sc . nextLong ( ) ; aka_hon = sc . nextLong ( ) ; ao_hon = sc . nextLong ( ) ; dekiru_max = Math . max ( R , B ) ; min = 0 ; long mid = ( min + dekiru_max ) / 2 ; while ( dekiru_max > 1 + min ) { dekiru = false ; mid = ( min + dekiru_max ) / 2 ; dekiru = Solve ( R , B , aka_hon , ao_hon , mid ) ; if ( dekiru == true ) { min = mid ; } else if ( dekiru == false ) { dekiru_max = mid ; } } System . out . println ( ( min + dekiru_max ) / 2 ) ; } static boolean Solve ( long a , long b , long c , long d , long wa ) { long aka = a - wa ; long ao = b - wa ; long po = aka / ( c - 1 ) + ao / ( d - 1 ) ; return aka >= 0 && ao >= 0 && po >= wa ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s = r . readLine ( ) ; String [ ] sl = s . split ( " [ \\ s ] + " ) ; long R = Long . parseLong ( sl [ 0 ] ) ; long B = Long . parseLong ( sl [ 1 ] ) ; s = r . readLine ( ) ; sl = s . split ( " [ \\ s ] + " ) ; long x = Long . parseLong ( sl [ 0 ] ) ; long y = Long . parseLong ( sl [ 1 ] ) ; long rl = 0 ; long rr = Math . min ( R , B ) + 1 ; while ( rr - rl >= 2 ) { long rm = ( rl + rr ) / 2 ; if ( ( R - rm ) / ( x - 1 ) + ( B - rm ) / ( y - 1 ) < rm ) { rr = rm ; } else { rl = rm ; } } System . out . println ( rl ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long r = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long ans = binSearch ( r , b , x , y ) ; System . out . println ( ans ) ; } public static long binSearch ( long r , long b , long x , long y ) { long ok = 0 ; long ng = Math . min ( r , b ) + 1 ; while ( Math . abs ( ok - ng ) > 1 ) { long mid = ( ok + ng ) / 2 ; if ( solve ( mid , r , b , x , y ) ) { ok = mid ; } else { ng = mid ; } } return ok ; } public static boolean solve ( long k , long r , long b , long x , long y ) { long rnum = ( r - k ) / ( x - 1 ) ; long bnum = ( b - k ) / ( y - 1 ) ; if ( rnum + bnum >= k ) { return true ; } return false ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; long r = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long Tmax = r + b + 1000L ; long Tmin = 0L ; long T = 0 ; while ( Tmax - Tmin > 1 ) { T = Tmin + ( Tmax - Tmin ) / 2 ; if ( r >= T && b >= T && ( r - T ) / ( x - 1 ) + ( b - T ) / ( y - 1 ) >= T ) { Tmin = T ; } else { Tmax = T ; } } long ans = Tmin ; System . out . println ( ans ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( ( int ) Math . pow ( sc . nextInt ( ) , 2 ) - sc . nextInt ( ) ) ; } }

N = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE print ( N * N - A ) NEW_LINE


n , a = map ( int , open ( 0 ) ) ; print ( n * n - a ) NEW_LINE


N = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE Y = N ** 2 - A NEW_LINE print ( Y ) NEW_LINE


N , A = int ( input ( ) ) , int ( input ( ) ) NEW_LINE print ( N * N - A ) NEW_LINE


N = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE B = N * N - A NEW_LINE print ( B ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int A = in . nextInt ( ) ; out . println ( N * N - A ) ; } } 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 . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int r = Integer . parseInt ( sc . next ( ) ) ; int g = Integer . parseInt ( sc . next ( ) ) ; out . println ( r * r - g ) ; out . flush ( ) ; } }


import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; int a = Integer . parseInt ( input . readLine ( ) ) ; System . out . println ( ( n * n ) - a ) ; } }


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


import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a < 0 ) a ++ ; if ( b < 0 ) b ++ ; System . out . println ( b - a ) ; } }

a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a < 0 : NEW_LINE INDENT a += 1 NEW_LINE DEDENT if b < 0 : NEW_LINE INDENT b += 1 NEW_LINE DEDENT print ( b - a ) NEW_LINE


def f ( x ) : NEW_LINE INDENT if x < 0 : NEW_LINE INDENT return x + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return x NEW_LINE DEDENT DEDENT A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( f ( B ) - f ( A ) ) NEW_LINE


A , B = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE if A > 0 and B > 0 : NEW_LINE INDENT print ( abs ( B - A ) ) NEW_LINE DEDENT elif A < 0 and B < 0 : NEW_LINE INDENT print ( abs ( B - A ) ) NEW_LINE DEDENT elif A < 0 and B > 0 : NEW_LINE INDENT print ( B - A - 1 ) NEW_LINE DEDENT elif A > 0 and B < 0 : NEW_LINE INDENT print ( A - B - 1 ) NEW_LINE DEDENT


a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( b - a - 1 if a * b < 0 else b - a ) NEW_LINE


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if A >= 0 : NEW_LINE INDENT ans = B - A NEW_LINE DEDENT elif B <= 0 : NEW_LINE INDENT ans = B - A NEW_LINE DEDENT else : NEW_LINE INDENT ans = B - A - 1 NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a < 0 && b > 0 ) { System . out . println ( ( Math . abs ( a ) + b - 1 ) ) ; } else if ( a < 0 && b < 0 ) { System . out . println ( ( Math . abs ( a - b ) ) ) ; } else if ( a > 0 && b > 0 ) { System . out . println ( ( ( b - a ) ) ) ; } } }


import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int f = s . nextInt ( ) , t = s . nextInt ( ) ; if ( f <= 0 && 0 <= t ) t -- ; System . out . println ( t - f ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] $ ) { Scanner c = new Scanner ( System . in ) ; long a = c . nextLong ( ) , b = c . nextLong ( ) ; System . out . println ( a * b < 0 ? b - a - 1 : b - a ) ; } }


import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( A < 0 && B > 0 ) { System . out . println ( B - A - 1 ) ; } else { System . out . println ( B - A ) ; } } }


import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Comparator ; 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 ) ; int n = sc . nextInt ( ) ; long [ ] [ ] a = new long [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] [ 0 ] = sc . nextLong ( ) ; a [ i ] [ 1 ] = i ; } Arrays . sort ( a , new Comparator < long [ ] > ( ) { @ Override public int compare ( long [ ] o1 , long [ ] o2 ) { if ( o1 [ 0 ] != o2 [ 0 ] ) { return - Long . compare ( o1 [ 0 ] , o2 [ 0 ] ) ; } else { return Long . compare ( o1 [ 1 ] , o2 [ 1 ] ) ; } } } ) ; long [ ] cnt = new long [ n ] ; int s = 0 , t = 0 ; while ( true ) { if ( s == n ) break ; while ( t != n && a [ s ] [ 1 ] <= a [ t ] [ 1 ] ) { ++ t ; } cnt [ ( int ) a [ s ] [ 1 ] ] += ( a [ s ] [ 0 ] - ( t == n ? 0 : a [ t ] [ 0 ] ) ) * s ; for ( int i = t - 1 ; i >= s ; -- i ) { cnt [ ( int ) a [ s ] [ 1 ] ] += ( a [ i ] [ 0 ] - ( t == n ? 0 : a [ t ] [ 0 ] ) ) ; } s = t ; } PrintWriter pw = new PrintWriter ( System . out ) ; for ( int i = 0 ; i < cnt . length ; ++ i ) { pw . println ( cnt [ i ] ) ; } pw . close ( ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

from functools import cmp_to_key NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def group ( a ) : NEW_LINE INDENT d = { } NEW_LINE for i , x in enumerate ( a ) : NEW_LINE INDENT d . setdefault ( x , [ ] ) . append ( i ) NEW_LINE DEDENT return list ( map ( lambda x : [ x [ 0 ] , x [ 1 ] [ 0 ] , len ( x [ 1 ] ) ] , sorted ( d . items ( ) , key = cmp_to_key ( lambda x , y : x [ 0 ] - y [ 0 ] ) , reverse = True ) ) ) NEW_LINE DEDENT ans = [ 0 ] * n NEW_LINE g = group ( a ) NEW_LINE g . append ( [ 0 , 0 , 0 ] ) NEW_LINE for c , n in zip ( g [ : - 1 ] , g [ 1 : ] ) : NEW_LINE INDENT ans [ c [ 1 ] ] += ( c [ 0 ] - n [ 0 ] ) * c [ 2 ] NEW_LINE n [ 1 ] = min ( c [ 1 ] , n [ 1 ] ) NEW_LINE n [ 2 ] += c [ 2 ] NEW_LINE DEDENT [ print ( a ) for a in ans ] NEW_LINE


import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def II ( ) : return int ( input ( ) ) NEW_LINE def LS ( ) : return input ( ) . split ( ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE a = LI ( ) NEW_LINE b = [ ( a [ i ] , i ) for i in range ( n ) ] NEW_LINE b . sort ( ) NEW_LINE b . reverse ( ) NEW_LINE r = [ 0 ] * n NEW_LINE s = sum ( a ) NEW_LINE t = inf NEW_LINE for i in range ( n ) : NEW_LINE INDENT ai , bi = b [ i ] [ 0 ] , b [ i ] [ 1 ] NEW_LINE if bi == 0 : NEW_LINE INDENT r [ 0 ] += s NEW_LINE break NEW_LINE DEDENT ti = ( ai - b [ i + 1 ] [ 0 ] ) * ( i + 1 ) NEW_LINE if t > bi : NEW_LINE INDENT t = bi NEW_LINE DEDENT r [ t ] += ti NEW_LINE s -= ti NEW_LINE DEDENT return ' \n ' . join ( map ( str , r ) ) NEW_LINE DEDENT print ( main ( ) ) NEW_LINE


def nibutan ( th , a ) : NEW_LINE INDENT top = len ( th ) NEW_LINE btm = 0 NEW_LINE while top > btm : NEW_LINE INDENT mid = ( top + btm ) // 2 NEW_LINE if th [ mid ] < a <= th [ mid + 1 ] : NEW_LINE INDENT return mid NEW_LINE DEDENT elif a <= th [ mid ] : NEW_LINE INDENT top = mid NEW_LINE DEDENT else : NEW_LINE INDENT btm = mid NEW_LINE DEDENT DEDENT DEDENT N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE th = [ 0 ] NEW_LINE num_th = [ ] NEW_LINE rem = [ ] NEW_LINE max_i = 0 NEW_LINE nonzeros = dict ( ) NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if a > th [ - 1 ] : NEW_LINE INDENT th . append ( a ) NEW_LINE num_th . append ( 1 ) NEW_LINE rem . append ( 0 ) NEW_LINE nonzeros [ i ] = max_i NEW_LINE max_i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT j = nibutan ( th , a ) NEW_LINE if j - 1 >= 0 : NEW_LINE INDENT num_th [ j - 1 ] += 1 NEW_LINE DEDENT rem [ j ] += a - th [ j ] NEW_LINE DEDENT DEDENT for i in range ( len ( num_th ) - 1 , 0 , - 1 ) : NEW_LINE INDENT num_th [ i - 1 ] += num_th [ i ] NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT if i in nonzeros : NEW_LINE INDENT ans = ( th [ nonzeros [ i ] + 1 ] - th [ nonzeros [ i ] ] ) * num_th [ nonzeros [ i ] ] NEW_LINE ans += rem [ nonzeros [ i ] ] NEW_LINE print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT


from collections import defaultdict , Counter NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE c = Counter ( a ) NEW_LINE values = reversed ( sorted ( set ( a ) ) ) NEW_LINE s = 0 NEW_LINE m = 0 NEW_LINE above = dict ( ) NEW_LINE n_above = dict ( ) NEW_LINE for v in values : NEW_LINE INDENT above [ v ] = s NEW_LINE n_above [ v ] = m NEW_LINE s += c [ v ] * v NEW_LINE m += c [ v ] NEW_LINE DEDENT above [ 0 ] = s NEW_LINE n_above [ 0 ] = m NEW_LINE m = 0 NEW_LINE u = [ 0 ] NEW_LINE for v in a : NEW_LINE INDENT if v > m : NEW_LINE INDENT u . append ( v ) NEW_LINE m = v NEW_LINE DEDENT DEDENT r = defaultdict ( int ) NEW_LINE last = 0 NEW_LINE for j , v in enumerate ( u ) : NEW_LINE INDENT r [ v ] = last - ( above [ v ] - n_above [ v ] * v ) NEW_LINE last = above [ v ] - n_above [ v ] * v NEW_LINE DEDENT m = 0 NEW_LINE for v in a : NEW_LINE INDENT if v > m : NEW_LINE INDENT print ( r [ v ] ) NEW_LINE m = v NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT


from collections import deque NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE A = inpl ( ) NEW_LINE X = sorted ( [ ( a , i ) for i , a in enumerate ( A , start = 1 ) ] , key = lambda x : [ x [ 0 ] , - x [ 1 ] ] ) NEW_LINE answer = [ 0 ] * ( N + 1 ) NEW_LINE a , i = X . pop ( ) NEW_LINE for c in range ( 1 , N ) : NEW_LINE INDENT b , j = X . pop ( ) NEW_LINE answer [ i ] += ( a - b ) * c NEW_LINE i = min ( i , j ) NEW_LINE a = b NEW_LINE DEDENT answer [ i ] += a * N NEW_LINE print ( * answer [ 1 : ] , sep = " \n " ) NEW_LINE


import java . util . * ; import java . io . * ; import static java . lang . System . in ; public 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 ( ) ; long [ ] left = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) left [ i ] = Math . max ( left [ i - 1 ] , a [ i ] ) ; PriorityQueue < Long > pq = new PriorityQueue < > ( 10 , Collections . reverseOrder ( ) ) ; long [ ] ans = new long [ n + 1 ] ; long hi = left [ n ] ; long cnt = 0 ; for ( int i = n ; i > 0 ; i -- ) { if ( a [ i ] <= left [ i - 1 ] ) { pq . add ( a [ i ] ) ; continue ; } long lo = left [ i - 1 ] ; cnt ++ ; ans [ i ] += cnt * ( hi - lo ) ; while ( pq . size ( ) > 0 && pq . peek ( ) > lo ) { ans [ i ] += pq . poll ( ) - lo ; cnt ++ ; } hi = lo ; } PrintWriter out = new PrintWriter ( System . out ) ; for ( int i = 1 ; i <= n ; i ++ ) out . println ( ans [ i ] ) ; out . flush ( ) ; } }


import java . io . PrintWriter ; import java . util . * ; public class Main { static final long MOD = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; ArrayList < Integer > index = new ArrayList < > ( ) ; ArrayList < Integer > value = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( index . size ( ) == 0 || value . get ( value . size ( ) - 1 ) < a [ i ] ) { index . add ( i ) ; value . add ( a [ i ] ) ; } } index . add ( N ) ; value . add ( Integer . MAX_VALUE ) ; long [ ] sum = new long [ index . size ( ) + 1 ] ; Arrays . sort ( a ) ; int p = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( value . get ( p ) <= a [ i ] ) { sum [ p ] += ( ( long ) N - i ) * ( value . get ( p ) - ( p > 0 ? value . get ( p - 1 ) : 0 ) ) ; p ++ ; } sum [ p ] += a [ i ] - ( p > 0 ? value . get ( p - 1 ) : 0 ) ; } long [ ] ans = new long [ N ] ; for ( int i = 0 ; i < index . size ( ) - 1 ; i ++ ) ans [ index . get ( i ) ] = sum [ i ] ; for ( int i = 0 ; i < N ; i ++ ) pw . println ( ans [ i ] ) ; sc . close ( ) ; pw . close ( ) ; } }


import java . util . Arrays ; import java . util . Scanner ; public class Main { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int n = sc . nextInt ( ) ; Pair [ ] p = new Pair [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) p [ i ] = new Pair ( i + 1 , sc . nextLong ( ) ) ; p [ n ] = new Pair ( 0 , 0 ) ; Arrays . sort ( p ) ; long [ ] res = new long [ n + 1 ] ; long cnt = 0 ; int idmin = n + 1 ; for ( int i = 0 ; i < n ; i ++ ) { Pair nowP = p [ i ] ; idmin = Math . min ( idmin , nowP . id ) ; cnt ++ ; while ( nowP . cnt == p [ i + 1 ] . cnt ) { i ++ ; cnt ++ ; } res [ idmin ] += cnt * ( nowP . cnt - p [ i + 1 ] . cnt ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) sb . append ( res [ i ] + " \n " ) ; System . out . print ( sb ) ; } class Pair implements Comparable < Pair > { int id ; long cnt ; public Pair ( int id , long cnt ) { super ( ) ; this . id = id ; this . cnt = cnt ; } @ Override public int compareTo ( Pair arg0 ) { if ( this . cnt == arg0 . cnt ) { return this . id - arg0 . id ; } return - Long . compare ( this . cnt , arg0 . cnt ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }


import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner io = new Scanner ( System . in ) ; int N = io . nextInt ( ) ; long [ ] ans = new long [ N ] ; PriorityQueue < Deck > que = new PriorityQueue < > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { que . add ( new Deck ( i , io . nextInt ( ) ) ) ; } que . add ( new Deck ( 0 , 0 ) ) ; Deck nowDeck ; int nowNO = Integer . MAX_VALUE ; int nowNum ; for ( int i = 1 ; i <= N ; i ++ ) { nowDeck = que . poll ( ) ; nowNO = Math . min ( nowNO , nowDeck . NO ) ; ans [ nowNO - 1 ] += ( long ) ( nowDeck . num - que . peek ( ) . num ) * i ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } class Deck implements Comparable < Deck > { int NO ; int num ; public Deck ( int NO , int num ) { this . NO = NO ; this . num = num ; } @ Override public int compareTo ( Deck o ) { return ( o . num - num == 0 ) ? o . NO - NO : o . num - num ; } }


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; int a [ ] = new int [ N ] ; int b [ ] = new int [ N ] ; int max = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; max = Math . max ( a [ i ] , max ) ; } Arrays . sort ( b ) ; int ans = 0 ; int sum = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( max > b [ i ] ) { break ; } sum += b [ i ] ; ans ++ ; if ( sum >= H ) { System . out . println ( ans ) ; return ; } } while ( sum < H ) { sum += max ; ans ++ ; } System . out . println ( ans ) ; } }

import bisect NEW_LINE n , h = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE a_s , b_s = [ ] , [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a , b = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE a_s . append ( a ) NEW_LINE b_s . append ( b ) NEW_LINE DEDENT a_s . sort ( ) NEW_LINE b_s . sort ( ) NEW_LINE throwable = bisect . bisect ( b_s , a_s [ - 1 ] ) NEW_LINE throw_sum = sum ( b_s [ throwable : ] ) NEW_LINE ans = 0 NEW_LINE for item in b_s [ throwable : ] [ : : - 1 ] : NEW_LINE INDENT h -= item NEW_LINE ans += 1 NEW_LINE if h <= 0 : NEW_LINE INDENT print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT ans += h // a_s [ - 1 ] NEW_LINE if h % a_s [ - 1 ] != 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT if ans <= 0 : NEW_LINE INDENT ans = 1 NEW_LINE DEDENT print ( ans ) NEW_LINE


import math NEW_LINE n , h = map ( int , input ( ) . split ( ) ) NEW_LINE a = sorted ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] , key = lambda x : x [ 1 ] ) [ : : - 1 ] NEW_LINE r = 0 NEW_LINE d = 0 NEW_LINE p = 0 NEW_LINE k = float ( " inf " ) NEW_LINE while p < n : NEW_LINE INDENT r += a [ p ] [ 1 ] NEW_LINE d = max ( d , a [ p ] [ 0 ] ) NEW_LINE k = min ( k , p + 1 + math . ceil ( max ( 0 , ( h - r ) ) / d ) ) NEW_LINE p += 1 NEW_LINE if r >= h : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( k ) NEW_LINE


from math import ceil NEW_LINE from numpy import cumsum NEW_LINE def solve ( string ) : NEW_LINE INDENT n , h , * ab = map ( int , string . split ( ) ) NEW_LINE max_a = max ( ab [ : : 2 ] ) NEW_LINE cnt = 0 NEW_LINE b = sorted ( [ b for b in ab [ 1 : : 2 ] if b > max_a ] , reverse = True ) NEW_LINE if sum ( b ) < h : NEW_LINE INDENT cnt = len ( b ) + ceil ( ( h - sum ( b ) ) / max_a ) NEW_LINE DEDENT else : NEW_LINE INDENT cnt = ( cumsum ( b ) >= h ) . argmax ( ) + 1 NEW_LINE DEDENT return str ( cnt ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( ' { } ▁ { } \n ' . format ( n , m ) + ' \n ' . join ( [ input ( ) for _ in range ( n ) ] ) ) ) NEW_LINE DEDENT


def d_katana_thrower ( N , H , Swords ) : NEW_LINE INDENT import math NEW_LINE swing_damage_max = max ( [ s [ 0 ] for s in Swords ] ) NEW_LINE throw_higher_than_swing = [ s [ 1 ] for s in Swords if s [ 1 ] >= swing_damage_max ] NEW_LINE throw_higher_than_swing . sort ( reverse = True ) NEW_LINE minimum_moving = 0 NEW_LINE for damage in throw_higher_than_swing : NEW_LINE INDENT if H <= 0 : NEW_LINE INDENT H = 0 NEW_LINE break NEW_LINE DEDENT H -= damage NEW_LINE minimum_moving += 1 NEW_LINE DEDENT minimum_moving += math . ceil ( H / swing_damage_max ) NEW_LINE return minimum_moving NEW_LINE DEDENT N , H = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE Swords = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( N ) ] NEW_LINE print ( d_katana_thrower ( N , H , Swords ) ) NEW_LINE


import sys NEW_LINE import math NEW_LINE stdin = sys . stdin NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE na = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ns = lambda : input ( ) NEW_LINE N , H = na ( ) NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT t = na ( ) NEW_LINE a . append ( t [ 0 ] ) NEW_LINE b . append ( t [ 1 ] ) NEW_LINE DEDENT m_a = max ( a ) NEW_LINE b . sort ( reverse = True ) NEW_LINE sum_b = 0 NEW_LINE b_i = 0 NEW_LINE if ( m_a > b [ - 1 ] ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT sum_b += b [ i ] NEW_LINE if ( b [ i ] <= m_a ) : NEW_LINE INDENT sum_b -= b [ i ] NEW_LINE b_i = i NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT b_i = N NEW_LINE sum_b = sum ( b ) NEW_LINE DEDENT res = 0 NEW_LINE if ( sum_b >= H ) : NEW_LINE INDENT for i in range ( b_i ) : NEW_LINE INDENT res += b [ i ] NEW_LINE if ( res >= H ) : NEW_LINE INDENT print ( i + 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT ct = 0 NEW_LINE H_resi = H - sum_b NEW_LINE ct += math . ceil ( H_resi / m_a ) NEW_LINE print ( ct + b_i ) NEW_LINE DEDENT


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long H = sc . nextInt ( ) ; PriorityQueue < Entry > sords = new PriorityQueue < Entry > ( new EntryComparator ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { sords . add ( new Entry ( sc . nextLong ( ) , false ) ) ; sords . add ( new Entry ( sc . nextLong ( ) , true ) ) ; } int cnt = 0 ; long aAttach = - 1l ; while ( H > 0 ) { Entry entry = sords . poll ( ) ; if ( ! entry . isB ) { aAttach = entry . attack ; break ; } H -= entry . attack ; cnt ++ ; } if ( aAttach != - 1 ) { cnt += ( long ) Math . ceil ( ( double ) H / aAttach ) ; } out . println ( cnt ) ; } static class EntryComparator implements Comparator < Entry > { @ Override public int compare ( Entry t1 , Entry t2 ) { if ( t1 . attack < t2 . attack ) { return 1 ; } return - 1 ; } } static class Entry { long attack ; boolean isB ; Entry ( long attack , boolean isB ) { this . attack = attack ; this . isB = isB ; } } }


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


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; String [ ] inputs = input . split ( " ▁ " ) ; int count = Integer . valueOf ( inputs [ 0 ] ) ; int score = Integer . valueOf ( inputs [ 1 ] ) ; int [ ] a = new int [ count ] ; int [ ] b = new int [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { String data = sc . nextLine ( ) ; String [ ] datas = data . split ( " ▁ " ) ; a [ i ] = Integer . valueOf ( datas [ 0 ] ) ; b [ i ] = Integer . valueOf ( datas [ 1 ] ) ; } int maxA = Integer . MIN_VALUE ; for ( int i = 0 ; i < count ; i ++ ) { if ( a [ i ] > maxA ) { maxA = a [ i ] ; } else if ( a [ i ] == maxA ) { } } int moves = 0 ; Arrays . sort ( b ) ; int [ ] j = new int [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { j [ count - i - 1 ] = b [ i ] ; } b = j ; for ( int i = 0 ; i < count ; i ++ ) { if ( b [ i ] >= maxA ) { moves = moves + 1 ; score = score - b [ i ] ; if ( score <= 0 ) { break ; } } } if ( score > 0 ) { int extraMoves = score / maxA ; if ( score - ( extraMoves * maxA ) > 0 ) moves = moves + extraMoves + 1 ; else moves = moves + extraMoves ; } System . out . println ( moves ) ; } }


import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; long h = Integer . parseInt ( sc . next ( ) ) ; Long [ ] Throw = new Long [ n ] ; long maxAP = 0 ; long t = 0 ; for ( int i = 0 ; i < n ; i ++ ) { t = Long . parseLong ( sc . next ( ) ) ; Throw [ i ] = Long . parseLong ( sc . next ( ) ) ; if ( t > maxAP ) maxAP = t ; } sc . close ( ) ; Arrays . sort ( Throw , Comparator . reverseOrder ( ) ) ; int cnt = 0 ; while ( cnt < n && 0 < h ) { if ( Throw [ cnt ] <= maxAP ) break ; h -= Throw [ cnt ] ; cnt ++ ; } if ( h > 0 ) { cnt += h / maxAP + 1 ; if ( h % maxAP == 0 ) cnt -- ; } System . out . println ( cnt ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double h = sc . nextDouble ( ) / 100 ; double b = sc . nextDouble ( ) ; System . out . println ( b * h * h ) ; } }

h , b = map ( float , input ( ) . split ( ) ) NEW_LINE print ( h * h * b / 10000 ) NEW_LINE


print ( eval ( input ( ) . replace ( ' ▁ ' , ' * *2 * ' ) ) / 1e4 ) NEW_LINE


def main ( ) : NEW_LINE INDENT h , bmi = map ( float , input ( ) . split ( ) ) NEW_LINE print ( h * h * bmi / 10000 ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE H , B = map ( float , input ( ) . split ( ) ) NEW_LINE print ( B * H * H / 10 ** 4 ) NEW_LINE


print ( ( lambda x , y : y * ( x / 100 ) ** 2 ) ( * map ( float , input ( ) . split ( ) ) ) ) NEW_LINE


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 ) { double h = in . nextDouble ( ) / 100.0 ; double BMI = in . nextDouble ( ) ; out . println ( BMI * h * h ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }


import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double h = scanner . nextDouble ( ) ; double bmi = scanner . nextDouble ( ) ; System . out . println ( h * h * bmi / 10000 ) ; } }


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 ) ; double he = sc . nextDouble ( ) / 100 ; double BMI = sc . nextDouble ( ) ; pl ( BMI * he * he ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } public static boolean isPrime ( int a ) { if ( a < 4 ) { if ( a == 2 || a == 3 ) { return true ; } else { return false ; } } else { for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { return false ; } if ( a % j != 0 && ( j + 1 ) * ( j + 1 ) > a ) { return true ; } } return true ; } } }


import java . util . * ; public class Main { private static double h ; private static double bmi ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; h = scan . nextDouble ( ) ; bmi = scan . nextDouble ( ) ; } public static void main ( String args [ ] ) { input ( ) ; System . out . println ( bmi * Math . pow ( h / 100 , 2 ) ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 4 ] [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; if ( i != 0 ) { if ( a [ i ] [ j ] == a [ i - 1 ] [ j ] ) { System . out . println ( " CONTINUE " ) ; return ; } } if ( j != 0 ) { if ( a [ i ] [ j ] == a [ i ] [ j - 1 ] ) { System . out . println ( " CONTINUE " ) ; return ; } } } } System . out . println ( " GAMEOVER " ) ; } }

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE mat = [ [ 0 ] * 4 for _ in range ( 4 ) ] NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for j in range ( 4 ) : NEW_LINE INDENT mat [ i ] [ j ] = l [ j ] NEW_LINE DEDENT DEDENT f = False NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if mat [ i ] [ j ] == mat [ i ] [ j + 1 ] : NEW_LINE INDENT f = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if not f : NEW_LINE INDENT for i in range ( 4 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if mat [ j ] [ i ] == mat [ j + 1 ] [ i ] : NEW_LINE INDENT f = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT if f : NEW_LINE INDENT print ( " CONTINUE " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " GAMEOVER " ) NEW_LINE DEDENT


grid = [ ] NEW_LINE ans = ' GAMEOVER ' NEW_LINE for _ in range ( 4 ) : NEW_LINE INDENT grid . append ( input ( ) . split ( ) ) NEW_LINE DEDENT for i in grid : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if i [ j ] == i [ j + 1 ] : NEW_LINE INDENT ans = ' CONTINUE ' NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT for k in range ( 3 ) : NEW_LINE INDENT for l in range ( 4 ) : NEW_LINE INDENT if grid [ k ] [ l ] == grid [ k + 1 ] [ l ] : NEW_LINE INDENT ans = ' CONTINUE ' NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


def ans ( ) : NEW_LINE INDENT board = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 4 ) ] NEW_LINE pattarn = [ ( 1 , 0 ) , ( - 1 , 0 ) , ( 0 , 1 ) , ( 0 , - 1 ) ] NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT for j in range ( 4 ) : NEW_LINE INDENT for x , y in pattarn : NEW_LINE INDENT try : NEW_LINE INDENT if i + y < 0 or j + x < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT elif board [ i + y ] [ j + x ] == board [ i ] [ j ] : NEW_LINE INDENT return " CONTINUE " NEW_LINE DEDENT DEDENT except : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT DEDENT DEDENT return " GAMEOVER " NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT print ( ans ( ) ) NEW_LINE DEDENT


import sys NEW_LINE input = sys . stdin . readline NEW_LINE n = 4 NEW_LINE a = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( 4 ) ] NEW_LINE judge = True NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if i + 1 <= n - 1 : NEW_LINE INDENT if a [ i ] [ j ] == a [ i + 1 ] [ j ] : NEW_LINE INDENT judge = False NEW_LINE DEDENT DEDENT if j + 1 <= n - 1 : NEW_LINE INDENT if a [ i ] [ j ] == a [ i ] [ j + 1 ] : NEW_LINE INDENT judge = False NEW_LINE DEDENT DEDENT DEDENT DEDENT if judge : NEW_LINE INDENT print ( ' GAMEOVER ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' CONTINUE ' ) NEW_LINE DEDENT


L = [ ] NEW_LINE for h in range ( 4 ) : NEW_LINE INDENT L . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT dxy = [ ( - 1 , 0 ) , ( 1 , 0 ) , ( - 0 , - 1 ) , ( 0 , 1 ) ] NEW_LINE ans = " GAMEOVER " NEW_LINE explore = 1 NEW_LINE for y in range ( 4 ) : NEW_LINE INDENT if not explore : NEW_LINE INDENT break NEW_LINE DEDENT for x in range ( 4 ) : NEW_LINE INDENT if not explore : NEW_LINE INDENT break NEW_LINE DEDENT for dy , dx in dxy : NEW_LINE INDENT ny = y + dy NEW_LINE nx = x + dx NEW_LINE if ( ny < 0 ) or ( ny >= 4 ) or ( nx < 0 ) or ( nx >= 4 ) : NEW_LINE INDENT continue NEW_LINE DEDENT if L [ y ] [ x ] == L [ ny ] [ nx ] : NEW_LINE INDENT ans = " CONTINUE " NEW_LINE explore = 0 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static IntStream REPS ( int r ) { return IntStream . range ( 0 , r ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INTS ( int l ) { return REPS ( l ) . map ( i -> getInt ( ) ) ; } public static void main ( String [ ] __ ) { int [ ] [ ] in = REPS ( 4 ) . mapToObj ( i -> INTS ( 4 ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { if ( i > 0 && in [ i - 1 ] [ j ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } if ( i < 3 && in [ i + 1 ] [ j ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } if ( j > 0 && in [ i ] [ j - 1 ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } if ( j < 3 && in [ i ] [ j + 1 ] == in [ i ] [ j ] ) { hoge ( ) ; return ; } } } System . out . println ( " GAMEOVER " ) ; } private static void hoge ( ) { System . out . println ( " CONTINUE " ) ; } }


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 = 4 ; int [ ] [ ] tile = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) tile [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; String res = " GAMEOVER " ; for ( int i = 0 ; i < n ; i ++ ) { int t = tile [ i ] [ 0 ] ; for ( int j = 1 ; j < n ; j ++ ) { if ( t == tile [ i ] [ j ] ) res = " CONTINUE " ; else t = tile [ i ] [ j ] ; } } for ( int i = 0 ; i < n ; i ++ ) { int t = tile [ 0 ] [ i ] ; for ( int j = 1 ; j < n ; j ++ ) { if ( t == tile [ j ] [ i ] ) res = " CONTINUE " ; else t = tile [ j ] [ i ] ; } } System . out . println ( res ) ; } }


import java . util . * ; import java . awt . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int [ ] dx = { - 1 , 0 , 1 , 0 } ; int [ ] dy = { 0 , - 1 , 0 , 1 } ; int [ ] [ ] A = new int [ 4 ] [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } int c = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { int x = j + dx [ k ] ; int y = i + dy [ k ] ; if ( d ( x , y ) ) { if ( A [ i ] [ j ] == A [ y ] [ x ] ) c ++ ; } } } } out . println ( c == 0 ? " GAMEOVER " : " CONTINUE " ) ; } static boolean d ( int x , int y ) { return 0 <= x && x < 4 && 0 <= y && y < 4 ; } }


import java . util . * ; public class Main { private static int a [ ] [ ] = new int [ 4 ] [ 4 ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { a [ i ] [ j ] = scan . nextInt ( ) ; } } } public static void main ( String args [ ] ) { input ( ) ; boolean flag = false ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { if ( j != 3 && a [ i ] [ j ] == a [ i ] [ j + 1 ] ) { flag = true ; break ; } if ( j != 3 && a [ j ] [ i ] == a [ j + 1 ] [ i ] ) { flag = true ; break ; } } } if ( flag ) System . out . println ( " CONTINUE " ) ; else System . out . println ( " GAMEOVER " ) ; } }


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

N , L = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ input ( ) . rstrip ( ) for _ in range ( N ) ] NEW_LINE print ( ' ' . join ( sorted ( S ) ) ) NEW_LINE


n , l = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a . append ( input ( ) ) NEW_LINE DEDENT for j in range ( n ) : NEW_LINE INDENT for i in range ( j ) : NEW_LINE INDENT if a [ i ] > a [ j ] : NEW_LINE INDENT b = a [ i ] NEW_LINE a [ i ] = a [ j ] NEW_LINE a [ j ] = b NEW_LINE DEDENT DEDENT DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT a [ 0 ] += a [ i ] NEW_LINE DEDENT print ( a [ 0 ] ) NEW_LINE


a , b = map ( int , input ( ) . split ( ) ) NEW_LINE letters = [ ] NEW_LINE for i in range ( a ) : NEW_LINE INDENT c = input ( ) NEW_LINE letters . append ( c ) NEW_LINE DEDENT letterss = sorted ( letters ) NEW_LINE mojiretsu = ' ' NEW_LINE for x in letterss : NEW_LINE INDENT mojiretsu += x NEW_LINE DEDENT print ( mojiretsu ) NEW_LINE


Num = [ int ( n ) for n in input ( ) . rstrip ( ) . split ( ) ] NEW_LINE Str = [ input ( ) . rstrip ( ) for _ in range ( Num [ 0 ] ) ] NEW_LINE print ( " " . join ( sorted ( Str ) ) ) NEW_LINE


n , l = map ( int , input ( ) . split ( ) ) NEW_LINE lines = sorted ( [ str ( input ( ) ) for i in range ( n ) ] ) NEW_LINE test = " " NEW_LINE for line in lines : NEW_LINE INDENT test += line NEW_LINE DEDENT print ( test ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BIrohaLovesStringsABCEdition solver = new BIrohaLovesStringsABCEdition ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BIrohaLovesStringsABCEdition { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int row = in . nextInt ( ) ; int col = in . nextInt ( ) ; String array [ ] = new String [ row ] ; for ( int i = 0 ; i < row ; i ++ ) { array [ i ] = in . next ( ) ; } Arrays . sort ( array ) ; String temp = " " ; for ( int i = 0 ; i < row ; i ++ ) { temp += array [ i ] ; } out . print ( temp ) ; } } 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 . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { String line = null ; List < String > tmpList = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ) { line = sc . nextLine ( ) ; String [ ] tmpArray = line . split ( " ▁ " ) ; int letterNum = Integer . parseInt ( tmpArray [ 0 ] ) ; for ( int i = 0 ; i < letterNum ; i ++ ) { tmpList . add ( sc . nextLine ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } tmpList . stream ( ) . sorted ( ) . forEach ( i -> System . out . print ( i ) ) ; } }


import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; sc . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextLine ( ) ) ; } Collections . sort ( list , Comparator . naturalOrder ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; for ( String str : list ) { sb . append ( str ) ; } System . out . println ( sb . toString ( ) ) ; } }


import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int len = sc . nextInt ( ) ; List l = new ArrayList < String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String tmp = sc . next ( ) ; l . add ( tmp ) ; } Collections . sort ( l ) ; for ( int i = 0 ; i < l . size ( ) ; i ++ ) { System . out . print ( l . get ( i ) ) ; if ( i == l . size ( ) - 1 ) { System . out . println ( " " ) ; } } sc . close ( ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .


import java . util . * ; public class Main { public void main ( Scanner sc ) { int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int limit = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } int dp [ ] [ ] [ ] = new int [ n + 1 ] [ limit + 1 ] [ w + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j <= limit ; j ++ ) { for ( int k = 0 ; k <= w ; k ++ ) { if ( k < a [ i ] ) { dp [ i + 1 ] [ j ] [ k ] = Math . max ( dp [ i ] [ j ] [ k ] , dp [ i + 1 ] [ j ] [ k ] ) ; } else { dp [ i + 1 ] [ j ] [ k ] = Math . max ( Math . max ( dp [ i ] [ j ] [ k ] , dp [ i ] [ j - 1 ] [ k - a [ i ] ] + b [ i ] ) , dp [ i + 1 ] [ j ] [ k ] ) ; } } } } System . out . println ( dp [ n ] [ limit ] [ w ] ) ; } public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { new Main ( ) . main ( sc ) ; } catch ( Exception e ) { throw e ; } } }

W = int ( input ( ) ) NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE AB = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE dp = [ [ 50001 for _ in range ( 100 * N + 1 ) ] for _ in range ( N + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] = 0 NEW_LINE total = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT a , b = AB [ i ] NEW_LINE for j in range ( i , - 1 , - 1 ) : NEW_LINE INDENT for v in range ( total , - 1 , - 1 ) : NEW_LINE INDENT dp [ j + 1 ] [ v + b ] = min ( dp [ j + 1 ] [ v + b ] , dp [ j ] [ v ] + a ) NEW_LINE DEDENT DEDENT total += b NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( 1 , K + 1 ) : NEW_LINE INDENT for j in range ( 100 * N + 1 ) : NEW_LINE INDENT if dp [ i ] [ j ] <= W : NEW_LINE INDENT ans = max ( ans , j ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


import sys NEW_LINE def   ? ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE W = int ( input ( ) ) NEW_LINE N , K = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE dp = { 0 : { 0 : 0 } } NEW_LINE INF = float ( " inf " ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT w , v = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE if w <= W : NEW_LINE INDENT for k in sorted ( dp . keys ( ) , reverse = True ) : NEW_LINE INDENT if K <= k : NEW_LINE INDENT continue NEW_LINE DEDENT tk = k + 1 NEW_LINE for j in dp [ k ] : NEW_LINE INDENT tv = j + v NEW_LINE tMin = min ( dp . get ( tk , { } ) . get ( tv , INF ) , dp [ k ] [ j ] + w ) NEW_LINE if W < tMin : NEW_LINE INDENT continue NEW_LINE DEDENT if tk in dp : NEW_LINE INDENT dp [ tk ] [ tv ] = tMin NEW_LINE DEDENT else : NEW_LINE INDENT dp [ tk ] = { tv : tMin } NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( max ( max ( ed . keys ( ) ) for ed in dp . values ( ) ) ) NEW_LINE DEDENT ? ( ) NEW_LINE


import numpy as np NEW_LINE max_w = int ( input ( ) ) NEW_LINE n , max_k = map ( int , input ( ) . split ( ) ) NEW_LINE dp = np . zeros ( ( max_k + 1 , max_w + 1 ) ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT w , val = map ( int , input ( ) . split ( ) ) NEW_LINE if w > max_w : NEW_LINE INDENT continue NEW_LINE DEDENT dp [ 1 : , w : ] = np . maximum ( dp [ : max_k , : max_w + 1 - w ] + val , dp [ 1 : , w : ] ) NEW_LINE DEDENT print ( int ( dp [ max_k , max_w ] ) ) NEW_LINE


W = int ( input ( ) ) NEW_LINE N , K = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE G = [ 0 ] * N NEW_LINE def calc ( i , max_a , w , k ) : NEW_LINE INDENT if i >= N or k >= K : NEW_LINE INDENT return 0 NEW_LINE DEDENT g_i0 = G [ i ] [ 0 ] NEW_LINE a = calc ( i + 1 , max_a if max_a < g_i0 else g_i0 , w , k ) NEW_LINE w_new = w + g_i0 NEW_LINE if w_new > W or g_i0 > max_a : NEW_LINE INDENT return a NEW_LINE DEDENT b = G [ i ] [ 1 ] + calc ( i + 1 , max_a , w_new , k + 1 ) NEW_LINE return a if a > b else b NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT A , B = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE G [ i ] = ( A , B ) NEW_LINE DEDENT G . sort ( key = lambda x : x [ 1 ] , reverse = True ) NEW_LINE print ( calc ( 0 , 100000 , 0 , 0 ) ) NEW_LINE


import numpy as np NEW_LINE from itertools import product NEW_LINE W = int ( input ( ) ) NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE wid_val = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for _ in range ( N ) ] NEW_LINE dp = np . zeros ( [ N + 1 , W + 1 , K + 1 ] , dtype = int ) NEW_LINE for i , num in product ( range ( 1 , N + 1 ) , range ( 1 , K + 1 ) ) : NEW_LINE INDENT key = wid_val [ i - 1 ] [ 0 ] NEW_LINE dp [ i , : key , num ] = dp [ i - 1 , : key , num ] NEW_LINE dp [ i , key : , num ] = np . maximum ( dp [ i - 1 , key : , num ] , dp [ i - 1 , : - key , num - 1 ] + wid_val [ i - 1 ] [ 1 ] ) NEW_LINE DEDENT print ( dp [ N ] [ W ] [ K ] ) NEW_LINE


import java . util . * ; public class Main { static long mod = 1000000000 + 7 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int W = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] b = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } int sumB = 0 ; for ( int w : b ) sumB += w ; int [ ] [ ] dp = new int [ K + 1 ] [ sumB + 1 ] ; for ( int i = 0 ; i < K + 1 ; i ++ ) Arrays . fill ( dp [ i ] , Integer . MAX_VALUE / 2 ) ; dp [ 0 ] [ 0 ] = 0 ; for ( int kind = 1 ; kind <= n ; kind ++ ) { for ( int k = K - 1 ; k >= 0 ; k -- ) { for ( int sum = sumB ; sum >= b [ kind ] ; sum -- ) { if ( dp [ k ] [ sum - b [ kind ] ] + a [ kind ] <= W ) dp [ k + 1 ] [ sum ] = Math . min ( dp [ k + 1 ] [ sum ] , dp [ k ] [ sum - b [ kind ] ] + a [ kind ] ) ; } } } int ans = - 1 ; for ( int k = 0 ; k <= K ; k ++ ) { for ( int sum = 0 ; sum <= sumB ; sum ++ ) { if ( dp [ k ] [ sum ] <= W ) ans = Math . max ( sum , ans ) ; } } System . out . println ( ans ) ; } }


import java . util . * ; import java . io . InputStreamReader ; import java . io . BufferedReader ; import java . util . Arrays ; import java . util . List ; import java . util . ArrayList ; import java . util . ArrayDeque ; import java . util . Deque ; import java . util . Collections ; import java . awt . Point ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int W = Integer . parseInt ( br . readLine ( ) ) ; String [ ] nk = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; int [ ] w = new int [ n + 1 ] ; int [ ] v = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] line = br . readLine ( ) . split ( " ▁ " ) ; w [ i + 1 ] = Integer . parseInt ( line [ 0 ] ) ; v [ i + 1 ] = Integer . parseInt ( line [ 1 ] ) ; } int [ ] [ ] [ ] dp = new int [ n + 1 ] [ W + 1 ] [ k + 1 ] ; dp [ 0 ] [ 0 ] [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= W ; j ++ ) { for ( int l = 1 ; l <= k ; l ++ ) { if ( j - w [ i ] >= 0 ) dp [ i ] [ j ] [ l ] = Math . max ( dp [ i - 1 ] [ j - w [ i ] ] [ l - 1 ] + v [ i ] , dp [ i - 1 ] [ j ] [ l ] ) ; else dp [ i ] [ j ] [ l ] = dp [ i - 1 ] [ j ] [ l ] ; } } } System . out . println ( dp [ n ] [ W ] [ k ] ) ; } }


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D solver = new D ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D { int n ; int [ ] [ ] [ ] dp ; int [ ] a ; int [ ] b ; public void solve ( int testNumber , Scanner in , PrintWriter out ) { int w = in . nextInt ( ) ; n = in . nextInt ( ) ; int k = in . nextInt ( ) ; dp = new int [ n ] [ n + 1 ] [ w + 1 ] ; a = new int [ n ] ; b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; b [ i ] = in . nextInt ( ) ; for ( int j = 0 ; j <= n ; j ++ ) { Arrays . fill ( dp [ i ] [ j ] , - 1 ) ; } } out . println ( calc ( 0 , w , k ) ) ; } private int calc ( int i , int w , int k ) { if ( i >= n || w <= 0 || k <= 0 ) { return 0 ; } else if ( dp [ i ] [ k ] [ w ] >= 0 ) { return dp [ i ] [ k ] [ w ] ; } int ans = calc ( i + 1 , w , k ) ; if ( w >= a [ i ] ) { ans = Math . max ( ans , calc ( i + 1 , w - a [ i ] , k - 1 ) + b [ i ] ) ; } return dp [ i ] [ k ] [ w ] = ans ; } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int w = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmp = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( tmp [ 0 ] ) ; int k = Integer . parseInt ( tmp [ 1 ] ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { tmp = br . readLine ( ) . split ( " ▁ " ) ; a [ i ] = Integer . parseInt ( tmp [ 0 ] ) ; b [ i ] = Integer . parseInt ( tmp [ 1 ] ) ; } int [ ] [ ] [ ] dp = new int [ n + 1 ] [ w + 1 ] [ k + 1 ] ; for ( int index = 0 ; index < n ; index ++ ) { for ( int width = 0 ; width <= w ; width ++ ) { for ( int num = 0 ; num < k ; num ++ ) { if ( a [ index ] > width ) dp [ index + 1 ] [ width ] [ num + 1 ] = dp [ index ] [ width ] [ num + 1 ] ; else dp [ index + 1 ] [ width ] [ num + 1 ] = Math . max ( dp [ index ] [ width ] [ num + 1 ] , dp [ index ] [ width - a [ index ] ] [ num ] + b [ index ] ) ; } } } System . out . println ( dp [ n ] [ w ] [ k ] ) ; } }


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . 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 ) ; TaskD solver = new TaskD ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskD { public void solve ( int testNumber , InputReader in , PrintWriter out ) { long k = in . nextLong ( ) ; long p = k / 50 ; long q = k % 50 ; long [ ] ans = new long [ 50 ] ; Arrays . fill ( ans , 49 + p ) ; for ( int i = 0 ; i < q ; i ++ ) { for ( int j = 0 ; j < 50 ; j ++ ) { if ( j == i ) { ans [ j ] += 50 ; } else { ans [ j ] -- ; } } } out . println ( ans . length ) ; for ( int i = 0 ; i < ans . length ; i ++ ) { if ( i > 0 ) out . print ( " ▁ " ) ; out . print ( ans [ i ] ) ; } out . println ( ) ; } } 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 sys NEW_LINE K = int ( input ( ) ) NEW_LINE a = K // 50 NEW_LINE b = K % 50 NEW_LINE if K == 0 : NEW_LINE INDENT print ( 2 ) NEW_LINE print ( 0 , 0 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT Ans = [ 100 + a - b ] * b + [ 49 + a - b ] * ( 50 - b ) NEW_LINE print ( 50 ) NEW_LINE print ( * Ans ) NEW_LINE


import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE import numpy as np NEW_LINE def solve_d ( k ) : NEW_LINE INDENT if k == 0 : NEW_LINE INDENT return [ 0 ] * 50 NEW_LINE DEDENT if k <= 50 : NEW_LINE INDENT arr = [ ] NEW_LINE for i in range ( k ) : NEW_LINE INDENT arr . append ( 50 - i ) NEW_LINE DEDENT for i in range ( k , 50 ) : NEW_LINE INDENT arr . append ( 0 ) NEW_LINE DEDENT return arr NEW_LINE DEDENT else : NEW_LINE INDENT arr = list ( reversed ( range ( 1 , 51 ) ) ) NEW_LINE base = ( k - 1 ) // 50 NEW_LINE for i in range ( 50 ) : NEW_LINE INDENT arr [ i ] += base - 1 NEW_LINE DEDENT for i in range ( k - base * 50 ) : NEW_LINE INDENT arr [ i ] += 1 NEW_LINE DEDENT return arr NEW_LINE DEDENT DEDENT K = int ( input ( ) ) NEW_LINE print ( 50 ) NEW_LINE print ( * solve_d ( K ) ) NEW_LINE def solve_e ( As ) : NEW_LINE INDENT ans = 0 NEW_LINE N = len ( As ) NEW_LINE As = As [ : ] NEW_LINE while True : NEW_LINE INDENT taken = [ 0 ] * N NEW_LINE for i , a in enumerate ( As ) : NEW_LINE INDENT taken [ i ] = a // N NEW_LINE As [ i ] -= taken [ i ] * N NEW_LINE DEDENT taken_sum = sum ( taken ) NEW_LINE if taken_sum == 0 : NEW_LINE INDENT break NEW_LINE DEDENT ans += taken_sum NEW_LINE for i in range ( N ) : NEW_LINE INDENT As [ i ] += ( taken_sum - taken [ i ] ) NEW_LINE DEDENT DEDENT return ans NEW_LINE NEW_LINE DEDENT