import java . util . ArrayList ; import java . util . List ; import java . util . Optional ; import java . util . Scanner ; public class Main { private static final String TLE = " TLE " ; public static String process ( TestCase testCase ) { final int N = testCase . N ; final int T = testCase . T ; final List < Integer > c = testCase . c ; final List < Integer > t = testCase . t ; Optional < Integer > minCost = Optional . empty ( ) ; for ( int i = 0 ; i < N ; ++ i ) { final int cost = c . get ( i ) ; final int time = t . get ( i ) ; if ( time <= T ) { if ( minCost . isPresent ( ) ) { minCost = minCost . map ( curr -> Math . min ( curr , cost ) ) ; } else { minCost = Optional . of ( cost ) ; } } } return minCost . map ( String :: valueOf ) . orElse ( TLE ) ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final String result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; List < Integer > c = new ArrayList < > ( ) ; List < Integer > t = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { c . add ( sc . nextInt ( ) ) ; t . add ( sc . nextInt ( ) ) ; } return new TestCase ( N , T , c , t ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final int N ; final int T ; final List < Integer > c ; final List < Integer > t ; public TestCase ( int N , int T , List < Integer > c , List < Integer > t ) { this . N = N ; this . T = T ; this . c = c ; this . t = t ; } } }


N , T = [ int ( elem ) for elem in input ( ) . split ( ) ] NEW_LINE min_cost = None NEW_LINE min_cost_time = None NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT c , t = [ int ( elem ) for elem in input ( ) . split ( ) ] NEW_LINE if t <= T : NEW_LINE INDENT if min_cost is None : NEW_LINE INDENT min_cost = c NEW_LINE min_cost_time = t NEW_LINE DEDENT else : NEW_LINE INDENT if c < min_cost : NEW_LINE INDENT min_cost = c NEW_LINE min_cost_time = t NEW_LINE DEDENT DEDENT DEDENT DEDENT if min_cost is None : NEW_LINE INDENT print ( ' TLE ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( min_cost ) NEW_LINE DEDENT


N , T = map ( int , input ( ) . split ( ) ) NEW_LINE m = min ( [ c if t <= T else 9999 for c , t in [ map ( int , input ( ) . split ( ) ) for _ in range ( N ) ] ] ) NEW_LINE print ( " TLE " if m == 9999 else m ) NEW_LINE


import sys NEW_LINE def solve ( N : int , T : int , c : " List [ int ] " , t : " List [ int ] " ) : NEW_LINE INDENT ret = float ( ' inf ' ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if t [ i ] <= T : NEW_LINE INDENT ret = min ( ret , c [ i ] ) NEW_LINE DEDENT DEDENT if ret == float ( ' inf ' ) : NEW_LINE INDENT print ( ' TLE ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ret ) NEW_LINE DEDENT 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 T = int ( next ( tokens ) ) NEW_LINE c = [ int ( ) ] * ( N ) NEW_LINE t = [ int ( ) ] * ( N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT c [ i ] = int ( next ( tokens ) ) NEW_LINE t [ i ] = int ( next ( tokens ) ) NEW_LINE DEDENT solve ( N , T , c , t ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import sys NEW_LINE ans = sys . maxsize NEW_LINE N , T = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT c , t = map ( int , input ( ) . split ( ) ) NEW_LINE if t <= T : NEW_LINE INDENT ans = min ( ans , c ) NEW_LINE DEDENT DEDENT if ans == sys . maxsize : NEW_LINE INDENT print ( " TLE " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ans ) NEW_LINE DEDENT


import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int t = Integer . parseInt ( sc . next ( ) ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int c = Integer . parseInt ( sc . next ( ) ) ; int time = Integer . parseInt ( sc . next ( ) ) ; if ( time <= t ) { map . put ( c , time ) ; } } int min = Integer . MAX_VALUE ; for ( Map . Entry < Integer , Integer > entry : map . entrySet ( ) ) { min = Math . min ( entry . getKey ( ) , min ) ; } System . out . println ( min == Integer . MAX_VALUE ? " TLE " : min ) ; } }

import sys NEW_LINE import copy NEW_LINE from bisect import bisect_left NEW_LINE def main ( ) : NEW_LINE INDENT N , T = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE CT = [ ] NEW_LINE isOK = False NEW_LINE for _ in range ( N ) : NEW_LINE INDENT c , t = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE if t <= T : NEW_LINE INDENT isOK = True NEW_LINE CT . append ( ( c , t ) ) NEW_LINE DEDENT DEDENT if isOK == False : NEW_LINE INDENT print ( " TLE " ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT CT . sort ( ) NEW_LINE c , t = CT [ 0 ] NEW_LINE print ( c ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int min = 10000000 ; while ( N -- > 0 ) { int c = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; if ( t <= T && c < min ) { min = c ; } } System . out . println ( min == 10000000 ? " TLE " : min ) ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] hairetu1 = new int [ N ] ; int [ ] hairetu2 = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { hairetu1 [ i ] = sc . nextInt ( ) ; hairetu2 [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( hairetu2 [ i ] <= T ) { count ++ ; } } if ( count == 0 ) { System . out . println ( " TLE " ) ; System . exit ( 0 ) ; } int z = 0 ; int [ ] hairetu3 = new int [ count ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( hairetu2 [ i ] <= T ) { hairetu3 [ z ] = hairetu1 [ i ] ; z ++ ; } } int min = hairetu3 [ 0 ] ; for ( int i = 0 ; i < count ; i ++ ) { if ( min > hairetu3 [ i ] ) { min = hairetu3 [ i ] ; } } System . out . println ( min ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String [ ] arr = new String [ 6 ] ; arr [ 0 ] = "1" ; arr [ 1 ] = "2" ; arr [ 2 ] = "3" ; arr [ 3 ] = "4" ; arr [ 4 ] = "5" ; arr [ 5 ] = "6" ; String r = " " ; int c = N % 30 ; for ( int i = 0 ; i < c ; i ++ ) { r = arr [ ( i % 5 ) ] ; arr [ ( i % 5 ) ] = arr [ ( i % 5 ) + 1 ] ; arr [ ( i % 5 ) + 1 ] = r ; } System . out . println ( arr [ 0 ] + arr [ 1 ] + arr [ 2 ] + arr [ 3 ] + arr [ 4 ] + arr [ 5 ] ) ; } }

import re NEW_LINE n = int ( input ( ) ) NEW_LINE card = [ i + 1 for i in range ( 6 ) ] NEW_LINE for i in range ( n % 30 ) : NEW_LINE INDENT card [ ( i % 5 ) ] , card [ ( i % 5 ) + 1 ] = card [ ( i % 5 ) + 1 ] , card [ ( i % 5 ) ] NEW_LINE DEDENT print ( re . sub ( r ' \D ' , ' ' , str ( card ) ) ) NEW_LINE


card = list ( range ( 1 , 7 ) ) NEW_LINE N = int ( input ( ) ) % 30 NEW_LINE for i in range ( N ) : NEW_LINE INDENT tmp = card [ i % 5 ] NEW_LINE card [ i % 5 ] = card [ ( i % 5 ) + 1 ] NEW_LINE card [ ( i % 5 ) + 1 ] = tmp NEW_LINE DEDENT for i in range ( 6 ) : NEW_LINE INDENT print ( card [ i ] , end = " " ) NEW_LINE DEDENT


import math NEW_LINE N = int ( input ( ) ) NEW_LINE MovingCardNum = math . floor ( N / 5 ) % 6 + 1 NEW_LINE List = list ( range ( MovingCardNum + 1 , 7 ) ) + list ( range ( 1 , MovingCardNum + 1 ) ) NEW_LINE idx = N % 5 NEW_LINE List [ ( idx + 1 ) : 6 ] = List [ idx : 5 ] NEW_LINE List [ idx ] = MovingCardNum NEW_LINE print ( ' ' . join ( [ str ( x ) for x in List ] ) ) NEW_LINE


N = int ( input ( ) ) % 30 NEW_LINE card = [ '1' , '2' , '3' , '4' , '5' , '6' ] NEW_LINE def sort ( Card , n ) : NEW_LINE INDENT tmp = n // 5 NEW_LINE idx = n % 5 NEW_LINE for i in range ( tmp ) : NEW_LINE INDENT Card . append ( Card . pop ( 0 ) ) NEW_LINE DEDENT Card . insert ( idx , Card . pop ( 0 ) ) NEW_LINE print ( ' ' . join ( Card ) ) NEW_LINE DEDENT sort ( card , N ) NEW_LINE


n = int ( input ( ) ) NEW_LINE N = n % 30 NEW_LINE I = N // 5 NEW_LINE i = N % 5 NEW_LINE number = [ [ 1 , 2 , 3 , 4 , 5 , 6 ] , [ 2 , 3 , 4 , 5 , 6 , 1 ] , [ 3 , 4 , 5 , 6 , 1 , 2 ] , [ 4 , 5 , 6 , 1 , 2 , 3 ] , [ 5 , 6 , 1 , 2 , 3 , 4 ] , [ 6 , 1 , 2 , 3 , 4 , 5 ] ] NEW_LINE for s in range ( 0 , i ) : NEW_LINE INDENT number [ I ] [ s ] , number [ I ] [ s + 1 ] = number [ I ] [ s + 1 ] , number [ I ] [ s ] NEW_LINE DEDENT number_str = " " NEW_LINE for t in number [ I ] : NEW_LINE INDENT number_str += str ( t ) NEW_LINE DEDENT print ( number_str ) NEW_LINE


import java . util . * ; public class Main { static int num [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int count = sc . nextInt ( ) % 30 ; for ( int i = 0 ; i < count ; i ++ ) { replace ( i ) ; } for ( int i = 0 ; i < 6 ; i ++ ) { System . out . print ( num [ i ] ) ; } System . out . println ( ) ; } public static void replace ( int a ) { a %= 5 ; int tmp = num [ a ] ; num [ a ] = num [ a + 1 ] ; num [ a + 1 ] = tmp ; } }


import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; private static void swap ( int [ ] a , int i ) { int tmp = a [ i ] ; a [ i ] = a [ i + 1 ] ; a [ i + 1 ] = tmp ; } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int [ ] c = { 1 , 2 , 3 , 4 , 5 , 6 } ; n %= 30 ; for ( int i = 0 ; i < n ; i ++ ) { swap ( c , i % 5 ) ; } for ( int x : c ) { out . print ( x ) ; } out . println ( ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Map < Integer , String > map = new HashMap < > ( ) ; StringBuilder str = new StringBuilder ( "123456" ) ; for ( int i = 0 ; i < 30 ; i ++ ) { map . put ( i , str . toString ( ) ) ; int x = i % 5 ; int y = x + 1 ; char tmp = str . charAt ( x ) ; str . setCharAt ( x , str . charAt ( y ) ) ; str . setCharAt ( y , tmp ) ; } Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) % 30 ; System . out . println ( map . get ( n ) ) ; } }


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 ( ) ; N %= 30 ; int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; for ( int i = 0 ; i < N ; i ++ ) { int j1 = i % 5 ; int j2 = i % 5 + 1 ; int tmp = arr [ j1 ] ; arr [ j1 ] = arr [ j2 ] ; arr [ j2 ] = tmp ; } StringBuilder builder = new StringBuilder ( ) ; for ( int num : arr ) { builder . append ( num ) ; } out . println ( builder . toString ( ) ) ; } }


import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] a = new int [ M ] ; int [ ] b = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { a [ i ] = sc . nextInt ( ) - 1 ; b [ i ] = sc . nextInt ( ) - 1 ; } int MAXD = 10 ; int [ ] [ ] dp = new int [ N ] [ MAXD + 1 ] ; int Q = sc . nextInt ( ) ; int [ ] c = new int [ Q + 1 ] ; for ( int i = 0 ; i < Q ; i ++ ) { int v = sc . nextInt ( ) - 1 ; int d = sc . nextInt ( ) ; c [ i + 1 ] = sc . nextInt ( ) ; dp [ v ] [ d ] = Math . max ( dp [ v ] [ d ] , i + 1 ) ; } for ( int i = MAXD ; i > 0 ; i -- ) { for ( int j = 0 ; j < M ; j ++ ) { dp [ a [ j ] ] [ i - 1 ] = Math . max ( dp [ a [ j ] ] [ i - 1 ] , dp [ b [ j ] ] [ i ] ) ; dp [ b [ j ] ] [ i - 1 ] = Math . max ( dp [ b [ j ] ] [ i - 1 ] , dp [ a [ j ] ] [ i ] ) ; } for ( int j = 0 ; j < N ; j ++ ) { dp [ j ] [ i - 1 ] = Math . max ( dp [ j ] [ i - 1 ] , dp [ j ] [ i ] ) ; } } for ( int i = 0 ; i < N ; i ++ ) pw . println ( c [ dp [ i ] [ 0 ] ] ) ; sc . close ( ) ; pw . close ( ) ; } }

from collections import defaultdict NEW_LINE def paint ( v , d , c ) : NEW_LINE INDENT if color [ v ] == 0 : NEW_LINE INDENT color [ v ] = c NEW_LINE DEDENT if dp [ v ] >= d or d == 0 : NEW_LINE INDENT return NEW_LINE DEDENT dp [ v ] = d NEW_LINE for nb in graph [ v ] : NEW_LINE INDENT paint ( nb , d - 1 , c ) NEW_LINE DEDENT DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE dp = [ 0 ] * N NEW_LINE color = [ 0 ] * N NEW_LINE graph = defaultdict ( set ) NEW_LINE for _ in range ( M ) : NEW_LINE INDENT i , j = map ( int , input ( ) . split ( ) ) NEW_LINE graph [ i - 1 ] . add ( j - 1 ) NEW_LINE graph [ j - 1 ] . add ( i - 1 ) NEW_LINE DEDENT Q = int ( input ( ) ) NEW_LINE vdcs = [ ] NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT v , d , c = map ( int , input ( ) . split ( ) ) NEW_LINE vdcs . append ( ( v - 1 , d , c ) ) NEW_LINE DEDENT vdcs . reverse ( ) NEW_LINE for v , d , c in vdcs : NEW_LINE INDENT paint ( v , d , c ) NEW_LINE DEDENT for c in color : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT


import sys NEW_LINE sys . setrecursionlimit ( 100000 ) NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE node = [ [ ] for i in range ( n + 1 ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE node [ a ] . append ( b ) NEW_LINE node [ b ] . append ( a ) NEW_LINE DEDENT q = int ( input ( ) ) NEW_LINE vdc = [ [ 0 ] * 3 for i in range ( q ) ] NEW_LINE for i in range ( q ) : NEW_LINE INDENT vdc [ i ] [ 0 ] , vdc [ i ] [ 1 ] , vdc [ i ] [ 2 ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT vdc = vdc [ : : - 1 ] NEW_LINE ans = [ 0 ] * ( n + 1 ) NEW_LINE visited = [ [ 0 ] * 11 for i in range ( n + 1 ) ] NEW_LINE def f ( v , d , c ) : NEW_LINE INDENT if d < 0 : NEW_LINE INDENT return NEW_LINE DEDENT if visited [ v ] [ d ] : NEW_LINE INDENT return NEW_LINE DEDENT visited [ v ] [ d ] = 1 NEW_LINE if ans [ v ] == 0 : NEW_LINE INDENT ans [ v ] = c NEW_LINE DEDENT for x in node [ v ] : NEW_LINE INDENT f ( x , d - 1 , c ) NEW_LINE DEDENT DEDENT for v , d , c in vdc : NEW_LINE INDENT f ( v , d , c ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( ans [ i + 1 ] ) NEW_LINE DEDENT


import sys , math , copy NEW_LINE HUGE = 2147483647 NEW_LINE HUGEL = 9223372036854775807 NEW_LINE ABC = " abcdefghijklmnopqrstuvwxyz " NEW_LINE MAX = 100001 NEW_LINE dp = [ 0 for i in range ( MAX ) ] NEW_LINE color = [ 0 for i in range ( MAX ) ] NEW_LINE e = [ [ ] for i in range ( MAX ) ] NEW_LINE def paint ( v , d , c ) : NEW_LINE INDENT if not color [ v ] : NEW_LINE INDENT color [ v ] = c NEW_LINE DEDENT if dp [ v ] >= d or d == 0 : NEW_LINE INDENT return NEW_LINE DEDENT dp [ v ] = d NEW_LINE for u in e [ v ] : NEW_LINE INDENT paint ( u , d - 1 , c ) NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE e [ a ] . append ( b ) NEW_LINE e [ b ] . append ( a ) NEW_LINE DEDENT q = int ( input ( ) ) NEW_LINE vq , dq , cq = [ ] , [ ] , [ ] NEW_LINE for i in range ( q ) : NEW_LINE INDENT v , d , c = map ( int , input ( ) . split ( ) ) NEW_LINE vq . append ( v ) NEW_LINE dq . append ( d ) NEW_LINE cq . append ( c ) NEW_LINE DEDENT assert len ( vq ) == len ( dq ) == len ( cq ) == q NEW_LINE for i in reversed ( range ( q ) ) : NEW_LINE INDENT paint ( vq [ i ] , dq [ i ] , cq [ i ] ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( color [ i + 1 ] ) NEW_LINE DEDENT DEDENT main ( ) NEW_LINE


import sys NEW_LINE def dfs ( v , d , c , e ) : NEW_LINE INDENT if ( dp [ v ] [ d ] != 0 ) : NEW_LINE INDENT return dp [ v ] [ d ] NEW_LINE DEDENT if ( d == 0 ) : NEW_LINE INDENT dp [ v ] [ d ] = c NEW_LINE return dp [ v ] [ d ] NEW_LINE DEDENT for u in e [ v ] : NEW_LINE INDENT dp [ u ] [ d - 1 ] = dfs ( u , d - 1 , c , e ) NEW_LINE DEDENT dp [ v ] [ d ] = dfs ( v , d - 1 , c , e ) NEW_LINE return dp [ v ] [ d ] NEW_LINE DEDENT stdin = sys . stdin NEW_LINE ns = lambda : stdin . readline ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE na = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) NEW_LINE dp = [ [ 0 ] * 11 for i in range ( 10 ** 5 + 1 ) ] NEW_LINE e = [ [ ] for i in range ( 10 ** 5 + 1 ) ] NEW_LINE N , M = na ( ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT a , b = na ( ) NEW_LINE a -= 1 NEW_LINE b -= 1 NEW_LINE e [ a ] . append ( b ) NEW_LINE e [ b ] . append ( a ) NEW_LINE DEDENT Q = ni ( ) NEW_LINE qv = [ [ 0 , 0 , 0 ] for i in range ( Q ) ] NEW_LINE for i in range ( Q ) : NEW_LINE INDENT v , d , c = na ( ) NEW_LINE v -= 1 NEW_LINE qv [ Q - 1 - i ] [ 0 ] = v NEW_LINE qv [ Q - 1 - i ] [ 1 ] = d NEW_LINE qv [ Q - 1 - i ] [ 2 ] = c NEW_LINE DEDENT for i in range ( Q ) : NEW_LINE INDENT dfs ( qv [ i ] [ 0 ] , qv [ i ] [ 1 ] , qv [ i ] [ 2 ] , e ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT print ( dp [ i ] [ 0 ] ) NEW_LINE DEDENT


from collections import deque NEW_LINE from collections import defaultdict NEW_LINE G = defaultdict ( list ) NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE color = [ 0 ] * ( N + 1 ) NEW_LINE for _ in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE G [ a ] . append ( b ) NEW_LINE G [ b ] . append ( a ) NEW_LINE DEDENT Q = int ( input ( ) ) NEW_LINE data = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( Q ) ] NEW_LINE data . reverse ( ) NEW_LINE color_d = [ - 1 ] * ( N + 1 ) NEW_LINE for v , d , c in data : NEW_LINE INDENT if color_d [ v ] >= d : NEW_LINE INDENT pass NEW_LINE DEDENT deq = deque ( [ v ] ) NEW_LINE if color [ v ] == 0 : NEW_LINE INDENT color [ v ] = c NEW_LINE DEDENT color_d [ v ] = d NEW_LINE while len ( deq ) > 0 : NEW_LINE INDENT s = deq . popleft ( ) NEW_LINE for t in G [ s ] : NEW_LINE INDENT if color_d [ t ] >= color_d [ s ] - 1 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT color_d [ t ] = color_d [ s ] - 1 NEW_LINE if color [ t ] == 0 : NEW_LINE INDENT color [ t ] = c NEW_LINE DEDENT if color_d [ t ] > 0 : NEW_LINE INDENT deq . append ( t ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT for n in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( color [ n ] ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] cdCase = new int [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { cdCase [ i ] = i ; } for ( int i = 0 ; i < M ; i ++ ) { int disk = sc . nextInt ( ) ; int index = 0 ; for ( int j = 0 ; j < N + 1 ; j ++ ) { if ( cdCase [ j ] == disk ) { index = j ; break ; } } cdCase [ index ] = cdCase [ 0 ] ; cdCase [ 0 ] = disk ; } for ( int i = 1 ; i < N + 1 ; i ++ ) { System . out . println ( cdCase [ i ] ) ; } } }

N , M = map ( int , input ( ) . split ( ) ) NEW_LINE n_lis = [ i for i in range ( 1 , N + 1 ) ] NEW_LINE liscd = 0 NEW_LINE for _ in range ( M ) : NEW_LINE INDENT cd = int ( input ( ) ) NEW_LINE if cd in n_lis : NEW_LINE INDENT case = n_lis . index ( cd ) NEW_LINE n_lis [ case ] = liscd NEW_LINE liscd = cd NEW_LINE DEDENT DEDENT for c in n_lis : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT


def b_cd_case ( N , M , Disk ) : NEW_LINE INDENT ans = list ( range ( N + 1 ) ) NEW_LINE for d in Disk : NEW_LINE INDENT ans [ ans . index ( d ) ] , ans [ 0 ] = ans [ 0 ] , ans [ ans . index ( d ) ] NEW_LINE DEDENT ans = ' \n ' . join ( map ( str , ans [ 1 : ] ) ) NEW_LINE return ans NEW_LINE DEDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE Disk = [ int ( input ( ) ) for _ in range ( M ) ] NEW_LINE print ( b_cd_case ( N , M , Disk ) ) NEW_LINE


inp1 = input ( ) NEW_LINE inp1 = inp1 . split ( ' ▁ ' ) NEW_LINE inp1 [ 0 ] = int ( inp1 [ 0 ] ) NEW_LINE inp1 [ 1 ] = int ( inp1 [ 1 ] ) NEW_LINE case = [ x for x in range ( 0 , inp1 [ 0 ] + 1 ) ] NEW_LINE caselist = dict ( zip ( case , case ) ) NEW_LINE listening = 0 NEW_LINE count = 0 NEW_LINE while ( count < inp1 [ 1 ] ) : NEW_LINE INDENT inp2 = int ( input ( ) ) NEW_LINE caselist [ listening ] = caselist [ inp2 ] NEW_LINE caselist [ inp2 ] = 0 NEW_LINE listening = inp2 NEW_LINE count += 1 NEW_LINE DEDENT out = { y : x for x , y in caselist . items ( ) } NEW_LINE for x in range ( 1 , inp1 [ 0 ] + 1 ) : NEW_LINE INDENT print ( out [ x ] ) NEW_LINE DEDENT


from itertools import product NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , M = inpl ( ) NEW_LINE where = list ( range ( 0 , N + 1 ) ) NEW_LINE now = 0 NEW_LINE for _ in range ( M ) : NEW_LINE INDENT disk = int ( input ( ) ) NEW_LINE where [ disk ] , where [ now ] = where [ now ] , where [ disk ] NEW_LINE now = disk NEW_LINE DEDENT answer = [ - 1 ] * ( N + 1 ) NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT answer [ where [ i ] ] = i NEW_LINE DEDENT print ( * answer [ 1 : ] , sep = " \n " ) NEW_LINE


import sys NEW_LINE import copy NEW_LINE input = sys . stdin . readline NEW_LINE N , M = map ( int , input ( ) . rstrip ( ) . split ( ) ) NEW_LINE disk = [ int ( input ( ) ) for _ in range ( M ) ] NEW_LINE ans = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT ans [ i ] = i NEW_LINE DEDENT for x in disk : NEW_LINE INDENT pos = 0 NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT if ans [ i ] == x : NEW_LINE INDENT pos = i NEW_LINE DEDENT DEDENT ans [ 0 ] , ans [ pos ] = ans [ pos ] , ans [ 0 ] NEW_LINE DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( ans [ i ] ) NEW_LINE DEDENT


import java . util . * ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] arr = new int [ n + 1 ] ; int h = 0 ; for ( int i = 0 ; i < n + 1 ; i ++ ) arr [ i ] = i ; for ( int i = 0 ; i < m ; i ++ ) { int c = sc . nextInt ( ) ; int key = 0 ; for ( int j = 1 ; j < arr . length ; j ++ ) { if ( arr [ j ] == c ) { key = j ; int tmp = h ; h = arr [ key ] ; arr [ key ] = tmp ; break ; } } } for ( int i = 1 ; i < arr . length ; i ++ ) System . out . println ( arr [ i ] ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArray = br . readLine ( ) . split ( " ▁ " ) ; int caseNum = Integer . parseInt ( strArray [ 0 ] ) ; int listenedCdNum = Integer . parseInt ( strArray [ 1 ] ) ; int listenDisk = 0 ; int [ ] cdCase = new int [ caseNum ] ; for ( int i = 1 ; i <= caseNum ; i ++ ) { cdCase [ i - 1 ] = i ; } for ( int i = 0 ; i < listenedCdNum ; i ++ ) { int disk = Integer . parseInt ( br . readLine ( ) ) ; for ( int j = 0 ; j < caseNum ; j ++ ) { if ( cdCase [ j ] == disk ) { cdCase [ j ] = listenDisk ; listenDisk = disk ; } } } for ( int diskNum : cdCase ) { System . out . println ( diskNum ) ; } } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner cin = new Scanner ( System . in ) ; int n = cin . nextInt ( ) ; int m = cin . nextInt ( ) ; int nowPlaying = 0 ; int [ ] CDCase = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) CDCase [ i ] = i + 1 ; for ( int i = 0 ; i < m ; i ++ ) { int targetCD = cin . nextInt ( ) ; int targetCase = - 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( CDCase [ j ] == targetCD ) { targetCase = j ; break ; } } if ( targetCase == - 1 ) continue ; CDCase [ targetCase ] = nowPlaying ; nowPlaying = targetCD ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( CDCase [ i ] ) ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] disks = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { disks [ i ] = i + 1 ; } int now = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int x = sc . nextInt ( ) ; if ( x == now ) { continue ; } for ( int j = 0 ; j < n ; j ++ ) { if ( disks [ j ] == x ) { disks [ j ] = now ; now = x ; break ; } } } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { sb . append ( disks [ i ] ) . append ( " \n " ) ; } System . out . print ( sb ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . execute ( ) ; } public void execute ( ) { Scanner sc = new Scanner ( System . in ) ; final int D = sc . nextInt ( ) ; final int G = sc . nextInt ( ) / 100 ; int [ ] score = new int [ D ] ; int [ ] p = new int [ D ] ; int [ ] c = new int [ D ] ; for ( int i = 0 ; i < D ; i ++ ) { score [ i ] = i + 1 ; p [ i ] = sc . nextInt ( ) ; c [ i ] = sc . nextInt ( ) / 100 ; } int minTurns = Integer . MAX_VALUE ; for ( int mask = 0 , bound = ( 1 << D ) ; mask < bound ; mask ++ ) { int s = 0 ; int turns = 0 ; boolean [ ] ptn = getPatterns ( D , mask ) ; for ( int i = 0 ; i < D ; i ++ ) { if ( ptn [ i ] ) { s += p [ i ] * score [ i ] + c [ i ] ; turns += p [ i ] ; } } if ( s >= G ) { minTurns = Math . min ( minTurns , turns ) ; continue ; } for ( int i = ( D - 1 ) ; i >= 0 ; i -- ) { if ( ptn [ i ] ) { continue ; } for ( int j = 0 ; j < p [ i ] - 1 ; j ++ ) { s += score [ i ] ; turns ++ ; if ( s >= G ) { minTurns = Math . min ( minTurns , turns ) ; break ; } } } } System . out . println ( minTurns ) ; sc . close ( ) ; } private boolean [ ] getPatterns ( int d , int mask ) { boolean [ ] patterns = new boolean [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { if ( ( mask & ( 1 << i ) ) > 0 ) { patterns [ i ] = true ; } } return patterns ; } }

D , G = map ( int , input ( ) . split ( ) ) NEW_LINE p , c = { } , { } NEW_LINE for i in range ( 1 , D + 1 ) : NEW_LINE INDENT pi , ci = map ( int , input ( ) . split ( ) ) NEW_LINE p [ i ] = pi NEW_LINE c [ i ] = ci NEW_LINE DEDENT ans = sum ( p . values ( ) ) NEW_LINE for i in range ( 2 ** D ) : NEW_LINE INDENT cmp = { i : False for i in range ( 1 , D + 1 ) } NEW_LINE score = 0 NEW_LINE ans_tmp = 0 NEW_LINE for j in range ( D ) : NEW_LINE INDENT if ( i >> j ) & 1 : NEW_LINE INDENT cmp [ j + 1 ] = True NEW_LINE score += ( j + 1 ) * 100 * p [ j + 1 ] + c [ j + 1 ] NEW_LINE ans_tmp += p [ j + 1 ] NEW_LINE DEDENT DEDENT keys = [ k for k , v in cmp . items ( ) if v == False ] NEW_LINE if G > score and len ( keys ) > 0 : NEW_LINE INDENT if ( G - score ) // ( max ( keys ) * 100 ) <= p [ max ( keys ) ] : NEW_LINE INDENT ans_tmp += ( G - score ) // ( max ( keys ) * 100 ) NEW_LINE if ( G - score ) % ( max ( keys ) * 100 ) != 0 : NEW_LINE INDENT ans_tmp += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans_tmp = sum ( p . values ( ) ) NEW_LINE DEDENT DEDENT ans = min ( ans , ans_tmp ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import sys NEW_LINE import itertools NEW_LINE import collections NEW_LINE import functools NEW_LINE import math NEW_LINE import operator NEW_LINE from queue import Queue NEW_LINE INF = float ( " inf " ) NEW_LINE def dfs ( curr , goal , count , probs ) : NEW_LINE INDENT if curr >= goal : NEW_LINE INDENT return count NEW_LINE DEDENT if len ( probs ) == 0 : NEW_LINE INDENT return INF NEW_LINE DEDENT m1 = dfs ( curr , goal , count , probs [ : - 1 ] ) NEW_LINE m2 = dfs ( curr + probs [ - 1 ] [ 0 ] * probs [ - 1 ] [ 1 ] + probs [ - 1 ] [ 2 ] , goal , count + probs [ - 1 ] [ 1 ] , probs [ : - 1 ] ) NEW_LINE m3 = INF NEW_LINE s = goal - curr NEW_LINE if ( probs [ - 1 ] [ 0 ] * probs [ - 1 ] [ 1 ] ) >= s : NEW_LINE INDENT m3 = count + int ( math . ceil ( s / probs [ - 1 ] [ 0 ] ) ) NEW_LINE DEDENT return min ( m1 , m2 , m3 ) NEW_LINE DEDENT def solve ( D : int , G : int , p : " List [ int ] " , c : " List [ int ] " ) : NEW_LINE INDENT probs = [ ] NEW_LINE for i in range ( D ) : NEW_LINE INDENT probs . append ( [ 100 * ( i + 1 ) , p [ i ] , c [ i ] ] ) NEW_LINE DEDENT m = dfs ( 0 , G , 0 , probs ) NEW_LINE print ( m ) 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 D = int ( next ( tokens ) ) NEW_LINE G = int ( next ( tokens ) ) NEW_LINE p = [ int ( ) ] * ( D ) NEW_LINE c = [ int ( ) ] * ( D ) NEW_LINE for i in range ( D ) : NEW_LINE INDENT p [ i ] = int ( next ( tokens ) ) NEW_LINE c [ i ] = int ( next ( tokens ) ) NEW_LINE DEDENT solve ( D , G , p , c ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import math NEW_LINE D , G = map ( int , input ( ) . split ( ) ) NEW_LINE p_c_list = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( D ) ] NEW_LINE min_n_solved = 1000000000 NEW_LINE for p_combi in range ( 1 << D ) : NEW_LINE INDENT tmp_score = 0 NEW_LINE n_solved = 0 NEW_LINE selected_p_idxs = [ ] NEW_LINE for digit in range ( D ) : NEW_LINE INDENT if ( p_combi >> digit ) & 1 : NEW_LINE INDENT tmp_score += 100 * ( digit + 1 ) * p_c_list [ digit ] [ 0 ] + p_c_list [ digit ] [ 1 ] NEW_LINE n_solved += p_c_list [ digit ] [ 0 ] NEW_LINE selected_p_idxs . append ( digit ) NEW_LINE DEDENT DEDENT score_diff = tmp_score - G NEW_LINE if score_diff >= 0 : NEW_LINE INDENT p_idx_lowest = selected_p_idxs [ 0 ] NEW_LINE score_per_p = 100 * ( p_idx_lowest + 1 ) NEW_LINE n_oversolved = None NEW_LINE score_diff_wo_bonus = score_diff - p_c_list [ p_idx_lowest ] [ 1 ] NEW_LINE if score_diff_wo_bonus > 0 : NEW_LINE INDENT n_oversolved = round ( score_diff_wo_bonus / score_per_p ) NEW_LINE if n_oversolved < p_c_list [ p_idx_lowest ] [ 0 ] : NEW_LINE INDENT n_solved -= n_oversolved NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT not_selected_p_idxs = [ p_idx for p_idx in range ( D ) if p_idx not in selected_p_idxs ] NEW_LINE not_selected_p_idxs = sorted ( not_selected_p_idxs , reverse = True ) NEW_LINE not_selected_p_idx_highest = not_selected_p_idxs [ 0 ] NEW_LINE addable_score = 100 * p_c_list [ not_selected_p_idx_highest ] [ 0 ] * ( not_selected_p_idx_highest + 1 ) NEW_LINE if score_diff + addable_score > 0 : NEW_LINE INDENT score_per_p = 100 * ( not_selected_p_idx_highest + 1 ) NEW_LINE n_undersolved = math . ceil ( abs ( score_diff ) / score_per_p ) NEW_LINE if n_undersolved < p_c_list [ not_selected_p_idx_highest ] [ 0 ] : NEW_LINE INDENT n_solved += n_undersolved NEW_LINE DEDENT DEDENT DEDENT if n_solved > 0 and score_diff >= 0 : NEW_LINE INDENT min_n_solved = min ( n_solved , min_n_solved ) NEW_LINE DEDENT DEDENT print ( min_n_solved ) NEW_LINE


print ( ( lambda d , D , G : ( lambda a : min ( d [ ' P ' ] + max ( 0 , d [ ' q ' ] ) for i in range ( 1 << D ) if d . update ( P = 0 , g = 0 , k = - 1 ) or any ( d . update ( P = d [ ' P ' ] + p , g = d [ ' g ' ] + c + 100 * p * - ~ j ) if i >> j & 1 else d . update ( k = j ) for j , ( p , c ) in enumerate ( a ) ) or d [ ' k ' ] < 0 and [ d . update ( q = 0 ) ] or d . update ( q = ( G - d [ ' g ' ] - 1 ) // ( 100 * - ~ d [ ' k ' ] ) + 1 ) or a [ d [ ' k ' ] ] [ 0 ] > d [ ' q ' ] ) ) ( [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * D ] ) ) ( { } , * map ( int , input ( ) . split ( ) ) ) ) NEW_LINE


import copy NEW_LINE def calc ( wk , kouho , G ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( D ) : NEW_LINE INDENT if kouho [ i ] == 1 : NEW_LINE INDENT G -= wk [ i ] [ 1 ] + 100 * ( i + 1 ) * wk [ i ] [ 0 ] NEW_LINE ans += wk [ i ] [ 0 ] NEW_LINE wk [ i ] [ 0 ] = 0 NEW_LINE DEDENT DEDENT if G <= 0 : NEW_LINE INDENT return ans NEW_LINE DEDENT solve = D - 1 NEW_LINE while G > 0 and solve >= 0 : NEW_LINE INDENT if wk [ solve ] [ 0 ] >= 2 : NEW_LINE INDENT wk [ solve ] [ 0 ] -= 1 NEW_LINE G -= 100 * ( solve + 1 ) NEW_LINE ans += 1 NEW_LINE DEDENT if wk [ solve ] [ 0 ] <= 1 : NEW_LINE INDENT solve -= 1 NEW_LINE DEDENT DEDENT return ans if G <= 0 else 10000 NEW_LINE DEDENT D , G = map ( int , input ( ) . split ( ) ) NEW_LINE zenbu = 2 ** D NEW_LINE prob = [ ] NEW_LINE min = 10000 NEW_LINE for i in range ( D ) : NEW_LINE INDENT prob . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT for i in range ( zenbu ) : NEW_LINE INDENT work = copy . deepcopy ( prob ) NEW_LINE kouho = [ ] NEW_LINE key = i NEW_LINE for j in range ( D ) : NEW_LINE INDENT kouho . append ( key % 2 ) NEW_LINE key //= 2 NEW_LINE DEDENT res = calc ( work , kouho , G ) NEW_LINE if res < min : NEW_LINE INDENT min = res NEW_LINE DEDENT DEDENT print ( str ( min ) ) NEW_LINE


import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int d = sc . nextInt ( ) ; int g = sc . nextInt ( ) ; int [ ] p = new int [ d + 1 ] ; int [ ] c = new int [ d + 1 ] ; for ( int i = 0 ; i < d ; i ++ ) { p [ i + 1 ] = sc . nextInt ( ) ; c [ i + 1 ] = sc . nextInt ( ) ; } int ans = 1000000000 ; for ( int i = 0 ; i < ( 1 << d ) ; i ++ ) { int temp = 0 ; long score = 0 ; for ( int j = 0 ; j < d ; j ++ ) { if ( ( 1 & ( i >> j ) ) == 1 ) { score += ( j + 1 ) * 100 * p [ j + 1 ] + c [ j + 1 ] ; temp += p [ j + 1 ] ; } } if ( score >= g ) { ans = min ( ans , temp ) ; } else { for ( int j = d - 1 ; j > - 1 ; j -- ) { if ( ( 1 & ( i >> j ) ) == 1 ) continue ; else { for ( int k = 1 ; k < p [ j + 1 ] ; k ++ ) { score += ( j + 1 ) * 100 ; temp += 1 ; if ( score >= g ) { ans = min ( ans , temp ) ; break ; } } break ; } } } } out . println ( ans ) ; } }


import java . util . Scanner ; public class Main { private static final int INF = 10000 ; private static int [ ] [ ] memo ; private static int solve ( int d , int g , int [ ] p , int [ ] c , int used ) { if ( memo [ g ] [ used ] != 0 ) return memo [ g ] [ used ] ; int res = INF ; for ( int i = 0 ; i < d ; i ++ ) { int bit = ( int ) Math . pow ( 2 , i ) ; if ( ( used / bit ) % 2 == 1 ) continue ; if ( ( i + 1 ) * ( p [ i ] - 1 ) >= g ) { res = Math . min ( res , ( int ) Math . ceil ( 1.0 * g / ( i + 1 ) ) ) ; } else if ( ( i + 1 ) * p [ i ] + c [ i ] >= g ) { res = Math . min ( res , p [ i ] ) ; } else { res = Math . min ( res , p [ i ] + solve ( d , g - ( ( i + 1 ) * p [ i ] + c [ i ] ) , p , c , used + bit ) ) ; } } memo [ g ] [ used ] = res ; return res ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int d = sc . nextInt ( ) ; int g = sc . nextInt ( ) / 100 ; int [ ] p = new int [ d ] ; int [ ] c = new int [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { p [ i ] = sc . nextInt ( ) ; c [ i ] = sc . nextInt ( ) / 100 ; } memo = new int [ 105501 ] [ 1024 ] ; System . out . println ( solve ( d , g , p , c , 0 ) ) ; sc . close ( ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int d = sc . nextInt ( ) ; int g = sc . nextInt ( ) ; Problem [ ] array = new Problem [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { array [ i ] = new Problem ( 100 * ( i + 1 ) , sc . nextInt ( ) , sc . nextInt ( ) ) ; } sc . close ( ) ; int ans = Integer . MAX_VALUE ; System . out . println ( dfs ( d , g , array , " " , ans ) ) ; } static class Problem { int p ; int c ; int total ; public Problem ( int s , int p , int c ) { this . p = p ; this . c = c ; this . total = s * p + c ; } } static int dfs ( int d , int g , Problem [ ] array , String select , int ans ) { if ( select . length ( ) == d ) { int total = 0 ; int cnt = 0 ; for ( int i = 0 ; i < d ; i ++ ) { if ( select . charAt ( i ) == '1' ) { total += array [ i ] . total ; cnt += array [ i ] . p ; } } if ( g <= total ) { return cnt ; } for ( int i = d - 1 ; i >= 0 ; i -- ) { if ( select . charAt ( i ) == '0' ) { double zanScore = g - total ; int zanCnt = ( int ) Math . ceil ( zanScore / ( 100 * ( i + 1 ) ) ) ; if ( zanCnt < array [ i ] . p ) { cnt += zanCnt ; } else { cnt = Integer . MAX_VALUE ; } break ; } } return cnt ; } ans = Math . min ( ans , dfs ( d , g , array , select + "0" , ans ) ) ; ans = Math . min ( ans , dfs ( d , g , array , select + "1" , ans ) ) ; return ans ; } }


public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int d = scanner . nextInt ( ) , g = scanner . nextInt ( ) ; int [ ] p = new int [ d ] , c = new int [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { p [ i ] = scanner . nextInt ( ) ; c [ i ] = scanner . nextInt ( ) ; } int ans = 10000 ; for ( int i = 0 ; i < 1 << d ; i ++ ) { int sum = 0 , count = 0 , zero = 0 ; for ( int j = 0 ; j < d ; j ++ ) { if ( ( 1 << j & i ) != 0 ) { sum += ( j + 1 ) * 100 * p [ j ] + c [ j ] ; count += p [ j ] ; } else { zero = j ; } } if ( sum < g ) { int t = ( int ) Math . ceil ( ( g - sum ) / ( ( zero + 1 ) * 100F ) ) ; if ( p [ zero ] < t ) continue ; count += Math . ceil ( ( g - sum ) / ( ( zero + 1 ) * 100F ) ) ; } ans = Math . min ( ans , count ) ; } System . out . println ( ans ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; int count = 0 ; String inputStr [ ] = new String [ input . length ( ) ] ; int currentIndex = 0 ; for ( int i = 0 ; i < input . length ( ) ; i ++ ) { inputStr [ currentIndex ] = input . substring ( i , i + 1 ) ; if ( currentIndex != 0 && ! inputStr [ currentIndex ] . equals ( inputStr [ currentIndex - 1 ] ) ) { currentIndex -- ; count += 2 ; } else { currentIndex ++ ; } } System . out . println ( count ) ; sc . close ( ) ; } }

s = input ( ) NEW_LINE a_1 = s . count ( "1" ) NEW_LINE b_1 = s . count ( "0" ) NEW_LINE if a_1 <= b_1 : NEW_LINE INDENT print ( 2 * a_1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 * b_1 ) NEW_LINE DEDENT


S = list ( input ( ) ) NEW_LINE prev = " " NEW_LINE index = 0 NEW_LINE ans = 0 NEW_LINE while index < len ( S ) : NEW_LINE INDENT if prev == " " : NEW_LINE INDENT prev = S [ index ] NEW_LINE index = index + 1 NEW_LINE continue NEW_LINE DEDENT if S [ index ] != prev : NEW_LINE INDENT S . pop ( index ) NEW_LINE S . pop ( index - 1 ) NEW_LINE ans = ans + 2 NEW_LINE if len ( S ) == 0 : NEW_LINE INDENT break NEW_LINE DEDENT index = index - 2 if index - 2 > 0 else 0 NEW_LINE prev = " " NEW_LINE DEDENT else : NEW_LINE INDENT prev = S [ index ] NEW_LINE index = index + 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import numpy as np NEW_LINE s = [ int ( i ) for i in input ( ) ] NEW_LINE array = np . array ( s ) NEW_LINE zero = np . sum ( array == 0 ) NEW_LINE one = np . sum ( array == 1 ) NEW_LINE print ( 2 * min ( zero , one ) ) NEW_LINE


S = input ( ) NEW_LINE redcount = S . count ( '0' ) NEW_LINE bluecount = S . count ( '1' ) NEW_LINE mincount = min ( redcount , bluecount ) NEW_LINE answer = mincount * 2 NEW_LINE print ( answer ) NEW_LINE


s = input ( ) ; print ( min ( s . count ( "0" ) , s . count ( "1" ) ) * 2 ) NEW_LINE


import java . util . LinkedList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; Main abc120C = new Main ( ) ; System . out . println ( abc120C . solve ( S ) ) ; } public int solve ( String S ) { ABC120CSolve abc120CSolve = new ABC120CSolve ( ) ; return abc120CSolve . solve ( S ) ; } class ABC120CSolve { static final int ZERO = ( int ) '0' ; public int solve ( String S ) { int ans = 0 ; LinkedList < Integer > list = new LinkedList ( ) ; for ( char c : S . toCharArray ( ) ) { int i = ( int ) c - ZERO ; if ( list . size ( ) == 0 ) { list . addLast ( i ) ; } else { if ( list . getLast ( ) != i ) { list . removeLast ( ) ; ans += 2 ; } else { list . addLast ( i ) ; } } } return ans ; } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; CUnification solver = new CUnification ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class CUnification { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; char [ ] arr = s . toCharArray ( ) ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] == '0' ) a ++ ; else b ++ ; } out . println ( Math . min ( a , b ) * 2 ) ; } } }


import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; List < String > sList = Arrays . asList ( S . split ( " " ) ) ; int zeroCount = 0 ; int oneCount = 0 ; int ans = 0 ; for ( String s : sList ) { if ( s . equals ( "0" ) ) { zeroCount ++ ; } else { oneCount ++ ; } } if ( zeroCount > oneCount ) { ans = oneCount * 2 ; } else { ans = zeroCount * 2 ; } System . out . println ( ans ) ; } }


import java . io . * ; class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; int [ ] rb = { 0 , 0 } ; for ( String s : str . split ( " " ) ) { if ( s . equals ( "0" ) ) { rb [ 0 ] ++ ; } else { rb [ 1 ] ++ ; } } System . out . println ( Math . min ( rb [ 0 ] , rb [ 1 ] ) * 2 ) ; } }


import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; class Pair { long first ; long second ; Pair ( long first , long second ) { this . first = first ; this . second = second ; } } @ SuppressWarnings ( " unchecked " ) public class Main { static void divisor ( ArrayList < Pair > div , long N ) { long n ; long i = 1 ; n = N ; while ( i <= Math . sqrt ( n ) ) { if ( n % i == 0 ) div . add ( new Pair ( i , n / i ) ) ; i ++ ; } } public static void main ( String [ ] args ) throws IOException { final String s ; try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { s = reader . readLine ( ) ; } PrintWriter out = new PrintWriter ( System . out ) ; final String [ ] sl = s . split ( " ▁ " ) ; int N = Integer . parseInt ( sl [ 0 ] ) ; int M = Integer . parseInt ( sl [ 1 ] ) ; ArrayList < Pair > div = new ArrayList < > ( ) ; divisor ( div , M ) ; long MAX = M / N + 1 ; long ans = 0 ; for ( Pair p : div ) { long first = p . first ; long second = p . second ; if ( first < MAX && ans < first ) ans = first ; if ( second < MAX && ans < second ) ans = second ; } out . println ( ans ) ; out . flush ( ) ; } }

N , M = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def solution ( ) : NEW_LINE INDENT if M - N < M // N : NEW_LINE INDENT for n in range ( N , M + 1 ) : NEW_LINE INDENT if M % n == 0 : NEW_LINE INDENT return M // n NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for m in range ( M // N , 0 , - 1 ) : NEW_LINE INDENT if M % m == 0 : NEW_LINE INDENT return m NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( solution ( ) ) NEW_LINE


import math NEW_LINE def soinsu ( N ) : NEW_LINE INDENT sqr = int ( math . sqrt ( N ) ) NEW_LINE lis = [ ] NEW_LINE for i in range ( 2 , sqr + 2 ) : NEW_LINE INDENT while N % i == 0 : NEW_LINE INDENT lis . append ( i ) NEW_LINE N = N // i NEW_LINE DEDENT DEDENT if not N == 1 : NEW_LINE INDENT lis . append ( N ) NEW_LINE DEDENT return lis NEW_LINE DEDENT def yakusu ( N ) : NEW_LINE INDENT sqr = int ( math . sqrt ( N ) ) NEW_LINE lis = [ ] NEW_LINE for i in range ( 1 , sqr + 2 ) : NEW_LINE INDENT if N % i == 0 : NEW_LINE INDENT lis . append ( i ) NEW_LINE lis . append ( N // i ) NEW_LINE DEDENT DEDENT return lis NEW_LINE DEDENT mod = 1000000007 NEW_LINE def modpow ( a , b , MOD = mod ) : NEW_LINE INDENT res = 1 NEW_LINE while b > 0 : NEW_LINE INDENT if ( b & 1 ) == 1 : NEW_LINE INDENT res = ( res * a ) % MOD NEW_LINE DEDENT a = ( a * a ) % MOD NEW_LINE b = b >> 1 NEW_LINE DEDENT return res NEW_LINE DEDENT fact = [ ] NEW_LINE def ncrinit ( MOD = mod ) : NEW_LINE INDENT fact . append ( 1 ) NEW_LINE for i in range ( 1 , 110005 ) : NEW_LINE INDENT fact . append ( ( fact [ i - 1 ] * i ) % MOD ) NEW_LINE DEDENT DEDENT def calcnCr ( n , r , MOD = mod ) : NEW_LINE INDENT up = fact [ n ] NEW_LINE down = modpow ( ( fact [ n - r ] * fact [ r ] ) % mod , mod - 2 , mod ) NEW_LINE return ( up * down ) % mod NEW_LINE DEDENT def compres ( lis ) : NEW_LINE INDENT li = [ ] NEW_LINE se = set ( lis ) NEW_LINE for i in se : NEW_LINE INDENT li . append ( lis . count ( i ) ) NEW_LINE DEDENT return li NEW_LINE DEDENT res = 1 NEW_LINE N , M = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE co = yakusu ( M ) NEW_LINE co . sort ( ) NEW_LINE for i in co : NEW_LINE INDENT if M // i >= N : NEW_LINE INDENT res = max ( res , i ) NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE


import sys NEW_LINE def solve ( N : int , M : int ) : NEW_LINE INDENT ret = 0 NEW_LINE i = 1 NEW_LINE while i * i <= M : NEW_LINE INDENT if M % i == 0 : NEW_LINE INDENT if i >= N : NEW_LINE INDENT ret = max ( ret , M // i ) NEW_LINE DEDENT if M // i >= N : NEW_LINE INDENT ret = max ( ret , i ) NEW_LINE DEDENT DEDENT i += 1 NEW_LINE DEDENT print ( ret ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE M = int ( next ( tokens ) ) NEW_LINE solve ( N , M ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


n , m = map ( int , input ( ) . split ( ) ) NEW_LINE f1 = [ ] NEW_LINE f2 = [ ] NEW_LINE for i1 in range ( 1 , int ( m ** 0.5 ) + 1 ) : NEW_LINE INDENT if m % i1 == 0 : NEW_LINE INDENT i2 = m // i1 NEW_LINE if i1 >= n : NEW_LINE INDENT ans = i2 NEW_LINE break NEW_LINE DEDENT elif i2 == n : NEW_LINE INDENT ans = i1 NEW_LINE break NEW_LINE DEDENT elif i2 < n : NEW_LINE INDENT ans = f1 [ - 1 ] NEW_LINE break NEW_LINE DEDENT f1 += [ i1 ] NEW_LINE f2 += [ i2 ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans = f1 [ - 1 ] NEW_LINE DEDENT print ( ans ) NEW_LINE


import math NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE def get_divisors ( n ) : NEW_LINE INDENT ret = [ ] NEW_LINE for i in range ( 1 , int ( math . sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT ret . append ( i ) NEW_LINE if n // i != i : NEW_LINE INDENT ret . append ( n // i ) NEW_LINE DEDENT DEDENT DEDENT return ret NEW_LINE DEDENT divs = get_divisors ( m ) NEW_LINE divs . sort ( reverse = True ) NEW_LINE for d in divs : NEW_LINE INDENT if d * n <= m : NEW_LINE INDENT print ( d ) NEW_LINE break NEW_LINE DEDENT DEDENT


import java . util . Scanner ; public class Main { public void main ( Scanner sc ) throws Exception { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . close ( ) ; int ans = 1 ; for ( int i = 1 ; i * i <= m ; i ++ ) { if ( m % i != 0 ) { continue ; } if ( i >= n ) { ans = Math . max ( ans , m / i ) ; } else if ( m / i >= n ) { ans = Math . max ( ans , i ) ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; } }


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long M = sc . nextInt ( ) ; Set < Long > divisors = new TreeSet < > ( Collections . reverseOrder ( ) ) ; for ( long i = 1 ; i <= ( long ) Math . sqrt ( M ) ; i ++ ) { if ( M % i == 0 ) { divisors . add ( i ) ; divisors . add ( M / i ) ; } } for ( long p : divisors ) { if ( M % p == 0 && M / p >= N ) { out . println ( p ) ; return ; } } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; final int m = ( int ) Math . sqrt ( M ) ; boolean [ ] prm = new boolean [ m + 1 ] ; for ( int i = 2 ; i < m + 1 ; i ++ ) prm [ i ] = true ; for ( int i = 2 ; i < m + 1 ; i ++ ) { if ( prm [ i ] ) { for ( int j = 2 * i ; j < m + 1 ; j += i ) prm [ j ] = false ; } } int [ ] L1 = new int [ m + 1 ] ; int [ ] L2 = new int [ m + 1 ] ; int id = 0 ; int M2 = M ; for ( int i = 2 ; i < m + 1 ; i ++ ) { if ( prm [ i ] && M2 % i == 0 ) { L1 [ id ] = i ; while ( M2 % i == 0 ) { L2 [ id ] ++ ; M2 /= i ; } id ++ ; } if ( i == m && M2 > 1 ) { L1 [ id ] = M2 ; L2 [ id ] ++ ; id ++ ; } } int p = solve ( 1 , L1 , L2 , 0 , N , id ) ; System . out . println ( M / p ) ; } public static int solve ( int a , int [ ] l1 , int [ ] l2 , int ind , int n , int l ) { if ( ind == l ) { if ( a >= n ) return a ; else return 1000000007 ; } else { int min = 1000000007 ; for ( int i = 0 ; i <= l2 [ ind ] ; i ++ ) { min = Math . min ( solve ( a * ( int ) Math . pow ( l1 [ ind ] , i ) , l1 , l2 , ind + 1 , n , l ) , min ) ; } return min ; } } }


import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; public class Main { static Queue < Integer > q = new LinkedList < Integer > ( ) ; static void Divisor ( int M ) { for ( int i = 1 ; i < Math . sqrt ( M ) ; i ++ ) { if ( M % i != 0 ) continue ; q . add ( i ) ; q . add ( M / i ) ; } if ( M % Math . sqrt ( M ) == 0 ) q . add ( ( int ) Math . sqrt ( M ) ) ; } public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; Divisor ( M ) ; int max = 0 ; while ( ! q . isEmpty ( ) ) { int s = q . remove ( ) ; if ( M % s == 0 && M / s >= N ) { max = Math . max ( max , s ) ; } } System . out . println ( max ) ; } } }


import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { private static final String ZERO = "0" ; private enum Direction { W , E ; } public static String process ( TestCase testCase ) { final int N = testCase . N ; final String S = testCase . S ; if ( N <= 0 ) { return ZERO ; } else { final List < Direction > directions = Arrays . stream ( S . split ( " " ) ) . map ( Direction :: valueOf ) . collect ( Collectors . toList ( ) ) ; long min = IntStream . range ( 1 , N ) . mapToObj ( directions :: get ) . filter ( Direction . E :: equals ) . count ( ) ; long change = min ; for ( int i = 1 ; i < N ; ++ i ) { final Direction prev = directions . get ( i - 1 ) ; final Direction curr = directions . get ( i ) ; if ( Direction . W . equals ( prev ) ) { change ++ ; } if ( Direction . E . equals ( curr ) ) { change -- ; } min = Math . min ( min , change ) ; } return String . valueOf ( min ) ; } } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final String result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; return new TestCase ( N , S ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final int N ; final String S ; public TestCase ( int N , String S ) { this . N = N ; this . S = S ; } } }

n = int ( input ( ) ) NEW_LINE s = list ( input ( ) ) NEW_LINE p = [ 0 , 0 ] NEW_LINE l = [ s . count ( " E " ) , s . count ( " W " ) ] NEW_LINE t = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if s [ i ] == " E " : NEW_LINE INDENT t . append ( l [ 0 ] + p [ 1 ] - 1 ) NEW_LINE l [ 0 ] -= 1 NEW_LINE p [ 0 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT t . append ( l [ 0 ] + p [ 1 ] ) NEW_LINE l [ 1 ] -= 1 NEW_LINE p [ 1 ] += 1 NEW_LINE DEDENT DEDENT print ( min ( t ) ) NEW_LINE


from sys import stdin NEW_LINE import numpy as np NEW_LINE N = int ( stdin . readline ( ) . rstrip ( ) . split ( ) [ 0 ] ) NEW_LINE S = stdin . readline ( ) . rstrip ( ) . split ( ) [ 0 ] NEW_LINE is_w_list = [ 1 if s == " W " else 0 for s in S ] NEW_LINE cumsum_w = np . append ( np . array ( [ 0 ] ) , ( np . cumsum ( is_w_list ) [ : - 1 ] ) ) NEW_LINE is_e_list = [ not ( x ) for x in is_w_list [ : : - 1 ] ] NEW_LINE cumsum_e = np . append ( np . array ( [ 0 ] ) , ( np . cumsum ( is_e_list ) [ : - 1 ] ) ) [ : : - 1 ] NEW_LINE print ( np . min ( cumsum_w + cumsum_e ) ) NEW_LINE


import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE n = II ( ) NEW_LINE s = SI ( ) NEW_LINE W = [ 0 ] NEW_LINE E = [ 0 ] NEW_LINE for c in s : NEW_LINE INDENT W . append ( W [ - 1 ] + ( c == ' W ' ) ) NEW_LINE E . append ( E [ - 1 ] + ( c == ' E ' ) ) NEW_LINE DEDENT e_max = E [ - 1 ] NEW_LINE ans = INF NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT ans = min ( ans , W [ i - 1 ] + e_max - E [ i ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE


def solve ( string ) : NEW_LINE INDENT length = len ( string ) NEW_LINE east , west = [ 0 ] * ( length + 1 ) , [ 0 ] * ( length + 2 ) NEW_LINE for i in range ( 1 , length + 1 ) : NEW_LINE INDENT if string [ i - 1 ] == " W " : NEW_LINE INDENT east [ i ] = east [ i - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT east [ i ] = east [ i - 1 ] NEW_LINE DEDENT DEDENT for j in range ( length , 0 , - 1 ) : NEW_LINE INDENT if string [ j - 1 ] == " E " : NEW_LINE INDENT west [ j ] = west [ j + 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT west [ j ] = west [ j + 1 ] NEW_LINE DEDENT DEDENT ans = length NEW_LINE for k in range ( 1 , length + 1 ) : NEW_LINE INDENT ans = min ( ans , east [ k - 1 ] + west [ k + 1 ] ) NEW_LINE DEDENT return ans NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE string = input ( ) NEW_LINE ans = solve ( string ) NEW_LINE print ( ans ) NEW_LINE DEDENT main ( ) NEW_LINE


n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE west = [ 0 for i in range ( n + 1 ) ] NEW_LINE east = [ 0 for i in range ( n + 1 ) ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT west [ i ] = west [ i - 1 ] NEW_LINE east [ i ] = east [ i - 1 ] NEW_LINE if s [ i - 1 ] == ' W ' : NEW_LINE INDENT west [ i ] += 1 NEW_LINE DEDENT if s [ i - 1 ] == ' E ' : NEW_LINE INDENT east [ i ] += 1 NEW_LINE DEDENT DEDENT ans = 1e9 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT reqd_east_cnt = i - 1 NEW_LINE got_east_cnt = east [ i - 1 ] NEW_LINE reqd_west_cnt = n - i NEW_LINE got_west_cnt = west [ n ] - west [ i ] NEW_LINE ans = min ( ans , reqd_east_cnt - got_east_cnt + reqd_west_cnt - got_west_cnt ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; String s = in . next ( ) ; int east = 0 ; int west = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' E ' ) east ++ ; else west ++ ; } int ans = Integer . MAX_VALUE ; int ce = 0 , cw = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int req = cw + east - ce + ( s . charAt ( i ) == ' E ' ? - 1 : 0 ) ; ans = Math . min ( ans , req ) ; if ( s . charAt ( i ) == ' E ' ) ce ++ ; else cw ++ ; } 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 . Scanner ; public class Main { public static int findMinTurns ( int n , String s ) { int eastTotal = 0 ; int westTotal = 0 ; for ( char ch : s . toCharArray ( ) ) { if ( ch == ' E ' ) { eastTotal ++ ; } else if ( ch == ' W ' ) { westTotal ++ ; } } int eastPassed = 0 ; int westPassed = 0 ; int currentTurns ; int leastTurns = n ; for ( char ch : s . toCharArray ( ) ) { currentTurns = westPassed + eastTotal - eastPassed ; if ( ch == ' E ' ) { currentTurns -- ; eastPassed ++ ; } else if ( ch == ' W ' ) { westPassed ++ ; } if ( currentTurns < leastTurns ) { leastTurns = currentTurns ; } } return leastTurns ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; System . out . println ( findMinTurns ( n , s ) ) ; sc . close ( ) ; } }


import java . util . * ; public class Main { static int n , k ; static int [ ] a ; static int modP = 1000000007 ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; char [ ] s = in . next ( ) . toCharArray ( ) ; int [ ] wOnLeftCnt = new int [ n ] ; int [ ] eOnLeftCnt = new int [ n ] ; int [ ] wOnRightCnt = new int [ n ] ; int [ ] eOnRightCnt = new int [ n ] ; int wCnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { wOnLeftCnt [ i ] = wCnt ; if ( s [ i ] == ' W ' ) { wCnt ++ ; } } int eCnt = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { eOnRightCnt [ i ] = eCnt ; if ( s [ i ] == ' E ' ) { eCnt ++ ; } } int minTurned = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( minTurned > wOnLeftCnt [ i ] + eOnRightCnt [ i ] ) { minTurned = wOnLeftCnt [ i ] + eOnRightCnt [ i ] ; } minTurned = Math . min ( minTurned , wOnLeftCnt [ i ] + eOnRightCnt [ i ] ) ; } System . out . println ( minTurned ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int numberOfPeople = sc . nextInt ( ) ; char [ ] peopleDirections = sc . next ( ) . toCharArray ( ) ; int [ ] east = new int [ numberOfPeople ] ; int [ ] west = new int [ numberOfPeople ] ; for ( int i = 0 ; i < numberOfPeople ; i ++ ) { if ( peopleDirections [ i ] == ' E ' ) { east [ i ] = 1 ; } else { west [ i ] = 1 ; } } for ( int i = 1 ; i < numberOfPeople ; i ++ ) { east [ i ] += east [ i - 1 ] ; west [ i ] += west [ i - 1 ] ; } int minimumNumberOfPeopleToChangeDirection = numberOfPeople ; for ( int i = 0 ; i < numberOfPeople ; i ++ ) { int countOfEastAtRightSide = east [ numberOfPeople - 1 ] - east [ i ] ; int countOfWestAtLeftSide = i == 0 ? 0 : west [ i - 1 ] ; int totalCount = countOfEastAtRightSide + countOfWestAtLeftSide ; if ( minimumNumberOfPeopleToChangeDirection > totalCount ) { minimumNumberOfPeopleToChangeDirection = totalCount ; } } System . out . println ( minimumNumberOfPeopleToChangeDirection ) ; } }


import java . util . Arrays ; import java . util . Scanner ; public class Main { static int N , K ; static int [ ] trees ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; K = sc . nextInt ( ) ; trees = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { trees [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( trees ) ; int current = trees [ K - 1 ] - trees [ 0 ] ; int height = 0 ; for ( int i = 1 ; i < N - K + 1 ; i ++ ) { height = trees [ i + K - 1 ] - trees [ i ] ; if ( current > height ) { current = height ; } } System . out . println ( current ) ; } }

N , K = map ( int , input ( ) . split ( ) ) NEW_LINE h = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT h . append ( int ( input ( ) ) ) NEW_LINE DEDENT h2 = sorted ( h ) NEW_LINE ans = 10 ** 9 NEW_LINE for i in range ( N - K + 1 ) : NEW_LINE INDENT if h2 [ i + K - 1 ] - h2 [ i ] < ans : NEW_LINE INDENT ans = h2 [ i + K - 1 ] - h2 [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


from sys import stdin NEW_LINE n , k = [ int ( _ ) for _ in stdin . readline ( ) . rstrip ( ) . split ( ) ] NEW_LINE h = [ int ( stdin . readline ( ) . rstrip ( ) ) for _ in range ( n ) ] NEW_LINE h . sort ( ) NEW_LINE print ( min ( h [ i + k - 1 ] - h [ i ] for i in range ( n - k + 1 ) ) ) NEW_LINE


import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def solve ( N : int , K : int , h : " List [ int ] " ) : NEW_LINE INDENT h . sort ( ) NEW_LINE print ( min ( h [ i + K - 1 ] - h [ i ] for i in range ( N - K + 1 ) ) ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE K = int ( next ( tokens ) ) NEW_LINE h = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , K , h ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


N , K = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE H = sorted ( [ int ( input ( ) ) for _ in range ( N ) ] ) NEW_LINE min_h = 1e15 NEW_LINE for i in range ( N - K + 1 ) : NEW_LINE INDENT tmp = H [ i + K - 1 ] - H [ i ] NEW_LINE if tmp < min_h : NEW_LINE INDENT min_h = tmp NEW_LINE DEDENT DEDENT print ( min_h ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) ) NEW_LINE heights = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT heights . append ( int ( input ( ) ) ) NEW_LINE DEDENT heights . sort ( ) NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( len ( heights ) ) : NEW_LINE INDENT if i + k - 1 >= len ( heights ) : NEW_LINE INDENT break NEW_LINE DEDENT ans = min ( ans , heights [ i + k - 1 ] - heights [ i ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] h = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } Arrays . sort ( h ) ; int min = h [ 0 ] ; int max = h [ K - 1 ] ; int diff = max - min ; for ( int i = K ; i < N ; i ++ ) { min = h [ i - K + 1 ] ; max = h [ i ] ; diff = Math . min ( diff , max - min ) ; } out . println ( diff ) ; } }


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 [ ] args ) { int n = scanner . nextInt ( ) , k = scanner . nextInt ( ) ; int [ ] h = IntStream . range ( 0 , n ) . map ( i -> scanner . nextInt ( ) ) . sorted ( ) . toArray ( ) ; System . out . println ( IntStream . range ( k - 1 , n ) . map ( i -> h [ i ] - h [ i - k + 1 ] ) . min ( ) . getAsInt ( ) ) ; } }


import java . io . InputStream ; import java . io . PrintStream ; import java . util . Arrays ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } Arrays . sort ( h ) ; int [ ] d = new int [ n - ( k - 1 ) ] ; for ( int i = 0 ; i < n - ( k - 1 ) ; i ++ ) { d [ i ] = h [ i + ( k - 1 ) ] - h [ i ] ; } Arrays . sort ( d ) ; out . println ( d [ 0 ] ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = bf . readLine ( ) . split ( " ▁ " ) ; int N = Integer . parseInt ( str [ 0 ] ) , K = Integer . parseInt ( str [ 1 ] ) ; int [ ] h = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { h [ i ] = Integer . parseInt ( bf . readLine ( ) ) ; } Arrays . sort ( h ) ; int min = h [ N - 1 ] - h [ 0 ] ; for ( int i = 0 ; i < N - K + 1 ; i ++ ) { int value = h [ i + K - 1 ] - h [ i ] ; if ( value < min ) { min = value ; } } System . out . println ( min ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] s = scanner . next ( ) . toCharArray ( ) ; int n = s . length ; long dp [ ] [ ] = new long [ n + 1 ] [ 4 ] ; for ( int i = 0 ; i <= 3 ; i ++ ) { dp [ n ] [ i ] = i == 3 ? 1 : 0 ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { for ( int j = 3 ; j >= 0 ; j -- ) { dp [ i ] [ j ] = dp [ i + 1 ] [ j ] * ( s [ i ] == ' ? ' ? 3L : 1L ) ; if ( j < 3 && ( s [ i ] == ' ? ' || s [ i ] == " ABC " . toCharArray ( ) [ j ] ) ) { dp [ i ] [ j ] += dp [ i + 1 ] [ j + 1 ] ; } dp [ i ] [ j ] %= 1_000_000_007L ; } } System . out . println ( dp [ 0 ] [ 0 ] ) ; } }

s = input ( ) NEW_LINE dp = [ [ 0 ] * ( len ( s ) + 1 ) for _ in range ( 4 ) ] NEW_LINE dp [ 0 ] [ 0 ] = 1 NEW_LINE for i , c in enumerate ( s ) : NEW_LINE INDENT if c == " A " or c == " ? " : NEW_LINE INDENT dp [ 1 ] [ i + 1 ] = dp [ 0 ] [ i ] NEW_LINE DEDENT if c == " B " or c == " ? " : NEW_LINE INDENT dp [ 2 ] [ i + 1 ] = dp [ 1 ] [ i ] NEW_LINE DEDENT if c == " C " or c == " ? " : NEW_LINE INDENT dp [ 3 ] [ i + 1 ] = dp [ 2 ] [ i ] NEW_LINE DEDENT for j in range ( 4 ) : NEW_LINE INDENT if c == " ? " : NEW_LINE INDENT dp [ j ] [ i + 1 ] += dp [ j ] [ i ] * 3 NEW_LINE DEDENT else : NEW_LINE INDENT dp [ j ] [ i + 1 ] += dp [ j ] [ i ] NEW_LINE DEDENT dp [ j ] [ i + 1 ] %= 10 ** 9 + 7 NEW_LINE DEDENT DEDENT print ( dp [ - 1 ] [ - 1 ] ) NEW_LINE


import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE test_data1 = ''' \ STRNEWLINE A ? ? C STRNEWLINE ''' NEW_LINE test_data2 = ''' \ STRNEWLINE ACACAC STRNEWLINE ''' NEW_LINE test_data3 = ''' \ STRNEWLINE ? ? ? ? C ? ? ? ? ? B ? ? ? ? ? ? A ? ? ? ? ? ? ? STRNEWLINE ''' NEW_LINE test_data4 = ''' \ STRNEWLINE ? AC ? AC STRNEWLINE ''' NEW_LINE td_num = 3 NEW_LINE def GetTestData ( index ) : NEW_LINE INDENT if index == 1 : NEW_LINE INDENT return test_data1 NEW_LINE DEDENT if index == 2 : NEW_LINE INDENT return test_data2 NEW_LINE DEDENT if index == 3 : NEW_LINE INDENT return test_data3 NEW_LINE DEDENT if index == 4 : NEW_LINE INDENT return test_data4 NEW_LINE DEDENT DEDENT if False : NEW_LINE INDENT with open ( " . . / test . txt " , mode = ' w ' ) as f : NEW_LINE INDENT f . write ( GetTestData ( td_num ) ) NEW_LINE DEDENT with open ( " . . / test . txt " ) as f : NEW_LINE INDENT s = f . readline ( ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT s = input ( ) NEW_LINE DEDENT n = len ( s ) NEW_LINE dc = dict ( ) NEW_LINE dc [ ' A ' ] = 0 NEW_LINE dc [ ' B ' ] = 1 NEW_LINE dc [ ' C ' ] = 2 NEW_LINE dc [ ' ? ' ] = 3 NEW_LINE dp = [ [ 0 for i in range ( 4 ) ] for j in range ( n + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] = 1 NEW_LINE mo = 10 ** 9 + 7 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for t in range ( 4 ) : NEW_LINE INDENT ch = s [ i ] NEW_LINE if dc [ ch ] == t - 1 or dc [ ch ] == 3 : NEW_LINE INDENT m = 1 NEW_LINE DEDENT else : NEW_LINE INDENT m = 0 NEW_LINE DEDENT if t != 0 : NEW_LINE INDENT dp [ i + 1 ] [ t ] += ( dp [ i ] [ t - 1 ] * m ) % mo NEW_LINE DEDENT dp [ i + 1 ] [ t ] += ( dp [ i ] [ t ] * max ( int ( dc [ ch ] / 3 ) * 3 , 1 ) ) % mo NEW_LINE DEDENT DEDENT ans = dp [ n ] [ 3 ] NEW_LINE print ( ans % mo ) NEW_LINE NEW_LINE


import sys NEW_LINE import itertools NEW_LINE import collections NEW_LINE import functools NEW_LINE import math NEW_LINE from queue import Queue NEW_LINE INF = float ( " inf " ) NEW_LINE MOD = 1000000007 NEW_LINE d = { } NEW_LINE def thpow ( q ) : NEW_LINE INDENT if q < 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT if q == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT if q in d : NEW_LINE INDENT return d [ q ] NEW_LINE DEDENT else : NEW_LINE INDENT d [ q ] = ( 3 * thpow ( q - 1 ) ) % MOD NEW_LINE return d [ q ] NEW_LINE DEDENT DEDENT def solve ( S : str ) : NEW_LINE INDENT dp = [ 0 , 0 , 0 ] NEW_LINE q = 0 NEW_LINE for ch in S : NEW_LINE INDENT a , b , c = dp NEW_LINE if ch == " A " : NEW_LINE INDENT dp = [ ( a + thpow ( q ) ) % MOD , b , c ] NEW_LINE DEDENT elif ch == " B " : NEW_LINE INDENT dp = [ a , ( b + a ) % MOD , c ] NEW_LINE DEDENT elif ch == " C " : NEW_LINE INDENT dp = [ a , b , ( c + b ) % MOD ] NEW_LINE DEDENT elif ch == " ? " : NEW_LINE INDENT dp = [ ( ( a * 3 % MOD ) + thpow ( q ) ) % MOD , ( ( b * 3 ) % MOD + a ) % MOD , ( ( c * 3 ) + b ) % MOD ] NEW_LINE q += 1 NEW_LINE DEDENT DEDENT print ( dp [ 2 ] ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE S = next ( tokens ) NEW_LINE solve ( S ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


X = list ( input ( ) ) NEW_LINE q_num = X . count ( " ? " ) NEW_LINE a_num = 0 NEW_LINE c_num = X . count ( " C " ) NEW_LINE left_q_num = 0 NEW_LINE right_q_num = q_num NEW_LINE ans = 0 NEW_LINE len_x = len ( X ) NEW_LINE q_dict = [ ] NEW_LINE b_ans = 0 NEW_LINE q_ans = 0 NEW_LINE q_dict = { } NEW_LINE q_dict [ q_num - 1 ] = ( 3 ** ( q_num - 1 ) ) % ( 10 ** 9 + 7 ) NEW_LINE q_dict [ q_num - 2 ] = ( 3 ** ( q_num - 2 ) ) % ( 10 ** 9 + 7 ) NEW_LINE q_dict [ q_num - 3 ] = ( 3 ** ( q_num - 3 ) ) % ( 10 ** 9 + 7 ) NEW_LINE q_dict [ q_num ] = ( 3 ** ( q_num ) ) % ( 10 ** 9 + 7 ) NEW_LINE if X [ 0 ] == " ? " : NEW_LINE INDENT right_q_num -= 1 NEW_LINE DEDENT elif X [ 0 ] == " C " : NEW_LINE INDENT c_num -= 1 NEW_LINE DEDENT for i , x in enumerate ( X ) : NEW_LINE INDENT if x == " B " or x == " ? " : NEW_LINE INDENT ans += ( a_num * c_num ) * ( q_dict [ ( left_q_num + right_q_num ) ] ) NEW_LINE if left_q_num + right_q_num >= 2 : NEW_LINE INDENT ans += ( right_q_num * left_q_num + 3 * ( left_q_num * c_num ) + 3 * ( right_q_num * a_num ) ) * ( q_dict [ ( left_q_num + right_q_num - 2 ) ] ) NEW_LINE DEDENT elif left_q_num + right_q_num == 1 : NEW_LINE INDENT ans += ( ( left_q_num * c_num ) + ( right_q_num * a_num ) ) * ( q_dict [ ( left_q_num + right_q_num - 1 ) ] ) NEW_LINE DEDENT ans = ans % ( 10 ** 9 + 7 ) NEW_LINE DEDENT if i == len_x - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if x == " A " : NEW_LINE INDENT a_num += 1 NEW_LINE DEDENT elif x == " ? " : NEW_LINE INDENT left_q_num += 1 NEW_LINE DEDENT if X [ i + 1 ] == " C " : NEW_LINE INDENT c_num -= 1 NEW_LINE DEDENT elif X [ i + 1 ] == " ? " : NEW_LINE INDENT right_q_num -= 1 NEW_LINE DEDENT DEDENT print ( ans % ( 10 ** 9 + 7 ) ) NEW_LINE


a = [ 1 ] + [ 0 ] * 4 NEW_LINE m = 10 ** 9 + 7 NEW_LINE for s in input ( ) : NEW_LINE INDENT i = ord ( s ) - 64 NEW_LINE if i > 0 : a [ i ] += a [ i - 1 ] NEW_LINE else : a = [ a [ i ] * 3 % m + a [ i - 1 ] for i in range ( 4 ) ] + [ 0 ] NEW_LINE DEDENT print ( a [ 3 ] % m ) NEW_LINE


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long [ ] [ ] dp = new long [ S . length ( ) + 1 ] [ 4 ] ; long prime = 1000000007 ; dp [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= S . length ( ) ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ; dp [ i ] [ j ] %= prime ; } if ( S . charAt ( i - 1 ) == ' A ' ) { dp [ i ] [ 1 ] += dp [ i - 1 ] [ 0 ] ; dp [ i ] [ 1 ] %= prime ; } else if ( S . charAt ( i - 1 ) == ' B ' ) { dp [ i ] [ 2 ] += dp [ i - 1 ] [ 1 ] ; dp [ i ] [ 2 ] %= prime ; } else if ( S . charAt ( i - 1 ) == ' C ' ) { dp [ i ] [ 3 ] += dp [ i - 1 ] [ 2 ] ; dp [ i ] [ 3 ] %= prime ; } else { for ( int j = 0 ; j < 4 ; j ++ ) { dp [ i ] [ j ] += 2 * dp [ i - 1 ] [ j ] ; dp [ i ] [ j ] %= prime ; } dp [ i ] [ 1 ] += dp [ i - 1 ] [ 0 ] ; dp [ i ] [ 2 ] += dp [ i - 1 ] [ 1 ] ; dp [ i ] [ 3 ] += dp [ i - 1 ] [ 2 ] ; dp [ i ] [ 1 ] %= prime ; dp [ i ] [ 2 ] %= prime ; dp [ i ] [ 3 ] %= prime ; } } out . println ( dp [ S . length ( ) ] [ 3 ] ) ; } }


import java . util . * ; public class Main { private static final char ABC [ ] = " ABC " . toCharArray ( ) ; private static final long MOD = 1_000_000_007L ; public void main ( Scanner sc ) throws Exception { char s [ ] = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; int len = s . length ; long data [ ] [ ] = new long [ len + 1 ] [ 4 ] ; data [ len ] [ 3 ] = 1 ; for ( int i = len - 1 ; i >= 0 ; i -- ) { data [ i ] [ 3 ] = ( s [ i ] == ' ? ' ? 3 : 1 ) * data [ i + 1 ] [ 3 ] ; data [ i ] [ 3 ] %= MOD ; } for ( int i = len - 1 ; i >= 0 ; i -- ) { for ( int j = 2 ; j >= 0 ; j -- ) { data [ i ] [ j ] = ( s [ i ] == ' ? ' ? 3 : 1 ) * data [ i + 1 ] [ j ] + ( s [ i ] == ABC [ j ] || s [ i ] == ' ? ' ? 1 : 0 ) * data [ i + 1 ] [ j + 1 ] ; data [ i ] [ j ] %= MOD ; } } System . out . println ( data [ 0 ] [ 0 ] % MOD ) ; } public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; } }


import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; StringBuffer sb = new StringBuffer ( S ) ; S = sb . reverse ( ) . toString ( ) ; String [ ] T = S . split ( " " ) ; long C = 0 ; long BC = 0 ; long ABC = 0 ; long AB = 1 ; long X = 1 ; for ( String i : T ) { if ( " ? " . equals ( i ) ) { ABC = ( ABC * 3 + BC ) % 1000000007 ; BC = ( BC * 3 + C ) % 1000000007 ; C = ( C * 3 + X ) % 1000000007 ; X = ( X * 3 ) % 1000000007 ; } else if ( " C " . equals ( i ) ) { AB = 0 ; C += X ; } else if ( " B " . equals ( i ) ) { BC += C ; } else if ( " A " . equals ( i ) ) { ABC += BC ; } } System . out . println ( ABC % 1000000007 ) ; } }


import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long mod = 1000000007L ; String ABC = " ABC " ; long [ ] [ ] dp = new long [ S . length ( ) ] [ 4 ] ; if ( S . charAt ( 0 ) == ' ? ' ) { dp [ 0 ] [ 0 ] = 3 ; } else { dp [ 0 ] [ 0 ] = 1 ; } if ( S . charAt ( 0 ) == ' A ' || S . charAt ( 0 ) == ' ? ' ) { dp [ 0 ] [ 1 ] = 1 ; } for ( int i = 1 ; i < S . length ( ) ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { if ( j == 0 ) { if ( S . charAt ( i ) == ' A ' || S . charAt ( i ) == ' B ' || S . charAt ( i ) == ' C ' ) { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] ; } else { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] * 3L ; } dp [ i ] [ j ] %= mod ; } else { long x = ( S . charAt ( i ) == ' ? ' ? 3L : 1L ) ; long y = ( ( S . charAt ( i ) == ABC . charAt ( j - 1 ) || S . charAt ( i ) == ' ? ' ) ? 1L : 0L ) ; dp [ i ] [ j ] = ( dp [ i - 1 ] [ j ] * x ) + ( dp [ i - 1 ] [ j - 1 ] * y ) ; dp [ i ] [ j ] %= mod ; } } } System . out . println ( dp [ S . length ( ) - 1 ] [ 3 ] ) ; } }


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

n = int ( input ( ) ) NEW_LINE print ( int ( sum ( [ i + 1 for i in range ( n ) ] ) / n * 10000 ) ) NEW_LINE


def calc ( n ) : NEW_LINE INDENT sum = ( n * ( n + 1 ) / 2 ) * 10000 NEW_LINE return ( int ) ( sum / n ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n , = map ( int , input ( ) . split ( ) ) NEW_LINE print ( calc ( n ) ) NEW_LINE DEDENT


n = int ( input ( ) ) NEW_LINE i = 0 NEW_LINE k = 10000 NEW_LINE sum = 0 NEW_LINE while i < n : NEW_LINE INDENT sum += k / n NEW_LINE k += 10000 NEW_LINE i += 1 NEW_LINE DEDENT print ( int ( sum ) ) NEW_LINE


print ( ( int ( input ( ) ) + 1 ) * 5000 ) NEW_LINE


N = float ( input ( ) ) NEW_LINE if N % 2 == 0 : NEW_LINE INDENT print ( int ( ( N / 2 + 0.5 ) * 10000 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( int ( ( N + 1 ) / 2 * 10000 ) ) NEW_LINE DEDENT


import java . util . ArrayList ; import java . util . Scanner ; import static java . lang . System . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static ArrayList < Integer > train = new ArrayList ( ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) ; int count = 0 ; String answer = null ; for ( int i = a ; i > 0 ; i -- ) { count += ( i * 10000 ) ; } count = count / a ; answer = String . valueOf ( count ) ; out . println ( answer ) ; out . flush ( ) ; } static ArrayList < Integer > gcd ( int a , int b ) { for ( int i = 101 ; i > 0 ; i -- ) { if ( a % i == 0 ) { if ( b % i == 0 ) { train . add ( i ) ; } } } return train ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .


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


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


import java . util . Arrays ; import java . util . Collection ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) , sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += i ; } System . out . println ( ( sum * 10000 ) / N ) ; } static String adjustValue ( int value ) { if ( 10 > value ) { return "0" + value ; } else { return value + " " ; } } }


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 ) ; TaskD solver = new TaskD ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskD { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; long a = in . nextLong ( ) , b = in . nextLong ( ) ; long [ ] x = in . nextLongArray ( n ) ; long sum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += Math . min ( a * ( x [ i + 1 ] - x [ i ] ) , b ) ; } out . println ( sum ) ; } } 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 long nextLong ( ) { return Long . parseLong ( nextString ( ) ) ; } public long [ ] nextLongArray ( int n ) { long [ ] res = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { res [ i ] = nextLong ( ) ; } return res ; } public InputReader ( InputStream inputStream ) { in = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; tok = new StringTokenizer ( " " ) ; } } }

n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ret = 0 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT ret += min ( a * ( x [ i + 1 ] - x [ i ] ) , b ) NEW_LINE DEDENT print ( ret ) NEW_LINE


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE from functools import partial , reduce NEW_LINE from operator import mul NEW_LINE prod = partial ( reduce , mul ) NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT N , A , B = LI ( ) NEW_LINE X = LI ( ) NEW_LINE ans = 0 NEW_LINE for x , y in zip ( X , X [ 1 : ] ) : NEW_LINE INDENT if ( y - x ) * A < B : NEW_LINE INDENT ans += ( y - x ) * A NEW_LINE DEDENT else : NEW_LINE INDENT ans += B NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE


( N , A , B ) = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE X = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE hirou = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT length = X [ i + 1 ] - X [ i ] NEW_LINE if length * A <= B : NEW_LINE INDENT hirou += length * A NEW_LINE DEDENT else : NEW_LINE INDENT hirou += B NEW_LINE DEDENT DEDENT print ( hirou ) NEW_LINE


N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE X . insert ( 0 , 0 ) NEW_LINE ans = 0 NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT ans += min ( A * ( X [ i ] - X [ i - 1 ] ) , B ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE diff = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT diff [ i ] = L [ i ] - L [ i - 1 ] NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT if diff [ i ] * A >= B : NEW_LINE INDENT ans += B NEW_LINE DEDENT else : NEW_LINE INDENT ans += diff [ i ] * A NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . Scanner ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . ArrayList ; import java . util . Set ; import java . util . Queue ; import java . text . DecimalFormat ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; long a = input . nextLong ( ) ; long b = input . nextLong ( ) ; long fatiga = 0 ; input . nextLine ( ) ; long pueblos [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { pueblos [ i ] = input . nextLong ( ) ; } input . nextLine ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( ( pueblos [ i + 1 ] - pueblos [ i ] ) * a < b ) fatiga += ( pueblos [ i + 1 ] - pueblos [ i ] ) * a ; else fatiga += b ; } System . out . println ( fatiga ) ; } }


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


import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long [ ] x = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) x [ i ] = sc . nextLong ( ) ; long ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans += Math . min ( A * ( x [ i + 1 ] - x [ i ] ) , B ) ; } PrintWriter out = new PrintWriter ( System . out ) ; out . println ( ans ) ; out . flush ( ) ; } }


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

t , x = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ' { :4f } ' . format ( t / x ) ) NEW_LINE


a , b = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( a / b ) NEW_LINE


T , X = map ( int , input ( ) . split ( ) ) NEW_LINE output = T / X NEW_LINE print ( output ) NEW_LINE


A = list ( map ( float , input ( ) . split ( ) ) ) NEW_LINE print ( A [ 0 ] / A [ 1 ] ) NEW_LINE


T , X = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE print ( float ( T ) / float ( X ) ) NEW_LINE


import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { ArrayList < Integer > list = new ArrayList < Integer > ( ) ; double a = Double . parseDouble ( sc . next ( ) ) ; double b = Double . parseDouble ( sc . next ( ) ) ; double count = 0 ; count = a / b ; System . out . println ( count ) ; System . out . flush ( ) ; sc . close ( ) ; } }


import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { BigDecimal number1 = new BigDecimal ( scanner . next ( ) ) ; BigDecimal number2 = new BigDecimal ( scanner . next ( ) ) ; System . out . println ( number1 . divide ( number2 , 10 , RoundingMode . HALF_UP ) ) ; } } }


import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " ▁ " ) ; double ans = Double . parseDouble ( s [ 0 ] ) / Double . parseDouble ( s [ 1 ] ) ; System . out . println ( ans ) ; } }


import java . util . * ; import java . lang . Math ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double t = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; System . out . println ( t / x ) ; sc . close ( ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; if ( a == 3 || a == 5 || a == 7 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } sc . close ( ) ; } }

List = [ 7 , 5 , 3 ] NEW_LINE X = int ( input ( ) ) NEW_LINE if X in List : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT


age = int ( input ( ) ) NEW_LINE ans = ' YES ' if age == 7 or age == 5 or age == 3 else ' NO ' NEW_LINE print ( ans ) NEW_LINE


a = [ "7" , "5" , "3" ] NEW_LINE old = input ( ) NEW_LINE res = " NO " NEW_LINE if old in a : NEW_LINE INDENT res = " YES " NEW_LINE DEDENT print ( res ) NEW_LINE


if int ( input ( ) ) in ( 7 , 5 , 3 ) : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT


X = input ( ) NEW_LINE if X in [ '3' , '5' , '7' ] : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT


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


import java . util . Scanner ; public class Main { static int N ; static String ans = " NO " ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; if ( N == 7 || N == 5 || N == 3 ) ans = " YES " ; System . out . println ( ans ) ; } }


import java . io . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; switch ( a ) { case 7 : case 5 : case 3 : System . out . println ( " YES " ) ; break ; default : System . out . println ( " NO " ) ; break ; } } }


import java . util . * ; import java . util . List ; import java . util . ArrayList ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int X = scanner . nextInt ( ) ; if ( X == 3 || X == 5 || X == 7 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }


import java . util . Scanner ; import java . util . StringJoiner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; String [ ] [ ] a = new String [ h ] [ w ] ; boolean [ ] row = new boolean [ h ] ; boolean [ ] column = new boolean [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { a [ i ] = sc . next ( ) . split ( " " ) ; row [ i ] = false ; } for ( int i = 0 ; i < w ; i ++ ) { column [ i ] = false ; } for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( " # " . equals ( a [ i ] [ j ] ) ) { row [ i ] = true ; column [ j ] = true ; } } } for ( int i = 0 ; i < h ; i ++ ) { if ( ! row [ i ] ) { continue ; } StringJoiner sj = new StringJoiner ( " " ) ; for ( int j = 0 ; j < w ; j ++ ) { if ( ! column [ j ] ) { continue ; } sj . add ( a [ i ] [ j ] ) ; } System . out . println ( sj . toString ( ) ) ; } } }

H , W = map ( int , input ( ) . split ( ) ) NEW_LINE bd = [ ] NEW_LINE for i in range ( H ) : NEW_LINE INDENT bd . append ( input ( ) ) NEW_LINE DEDENT x = set ( ) NEW_LINE y = set ( ) NEW_LINE for i in range ( H ) : NEW_LINE INDENT for j in range ( W ) : NEW_LINE INDENT if bd [ i ] [ j ] == " # " : NEW_LINE INDENT x . add ( j ) NEW_LINE y . add ( i ) NEW_LINE DEDENT DEDENT DEDENT for i in y : NEW_LINE INDENT for j in x : NEW_LINE INDENT print ( bd [ i ] [ j ] , end = " " ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT


f = lambda s : zip ( * [ t for t in s if ' # ' in t ] ) ; print ( * map ( ' ' . join , f ( f ( open ( 0 ) ) ) ) ) NEW_LINE


H , W = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ [ 0 ] * W for _ in range ( H ) ] NEW_LINE for h in range ( H ) : NEW_LINE INDENT a [ h ] = [ inp for inp in input ( ) ] NEW_LINE DEDENT check = [ [ 0 ] * W for _ in range ( H ) ] NEW_LINE for h in range ( H ) : NEW_LINE INDENT for w in range ( W ) : NEW_LINE INDENT if a [ h ] [ w ] == ' # ' : NEW_LINE INDENT check [ h ] [ w ] = 1 NEW_LINE DEDENT DEDENT DEDENT final_w = [ 0 ] * W NEW_LINE for h in range ( H ) : NEW_LINE INDENT final_w = [ final_w [ w ] + check [ h ] [ w ] for w in range ( W ) ] NEW_LINE DEDENT final_h = [ 0 ] * H NEW_LINE for w in range ( W ) : NEW_LINE INDENT final_h = [ final_h [ h ] + check [ h ] [ w ] for h in range ( H ) ] NEW_LINE DEDENT for h in range ( H ) : NEW_LINE INDENT res = ' ' NEW_LINE for w in range ( W ) : NEW_LINE INDENT if final_w [ w ] >= 1 and final_h [ h ] >= 1 : NEW_LINE INDENT res += a [ h ] [ w ] NEW_LINE DEDENT DEDENT print ( res + ' \n ' ) NEW_LINE DEDENT


H , W = map ( int , input ( ) . split ( ) ) NEW_LINE box = [ ] NEW_LINE for i in range ( H ) : NEW_LINE INDENT a = [ j for j in input ( ) ] NEW_LINE if all ( j == ' . ' for j in a ) : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT box . append ( a ) NEW_LINE DEDENT DEDENT idx = [ ] NEW_LINE for i in range ( len ( box [ 0 ] ) ) : NEW_LINE INDENT ct = 0 NEW_LINE for j in box : NEW_LINE INDENT if j [ i ] == ' . ' : NEW_LINE INDENT ct += 1 NEW_LINE DEDENT DEDENT if ct == len ( box ) : NEW_LINE INDENT idx . append ( i ) NEW_LINE DEDENT DEDENT for i in box : NEW_LINE INDENT for j in range ( len ( i ) ) : NEW_LINE INDENT if j < len ( i ) - 1 : NEW_LINE INDENT if j in idx : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT print ( i [ j ] , end = ' ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if j in idx : NEW_LINE INDENT print ( ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( i [ j ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT


def main ( ) : NEW_LINE INDENT H , W = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ [ " . " for _ in range ( W ) ] for _ in range ( H ) ] NEW_LINE ans = [ ] NEW_LINE is_column_white = [ True ] * H NEW_LINE is_row_white = [ True ] * W NEW_LINE for i in range ( H ) : NEW_LINE INDENT row = input ( ) NEW_LINE for j in range ( W ) : NEW_LINE INDENT a [ i ] [ j ] = row [ j ] NEW_LINE if row [ j ] == " # " : NEW_LINE INDENT is_column_white [ i ] = False NEW_LINE is_row_white [ j ] = False NEW_LINE DEDENT DEDENT DEDENT for i in range ( H ) : NEW_LINE INDENT if is_column_white [ i ] : NEW_LINE INDENT continue NEW_LINE DEDENT ans_row = " " NEW_LINE for j in range ( W ) : NEW_LINE INDENT if is_row_white [ j ] : NEW_LINE INDENT continue NEW_LINE DEDENT ans_row += a [ i ] [ j ] NEW_LINE DEDENT print ( ans_row ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT