import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] c = new int [ 6 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' ) { c [ 0 ] ++ ; } else if ( s . charAt ( i ) == ' B ' ) { c [ 1 ] ++ ; } else if ( s . charAt ( i ) == ' C ' ) { c [ 2 ] ++ ; } else if ( s . charAt ( i ) == ' D ' ) { c [ 3 ] ++ ; } else if ( s . charAt ( i ) == ' E ' ) { c [ 4 ] ++ ; } else if ( s . charAt ( i ) == ' F ' ) { c [ 5 ] ++ ; } } System . out . printf ( " % d ▁ % d ▁ % d ▁ % d ▁ % d ▁ % d % n " , c [ 0 ] , c [ 1 ] , c [ 2 ] , c [ 3 ] , c [ 4 ] , c [ 5 ] ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . util . stream . LongStream ; import java . io . IOException ; import java . util . stream . Collectors ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . stream . Stream ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String s = in . string ( ) ; out . println ( IntStream . rangeClosed ( ' A ' , ' F ' ) . mapToLong ( t -> s . chars ( ) . filter ( x -> x == t ) . count ( ) ) . mapToObj ( Long :: toString ) . collect ( Collectors . joining ( " ▁ " ) ) ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; int [ ] count = new int [ 6 ] ; for ( char cc : s . toCharArray ( ) ) count [ cc - ' A ' ] ++ ; out . printf ( " % d ▁ % d ▁ % d ▁ % d ▁ % d ▁ % d \n " , count [ 0 ] , count [ 1 ] , count [ 2 ] , count [ 3 ] , count [ 4 ] , count [ 5 ] ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }

import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; int [ ] count = new int [ 6 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count [ s . charAt ( i ) - ' A ' ] ++ ; } System . out . println ( count [ 0 ] + " ▁ " + count [ 1 ] + " ▁ " + count [ 2 ] + " ▁ " + count [ 3 ] + " ▁ " + count [ 4 ] + " ▁ " + count [ 5 ] ) ; } }

import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > map = new TreeMap < > ( ) ; String s = sc . next ( ) ; String A [ ] = { " A " , " B " , " C " , " D " , " E " , " F " } ; for ( int i = 0 ; i < 6 ; i ++ ) map . put ( A [ i ] , 0 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String S = s . substring ( i , i + 1 ) ; map . put ( S , map . get ( S ) + 1 ) ; } System . out . println ( map . get ( " A " ) + " ▁ " + map . get ( " B " ) + " ▁ " + map . get ( " C " ) + " ▁ " + map . get ( " D " ) + " ▁ " + map . get ( " E " ) + " ▁ " + map . get ( " F " ) ) ; } }

str = list ( input ( ) ) NEW_LINE moji = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ] NEW_LINE for i in range ( 6 ) : NEW_LINE INDENT print ( str . count ( moji [ i ] ) , end = ' ' ) NEW_LINE if i < 5 : NEW_LINE INDENT print ( ' ▁ ' , end = ' ' ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE

def count_up ( S : str ) -> list : NEW_LINE INDENT freq = { c : 0 for c in ' ABCDEF ' } NEW_LINE for c in S : NEW_LINE INDENT freq . setdefault ( c , 0 ) NEW_LINE freq [ c ] += 1 NEW_LINE DEDENT return [ v for _ , v in sorted ( freq . items ( ) ) ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT S = input ( ) NEW_LINE ans = count_up ( S ) NEW_LINE print ( ' ▁ ' . join ( map ( str , ans ) ) ) NEW_LINE DEDENT

from collections import Counter NEW_LINE S = [ i for i in input ( ) ] NEW_LINE ans = [ ] NEW_LINE ans . append ( str ( S . count ( " A " ) ) ) NEW_LINE ans . append ( str ( S . count ( " B " ) ) ) NEW_LINE ans . append ( str ( S . count ( " C " ) ) ) NEW_LINE ans . append ( str ( S . count ( " D " ) ) ) NEW_LINE ans . append ( str ( S . count ( " E " ) ) ) NEW_LINE ans . append ( str ( S . count ( " F " ) ) ) NEW_LINE print ( " ▁ " . join ( ans ) ) NEW_LINE

l = list ( input ( ) ) NEW_LINE ca = 0 NEW_LINE cb = 0 NEW_LINE cc = 0 NEW_LINE cd = 0 NEW_LINE ce = 0 NEW_LINE cf = 0 NEW_LINE for i in l : NEW_LINE INDENT if i == " A " : NEW_LINE INDENT ca += 1 NEW_LINE DEDENT elif i == " B " : NEW_LINE INDENT cb += 1 NEW_LINE DEDENT elif i == " C " : NEW_LINE INDENT cc += 1 NEW_LINE DEDENT elif i == " D " : NEW_LINE INDENT cd += 1 NEW_LINE DEDENT elif i == " E " : NEW_LINE INDENT ce += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cf += 1 NEW_LINE DEDENT DEDENT print ( ca , cb , cc , cd , ce , cf ) NEW_LINE

s = input ( ) NEW_LINE alpha = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ] NEW_LINE cnt = [ ] NEW_LINE for a in alpha [ : 5 ] : NEW_LINE INDENT print ( s . count ( a ) , end = " ▁ " ) NEW_LINE DEDENT print ( s . count ( alpha [ 5 ] ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String string = scanner . nextLine ( ) ; System . out . println ( string . chars ( ) . filter ( x -> x == '1' ) . count ( ) ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final PrintWriter sysout = new PrintWriter ( System . out , false ) ; private static StringTokenizer buffer ; private static String readLine ( ) { buffer = null ; try { return br . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } private static String read ( ) { if ( buffer == null || ! buffer . hasMoreTokens ( ) ) { buffer = new StringTokenizer ( readLine ( ) ) ; } return buffer . nextToken ( ) ; } private static int readInt ( ) { return Integer . parseInt ( read ( ) ) ; } private static int [ ] readIntArray ( int loop ) { int [ ] result = new int [ loop ] ; for ( int i = 0 ; i < loop ; i ++ ) { result [ i ] = readInt ( ) ; } return result ; } private static int [ ] splitInt ( ) { String [ ] tmp = read ( ) . split ( " " ) ; int [ ] result = new int [ tmp . length ] ; for ( int i = 0 , n = tmp . length ; i < n ; i ++ ) { result [ i ] = Integer . parseInt ( tmp [ i ] ) ; } return result ; } private static long readLong ( ) { return Long . parseLong ( read ( ) ) ; } private static double readDouble ( ) { return Double . parseDouble ( read ( ) ) ; } public static void main ( String [ ] args ) { run ( ) ; } private static void run ( ) { String [ ] input = readLine ( ) . split ( " " ) ; int count = 0 ; if ( input [ 0 ] . equals ( "1" ) ) count ++ ; if ( input [ 1 ] . equals ( "1" ) ) count ++ ; if ( input [ 2 ] . equals ( "1" ) ) count ++ ; System . out . println ( count ) ; } }

import java . util . Scanner ; class Main { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; System . out . println ( calc ( S ) ) ; } public static int calc ( String S ) { String [ ] s = S . split ( " " ) ; int count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] . equals ( "1" ) ) { count ++ ; } } return count ; } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int num = scan . nextInt ( ) ; int cnt = 0 ; boolean a = num > 99 ; if ( a ) { cnt ++ ; num = num - 100 ; } boolean b = num > 9 ; if ( b ) { num = num - 10 ; cnt ++ ; } boolean c = num == 1 ; if ( c ) { cnt ++ ; } System . out . println ( cnt ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] array = sc . nextLine ( ) . split ( " " ) ; int sum = 0 ; for ( String s : array ) { if ( Integer . parseInt ( s ) == 1 ) { sum ++ ; } } System . out . println ( sum ) ; } }

print ( input ( ) . count ( "1" ) ) NEW_LINE

s = int ( input ( ) ) NEW_LINE i = 0 NEW_LINE if ( s // 100 == 1 ) : NEW_LINE INDENT i = i + 1 NEW_LINE s = s - 100 NEW_LINE DEDENT if ( s // 10 == 1 ) : NEW_LINE INDENT i = i + 1 NEW_LINE s = s - 10 NEW_LINE DEDENT if ( s == 1 ) : NEW_LINE INDENT i = i + 1 NEW_LINE DEDENT print ( i ) NEW_LINE

s = input ( ) NEW_LINE counter = 0 NEW_LINE if s [ 0 ] == '1' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT if s [ 1 ] == '1' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT if s [ 2 ] == '1' : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT print ( counter ) NEW_LINE

str = list ( input ( ) ) NEW_LINE s1 = int ( str [ 0 ] ) NEW_LINE s2 = int ( str [ 1 ] ) NEW_LINE s3 = int ( str [ 2 ] ) NEW_LINE print ( s1 + s2 + s3 ) NEW_LINE

S = input ( ) NEW_LINE cnt = 0 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT if S [ i ] == "1" : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] cnt = new long [ 5 ] ; for ( int i = 0 ; i < n ; i ++ ) { char ch = sc . next ( ) . charAt ( 0 ) ; if ( ch == ' M ' ) cnt [ 0 ] ++ ; if ( ch == ' A ' ) cnt [ 1 ] ++ ; if ( ch == ' R ' ) cnt [ 2 ] ++ ; if ( ch == ' C ' ) cnt [ 3 ] ++ ; if ( ch == ' H ' ) cnt [ 4 ] ++ ; } sc . close ( ) ; int c = 0 ; for ( int i = 0 ; i < cnt . length ; i ++ ) { if ( cnt [ i ] > 0 ) c ++ ; } if ( c < 3 ) { System . out . println ( 0 ) ; return ; } long ans = 0L ; for ( int i = 0 ; i < cnt . length ; i ++ ) { for ( int j = i + 1 ; j < cnt . length ; j ++ ) { for ( int k = j + 1 ; k < cnt . length ; k ++ ) { ans += cnt [ i ] * cnt [ j ] * cnt [ k ] ; } } } System . out . println ( ans ) ; } }

public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; long m = 0 , a = 0 , r = 0 , c = 0 , h = 0 ; for ( int i = 0 ; i < n ; i ++ ) { switch ( scanner . next ( ) . charAt ( 0 ) ) { case ' M ' : m ++ ; continue ; case ' A ' : a ++ ; continue ; case ' R ' : r ++ ; continue ; case ' C ' : c ++ ; continue ; case ' H ' : h ++ ; } } System . out . println ( m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h ) ; } }

import java . util . * ; public class Main { static long Examine ( long countM , long countA , long countR , long countC , long countH ) { long count = 0 ; count += countR * countC * countH ; count += countA * countC * countH ; count += countA * countR * countH ; count += countA * countR * countC ; count += countM * countC * countH ; count += countM * countR * countH ; count += countM * countR * countC ; count += countM * countA * countH ; count += countM * countA * countC ; count += countM * countA * countR ; return count ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String [ ] names = new String [ N ] ; long countM = 0 ; long countA = 0 ; long countR = 0 ; long countC = 0 ; long countH = 0 ; String [ ] I = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { names [ i ] = sc . next ( ) ; I [ i ] = names [ i ] . substring ( 0 , 1 ) ; } for ( int k = 0 ; k < N ; k ++ ) { if ( I [ k ] . equals ( " M " ) ) countM ++ ; else if ( I [ k ] . equals ( " A " ) ) countA ++ ; else if ( I [ k ] . equals ( " R " ) ) countR ++ ; else if ( I [ k ] . equals ( " C " ) ) countC ++ ; else if ( I [ k ] . equals ( " H " ) ) countH ++ ; } System . out . println ( Examine ( countM , countA , countR , countC , countH ) ) ; sc . close ( ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] startNum = new long [ ' Z ' - ' A ' + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { String str = sc . next ( ) ; startNum [ str . charAt ( 0 ) - ' A ' ] ++ ; } long comb = 0 ; char [ ] march = new char [ ] { ' M ' , ' A ' , ' R ' , ' C ' , ' H ' } ; for ( int i = 0 ; i < march . length ; i ++ ) { for ( int j = i + 1 ; j < march . length ; j ++ ) { for ( int k = j + 1 ; k < march . length ; k ++ ) { comb += startNum [ march [ i ] - ' A ' ] * startNum [ march [ j ] - ' A ' ] * startNum [ march [ k ] - ' A ' ] ; } } } out . println ( comb ) ; } }

import java . io . File ; import java . io . IOException ; import java . lang . reflect . Array ; import java . util . * ; import java . util . Map . Entry ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; long [ ] march = new long [ 5 ] ; String marchS = " MARCH " ; for ( int i = 0 ; i < N ; i ++ ) { String S = in . next ( ) . substring ( 0 , 1 ) ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( S . equals ( String . valueOf ( marchS . charAt ( j ) ) ) ) { march [ j ] ++ ; break ; } } } long ans = 0 ; for ( int i = 0 ; i < 5 - 2 ; i ++ ) { for ( int j = i + 1 ; j < 5 - 1 ; j ++ ) { for ( int k = j + 1 ; k < 5 ; k ++ ) { ans += march [ i ] * march [ j ] * march [ k ] ; } } } System . out . println ( ans ) ; } }

N = int ( input ( ) ) NEW_LINE S = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT S . append ( list ( input ( ) ) [ 0 ] ) NEW_LINE DEDENT count = [ 0 ] * 5 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] == " M " : NEW_LINE INDENT count [ 0 ] += 1 NEW_LINE DEDENT elif S [ i ] == " A " : NEW_LINE INDENT count [ 1 ] += 1 NEW_LINE DEDENT elif S [ i ] == " R " : NEW_LINE INDENT count [ 2 ] += 1 NEW_LINE DEDENT elif S [ i ] == " C " : NEW_LINE INDENT count [ 3 ] += 1 NEW_LINE DEDENT elif S [ i ] == " H " : NEW_LINE INDENT count [ 4 ] += 1 NEW_LINE DEDENT DEDENT sum = 0 NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT sum += count [ i ] * count [ i + 1 ] * count [ i + 2 ] NEW_LINE DEDENT for i in range ( 2 ) : NEW_LINE INDENT sum += count [ i ] * count [ i + 1 ] * count [ i + 3 ] NEW_LINE sum += count [ i ] * count [ i + 2 ] * count [ i + 3 ] NEW_LINE DEDENT for i in range ( 3 ) : NEW_LINE INDENT sum += count [ 0 ] * count [ i + 1 ] * count [ 4 ] NEW_LINE DEDENT print ( sum ) NEW_LINE

from itertools import combinations NEW_LINE from numpy import prod NEW_LINE N = int ( input ( ) ) NEW_LINE S = [ input ( ) for _ in range ( N ) ] NEW_LINE first_chars = { ' M ' : 0 , ' A ' : 0 , ' R ' : 0 , ' C ' : 0 , ' H ' : 0 } NEW_LINE for s in S : NEW_LINE INDENT if s [ 0 ] in first_chars . keys ( ) : NEW_LINE INDENT first_chars [ s [ 0 ] ] += 1 NEW_LINE DEDENT DEDENT combs = list ( combinations ( [ v for v in first_chars . values ( ) if v > 0 ] , 3 ) ) NEW_LINE print ( sum ( [ prod ( comb ) for comb in combs ] ) ) NEW_LINE

from itertools import * ; s , * _ = zip ( * open ( 0 ) ) ; print ( sum ( p * q * r for p , q , r in combinations ( map ( s . count , ' MARCH ' ) , 3 ) ) ) NEW_LINE

import itertools NEW_LINE n = int ( input ( ) ) NEW_LINE s = [ [ ] for _ in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT s [ i ] = list ( input ( ) ) NEW_LINE DEDENT delete = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if s [ i ] [ 0 ] == " M " or s [ i ] [ 0 ] == " A " or s [ i ] [ 0 ] == " R " or s [ i ] [ 0 ] == " C " or s [ i ] [ 0 ] == " H " : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT delete . append ( i ) NEW_LINE DEDENT DEDENT diff = 0 NEW_LINE for i in range ( len ( delete ) ) : NEW_LINE INDENT del s [ delete [ i ] - diff ] NEW_LINE diff += 1 NEW_LINE DEDENT cand = [ 0 , 0 , 0 , 0 , 0 ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] [ 0 ] == " M " : NEW_LINE INDENT cand [ 0 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == " A " : NEW_LINE INDENT cand [ 1 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == " R " : NEW_LINE INDENT cand [ 2 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == " C " : NEW_LINE INDENT cand [ 3 ] += 1 NEW_LINE DEDENT if s [ i ] [ 0 ] == " H " : NEW_LINE INDENT cand [ 4 ] += 1 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 5 ) : NEW_LINE INDENT for j in range ( 5 ) : NEW_LINE INDENT if i == j : NEW_LINE INDENT break NEW_LINE DEDENT for k in range ( 5 ) : NEW_LINE INDENT if i == k : NEW_LINE INDENT break NEW_LINE DEDENT if j == k : NEW_LINE INDENT break NEW_LINE DEDENT ans += int ( cand [ i ] * cand [ j ] * cand [ k ] ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE

N = int ( input ( ) ) NEW_LINE S = [ input ( ) for i in range ( N ) ] NEW_LINE S_march = [ ] NEW_LINE MARCH = [ " M " , " A " , " R " , " C " , " H " ] NEW_LINE cmb = [ ] NEW_LINE ans = 0 NEW_LINE N_march = [ 0 ] * 5 NEW_LINE for Si in S : NEW_LINE INDENT for j in range ( 5 ) : NEW_LINE INDENT if Si [ : 1 ] == MARCH [ j ] : NEW_LINE INDENT N_march [ j ] += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( 2 ** 5 ) : NEW_LINE INDENT check = [ False ] * 5 NEW_LINE for j in range ( 5 ) : NEW_LINE INDENT if ( i >> j ) & 1 : NEW_LINE INDENT check [ j ] = True NEW_LINE DEDENT DEDENT if check . count ( True ) == 3 : NEW_LINE INDENT cmb . append ( check ) NEW_LINE DEDENT DEDENT for i in cmb : NEW_LINE INDENT tmp_list = [ ] NEW_LINE for j in range ( 5 ) : NEW_LINE INDENT if i [ j ] : NEW_LINE INDENT tmp_list . append ( N_march [ j ] ) NEW_LINE DEDENT DEDENT ans += tmp_list [ 0 ] * tmp_list [ 1 ] * tmp_list [ 2 ] NEW_LINE DEDENT print ( ans ) NEW_LINE NEW_LINE


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

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

import java . util . * ; public class Main { public static void main ( String [ ] args ) { B ( ) ; } public static void A ( ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s1 . charAt ( i ) != s2 . charAt ( 2 - i ) ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; } public static long binsearchN2 ( long left , long right , int N ) { if ( left >= right ) return ( long ) Math . pow ( right , 2 ) ; long mid = ( left + right ) / 2 ; if ( Math . pow ( mid , 2 ) > N ) return binsearchN2 ( left , mid - 1 , N ) ; else { if ( Math . pow ( mid + 1 , 2 ) > N ) return ( long ) Math . pow ( mid , 2 ) ; else return binsearchN2 ( mid + 1 , right , N ) ; } } public static void B ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; System . out . println ( binsearchN2 ( 0 , N , N ) ) ; } }

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

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long n = in . nextLong ( ) ; long ans = 0 ; for ( long i = 1 ; i * i <= n ; i ++ ) { ans = i * i ; } out . print ( ans ) ; } } }

N = int ( input ( ) ) NEW_LINE print ( int ( N ** .5 ) ** 2 ) NEW_LINE

N = int ( input ( ) . strip ( ) ) NEW_LINE for i in range ( N , 0 , - 1 ) : NEW_LINE INDENT kai = int ( pow ( i , 0.5 ) ) NEW_LINE if i == kai * kai : NEW_LINE INDENT print ( i ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT

from sys import exit NEW_LINE N = int ( input ( ) ) NEW_LINE anss = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( i ** 2 > N ) : NEW_LINE INDENT anss = i - 1 NEW_LINE break NEW_LINE DEDENT DEDENT print ( anss ** 2 ) NEW_LINE

N = int ( input ( ) ) NEW_LINE heihousu = [ ] NEW_LINE s = 0 NEW_LINE t = 0 NEW_LINE while ( t <= N ) : NEW_LINE INDENT s += 1 NEW_LINE t = s ** 2 NEW_LINE heihousu . append ( t ) NEW_LINE DEDENT print ( heihousu [ - 2 ] ) NEW_LINE

n = int ( input ( ) ) NEW_LINE import math NEW_LINE a = math . floor ( math . sqrt ( n ) ) NEW_LINE print ( a ** 2 ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; sc . close ( ) ; X = X - Z ; int ans = 0 ; while ( X >= 0 ) { X = X - ( Y + Z ) ; ans ++ ; } System . out . println ( ans == 0 ? 0 : ans - 1 ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int x = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int y = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int z = Integer . parseInt ( tokenizer . nextToken ( ) ) ; x -= z ; if ( x < 1 ) { System . out . println ( 0 ) ; } else { System . out . println ( x / ( y + z ) ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { B ( ) ; } public static void A ( ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; if ( s1 . compareTo ( s2 ) < 0 ) System . out . println ( " < " ) ; else if ( s1 . compareTo ( s2 ) == 0 ) System . out . println ( " = " ) ; else System . out . println ( " > " ) ; } public static void B ( ) { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; if ( X < Y || X < Z ) { System . out . println ( 0 ) ; return ; } X -= Z ; System . out . println ( X / ( Y + Z ) ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int ans = x / ( z + y ) ; if ( ans * ( z + y ) + z <= x ) System . out . println ( ans ) ; else System . out . println ( ans - 1 ) ; } }

import java . util . Scanner ; public class Main { static long N ; static long ans ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int semians = x / ( y + z ) ; if ( x % ( y + z ) < z ) semians -= 1 ; System . out . println ( semians ) ; } }

x , y , z = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE num = ( x - z ) // ( z + y ) NEW_LINE print ( num ) NEW_LINE

X , Y , Z = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE width_sum = 0 NEW_LINE while 1 : NEW_LINE INDENT if width_sum + Y + Z <= X - Z : NEW_LINE INDENT width_sum += Y + Z NEW_LINE ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

x , width , space = map ( int , input ( ) . split ( ) ) NEW_LINE N = 0 NEW_LINE if x < width + space : NEW_LINE INDENT print ( "0" ) NEW_LINE DEDENT else : NEW_LINE INDENT total_space = width + ( space ) NEW_LINE N = ( x - space ) // total_space NEW_LINE DEDENT print ( N ) NEW_LINE

import math NEW_LINE a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE a -= c NEW_LINE print ( math . floor ( a / ( b + c ) ) ) NEW_LINE

x , y , z = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE print ( ( x - z ) // ( y + z ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] x = new int [ M ] ; int [ ] y = new int [ M ] ; ArrayList [ ] edge = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { edge [ i ] = new ArrayList ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { x [ i ] = sc . nextInt ( ) - 1 ; y [ i ] = sc . nextInt ( ) - 1 ; edge [ x [ i ] ] . add ( y [ i ] ) ; } long [ ] dp = new long [ ( int ) Math . pow ( 2 , N ) ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < ( int ) Math . pow ( 2 , N ) ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) { boolean flg = true ; for ( int k = 0 ; k < N ; k ++ ) { if ( ( i & ( 1 << k ) ) != 0 && edge [ j ] . contains ( k ) ) flg = false ; } if ( flg ) dp [ i ] += dp [ i - ( 1 << j ) ] ; } } } System . out . println ( dp [ ( int ) Math . pow ( 2 , N ) - 1 ] ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; boolean [ ] [ ] info = new boolean [ N ] [ N ] ; for ( int i = 0 ; i < M ; i ++ ) { info [ sc . nextInt ( ) - 1 ] [ sc . nextInt ( ) - 1 ] = true ; } long [ ] dp = new long [ ( int ) Math . pow ( 2 , N ) ] ; boolean [ ] flag = new boolean [ ( int ) Math . pow ( 2 , N ) ] ; dp [ 0 ] = 1L ; flag [ 0 ] = true ; Queue < Integer > que = new ArrayDeque < > ( ) ; que . add ( 0 ) ; while ( ! que . isEmpty ( ) ) { int cur = que . poll ( ) ; check : for ( int i = 0 ; i < N ; i ++ ) { if ( ( cur >> i & 1 ) == 1 ) { continue ; } for ( int j = 0 ; j < N ; j ++ ) { if ( ( cur >> j & 1 ) == 1 && info [ i ] [ j ] ) { continue check ; } } dp [ cur + ( 1 << i ) ] += dp [ cur ] ; if ( ! flag [ cur + ( 1 << i ) ] ) { que . add ( cur + ( 1 << i ) ) ; flag [ cur + ( 1 << i ) ] = true ; } } } for ( int i = 0 ; i < ( int ) Math . pow ( 2 , N ) ; i ++ ) { } System . out . println ( dp [ ( int ) Math . pow ( 2 , N ) - 1 ] ) ; } }

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

import java . util . ArrayDeque ; import java . util . HashMap ; import java . util . Map ; import java . util . Queue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; Node [ ] nodes = new Node [ N ] ; for ( int i = 0 ; i < N ; i ++ ) nodes [ i ] = new Node ( i ) ; for ( int i = 0 ; i < M ; i ++ ) { Node x = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ; Node y = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ; x . neighbor . put ( y , 1 ) ; } sc . close ( ) ; int S = 1 << N ; long [ ] dp = new long [ S ] ; dp [ 0 ] = 1 ; Queue < Integer > que = new ArrayDeque < > ( ) ; que . add ( 0 ) ; while ( ! que . isEmpty ( ) ) { int s = que . remove ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( 1 << i & s ) > 0 ) continue ; boolean check = true ; for ( int j = 0 ; j < N ; j ++ ) { if ( ( 1 << j & s ) > 0 && nodes [ i ] . neighbor . containsKey ( nodes [ j ] ) ) { check = false ; break ; } } if ( check ) { if ( dp [ s + ( 1 << i ) ] == 0 ) { que . add ( s + ( 1 << i ) ) ; } dp [ s + ( 1 << i ) ] += dp [ s ] ; } } } System . out . println ( dp [ S - 1 ] ) ; } static class Node { int id ; Map < Node , Integer > neighbor = new HashMap < > ( ) ; Node ( int id ) { this . id = id ; } } }

import java . util . Scanner ; public class Main { static int [ ] [ ] xy ; static int [ ] two ; static int N ; static long [ ] dp ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; two = new int [ N ] ; two [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { two [ i ] = two [ i - 1 ] * 2 ; } xy = new int [ N ] [ N ] ; for ( int i = 0 ; i < M ; i ++ ) { int x = scan . nextInt ( ) - 1 ; int y = scan . nextInt ( ) - 1 ; xy [ y ] [ x ] = - 1 ; } dp = new long [ two [ N - 1 ] * 2 ] ; dp [ 0 ] = 1 ; System . out . println ( res ( two [ N - 1 ] * 2 - 1 ) ) ; } static long res ( int bit ) { if ( dp [ bit ] > 0 ) return dp [ bit ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( two [ i ] & bit ) > 0 ) { if ( admit ( bit - two [ i ] , i ) ) { dp [ bit ] += res ( bit - two [ i ] ) ; } } } return dp [ bit ] ; } static boolean admit ( int bit , int k ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( two [ i ] & bit ) > 0 ) { if ( xy [ i ] [ k ] == - 1 ) { return false ; } } } return true ; } }

def running ( N : int , M : int , queries : list ) -> int : NEW_LINE INDENT PHI = 0 NEW_LINE g = [ [ 0 ] * N for _ in range ( N ) ] NEW_LINE for u , v in queries : NEW_LINE INDENT g [ u - 1 ] [ v - 1 ] = 1 NEW_LINE g [ v - 1 ] [ u - 1 ] = - 1 NEW_LINE DEDENT dp = [ 0 for _ in range ( 1 << N ) ] NEW_LINE dp [ PHI ] = 1 NEW_LINE for S in range ( 1 , 1 << N ) : NEW_LINE INDENT for v in range ( N ) : NEW_LINE INDENT if S & ( 1 << v ) == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT S_v = S & ~ ( 1 << v ) NEW_LINE if any ( ( S_v & ( 1 << k ) ) and g [ k ] [ v ] == - 1 for k in range ( N ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT dp [ S ] += dp [ S_v ] NEW_LINE DEDENT DEDENT return dp [ ( 1 << N ) - 1 ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT M = 0 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( M ) ] NEW_LINE ans = running ( N , M , queries ) NEW_LINE print ( ans ) NEW_LINE DEDENT

from collections import defaultdict NEW_LINE from heapq import heappush , heappop NEW_LINE import sys NEW_LINE import math NEW_LINE import bisect NEW_LINE import random NEW_LINE def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def LS ( ) : return list ( map ( list , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE def S ( ) : return list ( sys . stdin . readline ( ) ) [ : - 1 ] NEW_LINE def IR ( n ) : return [ I ( ) for i in range ( n ) ] NEW_LINE def LIR ( n ) : return [ LI ( ) for i in range ( n ) ] NEW_LINE def SR ( n ) : return [ S ( ) for i in range ( n ) ] NEW_LINE def LSR ( n ) : return [ LS ( ) for i in range ( n ) ] NEW_LINE mod = 1000000007 NEW_LINE n , m = LI ( ) NEW_LINE out = [ 0 for i in range ( n ) ] NEW_LINE pow2 = [ 1 ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT pow2 . append ( pow2 [ - 1 ] * 2 ) NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT x , y = LI ( ) NEW_LINE x -= 1 NEW_LINE y -= 1 NEW_LINE out [ x ] += pow2 [ y ] NEW_LINE DEDENT k = pow2 [ n ] NEW_LINE dp = [ 0 for i in range ( k ) ] NEW_LINE dp [ 0 ] = 1 NEW_LINE bi = [ [ i , pow2 [ i ] ] for i in range ( n ) ] NEW_LINE for i in range ( k ) : NEW_LINE INDENT for j , bij in bi : NEW_LINE INDENT if ( not ( i & bij ) ) and ( not ( i & out [ j ] ) ) : NEW_LINE INDENT dp [ i | bij ] += dp [ i ] NEW_LINE DEDENT DEDENT DEDENT print ( dp [ - 1 ] ) NEW_LINE NEW_LINE

N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE li = [ 1 << i for i in range ( N ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT x , y = [ int ( i ) - 1 for i in input ( ) . split ( ) ] NEW_LINE li [ x ] = li [ x ] | ( 1 << y ) NEW_LINE DEDENT lisDP = [ { } for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ke = 1 << i NEW_LINE lisDP [ 0 ] [ ke ] = 1 NEW_LINE DEDENT for i in range ( N - 1 ) : NEW_LINE INDENT for bik , biv in lisDP [ i ] . items ( ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if bik & li [ j ] == 0 : NEW_LINE INDENT foo = bik | ( 1 << j ) NEW_LINE if foo in lisDP [ i + 1 ] . keys ( ) : NEW_LINE INDENT lisDP [ i + 1 ] [ foo ] += biv NEW_LINE DEDENT else : NEW_LINE INDENT lisDP [ i + 1 ] [ foo ] = biv NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT allnum = ( 1 << N ) - 1 NEW_LINE print ( lisDP [ N - 1 ] [ allnum ] ) NEW_LINE

import sys NEW_LINE from collections import deque , defaultdict NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE n , m = LI ( ) NEW_LINE G = [ [ ] for _ in range ( n ) ] NEW_LINE for _ in range ( m ) : NEW_LINE INDENT x , y = LI_ ( ) NEW_LINE G [ x ] . append ( y ) NEW_LINE DEDENT dp = [ 0 ] * ( 1 << n ) NEW_LINE dp [ 0 ] = 1 NEW_LINE for s in range ( 1 << n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if s >> i & 1 == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT others = s ^ ( 1 << i ) NEW_LINE for to in G [ i ] : NEW_LINE INDENT if others & ( 1 << to ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT dp [ s ] += dp [ others ] NEW_LINE DEDENT DEDENT DEDENT print ( dp [ - 1 ] ) NEW_LINE

I = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE n , m = I ( ) NEW_LINE v = [ 0 ] * n NEW_LINE d = [ 1 ] + [ 0 ] * 2 ** n NEW_LINE for _ in [ 0 ] * m : s , g = I ( ) ; v [ s - 1 ] += 1 << g - 1 NEW_LINE i , j = 0 , - 1 NEW_LINE for _ in range ( n * 2 ** n ) : NEW_LINE INDENT j += 1 NEW_LINE if j == n : NEW_LINE INDENT i += 1 NEW_LINE j = 0 NEW_LINE DEDENT d [ i | 1 << j ] += d [ i ] * ( i & ( 1 << j | v [ j ] ) < 1 ) NEW_LINE DEDENT print ( d [ - 2 ] ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int D = sc . nextInt ( ) ; System . out . println ( solve ( D ) ) ; sc . close ( ) ; } static final int MAXL = 17 ; static int N ; static long [ ] v ; static long solve ( int D ) { if ( D % 9 != 0 ) return 0 ; D /= 9 ; long [ ] B = new long [ MAXL ] ; B [ 0 ] = 1 ; for ( int i = 1 ; i < MAXL ; i ++ ) B [ i ] = B [ i - 1 ] * 10 ; long ans = 0 ; for ( int i = 1 ; i <= MAXL ; i ++ ) { N = ( i + 1 ) / 2 ; v = new long [ N ] ; for ( int j = 0 ; j < N ; j ++ ) for ( int k = j ; k < i - j ; k ++ ) v [ j ] += B [ k ] ; ans += count ( D , i , 0 , new int [ N ] ) ; } return ans ; } static long count ( long D , int l , int t , int [ ] x ) { if ( t == N ) { if ( D != 0 ) return 0 ; long ans = 1 ; for ( int i = 0 ; i < N ; i ++ ) { ans *= ( i == 0 ? 9 : 10 ) - Math . abs ( x [ i ] ) ; } if ( l % 2 == 0 ) ans *= 10 ; return ans ; } long ans = 0 ; for ( int m = - 9 ; m <= 9 ; m ++ ) { if ( - v [ t ] < D + v [ t ] * m && D + v [ t ] * m < v [ t ] ) { x [ t ] = m ; ans += count ( D + v [ t ] * m , l , t + 1 , x ) ; } } return ans ; } }

import java . util . * ; public class Main { public static long [ ] buildValues ( int d ) { long [ ] res = new long [ d / 2 ] ; long high = ( long ) Math . pow ( 10 , d - 1 ) ; long low = 1L ; for ( int i = 0 ; i < d / 2 ; i ++ ) { res [ i ] = high - low ; high /= 10 ; low *= 10 ; } return res ; } public static long calc ( long [ ] vs , long D ) { long res = 1 ; long ten = 10 ; for ( int i = 0 ; i < vs . length ; i ++ ) { long now = 0 ; while ( D % ten != 0 && now < 9 ) { D -= vs [ i ] ; now ++ ; } D = Math . abs ( D ) ; ten *= 10 ; res *= ( i == 0 ) ? ( 9 - now ) : ( 10 - now ) ; } return D == 0 ? res : 0 ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int D = in . nextInt ( ) ; long res = 0 ; for ( int d = 1 ; d <= 20 ; d ++ ) { long [ ] vs = buildValues ( d ) ; long next = calc ( vs , D ) ; if ( d % 2 == 1 ) next *= 10 ; res += next ; } System . out . println ( res ) ; } static int rev ( int x ) { String s = "0" ; while ( x > 0 ) { s += x % 10 + " " ; x /= 10 ; } return Integer . valueOf ( s ) ; } }

def solve ( d , K ) : NEW_LINE INDENT r = 1 NEW_LINE for k in range ( K , 1 , - 2 ) : NEW_LINE INDENT if d >= 10 ** k : NEW_LINE INDENT return 0 NEW_LINE DEDENT t = ( - d ) % 10 NEW_LINE d = abs ( ( d - t * ( 10 ** ( k - 1 ) - 1 ) ) // 10 ) NEW_LINE r *= 10 - t - ( K == k ) NEW_LINE DEDENT return r * ( 10 ** ( K % 2 ) ) if d == 0 else 0 NEW_LINE DEDENT D = int ( input ( ) ) NEW_LINE result = 0 NEW_LINE l = len ( str ( D ) ) NEW_LINE for k in range ( l , 2 * l + 1 ) : NEW_LINE INDENT result += solve ( D , k ) NEW_LINE DEDENT print ( result ) NEW_LINE

def solve ( k , d , fl ) : NEW_LINE INDENT if k <= 1 : NEW_LINE INDENT if d == 0 : NEW_LINE INDENT return 10 ** k NEW_LINE DEDENT return 0 NEW_LINE DEDENT x = ( - d ) % 10 NEW_LINE c = 9 - x + 1 - fl NEW_LINE d -= 10 ** ( k - 1 ) * x - x NEW_LINE return c * solve ( k - 2 , abs ( d ) // 10 , 0 ) NEW_LINE DEDENT d = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , 100 ) : NEW_LINE INDENT ans += solve ( i , d , 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE

def result ( letters , number , cant_zero ) : NEW_LINE INDENT if letters <= 1 : NEW_LINE INDENT if number == 0 : NEW_LINE INDENT return 10 ** letters NEW_LINE DEDENT return 0 NEW_LINE DEDENT diff = ( 10 - number % 10 ) % 10 NEW_LINE variants = number % 10 - cant_zero NEW_LINE if number % 10 == 0 : NEW_LINE INDENT variants = 10 - cant_zero NEW_LINE DEDENT number -= diff * ( 10 ** ( letters - 1 ) - 1 ) NEW_LINE number = abs ( number // 10 ) NEW_LINE return variants * result ( letters - 2 , number , 0 ) NEW_LINE DEDENT d = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 20 ) : NEW_LINE INDENT ans += result ( i , d , 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE

def solve ( d , k , outer ) : NEW_LINE INDENT if k <= 1 : NEW_LINE INDENT return 10 ** k if d == 0 else 0 NEW_LINE DEDENT t = ( - d ) % 10 NEW_LINE d -= t * 10 ** ( k - 1 ) - t NEW_LINE return ( 10 - t - outer ) * solve ( abs ( d // 10 ) , k - 2 , 0 ) NEW_LINE DEDENT D = int ( input ( ) ) NEW_LINE result = 0 NEW_LINE for k in range ( 1 , 20 ) : NEW_LINE INDENT result += solve ( D , k , 1 ) NEW_LINE DEDENT print ( result ) NEW_LINE


import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static IntStream REPS ( int v ) { return IntStream . range ( 0 , v ) ; } static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } static IntStream INS ( int n ) { return REPS ( n ) . map ( i -> getInt ( ) ) ; } static Scanner s = new Scanner ( System . in ) ; static int getInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { int a = getInt ( ) , b = getInt ( ) , c = getInt ( ) , d = getInt ( ) , e = getInt ( ) , f = getInt ( ) ; int rw = 100 * a , rs = 0 ; double max = 0 ; for ( int i = 0 ; true ; ++ i ) { int va = 100 * a * i ; if ( va > f ) break ; for ( int j = 0 ; true ; ++ j ) { int vb = 100 * b * j ; if ( va + vb > f ) break ; for ( int k = 0 ; true ; ++ k ) { int vc = c * k ; if ( va + vb + vc > f ) break ; for ( int l = 0 ; true ; ++ l ) { int vd = d * l ; if ( va + vb + vc + vd > f ) break ; if ( max < calc ( va + vb , vc + vd , e ) ) { max = calc ( va + vb , vc + vd , e ) ; rw = va + vb ; rs = vc + vd ; } } } } } System . out . println ( rw + rs + " ▁ " + rs ) ; } private static double calc ( int w , int s , int e ) { double r = w == 0 ? 0 : 100.0 * s / ( w + s ) ; return w / 100 * e < s ? 0 : r ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; int e = in . nextInt ( ) ; int f = in . nextInt ( ) ; int res = 0 , sugar = 0 ; for ( int va = 0 ; va <= f ; va += 100 * a ) { for ( int vb = 0 ; va + vb <= f ; vb += 100 * b ) { int water = va + vb ; int upper = water / 100 * e ; for ( int vc = 0 ; water + vc <= f && vc <= upper ; vc += c ) { for ( int vd = 0 ; water + vc + vd <= f && vc + vd <= upper ; vd += d ) { if ( sugar == 0 ) { sugar = vc + vd ; res = water + sugar ; } else { if ( ( vc + vd ) * res > sugar * ( water + vc + vd ) ) { sugar = vc + vd ; res = water + sugar ; } } } } } } System . out . println ( res + " ▁ " + sugar ) ; } } }

import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int E = sc . nextInt ( ) ; int F = sc . nextInt ( ) ; Set < Integer > waterSet = new HashSet < > ( ) ; Set < Integer > sugarSet = new HashSet < > ( ) ; createSugar ( sugarSet , C , D , F ) ; createWater ( waterSet , A , B , F ) ; double maxRatio = - 1 ; int resultSugar = - 1 ; int resultWater = - 1 ; for ( int water : waterSet ) { for ( int sugar : sugarSet ) { if ( ( water + sugar ) <= F && sugar <= ( water / 100 ) * E ) { double ratio = ( ( double ) ( 100 * sugar ) ) / ( water + sugar ) ; if ( ratio > maxRatio ) { maxRatio = ( ( double ) ( 100 * sugar ) ) / ( water + sugar ) ; resultSugar = sugar ; resultWater = water ; } } } } System . out . println ( resultSugar + resultWater + " ▁ " + resultSugar ) ; } private static void createWater ( Set < Integer > waterSet , int A , int B , int F ) { for ( int i = 0 ; i < F ; i ++ ) { for ( int j = 0 ; j < F ; j ++ ) { int water = A * 100 * i + B * 100 * j ; if ( water != 0 && water < F ) waterSet . add ( water ) ; } } } private static void createSugar ( Set < Integer > sugarSet , int C , int D , int F ) { for ( int i = 0 ; i < F ; i ++ ) { for ( int j = 0 ; j < F ; j ++ ) { int sugar = C * i + D * j ; if ( sugar < F ) sugarSet . add ( sugar ) ; } } } }

import java . util . ArrayList ; import java . util . Scanner ; public class Main { int a , b , c , d , e , f ; private ArrayList < Integer > listW , listS ; public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . read ( ) ; m . solve ( ) ; } private void read ( ) { Scanner sc = new Scanner ( System . in ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; d = sc . nextInt ( ) ; e = sc . nextInt ( ) ; f = sc . nextInt ( ) ; listW = new ArrayList < > ( ) ; listS = new ArrayList < > ( ) ; } private double calc ( int a , int b ) { return ( double ) ( 100 * b ) / ( a + b ) ; } private void solve ( ) { for ( int i = 0 ; i < f ; i ++ ) { for ( int j = 0 ; j < f ; j ++ ) { int w = a * i + b * j ; w *= 100 ; if ( w != 0 && w < f ) { listW . add ( w ) ; } } } for ( int i = 0 ; i < f ; i ++ ) { for ( int j = 0 ; j < f ; j ++ ) { int s = c * i + d * j ; if ( s < f ) listS . add ( s ) ; } } double rate = - 1. ; int ansS = - 1 , ansW = - 1 ; for ( int w : listW ) { for ( int s : listS ) { if ( w + s <= f && s <= ( w / 100 ) * e ) { double tmp = calc ( w , s ) ; if ( rate < tmp ) { ansS = s ; ansW = w ; rate = tmp ; } } } } System . out . printf ( " % d ▁ % d \n " , ( ansS + ansW ) , ansS ) ; } }

import java . util . Scanner ; public class Main { private static boolean isGreater ( int p , int q , int pp , int qq ) { p *= qq ; pp *= q ; return p > pp ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int E = sc . nextInt ( ) ; int F = sc . nextInt ( ) ; int ansX = 100 * A ; int ansY = 0 ; int maxP = 0 ; int maxQ = 1 ; for ( int ai = 0 ; ai * 100 <= F ; ai += A ) { int a = ai * 100 ; for ( int bi = 0 ; a + 100 * bi <= F ; bi += B ) { int b = bi * 100 ; for ( int c = 0 ; a + b + c <= F ; c += C ) { for ( int d = 0 ; a + b + c + d <= F ; d += D ) { if ( ( ai + bi ) * E < c + d ) { continue ; } int water = a + b ; int sugar = c + d ; if ( isGreater ( sugar * 100 , water + sugar , maxP , maxQ ) ) { maxP = sugar * 100 ; maxQ = water + sugar ; ansX = water + sugar ; ansY = sugar ; } } } } } System . out . println ( ansX + " ▁ " + ansY ) ; } }

A , B , C , D , E , F = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 100 * A , 0 NEW_LINE w = set ( ) NEW_LINE for a in range ( 0 , F + 1 , 100 * A ) : NEW_LINE INDENT for b in range ( 0 , F - a + 1 , 100 * B ) : NEW_LINE INDENT if a + b : NEW_LINE INDENT w . add ( a + b ) NEW_LINE DEDENT DEDENT DEDENT s = set ( ) NEW_LINE for c in range ( 0 , F + 1 , C ) : NEW_LINE INDENT for d in range ( 0 , F + 1 - c , D ) : NEW_LINE INDENT s . add ( c + d ) NEW_LINE DEDENT DEDENT for wi in w : NEW_LINE INDENT for sj in s : NEW_LINE INDENT if wi + sj <= F and 100 * sj / wi <= E : NEW_LINE INDENT ans = max ( ans , ( wi + sj , sj ) , key = lambda x : x [ 1 ] / x [ 0 ] ) NEW_LINE DEDENT DEDENT DEDENT print ( * ans ) NEW_LINE

from fractions import Fraction NEW_LINE from collections import Counter , defaultdict NEW_LINE II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE def main ( ) : NEW_LINE INDENT A , B , C , D , E , F = MI ( ) NEW_LINE A *= 100 NEW_LINE B *= 100 NEW_LINE water_ws = set ( ) NEW_LINE for a in range ( F // A + 1 ) : NEW_LINE INDENT for b in range ( F // B + 1 ) : NEW_LINE INDENT w = a * A + b * B NEW_LINE if w <= F : water_ws . add ( w ) NEW_LINE DEDENT DEDENT water_ws . remove ( 0 ) NEW_LINE sugar_w_max = max ( [ ww // 100 * E for ww in water_ws ] ) NEW_LINE sugar_ws = set ( ) NEW_LINE for c in range ( sugar_w_max // C ) : NEW_LINE INDENT for d in range ( sugar_w_max // D ) : NEW_LINE INDENT w = c * C + d * D NEW_LINE if w <= sugar_w_max : sugar_ws . add ( w ) NEW_LINE DEDENT DEDENT ans_w , ans_s = A , 0 NEW_LINE dens_max = - 1 NEW_LINE for ww in water_ws : NEW_LINE INDENT for sw in sugar_ws : NEW_LINE INDENT dens = Fraction ( sw , ww + sw ) NEW_LINE if ww + sw <= F and sw <= ww // 100 * E and dens > dens_max : NEW_LINE INDENT ans_w = ww + sw NEW_LINE ans_s = sw NEW_LINE dens_max = dens NEW_LINE DEDENT DEDENT DEDENT print ( ans_w , ans_s ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

A , B , C , D , E , F = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE ablist = [ ] NEW_LINE a , b = 0 , 0 NEW_LINE while ( 100 * A * a + 100 * B * b <= F ) : NEW_LINE INDENT while ( 100 * A * a + 100 * B * b <= F ) : NEW_LINE INDENT ablist . append ( ( a , b ) ) NEW_LINE b += 1 NEW_LINE DEDENT a += 1 NEW_LINE b = 0 NEW_LINE DEDENT ablist . remove ( ( 0 , 0 ) ) NEW_LINE wlist = [ 100 * A * ab [ 0 ] + 100 * B * ab [ 1 ] for ab in ablist ] NEW_LINE wset = set ( wlist ) NEW_LINE cdlist = [ ] NEW_LINE c , d = 0 , 0 NEW_LINE while ( C * c + D * d <= F ) : NEW_LINE INDENT while ( C * c + D * d <= F ) : NEW_LINE INDENT cdlist . append ( ( c , d ) ) NEW_LINE d += 1 NEW_LINE DEDENT c += 1 NEW_LINE d = 0 NEW_LINE DEDENT slist = [ C * cd [ 0 ] + D * cd [ 1 ] for cd in cdlist ] NEW_LINE sset = set ( slist ) NEW_LINE max_rate = - 1 NEW_LINE ret_sw = 0 NEW_LINE ret_s = 0 NEW_LINE for w in wset : NEW_LINE INDENT for s in sset : NEW_LINE INDENT if s + w <= F : NEW_LINE INDENT rate = s / ( s + w ) NEW_LINE if rate <= E / ( E + 100 ) : NEW_LINE INDENT if max_rate < rate : NEW_LINE INDENT max_rate = rate NEW_LINE ret_sw = s + w NEW_LINE ret_s = s NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( " { } ▁ { } " . format ( ret_sw , ret_s ) ) NEW_LINE

def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE from collections import defaultdict NEW_LINE A , B , C , D , E , F = inpl ( ) NEW_LINE H = defaultdict ( lambda : 0 ) NEW_LINE H [ ( 0 , 0 ) ] = 1 NEW_LINE x = [ ( 100 * A , 0 ) , ( 100 * B , 0 ) , ( 0 , C ) , ( 0 , D ) ] NEW_LINE flag = True NEW_LINE while flag : NEW_LINE INDENT flag = False NEW_LINE for i , j in x : NEW_LINE INDENT for ni , nj in H . copy ( ) . keys ( ) : NEW_LINE INDENT if i + j + ni + nj <= F and ni + i : NEW_LINE INDENT if ( nj + j ) / ( ni + i ) <= E / 100 : NEW_LINE INDENT if not H [ ( i + ni , j + nj ) ] : NEW_LINE INDENT H [ ( i + ni , j + nj ) ] = 1 NEW_LINE flag = True NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT anssw , anss = ( 100 * A , 0 ) NEW_LINE for k , l in H . keys ( ) : NEW_LINE INDENT if not k : NEW_LINE INDENT continue NEW_LINE DEDENT if anss / anssw < l / ( k + l ) : NEW_LINE INDENT anssw , anss = k + l , l NEW_LINE DEDENT DEDENT print ( anssw , anss ) NEW_LINE

import fractions as frac NEW_LINE a , b , c , d , e , f = map ( int , input ( ) . split ( ) ) NEW_LINE memo = [ [ ( - 1 , - 1 ) ] * 1000 for i in range ( 10000 ) ] NEW_LINE func = lambda t : frac . Fraction ( t [ 0 ] , t [ 1 ] ) if t [ 1 ] > 0 else - 10 NEW_LINE def dp ( s , w ) : NEW_LINE INDENT if w * e < s or w * 100 + s > f : NEW_LINE INDENT return ( - 1 , - 1 ) NEW_LINE DEDENT m = memo [ s ] [ w ] NEW_LINE if m [ 0 ] > 0 : NEW_LINE INDENT return m NEW_LINE DEDENT p0 = ( s , w ) NEW_LINE p1 = dp ( s , w + a ) NEW_LINE p2 = dp ( s , w + b ) NEW_LINE p3 = dp ( s + c , w ) NEW_LINE p4 = dp ( s + d , w ) NEW_LINE memo [ s ] [ w ] = max ( p0 , p1 , p2 , p3 , p4 , key = func ) if w > 0 else max ( p1 , p2 , key = func ) NEW_LINE return memo [ s ] [ w ] NEW_LINE DEDENT ans = dp ( 0 , 0 ) NEW_LINE print ( ans [ 0 ] + ans [ 1 ] * 100 , ans [ 0 ] ) NEW_LINE


import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] stones = new int [ N + 1 ] ; for ( int i = 0 ; i < Q ; i ++ ) { int start = sc . nextInt ( ) - 1 ; int end = sc . nextInt ( ) ; stones [ start ] += 1 ; stones [ end ] += - 1 ; } for ( int i = 0 ; i < N ; i ++ ) { if ( i > 0 ) stones [ i ] += stones [ i - 1 ] ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < N ; i ++ ) { sb . append ( stones [ i ] % 2 == 0 ? '0' : '1' ) ; } System . out . println ( sb . toString ( ) ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; int [ ] l = new int [ Q + 1 ] ; int [ ] r = new int [ Q + 1 ] ; int [ ] field = new int [ N + 2 ] ; int [ ] sum = new int [ N + 2 ] ; sum [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { field [ i ] = 0 ; } for ( int i = 0 ; i < Q ; i ++ ) { l [ i ] = scanner . nextInt ( ) ; r [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < Q ; i ++ ) { field [ l [ i ] ] += 1 ; field [ r [ i ] + 1 ] += - 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { sum [ i ] = sum [ i - 1 ] + field [ i ] ; } for ( int i = 1 ; i <= N ; i ++ ) { if ( sum [ i ] % 2 == 0 ) { System . out . print ( 0 ) ; } else { System . out . print ( 1 ) ; } } System . out . println ( ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] cum = new int [ N + 2 ] ; for ( int i = 0 ; i < Q ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; cum [ l ] += 1 ; cum [ r + 1 ] -= 1 ; } for ( int n = 1 ; n < N + 2 ; n ++ ) { cum [ n ] += cum [ n - 1 ] ; } for ( int n = 1 ; n <= N ; n ++ ) { if ( cum [ n ] % 2 == 0 ) { out . print ( 0 ) ; } else { out . print ( 1 ) ; } } out . println ( ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] a = new int [ N + 1 ] ; for ( int i = 0 ; i < Q ; i ++ ) { int start = sc . nextInt ( ) ; int end = sc . nextInt ( ) ; a [ start - 1 ] ++ ; a [ end ] -- ; } int [ ] b = new int [ N ] ; b [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { b [ i ] = b [ i - 1 ] + a [ i ] ; } for ( int i : b ) { System . out . print ( ( i % 2 == 0 ) ? 0 : 1 ) ; } System . out . println ( ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; int [ ] left = new int [ Q ] ; int [ ] right = new int [ Q ] ; for ( int i = 0 ; i < Q ; i ++ ) { left [ i ] = scanner . nextInt ( ) ; right [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( left ) ; Arrays . sort ( right ) ; long count = 0 ; int li = 0 ; int ri = 0 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { while ( li < Q && left [ li ] == i ) { li ++ ; count ++ ; } sb . append ( count % 2 == 0 ? '0' : '1' ) ; while ( ri < Q && right [ ri ] == i ) { ri ++ ; count -- ; } } System . out . println ( sb . toString ( ) ) ; } }

import math NEW_LINE import numpy as np NEW_LINE import copy NEW_LINE from collections import defaultdict , Counter NEW_LINE from itertools import product NEW_LINE from bisect import bisect_left , bisect_right NEW_LINE def s_inpl ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , Q = s_inpl ( ) NEW_LINE imos = [ 0 for _ in range ( N + 1 ) ] NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT li , ri = s_inpl ( ) NEW_LINE li -= 1 NEW_LINE ri -= 1 NEW_LINE imos [ li ] += 1 NEW_LINE imos [ ri + 1 ] -= 1 NEW_LINE DEDENT res = [ str ( i % 2 ) for i in np . cumsum ( imos ) [ : - 1 ] ] NEW_LINE print ( " " . join ( res ) ) NEW_LINE

from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( " Yes " ) NEW_LINE else : print ( " No " ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( " + " ) NEW_LINE elif ( x < y ) : print ( " - " ) NEW_LINE else : print ( " ? " ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def pne ( n ) : NEW_LINE INDENT print ( n , end = ' ' ) NEW_LINE DEDENT rem = pow ( 10 , 9 ) + 7 NEW_LINE n , q = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE add = [ 0 for i in range ( n + 1 ) ] NEW_LINE subtract = [ 0 for i in range ( n + 1 ) ] NEW_LINE a = [ ] NEW_LINE for i in range ( q ) : NEW_LINE INDENT left , right = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE add [ left ] += 1 NEW_LINE subtract [ right ] += 1 NEW_LINE DEDENT t = "01" NEW_LINE c = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT c += add [ i ] NEW_LINE print ( t [ c % 2 ] , end = ' ' ) NEW_LINE c -= subtract [ i ] NEW_LINE DEDENT print ( ) NEW_LINE

from itertools import accumulate NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE for i in range ( Q ) : NEW_LINE INDENT a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT b = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( Q ) : NEW_LINE INDENT b [ a [ i ] [ 0 ] - 1 ] += 1 NEW_LINE b [ a [ i ] [ 1 ] ] += - 1 NEW_LINE DEDENT ans = ' ' NEW_LINE for x in list ( accumulate ( b ) ) [ : - 1 ] : NEW_LINE INDENT if x % 2 == 0 : NEW_LINE INDENT ans += '0' NEW_LINE DEDENT else : NEW_LINE INDENT ans += '1' NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

def othello ( N : int , Q : int , queries : list ) -> str : NEW_LINE INDENT s = [ 0 ] * N NEW_LINE for l , r in queries : NEW_LINE INDENT s [ l - 1 ] += 1 NEW_LINE if r < N : NEW_LINE INDENT s [ r ] -= 1 NEW_LINE DEDENT DEDENT cum = [ 0 ] * N NEW_LINE cum [ 0 ] = s [ 0 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT cum [ i ] = cum [ i - 1 ] + s [ i ] NEW_LINE DEDENT return ' ' . join ( '0' if c % 2 == 0 else '1' for c in cum ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT Q = 0 NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( Q ) ] NEW_LINE ans = othello ( N , Q , queries ) NEW_LINE print ( ans ) NEW_LINE DEDENT

import sys NEW_LINE input = sys . stdin . readline NEW_LINE n , q = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE lr = [ [ int ( i ) - 1 for i in input ( ) . split ( ) ] for i in range ( q ) ] NEW_LINE cnt = [ 0 ] * n NEW_LINE for l , r in lr : NEW_LINE INDENT cnt [ l ] += 1 NEW_LINE if r < n - 1 : NEW_LINE INDENT cnt [ r + 1 ] -= 1 NEW_LINE DEDENT DEDENT res = " " NEW_LINE c = 0 NEW_LINE for x in cnt : NEW_LINE INDENT c += x NEW_LINE res += str ( c % 2 ) NEW_LINE DEDENT print ( res ) NEW_LINE


import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int p = sc . nextInt ( ) ; max = Math . max ( max , p ) ; sum += p ; } System . out . println ( sum -= max / 2 ) ; sc . close ( ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int sum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += list . get ( i ) ; } System . out . println ( sum += list . get ( n - 1 ) / 2 ) ; sc . close ( ) ; } }

import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int N = Integer . parseInt ( bf . readLine ( ) ) , max = 0 , sum = 0 ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = Integer . parseInt ( bf . readLine ( ) ) ; sum += p [ i ] ; if ( max < p [ i ] ) { max = p [ i ] ; } } sum -= max / 2 ; System . out . println ( sum ) ; } }

import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int max = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; max = Math . max ( max , tmp ) ; ans += tmp ; } System . out . println ( ans - max / 2 ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; list . set ( n - 1 , list . get ( n - 1 ) / 2 ) ; int sum = 0 ; for ( int i : list ) { sum += i ; } System . out . println ( sum ) ; sc . close ( ) ; } }

N = int ( input ( ) ) NEW_LINE P = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE M = int ( max ( P ) ) NEW_LINE print ( int ( sum ( P ) - M + M / 2 ) ) NEW_LINE

import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def solve ( N : int , p : " List [ int ] " ) : NEW_LINE INDENT print ( sum ( p ) - max ( p ) // 2 ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE p = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , p ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

S = 0 NEW_LINE N = int ( input ( ) ) NEW_LINE P = [ ] NEW_LINE for num in range ( N ) : NEW_LINE INDENT P . append ( int ( input ( ) ) ) NEW_LINE DEDENT P . sort ( reverse = True , key = int ) NEW_LINE P [ 0 ] = P [ 0 ] // 2 NEW_LINE for num in range ( N ) : NEW_LINE INDENT S += P [ num ] NEW_LINE DEDENT print ( S ) NEW_LINE

import sys NEW_LINE def main ( inp ) : NEW_LINE INDENT N = int ( next ( inp ) ) NEW_LINE P = sorted ( [ int ( next ( inp ) ) for _ in range ( N ) ] , reverse = True ) NEW_LINE P [ 0 ] = int ( P [ 0 ] / 2 ) NEW_LINE return sum ( P ) NEW_LINE DEDENT print ( main ( sys . stdin ) ) NEW_LINE

n = int ( input ( ) ) NEW_LINE l = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT p = int ( input ( ) ) NEW_LINE l [ i ] = p NEW_LINE DEDENT max_p = max ( l ) // 2 NEW_LINE ans = sum ( l ) - max_p NEW_LINE print ( ans ) NEW_LINE


import java . math . BigInteger ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { class Person { double x ; double y ; double c ; Person ( double x , double y , double c ) { super ( ) ; this . x = x ; this . y = y ; this . c = c ; } } try ( Scanner scan = new Scanner ( System . in ) ) { int n = scan . nextInt ( ) ; Person [ ] persons = new Person [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { persons [ i ] = new Person ( scan . nextDouble ( ) , scan . nextDouble ( ) , scan . nextDouble ( ) ) ; } double maxTime = BigInteger . TEN . pow ( 5 + 3 ) . multiply ( BigInteger . valueOf ( 2L ) ) . doubleValue ( ) ; double minTime = 0D ; double midTime = ( maxTime + minTime ) / 2 ; while ( maxTime - minTime > 0.0001 ) { final double mid = midTime ; double xMax = Arrays . stream ( persons ) . mapToDouble ( p -> p . x + mid / p . c ) . min ( ) . getAsDouble ( ) ; double xMin = Arrays . stream ( persons ) . mapToDouble ( p -> p . x - mid / p . c ) . max ( ) . getAsDouble ( ) ; double yMax = Arrays . stream ( persons ) . mapToDouble ( p -> p . y + mid / p . c ) . min ( ) . getAsDouble ( ) ; double yMin = Arrays . stream ( persons ) . mapToDouble ( p -> p . y - mid / p . c ) . max ( ) . getAsDouble ( ) ; if ( xMax > xMin && yMax > yMin ) { maxTime = midTime ; midTime = ( maxTime + minTime ) / 2 ; } else { minTime = midTime ; midTime = ( maxTime + minTime ) / 2 ; } } System . out . printf ( " % f " , midTime ) ; System . out . println ( ) ; } } }

import java . util . * ; import java . util . concurrent . SynchronousQueue ; public class Main { public static double f ( int [ ] x , int [ ] c , double p ) { double max = 0 ; int N = x . length ; for ( int i = 0 ; i < N ; i ++ ) { max = Math . max ( max , Math . abs ( p - x [ i ] ) * c [ i ] ) ; } return max ; } public static double search ( int [ ] x , int [ ] c ) { double l = - 100001 , r = 100001 ; int L = 100 ; while ( L -- >= 0 ) { double ll = ( l * 2 + r ) / 3 ; double rr = ( l + r * 2 ) / 3 ; if ( f ( x , c , ll ) > f ( x , c , rr ) ) l = ll ; else r = rr ; } return l ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] x = new int [ N ] ; int [ ] y = new int [ N ] ; int [ ] c = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; c [ i ] = sc . nextInt ( ) ; } double lx = search ( x , c ) ; double ly = search ( y , c ) ; double ans = Math . max ( f ( x , c , lx ) , f ( y , c , ly ) ) ; System . out . println ( ans ) ; } }

import java . util . * ; import java . math . * ; public class Main { private static double solve ( int n , double [ ] p , double [ ] c ) { double maxt = 0.0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( p [ i ] > p [ j ] ) { double x = ( c [ i ] * p [ i ] + c [ j ] * p [ j ] ) / ( c [ i ] + c [ j ] ) ; double t = c [ i ] * ( p [ i ] - x ) ; maxt = Math . max ( maxt , t ) ; } } } return maxt ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; double [ ] x = new double [ n ] ; double [ ] y = new double [ n ] ; double [ ] c = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = s . nextDouble ( ) ; y [ i ] = s . nextDouble ( ) ; c [ i ] = s . nextDouble ( ) ; } System . out . println ( Math . max ( solve ( n , x , c ) , solve ( n , y , c ) ) ) ; } }

import java . util . Scanner ; public class Main { void solve ( Scanner sc ) throws Throwable { int N = sc . nextInt ( ) ; int [ ] [ ] mans = new int [ N ] [ 3 ] ; for ( int i = 0 ; i < mans . length ; i ++ ) { mans [ i ] [ 0 ] = sc . nextInt ( ) ; mans [ i ] [ 1 ] = sc . nextInt ( ) ; mans [ i ] [ 2 ] = sc . nextInt ( ) ; } double ans = calcMax ( mans , true ) ; System . out . println ( Math . max ( ans , calcMax ( mans , false ) ) ) ; } private double calcMax ( int [ ] [ ] mans , boolean isSearchWidth ) { double maxTimeLeft = 0 ; double maxTimeRight = 0 ; double l = 1e5 ; double r = - 1e5 ; int x = isSearchWidth ? 0 : 1 ; for ( int i = 0 ; i < 100 ; i ++ ) { double targetL = ( l * 2 + r ) / 3 ; double targetR = ( l + r * 2 ) / 3 ; maxTimeLeft = 0 ; maxTimeRight = 0 ; for ( int j = 0 ; j < mans . length ; j ++ ) { maxTimeLeft = Math . max ( maxTimeLeft , ( Math . abs ( targetL - mans [ j ] [ x ] ) * mans [ j ] [ 2 ] ) ) ; maxTimeRight = Math . max ( maxTimeRight , ( Math . abs ( targetR - mans [ j ] [ x ] ) * mans [ j ] [ 2 ] ) ) ; } if ( maxTimeLeft > maxTimeRight ) { l = targetL ; } else { r = targetR ; } } return Math . max ( maxTimeLeft , maxTimeRight ) ; } public static void main ( String [ ] args ) throws Throwable { try ( Scanner sc = new Scanner ( System . in ) ) { new Main ( ) . solve ( sc ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Coordinate [ ] coordinate = new Coordinate [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { coordinate [ i ] = new Coordinate ( sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) ) ; } double maxX = 0 ; double maxY = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { double x1 = coordinate [ i ] . x ; double y1 = coordinate [ i ] . y ; double cost1 = coordinate [ i ] . cost ; for ( int j = i ; j < n ; j ++ ) { double x2 = coordinate [ j ] . x ; double y2 = coordinate [ j ] . y ; double cost2 = coordinate [ j ] . cost ; double midX = Math . abs ( x1 - x2 ) * cost1 / ( cost1 + cost2 ) * cost2 ; double midY = Math . abs ( y1 - y2 ) * cost1 / ( cost1 + cost2 ) * cost2 ; maxX = Math . max ( maxX , midX ) ; maxY = Math . max ( maxY , midY ) ; } } System . out . println ( Math . max ( maxX , maxY ) ) ; } } class Coordinate { double x ; double y ; double cost ; Coordinate ( double x , double y , double cost ) { this . x = x ; this . y = y ; this . cost = cost ; } }

import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = I ( ) NEW_LINE a = [ LI ( ) for _ in range ( n ) ] NEW_LINE mm = 0 NEW_LINE mi = 0 NEW_LINE mj = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT ai = a [ i ] NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT aj = a [ j ] NEW_LINE t = max ( abs ( ai [ 0 ] - aj [ 0 ] ) , abs ( ai [ 1 ] - aj [ 1 ] ) ) / ( 1 / ai [ 2 ] + 1 / aj [ 2 ] ) NEW_LINE if mm < t : NEW_LINE INDENT mm = t NEW_LINE mi = i NEW_LINE mj = j NEW_LINE DEDENT DEDENT DEDENT return mm NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE norumu_kun = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * N ] NEW_LINE lb , ub = 0 , 10 ** 10 NEW_LINE while ub - lb > 1e-5 : NEW_LINE INDENT mid = ( lb + ub ) / 2 NEW_LINE lx = ly = - 10 ** 10 NEW_LINE ux = uy = 10 ** 10 NEW_LINE for x , y , c in norumu_kun : NEW_LINE INDENT dist = mid / c NEW_LINE _lx , _ux = x - dist , x + dist NEW_LINE _ly , _uy = y - dist , y + dist NEW_LINE lx = _lx if _lx > lx else lx NEW_LINE ly = _ly if _ly > ly else ly NEW_LINE ux = _ux if ux > _ux else ux NEW_LINE uy = _uy if uy > _uy else uy NEW_LINE DEDENT if lx > ux or ly > uy : NEW_LINE INDENT lb = mid NEW_LINE DEDENT else : NEW_LINE INDENT ub = mid NEW_LINE DEDENT DEDENT print ( lb ) NEW_LINE

print ( max ( [ c1 * max ( abs ( x2 - x1 ) * c2 / ( c1 + c2 ) , abs ( y2 - y1 ) * c2 / ( c1 + c2 ) ) for ( x1 , y1 , c1 ) , ( x2 , y2 , c2 ) in __import__ ( " itertools " ) . combinations ( [ list ( map ( int , input ( ) . split ( ) ) ) for x in range ( int ( input ( ) ) ) ] , 2 ) ] ) ) NEW_LINE

from operator import itemgetter NEW_LINE n = int ( input ( ) ) NEW_LINE info = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE def solve ( ans ) : NEW_LINE INDENT x = [ [ info [ i ] [ 0 ] - ans / info [ i ] [ 2 ] , info [ i ] [ 0 ] + ans / info [ i ] [ 2 ] ] for i in range ( n ) ] NEW_LINE y = [ [ info [ i ] [ 1 ] - ans / info [ i ] [ 2 ] , info [ i ] [ 1 ] + ans / info [ i ] [ 2 ] ] for i in range ( n ) ] NEW_LINE x = sorted ( x , key = itemgetter ( 1 ) ) NEW_LINE y = sorted ( y , key = itemgetter ( 1 ) ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if x [ 0 ] [ 1 ] < x [ i ] [ 0 ] : NEW_LINE INDENT return False NEW_LINE DEDENT if y [ 0 ] [ 1 ] < y [ i ] [ 0 ] : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT ok = 10000000000 NEW_LINE ng = 0 NEW_LINE while abs ( ok - ng ) > 10 ** ( - 6 ) : NEW_LINE INDENT mid = ( ok + ng ) / 2 NEW_LINE if solve ( mid ) : NEW_LINE INDENT ok = mid NEW_LINE DEDENT else : NEW_LINE INDENT ng = mid NEW_LINE DEDENT DEDENT print ( mid ) NEW_LINE

from collections import defaultdict , Counter NEW_LINE from itertools import product , groupby , count , permutations , combinations NEW_LINE from math import pi , sqrt NEW_LINE from collections import deque NEW_LINE from bisect import bisect , bisect_left , bisect_right NEW_LINE INF = float ( " inf " ) NEW_LINE def ok ( t , x_y_c_list ) : NEW_LINE INDENT max_x_l , min_x_r , max_y_l , min_y_r = - INF , INF , - INF , INF NEW_LINE for x , y , c in x_y_c_list : NEW_LINE INDENT half = t / c NEW_LINE x_l , x_r = x - half , x + half NEW_LINE y_l , y_r = y - half , y + half NEW_LINE max_x_l = max ( max_x_l , x_l ) NEW_LINE min_x_r = min ( min_x_r , x_r ) NEW_LINE max_y_l = max ( max_y_l , y_l ) NEW_LINE min_y_r = min ( min_y_r , y_r ) NEW_LINE DEDENT return max_x_l <= min_x_r and max_y_l <= min_y_r NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE x_y_c_list = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT x , y , c = map ( int , input ( ) . split ( ) ) NEW_LINE x_y_c_list . append ( ( x , y , c ) ) NEW_LINE DEDENT low , high , ans = - 1 , int ( 1e14 ) - 1 , - 1 NEW_LINE while high - low > 0.00001 : NEW_LINE INDENT middle = ( low + high ) / 2 NEW_LINE if ok ( middle , x_y_c_list ) : NEW_LINE INDENT ans = middle NEW_LINE high = middle NEW_LINE DEDENT else : NEW_LINE INDENT low = middle NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int N = reader . nextInt ( ) ; int [ ] a = new int [ N ] ; int ans = 0 ; int [ ] M = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { ans += reader . nextInt ( ) - 1 ; } reader . close ( ) ; System . out . print ( ans ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; public class Main { static int a ; static int b ; static int c ; static int n ; static int l [ ] ; public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; PrintWriter out = new PrintWriter ( System . out ) ; String s ; String sl [ ] ; s = r . readLine ( ) ; sl = s . split ( " ▁ " ) ; n = Integer . parseInt ( sl [ 0 ] ) ; s = r . readLine ( ) ; sl = s . split ( " ▁ " ) ; int v = 0 ; for ( int i = 0 ; i < n ; i ++ ) { v += Integer . parseInt ( sl [ i ] ) - 1 ; } out . println ( v ) ; out . flush ( ) ; } }

import java . util . Scanner ; import java . util . Collections ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Queue ; import java . util . ArrayDeque ; import java . util . Deque ; import java . util . PriorityQueue ; import java . util . Set ; import java . util . HashMap ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] a = new int [ n ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; ans += a [ i ] - 1 ; } System . out . println ( ans ) ; } public static int upperBound ( long [ ] a , long val ) { return upperBound ( a , 0 , a . length , val ) ; } public static int upperBound ( long [ ] a , int l , int r , long val ) { if ( r - l == 1 ) { if ( a [ l ] > val ) return l ; return r ; } int mid = ( l + r ) / 2 ; if ( a [ mid ] > val ) { return upperBound ( a , l , mid , val ) ; } else { return upperBound ( a , mid , r , val ) ; } } public static int lowerBound ( long [ ] a , long val ) { return lowerBound ( a , 0 , a . length , val ) ; } public static int lowerBound ( long [ ] a , int l , int r , long val ) { if ( r - l == 1 ) { if ( a [ l ] < val ) return r ; return l ; } int mid = ( l + r ) / 2 ; if ( a [ mid ] < val ) { return lowerBound ( a , mid , r , val ) ; } else { return lowerBound ( a , l , mid , val ) ; } } }

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

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

import sys NEW_LINE import itertools NEW_LINE import collections NEW_LINE import functools NEW_LINE import math NEW_LINE from queue import Queue NEW_LINE INF = float ( " inf " ) NEW_LINE def solve ( N : int , a : " List [ int ] " ) : NEW_LINE INDENT print ( sum ( [ v - 1 for v in a ] ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE a = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , a ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

print ( - int ( input ( ) ) + sum ( list ( map ( int , input ( ) . split ( ) ) ) ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE a_list = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT return gcd ( b , a % b ) NEW_LINE DEDENT def lcm ( a , b ) : NEW_LINE INDENT return ( a * b ) // gcd ( a , b ) NEW_LINE DEDENT s = a_list [ 0 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT s = lcm ( s , a_list [ i ] ) NEW_LINE DEDENT def f ( m ) : NEW_LINE INDENT c = 0 NEW_LINE for a in a_list : NEW_LINE INDENT c += m % a NEW_LINE DEDENT return c NEW_LINE DEDENT print ( f ( s - 1 ) ) NEW_LINE

import fractions NEW_LINE from functools import reduce NEW_LINE def lcm_base ( x , y ) : NEW_LINE INDENT return ( x * y ) // fractions . gcd ( x , y ) NEW_LINE DEDENT def lcm_list ( numbers ) : NEW_LINE INDENT return reduce ( lcm_base , numbers , 1 ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE lcm = lcm_list ( A ) NEW_LINE ans = 0 NEW_LINE for i in A : NEW_LINE INDENT ans += ( lcm - 1 ) % i NEW_LINE DEDENT print ( ans ) NEW_LINE

from functools import reduce NEW_LINE from operator import mul NEW_LINE from sys import stdin NEW_LINE n = int ( stdin . readline ( ) . rstrip ( ) ) NEW_LINE al = [ int ( _ ) for _ in stdin . readline ( ) . rstrip ( ) . split ( ) ] NEW_LINE m = reduce ( mul , al ) - 1 NEW_LINE print ( sum ( m % a for a in al ) ) NEW_LINE


import java . io . * ; import java . util . * ; public class Main implements Runnable { private void solve ( ) throws IOException { int N = nextInt ( ) ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) arr [ i ] = nextInt ( ) ; Arrays . sort ( arr ) ; int s = 0 ; for ( int i : arr ) s += i ; if ( s % 10 != 0 ) { writer . println ( s ) ; } else { for ( int i = 0 ; i < arr . length ; ++ i ) { if ( ( arr [ i ] % 10 != 0 ) ) { writer . println ( ( s - arr [ i ] ) ) ; return ; } } writer . println ( 0 ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run ( ) { try { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; tokenizer = null ; writer = new PrintWriter ( System . out ) ; solve ( ) ; reader . close ( ) ; writer . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } } int nextInt ( ) throws IOException { return Integer . parseInt ( nextToken ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( nextToken ( ) ) ; } double nextDouble ( ) throws IOException { return Double . parseDouble ( nextToken ( ) ) ; } short nextShort ( ) throws IOException { return Short . parseShort ( nextToken ( ) ) ; } String nextToken ( ) throws IOException { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } }

import java . util . LinkedList ; import java . util . List ; import java . util . OptionalInt ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < Integer > ls = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) ls . add ( sc . nextInt ( ) ) ; int sum = ls . stream ( ) . mapToInt ( e -> e ) . sum ( ) ; if ( sum % 10 != 0 ) System . out . println ( sum ) ; else { OptionalInt tmp = ls . stream ( ) . mapToInt ( e -> e ) . filter ( e -> e % 10 != 0 ) . min ( ) ; if ( tmp . isPresent ( ) ) System . out . println ( sum - tmp . getAsInt ( ) ) ; else System . out . println ( 0 ) ; } } }

import java . io . BufferedReader ; import java . io . File ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { MyScanner sc = new MyScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) , sum = 0 ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; if ( sum % 10 == 0 ) for ( int i = 0 ; i < n ; i ++ ) if ( ( sum - a [ i ] ) % 10 != 0 ) { sum -= a [ i ] ; break ; } out . println ( sum % 10 == 0 ? 0 : sum ) ; out . flush ( ) ; out . close ( ) ; } static class MyScanner { StringTokenizer st ; BufferedReader br ; public MyScanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public MyScanner ( String file ) throws IOException { br = new BufferedReader ( new FileReader ( new File ( file ) ) ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; } } }

import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? " Yes " : " No " ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int n = nextInt ( ) ; int [ ] ar = nextIntArray ( n ) ; Arrays . sort ( ar ) ; long sum = 0 ; long notTenMultiple = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { sum += ar [ i ] ; if ( ar [ i ] % 10 != 0 ) { notTenMultiple = ar [ i ] ; } } if ( notTenMultiple == - 1 ) System . out . println ( 0 ) ; else if ( sum % 10 != 0 ) System . out . println ( sum ) ; else System . out . println ( sum - notTenMultiple ) ; } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] a = new int [ 101 ] ; int s1 = 0 , s2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; a [ k ] ++ ; if ( k % 10 == 0 ) s2 += k ; else s1 += k ; } if ( s1 == 0 ) { System . out . println ( 0 ) ; return ; } if ( s1 % 10 != 0 ) { System . out . println ( s1 + s2 ) ; return ; } for ( int i = 1 ; i <= 100 ; i ++ ) { if ( a [ i ] == 0 || i % 10 == 0 ) continue ; s1 -= i ; break ; } System . out . println ( s1 + s2 ) ; } }

def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntLines ( n ) : return [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE def genBits ( n ) : NEW_LINE INDENT bits = zeros ( n ) NEW_LINE for i in range ( 2 ** n ) : NEW_LINE INDENT for k in range ( n ) : NEW_LINE INDENT bits [ k ] = i % 2 NEW_LINE i //= 2 NEW_LINE DEDENT yield bits NEW_LINE DEDENT DEDENT def dmp ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def probC_TLE ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE S = getIntLines ( N ) NEW_LINE dmp ( ( N , S ) ) NEW_LINE maxPoint = 0 NEW_LINE for bit in genBits ( N ) : NEW_LINE INDENT point = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT point += S [ i ] * bit [ i ] NEW_LINE DEDENT if point % 10 == 0 : NEW_LINE INDENT point = 0 NEW_LINE DEDENT maxPoint = max ( point , maxPoint ) NEW_LINE dmp ( ( point , maxPoint ) ) NEW_LINE DEDENT return maxPoint NEW_LINE DEDENT def probC ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE S = getIntLines ( N ) NEW_LINE dmp ( ( N , S ) ) NEW_LINE tens = [ ] NEW_LINE nonTens = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] % 10 == 0 : NEW_LINE INDENT tens . append ( S [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT nonTens . append ( S [ i ] ) NEW_LINE DEDENT DEDENT total = sum ( nonTens ) NEW_LINE dmp ( total ) NEW_LINE if total > 0 and total % 10 == 0 : NEW_LINE INDENT total -= min ( nonTens ) NEW_LINE DEDENT dmp ( total ) NEW_LINE if total > 0 : NEW_LINE INDENT total += sum ( tens ) NEW_LINE DEDENT dmp ( total ) NEW_LINE return total NEW_LINE DEDENT debug = False NEW_LINE print ( probC ( ) ) NEW_LINE

import numpy as np NEW_LINE a = int ( input ( ) ) NEW_LINE k = [ ] NEW_LINE k10 = [ ] NEW_LINE s = 0 NEW_LINE for j in range ( a ) : NEW_LINE INDENT i = int ( input ( ) ) NEW_LINE if i % 10 == 0 : NEW_LINE INDENT k10 . append ( i ) NEW_LINE s += i NEW_LINE DEDENT else : NEW_LINE INDENT k . append ( i ) NEW_LINE DEDENT DEDENT k . sort ( ) NEW_LINE c = np . array ( k ) NEW_LINE l = c . sum ( ) NEW_LINE if l % 10 == 0 and len ( k ) != 0 : NEW_LINE INDENT l = l - c [ 0 ] NEW_LINE s = s + l NEW_LINE DEDENT elif len ( k ) == 0 : NEW_LINE INDENT s = 0 NEW_LINE DEDENT else : NEW_LINE INDENT s = s + l NEW_LINE DEDENT print ( s ) NEW_LINE

N = int ( input ( ) ) NEW_LINE S = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE score = { 0 } NEW_LINE for s in S : NEW_LINE INDENT tmp = set ( ) NEW_LINE for i in score : NEW_LINE INDENT tmp . add ( s + i ) NEW_LINE DEDENT score |= tmp NEW_LINE DEDENT for i in range ( 10 , 10010 , 10 ) : NEW_LINE INDENT if i in score : NEW_LINE INDENT score . remove ( i ) NEW_LINE DEDENT DEDENT print ( max ( score ) ) NEW_LINE

import sys NEW_LINE N = int ( input ( ) ) NEW_LINE scores = list ( map ( int , sys . stdin ) ) NEW_LINE perfect = sum ( scores ) NEW_LINE dp = [ 1 ] + [ 0 ] * perfect NEW_LINE for s in scores : NEW_LINE INDENT for i in range ( perfect - s , - 1 , - 1 ) : NEW_LINE INDENT dp [ i + s ] |= dp [ i ] NEW_LINE DEDENT DEDENT for s in range ( perfect , 0 , - 1 ) : NEW_LINE INDENT if dp [ s ] and s % 10 : NEW_LINE INDENT print ( s ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT

from collections import defaultdict NEW_LINE H = defaultdict ( lambda : 0 ) NEW_LINE H [ 0 ] = 1 NEW_LINE N = int ( input ( ) ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT i = int ( input ( ) ) NEW_LINE for ni , nv in H . copy ( ) . items ( ) : NEW_LINE INDENT H [ ni + i ] = 1 NEW_LINE DEDENT DEDENT K = reversed ( sorted ( list ( H . keys ( ) ) ) ) NEW_LINE ans = 0 NEW_LINE for j in K : NEW_LINE INDENT if j % 10 != 0 : NEW_LINE INDENT ans = j NEW_LINE break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; long Bcnt = 0 ; long cnt = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == ' W ' ) cnt += Bcnt ; if ( s [ i ] == ' B ' ) Bcnt ++ ; } System . out . println ( cnt ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class A { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . ns ( ) ; int n = s . length ( ) ; int done = 0 ; long ans = 0 ; for ( int dist = 0 ; dist < n ; dist ++ ) { if ( s . charAt ( n - dist - 1 ) == ' B ' ) { ans += dist - done ; done ++ ; } } out . println ( ans ) ; } } static class FastScanner { private BufferedReader in ; private StringTokenizer st ; public FastScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String ns ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl == null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return st . nextToken ( ) ; } } }

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

import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; String [ ] str = s . split ( " " ) ; Arrays . sort ( str , Comparator . reverseOrder ( ) ) ; long ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( str [ i ] . equals ( " B " ) ) { ans += i ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' B ' ) { ans -= i ; } } System . out . println ( ans ) ; } }

import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream in = System . in ; final byte [ ] bytes = new byte [ 200001 ] ; int length = 0 ; try { length = in . read ( bytes ) ; } catch ( IOException e ) { } int count = 0 ; long sum = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( bytes [ i ] == ' B ' ) count ++ ; else if ( bytes [ i ] == ' W ' ) sum += count ; } System . out . println ( sum ) ; } }

S = input ( ) NEW_LINE b = 0 NEW_LINE ans = 0 NEW_LINE for c in S : NEW_LINE INDENT if c == ' B ' : NEW_LINE INDENT b += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans += b NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

import numpy as np NEW_LINE s = np . array ( list ( input ( ) ) ) NEW_LINE ind = np . array ( np . where ( s == ' B ' ) ) NEW_LINE len_ind = ind . shape [ 1 ] NEW_LINE len = s . shape [ 0 ] NEW_LINE dist = np . arange ( len - len_ind , len ) NEW_LINE ans = np . sum ( dist - ind ) NEW_LINE print ( ans ) NEW_LINE

txt = input ( ) NEW_LINE txt_list = list ( txt ) NEW_LINE count = 0 NEW_LINE n_b = 0 NEW_LINE n_w = 0 NEW_LINE i = 0 NEW_LINE for i in range ( len ( txt_list ) ) : NEW_LINE INDENT if txt_list [ i ] == ' W ' : NEW_LINE INDENT n_w += 1 NEW_LINE DEDENT if ( i >= 1 and txt_list [ i - 1 ] == ' W ' and txt_list [ i ] == ' B ' ) or ( i == len ( txt_list ) - 1 and txt_list [ i ] == ' W ' ) : NEW_LINE INDENT count += n_b * n_w NEW_LINE n_w = 0 NEW_LINE DEDENT if txt_list [ i ] == ' B ' : NEW_LINE INDENT n_b += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE

S = list ( input ( ) ) NEW_LINE W_i = [ i for i , j in enumerate ( S ) if j == ' W ' ] NEW_LINE W_n = S . count ( ' W ' ) NEW_LINE cur = 0 NEW_LINE ans = 0 NEW_LINE for i in W_i : NEW_LINE INDENT ans += i - cur NEW_LINE cur += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE

S = input ( ) NEW_LINE counter = 0 NEW_LINE ans = 0 NEW_LINE for index , char in enumerate ( S ) : NEW_LINE INDENT if ( char == " W " ) : NEW_LINE INDENT ans += index - counter NEW_LINE counter += 1 NEW_LINE DEDENT DEDENT print ( int ( ans ) ) NEW_LINE