import java . util . * ; public class Main { private static int D [ ] = new int [ 7 ] ; private static int J [ ] = new int [ 7 ] ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; for ( int i = 0 ; i < 7 ; i ++ ) { D [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { J [ i ] = scan . nextInt ( ) ; } } public static void main ( String args [ ] ) { input ( ) ; int ans = 0 ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( D [ i ] >= J [ i ] ) ans += D [ i ] ; else ans += J [ i ] ; } System . out . println ( ans ) ; } }

import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int ans = 0 ; int [ ] d = new int [ 7 ] ; int [ ] j = new int [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { j [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { ans += max ( d [ i ] , j [ i ] ) ; } out . println ( ans ) ; } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String args [ ] ) { int max_sum = 0 ; Scanner scan = new Scanner ( System . in ) ; ArrayList < Integer > d = new ArrayList < Integer > ( ) ; ArrayList < Integer > j = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 7 ; i ++ ) d . add ( scan . nextInt ( ) ) ; for ( int i = 0 ; i < 7 ; i ++ ) j . add ( scan . nextInt ( ) ) ; for ( int i = 0 ; i < 7 ; i ++ ) max_sum += Math . max ( d . get ( i ) , j . get ( i ) ) ; System . out . println ( max_sum ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] d = new int [ 7 ] ; int [ ] j = new int [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 7 ; i ++ ) { j [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( d [ i ] >= j [ i ] ) { ans += d [ i ] ; } else { ans += j [ i ] ; } } System . out . println ( ans ) ; } }

import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] d = new int [ 7 ] , j = new int [ 7 ] ; int sum = 0 ; for ( int i = 0 ; i < 7 ; i ++ ) d [ i ] = s . nextInt ( ) ; for ( int i = 0 ; i < 7 ; i ++ ) j [ i ] = s . nextInt ( ) ; for ( int i = 0 ; i < 7 ; i ++ ) sum += Math . max ( d [ i ] , j [ i ] ) ; System . out . println ( sum ) ; } }

D = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE J = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = 0 NEW_LINE for i in range ( 7 ) : NEW_LINE INDENT if D [ i ] >= J [ i ] : NEW_LINE INDENT res += D [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT res += J [ i ] NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE

print ( sum ( map ( max , zip ( * eval ( ' map ( int , input ( ) . split ( ) ) , ' * 2 ) ) ) ) ) NEW_LINE

import numpy as np NEW_LINE D = np . array ( [ int ( _ ) for _ in input ( ) . split ( ) ] ) NEW_LINE J = np . array ( [ int ( _ ) for _ in input ( ) . split ( ) ] ) NEW_LINE print ( sum ( np . maximum ( D , J ) ) ) NEW_LINE

D , J = input ( ) . split ( " ▁ " ) , input ( ) . split ( " ▁ " ) NEW_LINE D , J = [ int ( i ) for i in D ] , [ int ( i ) for i in J ] NEW_LINE ans = 0 NEW_LINE for i in range ( 7 ) : NEW_LINE INDENT ans += max ( D [ i ] , J [ i ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE

def main ( ) : NEW_LINE INDENT dd = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE jj = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = sum ( max ( d , j ) for d , j in zip ( dd , jj ) ) NEW_LINE print ( res ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int B [ ] = new int [ N ] ; LinkedList list [ ] = new LinkedList [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { list [ i ] = new LinkedList ( ) ; } for ( int i = 1 ; i < N ; i ++ ) { B [ i ] = sc . nextInt ( ) ; list [ B [ i ] - 1 ] . add ( i ) ; } System . out . println ( get_money ( 0 , list ) ) ; } public static int get_money ( int num , LinkedList list [ ] ) { if ( list [ num ] . size ( ) == 0 ) { return 1 ; } else { int min = Integer . MAX_VALUE ; int max = 0 ; for ( int i = 0 ; i < list [ num ] . size ( ) ; i ++ ) { int n = get_money ( list [ num ] . get ( i ) , list ) ; min = Math . min ( min , n ) ; max = Math . max ( max , n ) ; } return min + max + 1 ; } } } class LinkedList { ArrayList < Integer > link = new ArrayList < Integer > ( ) ; public void add ( int vertex ) { link . add ( vertex ) ; } public int get ( int i ) { return link . get ( i ) ; } public void remove ( int vertex ) { } public void view ( ) { for ( int i = 0 ; i < link . size ( ) ; i ++ ) { System . out . println ( link . get ( i ) ) ; } } public boolean linked ( int vertex ) { if ( Arrays . asList ( link ) . contains ( vertex ) ) { return true ; } else { return false ; } } public int size ( ) { return link . size ( ) ; } }

import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) ; int [ ] salary = new int [ n ] ; List < Integer > [ ] list = IntStream . range ( 0 , n ) . mapToObj ( i -> new ArrayList < > ( ) ) . toArray ( List [ ] :: new ) ; for ( int i = 1 ; i < n ; i ++ ) list [ scanner . nextInt ( ) - 1 ] . add ( i ) ; boolean flag = true ; while ( flag ) { flag = false ; for ( int i = 0 ; i < n ; i ++ ) { int [ ] array = list [ i ] . stream ( ) . mapToInt ( j -> salary [ j ] ) . toArray ( ) ; if ( salary [ i ] == 0 && Arrays . stream ( array ) . noneMatch ( j -> j == 0 ) ) { flag = true ; salary [ i ] = Arrays . stream ( array ) . min ( ) . orElse ( 0 ) + Arrays . stream ( array ) . max ( ) . orElse ( 0 ) + 1 ; } } } System . out . println ( salary [ 0 ] ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

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 [ ] boss = new int [ N + 1 ] ; boss [ 0 ] = - 1 ; Map < Integer , List < Integer > > members = new HashMap < Integer , List < Integer > > ( ) ; for ( int i = 1 ; i <= N - 1 ; i ++ ) { int b = sc . nextInt ( ) ; boss [ i + 1 ] = b ; List < Integer > member = new ArrayList < Integer > ( ) ; if ( members . containsKey ( b ) ) { member = members . get ( b ) ; } member . add ( i + 1 ) ; members . put ( b , member ) ; } Queue < Integer > checkMember = new ArrayDeque < Integer > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( ! members . containsKey ( i ) ) { checkMember . add ( i ) ; } } int [ ] salary = new int [ N + 1 ] ; while ( ! checkMember . isEmpty ( ) ) { int n = checkMember . poll ( ) ; if ( ! members . containsKey ( n ) ) { salary [ n ] = 1 ; } else { int max = Integer . MIN_VALUE ; int min = Integer . MAX_VALUE ; for ( Integer m : members . get ( n ) ) { max = Math . max ( max , salary [ m ] ) ; min = Math . min ( min , salary [ m ] ) ; } salary [ n ] = max + min + 1 ; } if ( ! checkMember . contains ( boss [ n ] ) && boss [ n ] != - 1 ) { checkMember . add ( boss [ n ] ) ; } } out . println ( salary [ 1 ] ) ; } }

import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] b = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } List < List < Integer > > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { List < Integer > subList = new ArrayList < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( i + 1 == b [ j ] ) { subList . add ( j ) ; } } list . add ( subList ) ; } int [ ] p = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( list . get ( i ) . size ( ) == 0 ) { p [ i ] = 1 ; } else { int min = ( int ) 1e9 ; int max = 0 ; for ( int j = 0 ; j < list . get ( i ) . size ( ) ; j ++ ) { min = Math . min ( min , p [ list . get ( i ) . get ( j ) ] ) ; max = Math . max ( max , p [ list . get ( i ) . get ( j ) ] ) ; } p [ i ] = min + max + 1 ; } } System . out . println ( p [ 0 ] ) ; } }

import java . util . * ; public class Main { static ArrayList < Integer > [ ] lists ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; lists = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { lists [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 2 ; i <= n ; i ++ ) { int x = sc . nextInt ( ) ; lists [ x ] . add ( i ) ; } System . out . println ( getIncome ( 1 ) ) ; } static int getIncome ( int idx ) { if ( lists [ idx ] . size ( ) == 0 ) { return 1 ; } int max = 0 ; int min = Integer . MAX_VALUE ; for ( int x : lists [ idx ] ) { int y = getIncome ( x ) ; if ( max < y ) { max = y ; } if ( min > y ) { min = y ; } } return max + min + 1 ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

from collections import defaultdict as dd NEW_LINE n = int ( input ( ) ) NEW_LINE salary = [ 0 ] * ( n + 1 ) NEW_LINE d = dd ( list ) NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT d [ int ( input ( ) ) ] . append ( i ) NEW_LINE DEDENT def calcsalary ( i ) : NEW_LINE INDENT if d [ i ] == [ ] : NEW_LINE INDENT salary [ i ] = 1 NEW_LINE return 1 NEW_LINE DEDENT else : NEW_LINE INDENT subord = [ ] NEW_LINE for x in d [ i ] : NEW_LINE INDENT if salary [ x ] : NEW_LINE INDENT subord . append ( salary [ x ] ) NEW_LINE DEDENT else : NEW_LINE INDENT subord . append ( calcsalary ( x ) ) NEW_LINE DEDENT DEDENT salary [ x ] = max ( subord ) + min ( subord ) + 1 NEW_LINE return salary [ x ] NEW_LINE DEDENT DEDENT print ( calcsalary ( 1 ) ) NEW_LINE

def salary ( N : int , B : list ) -> int : NEW_LINE INDENT tree = [ [ ] for _ in range ( N ) ] NEW_LINE for i , b in enumerate ( B ) : NEW_LINE INDENT tree [ b - 1 ] . append ( i + 1 ) NEW_LINE DEDENT def dfs ( v : int ) -> int : NEW_LINE INDENT if not tree [ v ] : NEW_LINE INDENT return 1 NEW_LINE DEDENT max_s , min_s = 0 , float ( ' inf ' ) NEW_LINE for child in tree [ v ] : NEW_LINE INDENT d = dfs ( child ) NEW_LINE max_s = max ( max_s , d ) NEW_LINE min_s = min ( min_s , d ) NEW_LINE DEDENT return max_s + min_s + 1 NEW_LINE DEDENT return dfs ( 0 ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE B = [ int ( input ( ) ) for _ in range ( N - 1 ) ] NEW_LINE ans = salary ( N , B ) NEW_LINE print ( ans ) NEW_LINE DEDENT

import sys NEW_LINE input = sys . stdin . readline NEW_LINE class Tree : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . par = [ i for i in range ( n ) ] NEW_LINE DEDENT def unite ( self , par , chi ) : NEW_LINE INDENT self . par [ chi ] = par NEW_LINE DEDENT def get_child ( self , par ) : NEW_LINE INDENT child = set ( ) NEW_LINE for i in range ( len ( self . par ) ) : NEW_LINE INDENT if i != par and self . par [ i ] == par : NEW_LINE INDENT child . add ( i ) NEW_LINE DEDENT DEDENT return child NEW_LINE DEDENT DEDENT def salary ( x ) : NEW_LINE INDENT if money [ x ] != - 1 : NEW_LINE INDENT return money [ x ] NEW_LINE DEDENT else : NEW_LINE INDENT chilist = member . get_child ( x ) NEW_LINE if len ( chilist ) == 0 : NEW_LINE INDENT money [ x ] = 1 NEW_LINE return money [ x ] NEW_LINE DEDENT else : NEW_LINE INDENT sub = set ( ) NEW_LINE for i in chilist : NEW_LINE INDENT sub . add ( salary ( i ) ) NEW_LINE DEDENT money [ x ] = max ( sub ) + min ( sub ) + 1 NEW_LINE return money [ x ] NEW_LINE DEDENT DEDENT DEDENT N = int ( input ( ) ) NEW_LINE B = [ 0 ] * 2 + [ int ( input ( ) ) for _ in range ( N - 1 ) ] NEW_LINE member = Tree ( N + 1 ) NEW_LINE money = [ - 1 ] * ( N + 1 ) NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT member . unite ( B [ i ] , i ) NEW_LINE DEDENT print ( salary ( 1 ) ) NEW_LINE

n = int ( input ( ) ) NEW_LINE b = [ [ 0 , 0 ] ] + [ [ i , int ( input ( ) ) - 1 ] for i in range ( 1 , n ) ] NEW_LINE b = b [ : : - 1 ] NEW_LINE salary = [ [ ] for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if not salary [ i ] : NEW_LINE INDENT salary [ i ] . append ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT salary [ i ] . append ( min ( salary [ i ] ) + max ( salary [ i ] ) + 1 ) NEW_LINE DEDENT salary [ ( n - 1 ) - b [ i ] [ 1 ] ] . append ( salary [ i ] [ - 1 ] ) NEW_LINE DEDENT print ( salary [ n - 1 ] [ - 1 ] ) NEW_LINE

n = int ( input ( ) ) NEW_LINE salary = [ 0 , 1 ] NEW_LINE ans = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT k = int ( input ( ) ) NEW_LINE salary . append ( k ) NEW_LINE DEDENT def find ( x , i ) : NEW_LINE INDENT if salary [ x ] == x : NEW_LINE INDENT return i NEW_LINE DEDENT return find ( salary [ x ] , i + 1 ) NEW_LINE DEDENT order = [ ] NEW_LINE for i in range ( len ( salary ) ) : NEW_LINE INDENT order . append ( [ find ( salary [ i ] , 0 ) , i ] ) NEW_LINE DEDENT order . sort ( ) NEW_LINE order . reverse ( ) NEW_LINE salary [ 1 ] = 0 NEW_LINE for i in order : NEW_LINE INDENT stack = [ ] NEW_LINE if salary . count ( i [ 1 ] ) == 0 : NEW_LINE INDENT ans [ i [ 1 ] ] = 1 NEW_LINE DEDENT elif salary . count ( i [ 1 ] ) == 1 : NEW_LINE INDENT for j in range ( len ( salary ) ) : NEW_LINE INDENT if salary [ j ] == i [ 1 ] : NEW_LINE INDENT ans [ i [ 1 ] ] = ans [ j ] * 2 + 1 NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for j in range ( len ( salary ) ) : NEW_LINE INDENT if salary [ j ] == i [ 1 ] : NEW_LINE INDENT stack . append ( ans [ j ] ) NEW_LINE DEDENT DEDENT ans [ i [ 1 ] ] = min ( stack ) + max ( stack ) + 1 NEW_LINE DEDENT DEDENT print ( ans [ 1 ] ) NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int c = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int target = c % b ; for ( int i = 1 ; i <= b ; i ++ ) { if ( i * a % b == target ) { System . out . println ( " YES " ) ; return ; } } System . out . println ( " NO " ) ; } }

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 A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int total = 0 ; String ans = " NO " ; for ( int i = 0 ; i <= A * B ; i ++ ) { total += A ; if ( total % B == C ) { ans = " YES " ; break ; } } 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 char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

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

import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; 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 cnt = 1 ; List < Integer > list = new ArrayList < > ( ) ; while ( true ) { int i = a * cnt % b ; if ( i == c ) { System . out . println ( " YES " ) ; System . exit ( 0 ) ; } else if ( list . contains ( i ) ) { System . out . println ( " NO " ) ; System . exit ( 0 ) ; } else { list . add ( i ) ; cnt ++ ; } } } }

import java . util . Scanner ; public class Main { static int k ; static String ans = " NO " ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; for ( int i = 1 ; i <= b ; i ++ ) { if ( a * i % b == c ) ans = " YES " ; } System . out . println ( ans ) ; } }

A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE R = { i : False for i in range ( B ) } NEW_LINE X = 0 NEW_LINE while True : NEW_LINE INDENT X += A NEW_LINE r = X % B NEW_LINE if r == C : NEW_LINE INDENT print ( " YES " ) NEW_LINE exit ( ) NEW_LINE DEDENT if R [ r ] : NEW_LINE INDENT print ( " NO " ) NEW_LINE exit ( ) NEW_LINE DEDENT R [ r ] = True NEW_LINE DEDENT

def gcd ( x , y ) : NEW_LINE INDENT while y : NEW_LINE INDENT x , y = y , x % y NEW_LINE DEDENT return x NEW_LINE DEDENT A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if C % gcd ( A , B ) == 0 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT

from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a , b , c = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE i = 1 NEW_LINE ans = ' NO ' NEW_LINE while i < b : NEW_LINE INDENT if ( a * i % b == c ) : NEW_LINE INDENT ans = ' YES ' NEW_LINE break NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( 1 , B + 1 ) : NEW_LINE INDENT if ( A * i ) % B == C : NEW_LINE INDENT return ' YES ' NEW_LINE DEDENT DEDENT return ' NO ' NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT

A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE amaris = [ ] NEW_LINE flag = False NEW_LINE count = 1 NEW_LINE tmp = A NEW_LINE while True : NEW_LINE INDENT amari = tmp % B NEW_LINE if C == amari : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT if amari in amaris : NEW_LINE INDENT break NEW_LINE DEDENT amaris . append ( amari ) NEW_LINE count += 1 NEW_LINE tmp = A * count NEW_LINE DEDENT if flag : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT


import java . util . ArrayList ; import java . util . List ; 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 = reader . nextInt ( ) ; int b = reader . nextInt ( ) ; int K = reader . nextInt ( ) ; List < Integer > P = new ArrayList < Integer > ( ) ; String ans = " YES " ; for ( int i = 0 ; i < K ; i ++ ) { int num = reader . nextInt ( ) ; if ( P . contains ( num ) || num == a || num == b ) { ans = " NO " ; } P . add ( num ) ; } System . out . println ( ans ) ; reader . close ( ) ; } }

import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Map < Integer , Integer > map = new TreeMap ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; for ( int i = 0 ; i < d ; i ++ ) map . put ( sc . nextInt ( ) , 1 ) ; System . out . println ( map . size ( ) == d && map . containsKey ( b ) == false && map . containsKey ( c ) == false ? " YES " : " NO " ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

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 . HashSet ; import java . util . Set ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int K = in . nextInt ( ) ; String ans = " YES " ; Set < Integer > list = new HashSet < Integer > ( ) ; int tmp ; for ( int i = 0 ; i < K ; i ++ ) { tmp = in . nextInt ( ) ; if ( tmp == a || tmp == b ) { ans = " NO " ; } list . add ( tmp ) ; } if ( list . size ( ) < K ) { ans = " NO " ; } if ( N < K ) { ans = " NO " ; } 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 char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Collection ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . io . UncheckedIOException ; import java . util . List ; 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 ) { int n = in . ints ( ) ; List < Integer > s = new ArrayList < > ( ) ; s . add ( in . ints ( ) ) ; s . add ( in . ints ( ) ) ; int k = in . ints ( ) ; for ( int i = 0 ; i < k ; i ++ ) { s . add ( in . ints ( ) ) ; } if ( s . size ( ) > s . stream ( ) . distinct ( ) . count ( ) ) { out . println ( " NO " ) ; } else { out . println ( " YES " ) ; } } } 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 ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] line = scanner . nextLine ( ) . split ( " ▁ " , 2 ) ; int a = Integer . parseInt ( line [ 0 ] ) ; int b = Integer . parseInt ( line [ 1 ] ) ; boolean [ ] passed = new boolean [ n ] ; passed [ a - 1 ] = true ; passed [ b - 1 ] = true ; int k = Integer . parseInt ( scanner . nextLine ( ) ) ; line = scanner . nextLine ( ) . split ( " ▁ " , k ) ; boolean yes = true ; for ( int i = 0 ; i < k ; i ++ ) { int p = Integer . parseInt ( line [ i ] ) ; if ( passed [ p - 1 ] ) { yes = false ; break ; } passed [ p - 1 ] = true ; } if ( yes ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

n = input ( ) NEW_LINE org = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE k = input ( ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE t_arr = list ( set ( arr + org ) ) NEW_LINE print ( ' YES ' ) if len ( arr + org ) == len ( t_arr ) else print ( ' NO ' ) 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 = ip ( ) NEW_LINE x , y = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE k = ip ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a . append ( x ) NEW_LINE a . append ( y ) NEW_LINE s = set ( a ) NEW_LINE if len ( s ) == len ( a ) : NEW_LINE INDENT j ( 1 ) NEW_LINE DEDENT else : j ( 0 ) NEW_LINE

import sys NEW_LINE N = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE P = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE visited = [ a , b ] NEW_LINE for p in P : NEW_LINE INDENT if p in visited : NEW_LINE INDENT print ( " NO " ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT visited . append ( p ) NEW_LINE DEDENT print ( " YES " ) NEW_LINE

def solve ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a , b = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE p = list ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE ans = ' YES ' NEW_LINE if a in p or b in p : NEW_LINE INDENT ans = ' NO ' NEW_LINE DEDENT if len ( p ) != len ( set ( p ) ) : NEW_LINE INDENT ans = ' NO ' NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT solve ( ) NEW_LINE

N = int ( input ( ) ) NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE Plist = ( input ( ) . split ( ) ) NEW_LINE Plist_i = [ int ( s ) for s in Plist ] NEW_LINE def is_unique ( seq ) : NEW_LINE INDENT return len ( seq ) == len ( set ( seq ) ) NEW_LINE DEDENT if N < 2 : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT elif K > ( N - 2 ) : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT elif a == b : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT elif is_unique ( Plist_i ) == False : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT


import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( a == b ) { System . out . println ( c ) ; } else if ( a == c ) { System . out . println ( b ) ; } else if ( b == c ) { System . out . println ( a ) ; } } }

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

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

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

a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if a == b : NEW_LINE INDENT print ( int ( c ) ) NEW_LINE DEDENT elif b == c : NEW_LINE INDENT print ( int ( a ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( b ) ) NEW_LINE DEDENT

def rect ( l1 : int , l2 : int , l3 : int ) -> int : NEW_LINE INDENT if l1 == l2 : NEW_LINE INDENT return l3 NEW_LINE DEDENT if l1 == l3 : NEW_LINE INDENT return l2 NEW_LINE DEDENT return l1 NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT l1 , l2 , l3 = map ( int , input ( ) . split ( ) ) NEW_LINE ans = rect ( l1 , l2 , l3 ) NEW_LINE print ( ans ) NEW_LINE DEDENT

print ( eval ( input ( ) . replace ( ' ▁ ' , ' ^ ' ) ) ) NEW_LINE

llist = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cnt1 = 1 NEW_LINE cnt2 = 0 NEW_LINE l4 = 0 NEW_LINE for i in range ( 1 , 3 ) : NEW_LINE INDENT if llist [ 0 ] == llist [ i ] : NEW_LINE INDENT cnt1 += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt2 += 1 NEW_LINE l4 = llist [ i ] NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE if cnt1 == 1 : NEW_LINE INDENT ans = llist [ 0 ] NEW_LINE DEDENT elif cnt1 == 2 : NEW_LINE INDENT ans = l4 NEW_LINE DEDENT else : NEW_LINE INDENT ans = llist [ 0 ] NEW_LINE DEDENT print ( ans ) NEW_LINE

import collections NEW_LINE l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = collections . Counter ( l ) NEW_LINE b = len ( set ( l ) ) NEW_LINE if b == 1 : NEW_LINE INDENT ans = l [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT for k in a . keys ( ) : NEW_LINE INDENT if a [ k ] == 1 : NEW_LINE INDENT ans = k NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


import java . math . BigDecimal ; import java . util . AbstractMap . SimpleEntry ; import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; BigDecimal sum = BigDecimal . ZERO ; List < Entry < Integer , Integer > > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) list . add ( new SimpleEntry < Integer , Integer > ( sc . nextInt ( ) , sc . nextInt ( ) ) ) ; list = list . stream ( ) . sorted ( Comparator . comparingInt ( entry -> entry . getKey ( ) ) ) . collect ( Collectors . toList ( ) ) ; for ( Entry < Integer , Integer > entry : list ) { if ( m == 0 ) break ; BigDecimal a = BigDecimal . valueOf ( entry . getKey ( ) ) ; BigDecimal b = BigDecimal . valueOf ( entry . getValue ( ) ) ; if ( m > entry . getValue ( ) ) { m -= entry . getValue ( ) ; sum = sum . add ( a . multiply ( b ) ) ; } else if ( m <= entry . getValue ( ) ) { b = BigDecimal . valueOf ( m ) ; sum = sum . add ( a . multiply ( b ) ) ; m = 0 ; } } System . out . println ( sum . toString ( ) ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] [ ] A = new long [ N ] [ 2 ] ; int k = 0 ; int number = 0 ; long sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } Arrays . sort ( A , ( a , b ) -> Long . compare ( a [ 0 ] , b [ 0 ] ) ) ; while ( M > k ) { k += A [ number ] [ 1 ] ; sum += A [ number ] [ 0 ] * A [ number ] [ 1 ] ; number ++ ; } if ( k != M ) { sum -= A [ number - 1 ] [ 0 ] * ( k - M ) ; } PrintWriter out = new PrintWriter ( System . out ) ; out . print ( sum ) ; out . flush ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { 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 . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Data > list = new ArrayList < Data > ( ) ; String [ ] line_list = sc . nextLine ( ) . split ( " ▁ " ) ; int N = Integer . parseInt ( line_list [ 0 ] ) ; int M = Integer . parseInt ( line_list [ 1 ] ) ; for ( int i = 0 ; i < N ; i ++ ) { line_list = sc . nextLine ( ) . split ( " ▁ " ) ; list . add ( new Data ( Long . parseLong ( line_list [ 0 ] ) , Integer . parseInt ( line_list [ 1 ] ) ) ) ; } list . sort ( ( a , b ) -> a . compareTo ( b ) ) ; long kingaku = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Data data = list . get ( i ) ; if ( M < data . getSuryou ( ) ) { kingaku = kingaku + M * data . getTanka ( ) ; break ; } else { kingaku = kingaku + data . getSuryou ( ) * data . getTanka ( ) ; M = M - data . getSuryou ( ) ; } } System . out . println ( kingaku ) ; } public static class Data implements Comparable < Data > { long tanka ; int suryou ; public Data ( long p_tanka , int p_suryou ) { this . tanka = p_tanka ; this . suryou = p_suryou ; } @ Override public int compareTo ( Data d ) { if ( this . tanka < d . tanka ) return - 1 ; if ( this . tanka > d . tanka ) return 1 ; return 0 ; } public long getTanka ( ) { return tanka ; } public void setTanka ( long tanka ) { this . tanka = tanka ; } public int getSuryou ( ) { return suryou ; } public void setSuryou ( int suryou ) { this . suryou = suryou ; } } }

import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; scanner . nextLine ( ) ; List < Store > list = IntStream . range ( 0 , n ) . mapToObj ( i -> { Store store = new Store ( ) ; store . price = scanner . nextInt ( ) ; store . amount = scanner . nextInt ( ) ; scanner . nextLine ( ) ; return store ; } ) . sorted ( ( x , y ) -> x . price - y . price ) . collect ( Collectors . toList ( ) ) ; long sum = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Store store = list . get ( i ) ; if ( store . amount >= m ) { sum += ( long ) store . price * m ; break ; } else { sum += ( long ) store . price * store . amount ; m -= store . amount ; } } System . out . println ( sum ) ; } } private static class Store { int price ; int amount ; } }

import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; TreeMap < Long , Integer > map = new TreeMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { long cost = sc . nextLong ( ) ; int num = sc . nextInt ( ) ; map . put ( cost , map . containsKey ( cost ) ? num + map . get ( cost ) : num ) ; } sc . close ( ) ; long totalcost = 0 ; int bought = 0 ; for ( Map . Entry < Long , Integer > kv : map . entrySet ( ) ) { long cost = kv . getKey ( ) ; int maxnum = kv . getValue ( ) ; int buycount = Math . min ( maxnum , M - bought ) ; totalcost += buycount * cost ; bought += buycount ; if ( bought > M ) { break ; } } System . out . println ( totalcost ) ; } }

N , M = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = { } NEW_LINE B = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT A [ i ] , B [ i ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT A = sorted ( A . items ( ) , key = lambda x : x [ 1 ] ) NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if M > B [ A [ i ] [ 0 ] ] : NEW_LINE INDENT ans += A [ i ] [ 1 ] * B [ A [ i ] [ 0 ] ] NEW_LINE M -= B [ A [ i ] [ 0 ] ] NEW_LINE DEDENT else : NEW_LINE INDENT ans += A [ i ] [ 1 ] * M NEW_LINE break ; NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

import sys ; n , m = input ( ) . split ( ) ; m = int ( m ) ; a = [ ] ; i = n = c = 0 ; a = sorted ( tuple ( map ( int , e . split ( ) ) ) for e in sys . stdin ) NEW_LINE while m > 0 : c += a [ i ] [ 0 ] * a [ i ] [ 1 ] ; m -= a [ i ] [ 1 ] ; i += 1 NEW_LINE print ( c + m * a [ ~ - i ] [ 0 ] ) NEW_LINE

from collections import namedtuple NEW_LINE Shop = namedtuple ( ' Shop ' , ( ' a ' , ' b ' ) ) NEW_LINE def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE shops = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE shops . append ( Shop ( a , b ) ) NEW_LINE DEDENT print ( solve ( shops , m ) ) NEW_LINE DEDENT def solve ( shops , m ) : NEW_LINE INDENT cost = 0 NEW_LINE count = 0 NEW_LINE for shop in sorted ( shops ) : NEW_LINE INDENT if count + shop . b >= m : NEW_LINE INDENT cost += shop . a * ( m - count ) NEW_LINE return cost NEW_LINE DEDENT count += shop . b NEW_LINE cost += shop . a * shop . b NEW_LINE DEDENT DEDENT main ( ) NEW_LINE

n , m , * t = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for a , b in sorted ( zip ( t [ : : 2 ] , t [ 1 : : 2 ] ) ) : NEW_LINE INDENT ans += min ( b , m ) * a NEW_LINE m -= b NEW_LINE if m <= 0 : NEW_LINE INDENT print ( ans ) NEW_LINE break NEW_LINE DEDENT DEDENT

import itertools NEW_LINE N , M = tuple ( [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] ) NEW_LINE AB = [ tuple ( [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] ) for i in range ( N ) ] NEW_LINE ans = 0 NEW_LINE count = 0 NEW_LINE for a , b in sorted ( AB , key = lambda x : x [ 0 ] ) : NEW_LINE INDENT if M - count <= b : NEW_LINE INDENT ans += ( M - count ) * a NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT count += b NEW_LINE ans += a * b NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( a * b <= c ) { System . out . println ( a * b ) ; } else if ( c < a * b ) { System . out . println ( c ) ; } } }

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

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; import java . util . TreeSet ; import org . omg . Messaging . SyncScopeHelper ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_100 ( ) . doIt ( ) ; } class Test_100 { void doIt ( ) { int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int PlanA = N * A ; int PlanB = B ; if ( PlanA < PlanB ) System . out . println ( PlanA ) ; else System . out . println ( PlanB ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numN = 0 ; int numA = 0 ; int numB = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; numA = scanner . nextInt ( ) ; numB = scanner . nextInt ( ) ; System . out . println ( Math . min ( numA * numN , numB ) ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( A * N < B ? A * N : B ) ; } }

n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( min ( n * a , b ) ) NEW_LINE

N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if ( N * A > B ) : NEW_LINE INDENT print ( B ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( N * A ) NEW_LINE DEDENT

N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if N * A < B : NEW_LINE INDENT print ( N * A ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( B ) NEW_LINE DEDENT

n , a , b = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE print ( min ( n * a , b ) ) NEW_LINE

N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( N * A if N * A < B else B ) NEW_LINE


import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = readInt ( ) ; char [ ] [ ] charMatrix = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String tmpStr = sc . next ( ) ; for ( int j = 0 ; j < N ; j ++ ) { charMatrix [ i ] [ j ] = tmpStr . charAt ( j ) ; } } long cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { char [ ] [ ] shiftedMatrix = shiftCharMatrix ( charMatrix , 0 , i ) ; if ( checkCharMatrixSymmetry ( shiftedMatrix ) ) { cnt += N ; } } System . out . println ( cnt ) ; } private static char [ ] [ ] shiftCharMatrix ( char [ ] [ ] matrix , int H , int W ) { int SIZE_H = matrix . length ; int SIZE_W = matrix [ 0 ] . length ; char [ ] [ ] shiftedMatrix = new char [ SIZE_H ] [ SIZE_W ] ; for ( int h = 0 ; h < SIZE_H ; h ++ ) { for ( int w = 0 ; w < SIZE_W ; w ++ ) { int next_h = ( h + H ) % SIZE_H ; int next_w = ( w + W ) % SIZE_W ; shiftedMatrix [ next_h ] [ next_w ] = matrix [ h ] [ w ] ; } } return shiftedMatrix ; } private static boolean checkCharMatrixSymmetry ( char [ ] [ ] matrix ) { int N = matrix . length ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i ; j < N ; j ++ ) { if ( matrix [ i ] [ j ] != matrix [ j ] [ i ] ) { return false ; } } } return true ; } private static char readChar ( ) { return sc . next ( ) . charAt ( 0 ) ; } private static int readInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } private static long readLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; String [ ] s = in . nextStringArray ( n ) ; int count = 0 ; out : for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { if ( j == k ) continue ; if ( s [ j ] . charAt ( ( k + i ) % n ) != s [ k ] . charAt ( ( j + i ) % n ) ) continue out ; } } count ++ ; } count *= n ; out . println ( count ) ; } } static class InputReader { BufferedReader in ; StringTokenizer tok ; public String nextString ( ) { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) , " ▁ " ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return tok . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } public String [ ] nextStringArray ( int n ) { String [ ] res = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { res [ i ] = nextString ( ) ; } return res ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( " " ) ; } } }

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 ( ) ; int ansbase = 0 ; String [ ] S = new String [ N ] ; char [ ] [ ] s = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { S [ i ] = sc . next ( ) ; for ( int j = 0 ; j < N ; j ++ ) { s [ i ] [ j ] = S [ i ] . charAt ( j ) ; } } for ( int i = 0 ; i < N ; i ++ ) { Boolean OK = true ; for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( s [ ( i + j ) % N ] [ k ] != s [ ( i + k ) % N ] [ j ] ) { OK = false ; } } } if ( OK ) { ansbase ++ ; } } System . out . println ( ansbase * N ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; char [ ] [ ] board ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; board = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { board [ i ] = sc . next ( ) . toCharArray ( ) ; } solve ( ) ; } void solve ( ) { long count = 0 ; for ( int a = 0 ; a < n ; a ++ ) { int b = 0 ; boolean flag = true ; b : for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( board [ ( i + a ) % n ] [ ( j + b ) % n ] != board [ ( j + a ) % n ] [ ( i + b ) % n ] ) { flag = false ; break b ; } } } if ( flag ) { count ++ ; } } System . out . println ( count * n ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { 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 . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] [ ] str = new String [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String tmpStr = sc . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { str [ i ] [ j ] = String . valueOf ( tmpStr . charAt ( j ) ) ; } } int count = 0 ; String [ ] [ ] secondStr = new String [ n ] [ n ] ; for ( int A = 0 ; A < n ; A ++ ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { secondStr [ i ] [ j ] = str [ ( i + A ) % n ] [ j ] ; } } boolean ans = true ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ! ( secondStr [ i ] [ j ] . equals ( secondStr [ j ] [ i ] ) ) ) { ans = false ; } } } if ( ans == true ) count += n ; } System . out . println ( count ) ; } }

import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ list ( input ( ) ) for i in range ( n ) ] NEW_LINE a = np . array ( a ) NEW_LINE c = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT a = np . roll ( a , 1 , axis = 0 ) NEW_LINE if len ( a [ a != a . T ] ) == 0 : c += n NEW_LINE DEDENT print ( c ) NEW_LINE

if __name__ == ' _ _ main _ sample _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE rows = [ input ( ) for _ in range ( N ) ] NEW_LINE ans = 0 NEW_LINE for n in range ( N ) : NEW_LINE INDENT flag = False NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT num = j - n if j - n >= 0 else N + ( j - n ) NEW_LINE a = i - n if i - n >= 0 else N + ( i - n ) NEW_LINE if rows [ i ] [ num ] != rows [ j ] [ a ] : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT if flag == True : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if flag == False : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans * N ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE Sss = [ input ( ) for _ in range ( N ) ] NEW_LINE Sss_tr = list ( map ( ' ' . join , zip ( * Sss ) ) ) NEW_LINE ans = 0 NEW_LINE for k in range ( N ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if ( Sss [ i ] [ - k : ] + Sss [ i ] [ : - k ] ) != Sss_tr [ i - k ] : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans += N NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE B = [ tuple ( SI ( ) ) for _ in range ( n ) ] NEW_LINE BT = list ( zip ( * B ) ) NEW_LINE res = 0 NEW_LINE for a in range ( n ) : NEW_LINE INDENT is_good = True NEW_LINE for i in range ( n ) : NEW_LINE INDENT if B [ i ] [ n - a : ] + B [ i ] [ : n - a ] != BT [ ( i - a ) % n ] : NEW_LINE INDENT is_good = False NEW_LINE DEDENT DEDENT if is_good : NEW_LINE INDENT res += n NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

import numpy as np NEW_LINE from scipy . ndimage . interpolation import shift as scipy_shift NEW_LINE class shift : NEW_LINE INDENT def __init__ ( self , a ) : NEW_LINE INDENT self . arr = a NEW_LINE self . height = a . shape [ 0 ] NEW_LINE self . width = a . shape [ 1 ] NEW_LINE DEDENT def shifted ( self , down , right ) : NEW_LINE INDENT temp1 = self . arr [ list ( np . linspace ( - down , - down + self . height - 1 , self . height ) . astype ( np . int32 ) % self . height ) , : ] NEW_LINE temp2 = temp1 [ : , list ( np . linspace ( - right , - right + self . width - 1 , self . width ) . astype ( np . int32 ) % self . width ) ] NEW_LINE return temp2 NEW_LINE DEDENT def shifted_zero ( self , down , right ) : NEW_LINE INDENT index_vertical = np . arange ( self . height ) NEW_LINE index_horizontal = np . arange ( self . width ) NEW_LINE temp1 = self . arr [ list ( scipy_shift ( index_vertical , down , output = int , mode = ' constant ' ) ) , : ] NEW_LINE temp2 = temp1 [ : , list ( scipy_shift ( index_horizontal , right , output = int , mode = ' constant ' ) ) ] NEW_LINE return temp2 NEW_LINE DEDENT def is_sym ( self , down , right ) : NEW_LINE INDENT temp = self . shifted ( down , right ) NEW_LINE delta = temp - temp . T NEW_LINE return ( not ( delta * delta ) . sum ( ) ) NEW_LINE DEDENT DEDENT N = int ( input ( ) ) NEW_LINE array = [ list ( input ( ) ) for i in range ( N ) ] NEW_LINE array_int = np . array ( [ [ ord ( i ) for i in j ] for j in array ] ) NEW_LINE if N >= 2 : NEW_LINE INDENT count = np . array ( [ shift ( array_int ) . is_sym ( 0 , i ) * ( N - i ) for i in range ( N ) ] ) . sum ( ) + np . array ( [ shift ( array_int ) . is_sym ( i , 0 ) * ( N - i ) for i in range ( 1 , N ) ] ) . sum ( ) NEW_LINE DEDENT else : NEW_LINE INDENT count = int ( shift ( array_int ) . is_sym ( 0 , 0 ) ) NEW_LINE DEDENT print ( count ) NEW_LINE

import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE n = ni ( ) NEW_LINE grid = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT s = ns ( ) NEW_LINE s = s + s NEW_LINE grid . append ( s ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT grid . append ( grid [ i ] ) NEW_LINE DEDENT vert = [ ] NEW_LINE hrzn = [ ] NEW_LINE for i in range ( 2 * n ) : NEW_LINE INDENT hrzn . append ( grid [ i ] ) NEW_LINE DEDENT for j in range ( 2 * n ) : NEW_LINE INDENT temp = " " NEW_LINE for i in range ( 2 * n ) : NEW_LINE INDENT temp += grid [ i ] [ j : j + 1 ] NEW_LINE DEDENT vert . append ( temp ) NEW_LINE DEDENT ans = 0 NEW_LINE for a in range ( n ) : NEW_LINE INDENT for b in range ( 1 ) : NEW_LINE INDENT ok = True NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if vert [ b + i ] [ a + i : a + n ] != hrzn [ a + i ] [ b + i : b + n ] : NEW_LINE INDENT ok = False NEW_LINE break NEW_LINE DEDENT DEDENT if ok : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans * n ) NEW_LINE


import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; String s = sc . next ( ) ; int l = 0 , r = 1 ; int n = s . length ( ) ; int ans = 0 ; while ( r < n && l < n - 1 ) { if ( l == r ) r ++ ; if ( s . charAt ( l ) == ' S ' ) { if ( s . charAt ( r ) == ' T ' ) { ans ++ ; r ++ ; l ++ ; } else { r ++ ; } } else { l ++ ; } } out . println ( n - ans * 2 ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; 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 ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ASTring solver = new ASTring ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ASTring { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String x = in . string ( ) ; int ans = x . length ( ) ; int stack = 0 ; for ( char c : x . toCharArray ( ) ) { if ( c == ' S ' ) { stack ++ ; } else if ( stack > 0 ) { stack -- ; ans -= 2 ; } } out . println ( ans ) ; } } 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 . 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 ) { String s = sc . next ( ) ; ArrayDeque < Character > dq = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == ' T ' ) { if ( dq . peekFirst ( ) == null || dq . peekFirst ( ) == ' T ' ) { dq . addFirst ( c ) ; } else if ( dq . peekFirst ( ) == ' S ' ) { dq . removeFirst ( ) ; } } else if ( c == ' S ' ) { dq . addFirst ( c ) ; } } System . out . println ( dq . size ( ) ) ; } }

import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; int [ ] stacks = new int [ a . length ( ) ] ; int kaisu = 0 ; int pointer = 0 ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) == ' S ' ) { stacks [ pointer ] = 1 ; pointer ++ ; } else if ( a . charAt ( i ) == ' T ' ) { stacks [ pointer ] = 2 ; pointer ++ ; } if ( pointer >= 2 ) { if ( stacks [ pointer - 2 ] == 1 && stacks [ pointer - 1 ] == 2 ) { stacks [ pointer - 2 ] = 0 ; stacks [ pointer - 1 ] = 0 ; pointer -= 2 ; kaisu ++ ; } } } System . out . println ( ( a . length ( ) - kaisu * 2 ) ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String X = sc . next ( ) ; Deque < Character > stack = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < X . length ( ) ; i ++ ) { if ( X . charAt ( i ) == ' S ' ) { stack . push ( X . charAt ( i ) ) ; } else { if ( stack . size ( ) == 0 ) { stack . push ( X . charAt ( i ) ) ; } else if ( stack . peek ( ) == ' S ' ) { stack . pop ( ) ; } else if ( stack . peek ( ) == ' T ' ) { stack . push ( X . charAt ( i ) ) ; } } } System . out . println ( stack . size ( ) ) ; } }

s = input ( ) NEW_LINE t = [ ] NEW_LINE for a in s : NEW_LINE INDENT t . append ( a ) NEW_LINE if len ( t ) >= 2 : NEW_LINE INDENT if t [ - 2 ] == ' S ' and t [ - 1 ] == ' T ' : NEW_LINE INDENT for i in range ( 2 ) : NEW_LINE INDENT t . pop ( - 1 ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( len ( t ) ) NEW_LINE

X = input ( ) NEW_LINE from collections import deque NEW_LINE lt = deque ( ) NEW_LINE r = 0 NEW_LINE ans = 0 NEW_LINE while r < len ( X ) : NEW_LINE INDENT if ( X [ r : r + 2 ] == ' ST ' ) : NEW_LINE INDENT ans += 2 NEW_LINE r += 2 NEW_LINE continue NEW_LINE DEDENT elif ( len ( lt ) > 0 and X [ lt [ - 1 ] ] + X [ r ] == ' ST ' ) : NEW_LINE INDENT ans += 2 NEW_LINE lt . pop ( ) NEW_LINE r += 1 NEW_LINE continue NEW_LINE DEDENT if ( X [ r ] == ' S ' ) : NEW_LINE INDENT lt . append ( r ) NEW_LINE r += 1 NEW_LINE DEDENT else : NEW_LINE INDENT r += 1 NEW_LINE lt . clear ( ) NEW_LINE DEDENT DEDENT print ( len ( X ) - ans ) NEW_LINE

def solve ( s ) : NEW_LINE INDENT sums = 0 NEW_LINE sumt = 0 NEW_LINE ans = 0 NEW_LINE for i in s : NEW_LINE INDENT if i == ' S ' : NEW_LINE INDENT sums += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if sums > 0 : NEW_LINE INDENT sums -= 1 NEW_LINE ans += 2 NEW_LINE DEDENT DEDENT DEDENT return len ( s ) - ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT

S = input ( ) NEW_LINE N = len ( S ) NEW_LINE ans = N NEW_LINE stack = [ ] NEW_LINE stack . append ( S [ 0 ] ) NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if len ( stack ) != 0 and stack [ len ( stack ) - 1 ] == ' S ' and S [ i ] == ' T ' : NEW_LINE INDENT ans -= 2 NEW_LINE stack . pop ( ) NEW_LINE DEDENT elif S [ i ] == ' S ' : NEW_LINE INDENT stack . append ( S [ i ] ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

S = input ( ) NEW_LINE result = " " NEW_LINE for s in S : NEW_LINE INDENT if ( s == " T " and result == " " ) : NEW_LINE INDENT result += s NEW_LINE DEDENT elif ( s == " T " and result [ - 1 ] == " S " ) : NEW_LINE INDENT result = result [ : - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT result += s NEW_LINE DEDENT DEDENT print ( len ( result ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int i , j ; double p , q , n , a , b , c , d , ans ; int pX [ ] = new int [ 12 ] ; int pY [ ] = new int [ 12 ] ; ans = 10000000 ; p = sc . nextInt ( ) ; q = sc . nextInt ( ) ; n = sc . nextInt ( ) ; for ( i = 0 ; i < n ; i ++ ) { pX [ i ] = sc . nextInt ( ) ; pY [ i ] = sc . nextInt ( ) ; } for ( i = 0 ; i < n ; i ++ ) { j = ( i < n - 1 ) ? i + 1 : 0 ; a = pX [ j ] - pX [ i ] ; b = pY [ j ] - pY [ i ] ; c = Math . sqrt ( a * a + b * b ) ; d = ( a * ( q - pY [ i ] ) + b * ( pX [ i ] - p ) ) / c ; d = ( d >= 0 ) ? d : - d ; if ( ans > d ) ans = d ; } System . out . println ( ans ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double cx = sc . nextDouble ( ) ; double cy = sc . nextDouble ( ) ; int N = sc . nextInt ( ) ; double [ ] x = new double [ N + 2 ] ; double [ ] y = new double [ N + 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextDouble ( ) ; y [ i ] = sc . nextDouble ( ) ; } double min = 100000000 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { double l = dist ( x [ i ] , x [ i + 1 ] , y [ i ] , y [ i + 1 ] , cx , cy ) ; min = Math . min ( l , min ) ; } double l = dist ( x [ N - 1 ] , x [ 0 ] , y [ N - 1 ] , y [ 0 ] , cx , cy ) ; min = Math . min ( l , min ) ; System . out . println ( min ) ; } public static double dist ( double x1 , double x2 , double y1 , double y2 , double x , double y ) { if ( x1 == x2 ) { return Math . abs ( x - x1 ) ; } else if ( y1 == y2 ) { return Math . abs ( y - y1 ) ; } else { double a = ( y1 - y2 ) / ( x1 - x2 ) ; double b = y1 - a * x1 ; return Math . abs ( y - a * x - b ) / Math . sqrt ( 1 + a * a ) ; } } }

import cmath , sys NEW_LINE t_x , t_y = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE poly = [ list ( map ( int , e . split ( ) ) ) for e in sys . stdin ] NEW_LINE ans = 10000 NEW_LINE for i in range ( N ) : NEW_LINE INDENT p1 , p2 = poly [ i - 1 ] , poly [ i ] NEW_LINE p = complex ( p2 [ 0 ] - p1 [ 0 ] , p2 [ 1 ] - p1 [ 1 ] ) NEW_LINE t = complex ( t_x - p1 [ 0 ] , t_y - p1 [ 1 ] ) NEW_LINE t *= p . conjugate ( ) / abs ( p ) NEW_LINE dist = abs ( t . imag ) NEW_LINE if dist < ans : NEW_LINE INDENT ans = dist NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

from math import sqrt NEW_LINE x , y = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * N ] NEW_LINE a += [ a [ 0 ] ] NEW_LINE ans = float ( " inf " ) NEW_LINE for ( x1 , y1 ) , ( x2 , y2 ) in zip ( a , a [ 1 : ] ) : NEW_LINE INDENT if x1 == x2 : NEW_LINE INDENT d = abs ( x - x1 ) NEW_LINE DEDENT elif y1 == y2 : NEW_LINE INDENT d = abs ( y - y1 ) NEW_LINE DEDENT else : NEW_LINE INDENT inc = ( y2 - y1 ) / ( x2 - x1 ) NEW_LINE a = inc NEW_LINE b = - 1 NEW_LINE c = - inc * x1 + y1 NEW_LINE d = abs ( ( a * x + b * y + c ) / sqrt ( a ** 2 + b ** 2 ) ) NEW_LINE DEDENT ans = min ( ans , d ) NEW_LINE DEDENT print ( ans ) NEW_LINE

class Vector : NEW_LINE INDENT def __init__ ( self , x , y ) : NEW_LINE INDENT self . x = x NEW_LINE self . y = y NEW_LINE DEDENT def __add__ ( self , other ) : NEW_LINE INDENT return Vector ( self . x + other . x , self . y + other . y ) NEW_LINE DEDENT def __sub__ ( self , other ) : NEW_LINE INDENT return Vector ( self . x - other . x , self . y - other . y ) NEW_LINE DEDENT def __mult__ ( self , scaler ) : NEW_LINE INDENT return Vector ( self . x * scaler , self . y * scaler ) NEW_LINE DEDENT def dot ( self , other ) : NEW_LINE INDENT return self . x * other . x + self . y * other . y NEW_LINE DEDENT def length ( self ) : NEW_LINE INDENT return self . dot ( self ) ** 0.5 NEW_LINE DEDENT def abs_cross ( self , other ) : NEW_LINE INDENT return abs ( self . x * other . y - self . y * other . x ) NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE xy = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT xi , yi = map ( int , input ( ) . split ( ) ) NEW_LINE xy . append ( ( xi - x , yi - y ) ) NEW_LINE DEDENT xy . append ( xy [ 0 ] ) NEW_LINE del x , y NEW_LINE mi = 999999999.0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT v1 = Vector ( * xy [ i ] ) NEW_LINE v2 = Vector ( * xy [ i + 1 ] ) NEW_LINE mi = min ( mi , v1 . length ( ) ) NEW_LINE if cross_orthogonal ( v1 , v2 ) : NEW_LINE INDENT mi = min ( mi , dist_orthogonal ( v1 , v2 ) ) NEW_LINE DEDENT DEDENT print ( mi ) NEW_LINE DEDENT def cross_orthogonal ( v1 , v2 ) : NEW_LINE INDENT v3 = v2 - v1 NEW_LINE return v1 . dot ( v3 ) * v2 . dot ( v3 ) < 0 NEW_LINE DEDENT def dist_orthogonal ( v1 , v2 ) : NEW_LINE INDENT return v1 . abs_cross ( v2 ) / ( v2 - v1 ) . length ( ) NEW_LINE DEDENT main ( ) NEW_LINE

def b_ant ( X , Y , N , Pos ) : NEW_LINE INDENT import numpy NEW_LINE import math NEW_LINE pos_initial = numpy . array ( [ X , Y ] ) NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT v1 = numpy . array ( Pos [ i ] ) NEW_LINE v2 = numpy . array ( Pos [ ( i + 1 ) % N ] ) NEW_LINE vec_edge = v2 - v1 NEW_LINE vec_init = pos_initial - v1 NEW_LINE vec_edge_norm = numpy . linalg . norm ( vec_edge ) NEW_LINE vec_init_norm = numpy . linalg . norm ( vec_init ) NEW_LINE theta = math . acos ( numpy . dot ( vec_edge , vec_init ) / ( vec_edge_norm * vec_init_norm ) ) NEW_LINE ans = min ( ans , vec_init_norm * math . sin ( theta ) ) NEW_LINE DEDENT ans = round ( ans , 10 ) NEW_LINE return ans NEW_LINE DEDENT X , Y = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE Pos = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( N ) ] NEW_LINE print ( b_ant ( X , Y , N , Pos ) ) NEW_LINE

import numpy as np NEW_LINE from numpy import * NEW_LINE def distance_l ( a , b , c ) : NEW_LINE INDENT u = np . array ( [ b [ 0 ] - a [ 0 ] , b [ 1 ] - a [ 1 ] ] ) NEW_LINE v = np . array ( [ c [ 0 ] - a [ 0 ] , c [ 1 ] - a [ 1 ] ] ) NEW_LINE L = abs ( cross ( u , v ) / linalg . norm ( u ) ) NEW_LINE return L NEW_LINE DEDENT def distance_seg ( a , b , c ) : NEW_LINE INDENT u = np . array ( [ b [ 0 ] - a [ 0 ] , b [ 1 ] - a [ 1 ] ] ) NEW_LINE v = np . array ( [ c [ 0 ] - a [ 0 ] , c [ 1 ] - a [ 1 ] ] ) NEW_LINE w = np . array ( [ c [ 0 ] - b [ 0 ] , c [ 1 ] - b [ 1 ] ] ) NEW_LINE res = 0 NEW_LINE if dot ( u , v ) <= 0 : NEW_LINE INDENT res = linalg . norm ( v ) NEW_LINE DEDENT elif dot ( - u , w ) <= 0 : NEW_LINE INDENT res = linalg . norm ( w ) NEW_LINE DEDENT else : NEW_LINE INDENT res = distance_l ( a , b , c ) NEW_LINE DEDENT return res NEW_LINE DEDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE px = [ 0 ] * N NEW_LINE py = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT px [ i ] , py [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT res = float ( ' inf ' ) NEW_LINE u = np . array ( [ x , y ] ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT j = ( i + 1 ) % N NEW_LINE v = np . array ( [ px [ i ] , py [ i ] ] ) NEW_LINE w = np . array ( [ px [ j ] , py [ j ] ] ) NEW_LINE curr = distance_seg ( v , w , u ) NEW_LINE res = min ( res , curr ) NEW_LINE DEDENT print ( res ) NEW_LINE


import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; TreeSet < Integer > set = new TreeSet < > ( ) ; for ( int i = a ; i <= Math . min ( b , a + k - 1 ) ; i ++ ) set . add ( i ) ; for ( int i = b ; i >= Math . max ( a , b - k + 1 ) ; i -- ) set . add ( i ) ; set . forEach ( out :: println ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . HashSet ; import java . util . Set ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int c = Integer . parseInt ( tokenizer . nextToken ( ) ) ; Set < Integer > hashSet = new HashSet < > ( ) ; StringBuilder out = new StringBuilder ( ) ; for ( int i = a ; i < a + c && i <= b ; i ++ ) { if ( ! hashSet . contains ( i ) ) { out . append ( i ) . append ( " \n " ) ; hashSet . add ( i ) ; } } for ( int i = b - c + 1 ; i <= b && i > a ; i ++ ) { if ( ! hashSet . contains ( i ) ) { out . append ( i ) . append ( " \n " ) ; hashSet . add ( i ) ; } } System . out . print ( out ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; for ( int i = a ; i <= a + k - 1 && i <= b ; i ++ ) { System . out . println ( i ) ; if ( i == a + k - 1 || i == b ) { i ++ ; for ( int j = Math . max ( i , b - k + 1 ) ; j <= b ; j ++ ) System . out . println ( j ) ; } } } }

import java . io . * ; import java . util . Arrays ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] input = Arrays . stream ( stdin . readLine ( ) . split ( " ▁ " ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; IntStream . rangeClosed ( input [ 0 ] , input [ 1 ] ) . filter ( i -> { int order = i - input [ 0 ] ; if ( order < input [ 2 ] || input [ 1 ] - input [ 0 ] - input [ 2 ] < order ) return true ; else return false ; } ) . forEach ( System . out :: println ) ; } }

import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > array = new ArrayList < > ( ) ; for ( int i = 0 ; i < K ; i ++ ) { if ( A + i <= B ) array . add ( A + i ) ; } for ( int i = K - 1 ; i >= 0 ; i -- ) { if ( ! array . contains ( B - i ) && B - i >= A ) array . add ( B - i ) ; } for ( int i = 0 ; i < array . size ( ) ; i ++ ) { System . out . println ( array . get ( i ) ) ; } } }

a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE res = [ ] NEW_LINE for i in range ( a , min ( a + k , b ) ) : NEW_LINE INDENT res . append ( i ) NEW_LINE DEDENT for j in range ( max ( a , b - k + 1 ) , b + 1 ) : NEW_LINE INDENT res . append ( j ) NEW_LINE DEDENT res = sorted ( set ( res ) ) NEW_LINE for i in res : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT

lists = input ( ) . split ( ) NEW_LINE a = int ( lists [ 0 ] ) NEW_LINE b = int ( lists [ 1 ] ) NEW_LINE x = int ( lists [ 2 ] ) * 2 NEW_LINE answer = [ ] NEW_LINE next = 0 NEW_LINE for num in range ( 0 , x ) : NEW_LINE INDENT if ( a == b ) : NEW_LINE INDENT answer . append ( a ) NEW_LINE break NEW_LINE DEDENT answer . append ( a ) NEW_LINE answer . append ( b ) NEW_LINE a += 1 NEW_LINE b -= 1 NEW_LINE if ( len ( answer ) >= x or a > b or b < 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT if ( a == b ) : NEW_LINE INDENT answer . append ( a ) NEW_LINE if ( a + num < b - num ) : NEW_LINE INDENT for b_num in range ( b , a ) : NEW_LINE INDENT answer . append ( b_num ) NEW_LINE if ( len ( answer ) > x ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT elif ( a + num > b - num ) : NEW_LINE INDENT for a_num in range ( a , b ) : NEW_LINE INDENT answer . append ( a_num ) NEW_LINE if ( len ( answer ) > x ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT break NEW_LINE DEDENT DEDENT answer . sort ( ) NEW_LINE for a in answer : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT

a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE if b - a < k * 2 : NEW_LINE INDENT for i in range ( a , b + 1 ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( a , b + 1 ) [ : k ] : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT for i in range ( a , b + 1 ) [ - k : ] : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT

import sys NEW_LINE input = sys . stdin . readline NEW_LINE a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE if b - a + 1 >= 2 * k : NEW_LINE INDENT for i in range ( 0 , k ) : NEW_LINE INDENT print ( a + i ) NEW_LINE DEDENT for i in range ( k - 1 , - 1 , - 1 ) : NEW_LINE INDENT print ( b - i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( a , b + 1 ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT

a , b , k = map ( int , input ( ) . split ( ) ) NEW_LINE N = [ int ( i ) for i in range ( a , min ( a + k , b + 1 ) ) ] NEW_LINE M = [ int ( i ) for i in range ( max ( a , b - k + 1 ) , b + 1 ) ] NEW_LINE print ( * sorted ( set ( M + N ) ) , sep = " \n " ) 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 ans = ( int ) 1e9 ; if ( n == 1 ) { ans = 0 ; System . out . println ( ans ) ; return ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 1 ; i + j <= n && i * j <= n ; j ++ ) { int x = Math . abs ( i - j ) ; int v = i * j ; int res = n - v ; int sum = x + res ; if ( res >= 0 && sum < ans ) { ans = sum ; } } } System . out . println ( ans ) ; } }

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 ) { int ans = Integer . MAX_VALUE ; int n = in . nextInt ( ) ; for ( int h = 1 ; h <= n ; h ++ ) { int w = n / h ; ans = Math . min ( ans , n - h * w + Math . abs ( h - w ) ) ; } out . println ( ans ) ; } } 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 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; 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 ; 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 ) { int n = in . ints ( ) ; int score = 10000000 ; for ( int i = 1 ; i <= n ; i ++ ) { int h = n / i ; int ns = Math . abs ( h - i ) + n - h * i ; score = Math . min ( ns , score ) ; } out . println ( score ) ; } } 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 ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }

import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int hen = 1 ; int min = 20000000 ; while ( ! ( hen * hen > n ) ) { hen ++ ; } hen -- ; while ( hen != 0 ) { min = Math . min ( ( n - n / hen * hen ) + ( n / hen - hen ) , min ) ; hen -- ; } System . out . println ( min ) ; sc . close ( ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int A = reader . nextInt ( ) ; int base = getMaxSqueaBase ( A ) ; int min = A - ( int ) Math . pow ( base , 2 ) ; if ( min > 0 ) { for ( int i = base ; i > 0 ; i -- ) { int remain = A - ( int ) Math . pow ( i , 2 ) ; int tmp = 0 ; while ( i <= remain ) { remain -= i ; tmp ++ ; } if ( remain + tmp < min ) { min = remain + tmp ; } } } System . out . println ( min ) ; reader . close ( ) ; } public static int getMaxSqueaBase ( int num ) { int base = 1 ; while ( Math . pow ( ( base + 1 ) , 2 ) <= num ) { base ++ ; } return base ; } }

n = int ( input ( ) ) NEW_LINE s = int ( n ** 0.5 ) NEW_LINE best = 10 ** 9 NEW_LINE for i in range ( s , 0 , - 1 ) : NEW_LINE INDENT q , m = divmod ( n , i ) NEW_LINE best = min ( best , abs ( i - q ) + m ) NEW_LINE DEDENT print ( best ) NEW_LINE

def rect_rect_rect_rect_rect ( n : int ) -> int : NEW_LINE INDENT h = 1 NEW_LINE min_d = float ( ' inf ' ) NEW_LINE while h * h <= n : NEW_LINE INDENT w = n // h NEW_LINE min_d = min ( abs ( h - w ) + ( n - w * h ) , min_d ) NEW_LINE h += 1 NEW_LINE DEDENT return min_d NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE ans = rect_rect_rect_rect_rect ( n ) NEW_LINE print ( ans ) NEW_LINE DEDENT

import sys NEW_LINE import math NEW_LINE def solve ( n : int ) : NEW_LINE INDENT ans = n NEW_LINE for i in range ( 1 , int ( math . sqrt ( n ) ) + 1 ) : NEW_LINE INDENT w = int ( n / i ) NEW_LINE ans = min ( ans , abs ( i - w ) + n - ( i * w ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE n = int ( next ( tokens ) ) NEW_LINE solve ( n ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

n = int ( input ( ) ) NEW_LINE mnsk = [ ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for h in range ( 1 , n + 1 ) : NEW_LINE INDENT if i * h <= n : NEW_LINE INDENT mnsk . append ( n - i * h + abs ( i - h ) ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( min ( mnsk ) ) NEW_LINE

from math import sqrt NEW_LINE n = int ( input ( ) ) NEW_LINE ans = 10 ** 9 NEW_LINE for i in range ( 1 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT ans = min ( ans , n - i * ( n // i ) + abs ( i - ( n // i ) ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean [ ] a = new boolean [ N + 1 ] ; long odd = 0 ; long even = 0 ; long max = Long . MIN_VALUE ; int mp = - 1 ; for ( int i = 1 ; i <= N ; ++ i ) { long temp = sc . nextLong ( ) ; if ( temp > max ) { max = temp ; mp = i ; } if ( temp > 0 ) { a [ i ] = true ; if ( i % 2 == 1 ) odd += temp ; else even += temp ; } } if ( odd == 0 && even == 0 ) { System . out . println ( max ) ; System . out . println ( N - 1 ) ; for ( int i = N ; i > mp ; -- i ) { System . out . println ( i ) ; } for ( int i = 1 ; i < mp ; ++ i ) { System . out . println ( 1 ) ; } return ; } System . out . println ( Math . max ( odd , even ) ) ; int offset = odd > even ? 1 : 0 ; int p = N ; ArrayList < Integer > al = new ArrayList < Integer > ( ) ; while ( ! a [ p ] || ( p + offset ) % 2 != 0 ) { al . add ( p ) ; p -- ; } int left = 0 ; while ( ! a [ left ] || ( left + offset ) % 2 != 0 ) left ++ ; for ( int i = p - 2 ; i >= left ; i -= 2 ) { if ( a [ i ] ) al . add ( i + 1 ) ; else al . add ( i ) ; } for ( int i = 1 ; i < left ; ++ i ) al . add ( 1 ) ; System . out . println ( al . size ( ) ) ; for ( int i = 0 ; i < al . size ( ) ; i ++ ) { System . out . println ( al . get ( i ) ) ; } return ; } }

N = int ( input ( ) ) NEW_LINE * A , = map ( int , input ( ) . split ( ) ) NEW_LINE def calc ( A ) : NEW_LINE INDENT if len ( A ) == 1 : NEW_LINE INDENT return [ ] , A [ 0 ] NEW_LINE DEDENT res = [ ] NEW_LINE if len ( A ) % 2 == 0 : NEW_LINE INDENT res . append ( len ( A ) ) NEW_LINE A = A [ : - 1 ] NEW_LINE DEDENT if all ( a <= 0 for a in A [ : : 2 ] ) : NEW_LINE INDENT ma = max ( A [ : : 2 ] ) NEW_LINE i = 0 NEW_LINE while A [ i ] != ma : NEW_LINE INDENT i += 1 NEW_LINE res . append ( 1 ) NEW_LINE DEDENT j = len ( A ) NEW_LINE while i < j - 1 : NEW_LINE INDENT res . append ( j - i ) NEW_LINE j -= 1 NEW_LINE DEDENT return res , ma NEW_LINE DEDENT l = 0 ; r = len ( A ) NEW_LINE while A [ 0 ] < 0 : NEW_LINE INDENT res . append ( 1 ) NEW_LINE res . append ( 1 ) NEW_LINE A = A [ 2 : ] NEW_LINE DEDENT v = 0 NEW_LINE while len ( A ) > 2 : NEW_LINE INDENT if A [ 2 ] < 0 : NEW_LINE INDENT res . append ( 3 ) NEW_LINE if len ( A ) > 4 : NEW_LINE INDENT A = A [ : 2 ] + A [ 4 : ] NEW_LINE DEDENT else : NEW_LINE INDENT A = A [ : 2 ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res . append ( 2 ) NEW_LINE A [ 2 ] += A [ 0 ] NEW_LINE A = A [ 2 : ] NEW_LINE DEDENT DEDENT if len ( A ) > 1 : NEW_LINE INDENT res . append ( 2 ) NEW_LINE DEDENT return res , A [ 0 ] NEW_LINE DEDENT r , v = calc ( A ) NEW_LINE if len ( A ) > 1 : NEW_LINE INDENT r0 , v0 = calc ( A [ 1 : ] ) NEW_LINE if v < v0 : NEW_LINE INDENT r = [ 1 ] + r0 NEW_LINE v = v0 NEW_LINE DEDENT DEDENT print ( v , len ( r ) , * r , sep = ' \n ' ) NEW_LINE

def solve ( n , aaa ) : NEW_LINE INDENT odd_idx , even_idx = [ ] , [ ] NEW_LINE odd_sum , even_sum = 0 , 0 NEW_LINE for i in range ( 0 , n , 2 ) : NEW_LINE INDENT if aaa [ i ] > 0 : NEW_LINE INDENT even_idx . append ( i ) NEW_LINE even_sum += aaa [ i ] NEW_LINE DEDENT DEDENT for i in range ( 1 , n , 2 ) : NEW_LINE INDENT if aaa [ i ] > 0 : NEW_LINE INDENT odd_idx . append ( i ) NEW_LINE odd_sum += aaa [ i ] NEW_LINE DEDENT DEDENT if odd_sum < even_sum : NEW_LINE INDENT ans = even_sum NEW_LINE idx = even_idx NEW_LINE DEDENT else : NEW_LINE INDENT ans = odd_sum NEW_LINE idx = odd_idx NEW_LINE DEDENT if ans == 0 : NEW_LINE INDENT import numpy as np NEW_LINE i = np . argmax ( aaa ) NEW_LINE ans = aaa [ i ] NEW_LINE buf = list ( range ( n , i + 1 , - 1 ) ) + [ 1 ] * i NEW_LINE return ans , buf NEW_LINE DEDENT j = idx [ - 1 ] NEW_LINE buf = list ( range ( n , j + 1 , - 1 ) ) NEW_LINE for i in idx [ - 2 : : - 1 ] : NEW_LINE INDENT buf . extend ( range ( ( i + j ) // 2 + 1 , i + 1 , - 1 ) ) NEW_LINE j = i NEW_LINE DEDENT buf += [ 1 ] * idx [ 0 ] NEW_LINE return ans , buf NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE aaa = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans , buf = solve ( n , aaa ) NEW_LINE print ( ans ) NEW_LINE print ( len ( buf ) ) NEW_LINE print ( ' \n ' . join ( map ( str , buf ) ) ) NEW_LINE

import sys NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ ( int ( v ) , i ) for i , v in enumerate ( input ( ) . split ( ) ) ] NEW_LINE ao = sum ( [ v for v , i in a if i % 2 and v > 0 ] ) NEW_LINE ae = sum ( [ v for v , i in a if not i % 2 and v > 0 ] ) NEW_LINE if max ( ao , ae ) == 0 : NEW_LINE INDENT ai = a . index ( max ( a ) ) NEW_LINE Ans = [ 1 ] * ( ai ) + list ( range ( N - ai , 1 , - 1 ) ) NEW_LINE print ( max ( a ) [ 0 ] ) NEW_LINE print ( len ( Ans ) ) NEW_LINE for i in Ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT if ao >= ae : NEW_LINE INDENT print ( ao ) NEW_LINE yn = [ i for v , i in a if i % 2 and v > 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT print ( ae ) NEW_LINE yn = [ i for v , i in a if not i % 2 and v > 0 ] NEW_LINE DEDENT listyn = [ i in yn for i in range ( N ) ] NEW_LINE Ans = [ ] NEW_LINE while not listyn [ 0 ] : NEW_LINE INDENT Ans . append ( 1 ) NEW_LINE listyn = listyn [ 1 : ] NEW_LINE DEDENT while not listyn [ - 1 ] : NEW_LINE INDENT Ans . append ( len ( listyn ) ) NEW_LINE listyn = listyn [ : - 1 ] NEW_LINE DEDENT while True : NEW_LINE INDENT if len ( listyn ) == 1 : NEW_LINE INDENT break NEW_LINE DEDENT if len ( listyn ) == [ 2 , 3 ] : NEW_LINE INDENT Ans . append ( 2 ) NEW_LINE break NEW_LINE DEDENT if listyn [ 2 ] : NEW_LINE INDENT Ans . append ( 2 ) NEW_LINE listyn = [ True ] + listyn [ 3 : ] NEW_LINE DEDENT else : NEW_LINE INDENT Ans . append ( 3 ) NEW_LINE listyn = [ True , False ] + listyn [ 4 : ] NEW_LINE DEDENT DEDENT print ( len ( Ans ) ) NEW_LINE for i in Ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT

n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE use = [ False ] * n NEW_LINE mx = max ( a ) NEW_LINE if mx < 0 : NEW_LINE INDENT use [ a . index ( mx ) ] = True NEW_LINE DEDENT else : NEW_LINE INDENT evn = sum ( max ( i , 0 ) for i in a [ : : 2 ] ) NEW_LINE odd = sum ( max ( i , 0 ) for i in a [ 1 : : 2 ] ) NEW_LINE mx = max ( evn , odd ) NEW_LINE for i in range ( int ( evn < odd ) , n , 2 ) : NEW_LINE INDENT if a [ i ] > 0 : NEW_LINE INDENT use [ i ] = True NEW_LINE DEDENT DEDENT DEDENT print ( mx ) NEW_LINE beg = 0 NEW_LINE while not use [ beg ] : NEW_LINE INDENT beg += 1 NEW_LINE DEDENT res = [ 1 ] * beg NEW_LINE end = n - 1 NEW_LINE while beg < end : NEW_LINE INDENT if use [ end ] : NEW_LINE INDENT if use [ end - 2 ] : NEW_LINE INDENT a [ end - 2 ] += a [ end ] NEW_LINE res . append ( end - beg ) NEW_LINE end -= 2 NEW_LINE use [ end ] = True NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( end - beg - 1 ) NEW_LINE a [ end - 2 ] = a [ end ] NEW_LINE end -= 2 NEW_LINE use [ end ] = True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT res . append ( end - beg + 1 ) NEW_LINE end -= 1 NEW_LINE DEDENT DEDENT print ( len ( res ) ) NEW_LINE for i in res : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT

n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE mx = max ( a ) NEW_LINE a [ a . index ( mx ) ] = abs ( mx ) NEW_LINE evn = sum ( max ( 0 , i ) for i in a [ : : 2 ] ) NEW_LINE odd = sum ( max ( 0 , i ) for i in a [ 1 : : 2 ] ) NEW_LINE if mx < 0 : NEW_LINE INDENT print ( mx ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( max ( evn , odd ) ) NEW_LINE DEDENT oe = int ( evn < odd ) NEW_LINE res = [ ] NEW_LINE beg = 0 NEW_LINE while beg % 2 != oe or a [ beg ] < 0 : NEW_LINE INDENT res . append ( 1 ) NEW_LINE beg += 1 NEW_LINE DEDENT end = n - 1 NEW_LINE while end % 2 != oe or a [ end ] < 0 : NEW_LINE INDENT res . append ( end - beg + 1 ) NEW_LINE end -= 1 NEW_LINE DEDENT while beg < end : NEW_LINE INDENT if a [ end - 2 ] < 0 : NEW_LINE INDENT res . append ( end - beg - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( end - beg ) NEW_LINE DEDENT end -= 2 NEW_LINE DEDENT print ( len ( res ) ) NEW_LINE for i in res : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT